[Checkins] SVN: grok/trunk/ Merged r114947 from branch 1.1 (i18n of grok.Role) and synced changelog with branch 1.1

Vincent Fretin vincent.fretin at gmail.com
Fri Jul 23 06:53:33 EDT 2010


Log message for revision 114950:
  Merged r114947 from branch 1.1 (i18n of grok.Role) and synced changelog with branch 1.1

Changed:
  U   grok/trunk/CHANGES.txt
  U   grok/trunk/setup.py
  U   grok/trunk/src/grok/meta.py
  A   grok/trunk/src/grok/tests/security/role_i18n.py

-=-
Modified: grok/trunk/CHANGES.txt
===================================================================
--- grok/trunk/CHANGES.txt	2010-07-23 09:43:00 UTC (rev 114949)
+++ grok/trunk/CHANGES.txt	2010-07-23 10:53:32 UTC (rev 114950)
@@ -16,6 +16,37 @@
   packages such as zope.app.zcmlfiles, that used to take care of that
   configuration step.
 
+1.1.2 (unreleased)
+==================
+
+- Internationalization of title and description of roles are not lost anymore.
+
+- `create_application` now raises a `KeyError`, in cases of key
+  duplication, to match the ``zope.container`` behavior. Tests have
+  been adapted accordingly.
+
+- Added `KeyError` error handling to the existing `DuplicationError`,
+  to fit the ``zope.container`` changes. Tests have been adapted accordingly.
+
+1.1.1 (2010-05-30)
+==================
+
+- Make use of the groktoolkit 1.1.1 that includes several bugfix releases
+  of Grok's dependencies such as:
+
+  - zope.password, where the SSHAPasswordManager was fixed.
+
+  - zope.publisher, that fixes the long standing XML-RPC "hanging" bug.
+
+- Cleanups in the buildout parts.
+
+- Remove zope.app.twisted.
+
+1.1 (2010-05-18)
+================
+
+- Add zope.pluggablauth as a dependency.
+
 1.1rc1 (2010-02-25)
 ===================
 

Modified: grok/trunk/setup.py
===================================================================
--- grok/trunk/setup.py	2010-07-23 09:43:00 UTC (rev 114949)
+++ grok/trunk/setup.py	2010-07-23 10:53:32 UTC (rev 114950)
@@ -69,6 +69,7 @@
         'zope.event',
         'zope.exceptions',
         'zope.i18n',
+        'zope.i18nmessageid',
         'zope.interface',
         'zope.intid',
         'zope.keyreference',

Modified: grok/trunk/src/grok/meta.py
===================================================================
--- grok/trunk/src/grok/meta.py	2010-07-23 09:43:00 UTC (rev 114949)
+++ grok/trunk/src/grok/meta.py	2010-07-23 10:53:32 UTC (rev 114950)
@@ -32,6 +32,7 @@
 from zope.securitypolicy.interfaces import IRole
 from zope.securitypolicy.rolepermission import rolePermissionManager
 
+from zope.i18nmessageid import Message
 from zope.intid import IntIds
 from zope.intid.interfaces import IIntIds
 from zope.catalog.catalog import Catalog
@@ -278,7 +279,11 @@
                 "grok.name to specify one.", factory)
         # We can safely convert to unicode, since the directives makes sure
         # it is either unicode already or ASCII.
-        role = factory(unicode(name), unicode(title), unicode(description))
+        if not isinstance(title, Message):
+            title = unicode(title)
+        if not isinstance(description, Message):
+            description = unicode(description)
+        role = factory(unicode(name), title, description)
 
         config.action(
             discriminator=('utility', IRole, name),

Copied: grok/trunk/src/grok/tests/security/role_i18n.py (from rev 114947, grok/branches/1.1/src/grok/tests/security/role_i18n.py)
===================================================================
--- grok/trunk/src/grok/tests/security/role_i18n.py	                        (rev 0)
+++ grok/trunk/src/grok/tests/security/role_i18n.py	2010-07-23 10:53:32 UTC (rev 114950)
@@ -0,0 +1,75 @@
+"""
+A Role component have a title and description, that can be internationalized.
+
+Let's grok this package and check we still have a Message object for the
+internationalized title and description of the defined roles.
+
+  >>> grok.testing.grok(__name__)
+  >>> from zope.securitypolicy.interfaces import IRole
+  >>> from zope.component import getUtility
+  >>> from zope.i18nmessageid import Message
+
+A grok.Role without any internationalization.
+The id, title and description should be unicode::
+
+  >>> role = getUtility(IRole, name="RoleWithoutI18n")
+  >>> role.id
+  u'RoleWithoutI18n'
+  >>> role.title
+  u'RoleWithoutI18n'
+  >>> role.description
+  u'My role without i18n'
+  >>>
+  >>> isinstance(role.id, Message)
+  False
+  >>> isinstance(role.title, Message)
+  False
+  >>> isinstance(role.description, Message)
+  False
+
+A grok.Role registered with the name and description directives only, both
+internationalized.
+The id is taken from the name directive and should not be a Message object.
+The title is taken from the name directive because the title directive is not used.
+::
+
+  >>> role = getUtility(IRole, name="RoleWithI18n")
+  >>> isinstance(role.id, Message)
+  False
+  >>> isinstance(role.title, Message)
+  True
+  >>> isinstance(role.description, Message)
+  True
+
+A grok.Role registered with name, title and description directives::
+
+  >>> role = getUtility(IRole, name="RoleWithI18nTitle")
+  >>> isinstance(role.id, Message)
+  False
+  >>> isinstance(role.title, Message)
+  True
+  >>> isinstance(role.description, Message)
+  True
+"""
+
+import grok
+import zope.interface
+from zope.i18nmessageid import MessageFactory
+
+_ = MessageFactory("testi18n")
+
+
+class RoleWithoutI18n(grok.Role):
+    grok.name('RoleWithoutI18n')
+    grok.description('My role without i18n')
+
+
+class RoleWithI18n(grok.Role):
+    grok.name(_('RoleWithI18n'))
+    grok.description(_(u'My role with i18n'))
+
+
+class RoleWithI18nTitle(grok.Role):
+    grok.name('RoleWithI18nTitle')
+    grok.title(_('RoleWithI18n'))
+    grok.description(_(u'My role with i18n'))



More information about the checkins mailing list