# HG changeset patch # User Thierry Florac # Date 1348153582 -7200 # Node ID b4b587dd45ca07be1d2c4b9d35ba899824ddb40e # Parent c02d355d3ffd5c9d241193dcae6ba27a744faca7 Added a persistent utility to store ZEO connection settings diff -r c02d355d3ffd -r b4b587dd45ca docs/HISTORY.txt --- a/docs/HISTORY.txt Thu Sep 13 10:56:25 2012 +0200 +++ b/docs/HISTORY.txt Thu Sep 20 17:06:22 2012 +0200 @@ -4,6 +4,7 @@ 0.3.13 ------ - added "ztfy.utils.container" utility module + - added a persistent utility to store ZEO connection settings - added "TextLine list" schema field and widget - added Python 2.7 compatibility code and timeout parameter to XML-RPC protocol helper diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/browser/configure.zcml --- a/src/ztfy/utils/browser/configure.zcml Thu Sep 13 10:56:25 2012 +0200 +++ b/src/ztfy/utils/browser/configure.zcml Thu Sep 20 17:06:22 2012 +0200 @@ -1,8 +1,33 @@ + + + + + + + diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/browser/zodb.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ztfy/utils/browser/zodb.py Thu Sep 20 17:06:22 2012 +0200 @@ -0,0 +1,39 @@ +### -*- coding: utf-8 -*- #################################################### +############################################################################## +# +# Copyright (c) 2012 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## + + +# import standard packages + +# import Zope3 interfaces + +# import local interfaces +from ztfy.skin.interfaces import IPropertiesMenuTarget +from ztfy.utils.interfaces import IZEOConnection + +# import Zope3 packages +from z3c.form import field +from zope.interface import implements + +# import local packages +from ztfy.skin.form import EditForm + + +class ZEOConnectionEditForm(EditForm): + """Sequential ID utility edit form""" + + implements(IPropertiesMenuTarget) + + fields = field.Fields(IZEOConnection) + autocomplete = 'off' diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/configure.zcml --- a/src/ztfy/utils/configure.zcml Thu Sep 13 10:56:25 2012 +0200 +++ b/src/ztfy/utils/configure.zcml Thu Sep 20 17:06:22 2012 +0200 @@ -6,8 +6,7 @@ - + \n" "Language-Team: French \n" diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.mo Binary file src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.mo has changed diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.po --- a/src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.po Thu Sep 13 10:56:25 2012 +0200 +++ b/src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.po Thu Sep 20 17:06:22 2012 +0200 @@ -16,7 +16,7 @@ msgid "" msgstr "" "Project-Id-Version: ZTFY.utils\n" -"POT-Creation-Date: Thu Apr 12 00:21:57 2012\n" +"POT-Creation-Date: Thu Sep 20 17:01:57 2012\n" "PO-Revision-Date: 2012-03-26 14:18+0200\n" "Last-Translator: Thierry Florac \n" "Language-Team: français <>\n" @@ -460,19 +460,72 @@ msgid "Arabic (iso8859_6)" msgstr "Arabe (iso8859-6)" +#: ztfy/utils/interfaces.py:155 +msgid "ZEO server name" +msgstr "Nom du serveur" + +#: ztfy/utils/interfaces.py:156 +msgid "Hostname of ZEO server" +msgstr "Nom ou adresse IP du serveur ZEO" + +#: ztfy/utils/interfaces.py:160 +msgid "ZEO server port" +msgstr "Numéro de port" + +#: ztfy/utils/interfaces.py:161 +msgid "Port number of ZEO server" +msgstr "N° du port TCP d'écoute du serveur ZEO" + +#: ztfy/utils/interfaces.py:165 +msgid "ZEO server storage" +msgstr "Nom du stockage" + +#: ztfy/utils/interfaces.py:166 +msgid "Storage name on ZEO server" +msgstr "Nom du stockage ZEO" + +#: ztfy/utils/interfaces.py:170 +msgid "ZEO user name" +msgstr "Code utilisateur" + +#: ztfy/utils/interfaces.py:171 +msgid "User name on ZEO server" +msgstr "Code utilisateur de connexion au serveur ZEO" + +#: ztfy/utils/interfaces.py:174 +msgid "ZEO password" +msgstr "Mot de passe" + +#: ztfy/utils/interfaces.py:175 +msgid "User password on ZEO server" +msgstr "Mot de passe de connexion au serveur ZEO" + +#: ztfy/utils/interfaces.py:178 +msgid "ZEO server realm" +msgstr "Royaume" + +#: ztfy/utils/interfaces.py:179 +msgid "Realm name on ZEO server" +msgstr "Nom du royaume du serveur ZEO, si nécessaire" + #: ztfy/utils/request.py:40 msgid "No Request in interaction !" msgstr "Pas de requête en cours !" -#: ztfy/utils/schema.py:58 +#: ztfy/utils/schema.py:66 msgid "Color length must be 3 or 6 characters" msgstr "La longueur du code couleur doit être de 3 ou 6 caractères" -#: ztfy/utils/schema.py:61 +#: ztfy/utils/schema.py:69 msgid "" "Color value must contain only valid color codes (numbers or letters between " "'A' end 'F')" -msgstr "Une couleur ne doit contenir que des caractères hexadécimaux (nombres et lettres de 'A' à 'F')" +msgstr "Une couleur ne doit contenir que des caractères hexadécimaux (nombres et " +"lettres de 'A' à 'F')" + +#: ztfy/utils/schema.py:92 +msgid "The entered value is not a valid decimal literal." +msgstr "La valeur indiquée n'est pas une valeur décimale correcte !" #: ztfy/utils/security.py:71 msgid "< missing principal %s >" diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/locales/ztfy.utils.pot --- a/src/ztfy/utils/locales/ztfy.utils.pot Thu Sep 13 10:56:25 2012 +0200 +++ b/src/ztfy/utils/locales/ztfy.utils.pot Thu Sep 20 17:06:22 2012 +0200 @@ -14,7 +14,7 @@ msgid "" msgstr "" "Project-Id-Version: Meaningless\n" -"POT-Creation-Date: Thu Apr 12 00:21:57 2012\n" +"POT-Creation-Date: Thu Sep 20 17:01:57 2012\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: Zope 3 Developers \n" @@ -455,18 +455,70 @@ msgid "Arabic (iso8859_6)" msgstr "" +#: ztfy/utils/interfaces.py:155 +msgid "ZEO server name" +msgstr "" + +#: ztfy/utils/interfaces.py:156 +msgid "Hostname of ZEO server" +msgstr "" + +#: ztfy/utils/interfaces.py:160 +msgid "ZEO server port" +msgstr "" + +#: ztfy/utils/interfaces.py:161 +msgid "Port number of ZEO server" +msgstr "" + +#: ztfy/utils/interfaces.py:165 +msgid "ZEO server storage" +msgstr "" + +#: ztfy/utils/interfaces.py:166 +msgid "Storage name on ZEO server" +msgstr "" + +#: ztfy/utils/interfaces.py:170 +msgid "ZEO user name" +msgstr "" + +#: ztfy/utils/interfaces.py:171 +msgid "User name on ZEO server" +msgstr "" + +#: ztfy/utils/interfaces.py:174 +msgid "ZEO password" +msgstr "" + +#: ztfy/utils/interfaces.py:175 +msgid "User password on ZEO server" +msgstr "" + +#: ztfy/utils/interfaces.py:178 +msgid "ZEO server realm" +msgstr "" + +#: ztfy/utils/interfaces.py:179 +msgid "Realm name on ZEO server" +msgstr "" + #: ztfy/utils/request.py:40 msgid "No Request in interaction !" msgstr "" -#: ztfy/utils/schema.py:58 +#: ztfy/utils/schema.py:66 msgid "Color length must be 3 or 6 characters" msgstr "" -#: ztfy/utils/schema.py:61 +#: ztfy/utils/schema.py:69 msgid "Color value must contain only valid color codes (numbers or letters between 'A' end 'F')" msgstr "" +#: ztfy/utils/schema.py:92 +msgid "The entered value is not a valid decimal literal." +msgstr "" + #: ztfy/utils/security.py:71 msgid "< missing principal %s >" msgstr "" diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/zodb.py --- a/src/ztfy/utils/zodb.py Thu Sep 13 10:56:25 2012 +0200 +++ b/src/ztfy/utils/zodb.py Thu Sep 20 17:06:22 2012 +0200 @@ -16,6 +16,7 @@ __docformat__ = "restructuredtext" # import standard packages +from persistent import Persistent # import Zope3 interfaces from persistent.interfaces import IPersistent @@ -23,14 +24,48 @@ from ZODB.interfaces import IConnection # import local interfaces +from ztfy.utils.interfaces import IZEOConnection # import Zope3 packages +from ZEO import ClientStorage +from ZODB import DB from zope.component import adapter -from zope.interface import implementer +from zope.container.contained import Contained +from zope.interface import implementer, implements +from zope.schema.fieldproperty import FieldProperty # import local packages +class ZEOConnectionInfo(object): + """ZEO connection info""" + + implements(IZEOConnection) + + server_name = FieldProperty(IZEOConnection['server_name']) + server_port = FieldProperty(IZEOConnection['server_port']) + storage = FieldProperty(IZEOConnection['storage']) + username = FieldProperty(IZEOConnection['username']) + password = FieldProperty(IZEOConnection['password']) + server_realm = FieldProperty(IZEOConnection['server_realm']) + + def getConnection(self, wait=False, get_storage=False): + """Get a tuple made of storage and DB connection for given settings""" + storage = ClientStorage.ClientStorage((str(self.server_name), self.server_port), + storage=self.server_storage, + username=self.server_username or '', + password=self.server_password or '', + realm=self.server_realm, + wait=wait) + db = DB(storage) + return (storage, db) if get_storage else db + + +class ZEOConnectionUtility(ZEOConnectionInfo, Persistent, Contained): + """Persistent ZEO connection settings utility""" + + + # IPersistent adapters copied from zc.twist package # also register this for adapting from IConnection @adapter(IPersistent) diff -r c02d355d3ffd -r b4b587dd45ca src/ztfy/utils/zodb.zcml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ztfy/utils/zodb.zcml Thu Sep 20 17:06:22 2012 +0200 @@ -0,0 +1,21 @@ + + + + + + + + + + + + \ No newline at end of file