[Checkins] SVN: zope.securitypolicy/trunk/ Use `_z_instances` instead of `__instances__` for storing instances for ``zope.securitypolicy.settings.PermissionSetting`` singleton implementation, because __*__ name pattern is reserved for special names in python.

Dan Korostelev nadako at gmail.com
Mon Mar 9 20:20:50 EDT 2009


Log message for revision 97748:
  Use `_z_instances` instead of `__instances__` for storing instances for ``zope.securitypolicy.settings.PermissionSetting`` singleton implementation, because __*__ name pattern is reserved for special names in python.
  

Changed:
  U   zope.securitypolicy/trunk/CHANGES.txt
  U   zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py

-=-
Modified: zope.securitypolicy/trunk/CHANGES.txt
===================================================================
--- zope.securitypolicy/trunk/CHANGES.txt	2009-03-10 00:02:10 UTC (rev 97747)
+++ zope.securitypolicy/trunk/CHANGES.txt	2009-03-10 00:20:49 UTC (rev 97748)
@@ -14,6 +14,11 @@
   The ``zope.app.security`` will be adapted to import them from
   ``zope.securitypolicy.interfaces``.
 
+- Use `_z_instances` instead of `__instances__` for storing instances
+  for ``zope.securitypolicy.settings.PermissionSetting`` singleton
+  implementation, because __*__ name pattern is reserved for special
+  names in python.
+
 - Improve documentation formatting, add it to the package's long
   description.
 

Modified: zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py
===================================================================
--- zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py	2009-03-10 00:02:10 UTC (rev 97747)
+++ zope.securitypolicy/trunk/src/zope/securitypolicy/settings.py	2009-03-10 00:20:49 UTC (rev 97748)
@@ -20,11 +20,6 @@
 $Id$
 """
 
-# The location of this module within the package hierarchy is an
-# accident of implementation.  This may change; see the issue:
-# http://www.zope.org/Collectors/Zope3-dev/712
-
-
 class PermissionSetting(object):
     """PermissionSettings should be considered as immutable.
     They can be compared by identity. They are identified by
@@ -36,9 +31,9 @@
         name. If the name already exists in the dict, return that
         instance rather than creating a new one.
         """
-        instances = cls.__dict__.get('__instances__')
+        instances = cls.__dict__.get('_z_instances')
         if instances is None:
-            cls.__instances__ = instances = {}
+            cls._z_instances = instances = {}
         it = instances.get(name)
         if it is None:
             instances[name] = it = object.__new__(cls)



More information about the Checkins mailing list