[Erp5-report] r13559 - in /erp5/trunk/products/ERP5Type: ./ Accessor/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Mar 22 14:30:00 CET 2007


Author: romain
Date: Thu Mar 22 14:29:58 2007
New Revision: 13559

URL: http://svn.erp5.org?rev=13559&view=rev
Log:
Add checked_permission to related accessors.
It may be used for example to check if user has the View permission on objects.

Modified:
    erp5/trunk/products/ERP5Type/Accessor/Related.py
    erp5/trunk/products/ERP5Type/Accessor/RelatedValue.py
    erp5/trunk/products/ERP5Type/Base.py

Modified: erp5/trunk/products/ERP5Type/Accessor/Related.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Accessor/Related.py?rev=13559&r1=13558&r2=13559&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Accessor/Related.py (original)
+++ erp5/trunk/products/ERP5Type/Accessor/Related.py Thu Mar 22 14:29:58 2007
@@ -52,32 +52,15 @@
     if self._warning:
       LOG("ERP5Type Deprecated Getter Id:",0, self._id)
     return instance._getDefaultRelatedProperty(
-                                     self._key, 'relative_url',
-                                     spec=kw.get('spec',()),
-                                     filter=kw.get('filter', None),
-                                     portal_type=kw.get('portal_type',()))
+                           self._key, 'relative_url',
+                           spec=kw.get('spec',()),
+                           filter=kw.get('filter', None),
+                           portal_type=kw.get('portal_type',()),
+                           checked_permission=kw.get('checked_permission', None))
 
   psyco.bind(__call__)
 
 Getter = DefaultGetter
-
-class RestrictedDefaultGetter(DefaultGetter):
-  """
-  Gets a default reference object
-  """
-  def __call__(self, instance, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getDefaultRelatedProperty(
-                     self._key, 'relative_url',
-                     spec=kw.get('spec',()),
-                     filter=kw.get('filter', None),
-                     portal_type=kw.get('portal_type',()),
-                     query=instance.portal_catalog.getSecurityQuery(),)
-
-  psyco.bind(__call__)
-
-RestrictedGetter = RestrictedDefaultGetter
 
 class ListGetter(Method):
   """
@@ -102,26 +85,11 @@
     if self._warning:
       LOG("ERP5Type Deprecated Getter Id:",0, self._id)
     return instance._getRelatedPropertyList(
-                                      self._key, 'relative_url',
-                                      spec=kw.get('spec',()),
-                                      filter=kw.get('filter', None),
-                                      portal_type=kw.get('portal_type',()))
-
-  psyco.bind(__call__)
-
-class RestrictedListGetter(ListGetter):
-  """
-  Gets a list of reference objects
-  """
-  def __call__(self, instance, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getRelatedPropertyList(
-                      self._key, 'relative_url',
-                      spec=kw.get('spec',()),
-                      filter=kw.get('filter', None),
-                      portal_type=kw.get('portal_type',()),
-                      query=instance.portal_catalog.getSecurityQuery(),)
+                          self._key, 'relative_url',
+                          spec=kw.get('spec',()),
+                          filter=kw.get('filter', None),
+                          portal_type=kw.get('portal_type',()),
+                          checked_permission=kw.get('checked_permission', None))
 
   psyco.bind(__call__)
 
@@ -133,12 +101,3 @@
     result_list = ListGetter.__call__(self, instance, *args, **kw)
     result_set = dict([(x, 0) for x in result_list]).keys()
     return result_set
-
-class RestrictedSetGetter(RestrictedListGetter):
-  """
-  Gets a category value set
-  """
-  def __call__(self, instance, *args, **kw):
-    result_list = RestrictedListGetter.__call__(self, instance, *args, **kw)
-    result_set = dict([(x, 0) for x in result_list]).keys()
-    return result_set

Modified: erp5/trunk/products/ERP5Type/Accessor/RelatedValue.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Accessor/RelatedValue.py?rev=13559&r1=13558&r2=13559&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Accessor/RelatedValue.py (original)
+++ erp5/trunk/products/ERP5Type/Accessor/RelatedValue.py Thu Mar 22 14:29:58 2007
@@ -62,31 +62,13 @@
                             filter=kw.get('filter', None),
                             portal_type=kw.get('portal_type',()),
                             strict_membership=kw.get('strict_membership',
-                            kw.get('strict', None))) # 'strict' is deprecated
+                                                     # 'strict' is deprecated
+                                                     kw.get('strict', None)),
+                            checked_permission=kw.get('checked_permission', None))
 
   psyco.bind(__call__)
 
 Getter = DefaultGetter
-
-class RestrictedDefaultGetter(DefaultGetter):
-  """
-  Gets a default reference object
-  """
-  def __call__(self, instance, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getDefaultRelatedValue(
-                            self._key,
-                            spec=kw.get('spec',()),
-                            filter=kw.get('filter', None),
-                            portal_type=kw.get('portal_type',()),
-                            strict_membership=kw.get('strict_membership',
-                            kw.get('strict', None)), # 'strict' is deprecated
-                            query=instance.portal_catalog.getSecurityQuery(),)
-
-  psyco.bind(__call__)
-
-RestrictedGetter = RestrictedDefaultGetter
 
 class ListGetter(Method):
   """
@@ -119,26 +101,10 @@
                            spec=kw.get('spec',()),
                            filter=kw.get('filter', None),
                            portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None))) # 'strict' is deprecated
-
-  psyco.bind(__call__)
-
-class RestrictedListGetter(ListGetter):
-  """
-  Gets a list of reference objects
-  """
-  def __call__(self, instance, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getRelatedValueList(
-                           self._key,
-                           spec=kw.get('spec',()),
-                           filter=kw.get('filter', None),
-                           portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None)), # 'strict' is deprecated
-                           query=instance.portal_catalog.getSecurityQuery(),)
+                           strict_membership=kw.get('strict_membership',
+                                                    # 'strict' is deprecated
+                                                    kw.get('strict', None)),
+                           checked_permission=kw.get('checked_permission', None))
 
   psyco.bind(__call__)
 
@@ -148,15 +114,6 @@
   """
   def __call__(self, instance, *args, **kw):
     result_list = ListGetter.__call__(self, instance, *args, **kw)
-    result_set = dict([(x, 0) for x in result_list]).keys()
-    return result_set
-
-class RestrictedSetGetter(RestrictedListGetter):
-  """
-  Gets a category value set
-  """
-  def __call__(self, instance, *args, **kw):
-    result_list = RestrictedListGetter.__call__(self, instance, *args, **kw)
     result_set = dict([(x, 0) for x in result_list]).keys()
     return result_set
 
@@ -187,34 +144,14 @@
                            spec=kw.get('spec',()),
                            filter=kw.get('filter', None),
                            portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None))) # 'strict' is deprecated
-
+                           strict_membership=kw.get('strict_membership',
+                                                    # 'strict' is deprecated
+                                                    kw.get('strict', None)),
+                           checked_permission=kw.get('checked_permission', None))
 
   psyco.bind(__call__)
 
 IdGetter = DefaultIdGetter
-
-class RestrictedDefaultIdGetter(DefaultIdGetter):
-  """
-  Gets a default reference object
-  """
-  def __call__(self, instance, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getDefaultRelatedProperty(
-                           self._key, 'id',
-                           spec=kw.get('spec',()),
-                           filter=kw.get('filter', None),
-                           portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None)), # 'strict' is deprecated
-                           query=instance.portal_catalog.getSecurityQuery(),)
-
-
-  psyco.bind(__call__)
-
-RestrictedIdGetter = RestrictedDefaultIdGetter
 
 class IdListGetter(Method):
     """
@@ -243,44 +180,19 @@
                            spec=kw.get('spec',()),
                            filter=kw.get('filter', None),
                            portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None))) # 'strict' is deprecated
+                           strict_membership=kw.get('strict_membership',
+                                                    # 'strict' is deprecated
+                                                    kw.get('strict', None)),
+                           checked_permission=kw.get('checked_permission', None))
 
     psyco.bind(__call__)
 
-class RestrictedIdListGetter(IdListGetter):
-    """
-    Gets a list of reference objects
-    """
-    def __call__(self, instance, *args, **kw):
-      if self._warning:
-        LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-      return instance._getRelatedPropertyList(
-                           self._key, 'id',
-                           spec=kw.get('spec',()),
-                           filter=kw.get('filter', None),
-                           portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None)), # 'strict' is deprecated
-                           query=instance.portal_catalog.getSecurityQuery(),)
-
-    psyco.bind(__call__)
-
 class IdSetGetter(IdListGetter):
   """
   Gets a category value set
   """
   def __call__(self, instance, *args, **kw):
     result_list = IdListGetter.__call__(self, instance, *args, **kw)
-    result_set = dict([(x, 0) for x in result_list]).keys()
-    return result_set
-
-class RestrictedIdSetGetter(RestrictedIdListGetter):
-  """
-  Gets a category value set
-  """
-  def __call__(self, instance, *args, **kw):
-    result_list = RestrictedIdListGetter.__call__(self, instance, *args, **kw)
     result_set = dict([(x, 0) for x in result_list]).keys()
     return result_set
 
@@ -311,32 +223,14 @@
                          spec=kw.get('spec',()),
                          filter=kw.get('filter', None),
                          portal_type=kw.get('portal_type',()),
-                         strict_membership=kw.get('strict_membership', 
-                         kw.get('strict', None))) # 'strict' is deprecated
+                         strict_membership=kw.get('strict_membership',
+                                                  # 'strict' is deprecated
+                                                  kw.get('strict', None)),
+                         checked_permission=kw.get('checked_permission', None))
 
   psyco.bind(__call__)
 
 TitleGetter = DefaultTitleGetter
-
-class RestrictedDefaultTitleGetter(DefaultTitleGetter):
-  """
-  Gets a default reference object
-  """
-  def __call__(self, instance, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getDefaultRelatedProperty(
-                         self._key, 'title',
-                         spec=kw.get('spec',()),
-                         filter=kw.get('filter', None),
-                         portal_type=kw.get('portal_type',()),
-                         strict_membership=kw.get('strict_membership', 
-                         kw.get('strict', None)), # 'strict' is deprecated
-                         query=instance.portal_catalog.getSecurityQuery(),)
-
-  psyco.bind(__call__)
-
-RestrictedTitleGetter = RestrictedDefaultTitleGetter
 
 class TitleListGetter(Method):
   """
@@ -365,25 +259,10 @@
                         spec=kw.get('spec',()),
                         filter=kw.get('filter', None),
                         portal_type=kw.get('portal_type',()),
-                        strict_membership=kw.get('strict_membership', 
-                        kw.get('strict', None))) # 'strict' is deprecated
-  psyco.bind(__call__)
-
-class RestrictedTitleListGetter(TitleListGetter):
-  """
-  Gets a list of reference objects
-  """
-  def __call__(self, instance, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getRelatedPropertyList(
-                        self._key, 'title',
-                        spec=kw.get('spec',()),
-                        filter=kw.get('filter', None),
-                        portal_type=kw.get('portal_type',()),
-                        strict_membership=kw.get('strict_membership', 
-                        kw.get('strict', None)), # 'strict' is deprecated
-                        query=instance.portal_catalog.getSecurityQuery(),)
+                        strict_membership=kw.get('strict_membership',
+                                                 # 'strict' is deprecated
+                                                 kw.get('strict', None)),
+                        checked_permission=kw.get('checked_permission', None))
 
   psyco.bind(__call__)
 
@@ -393,16 +272,6 @@
   """
   def __call__(self, instance, *args, **kw):
     result_list = TitleListGetter.__call__(self, instance, *args, **kw)
-    result_set = dict([(x, 0) for x in result_list]).keys()
-    return result_set
-
-class RestrictedTitleSetGetter(RestrictedTitleListGetter):
-  """
-  Gets a category value set
-  """
-  def __call__(self, instance, *args, **kw):
-    result_list = RestrictedTitleListGetter.__call__(self, instance, 
-                                                     *args, **kw)
     result_set = dict([(x, 0) for x in result_list]).keys()
     return result_set
 
@@ -433,31 +302,13 @@
                          spec=kw.get('spec',()),
                          filter=kw.get('filter', None),
                          portal_type=kw.get('portal_type',()),
-                         strict_membership=kw.get('strict_membership', 
-                         kw.get('strict', None))) # 'strict' is deprecated
+                         strict_membership=kw.get('strict_membership',
+                                                  # 'strict' is deprecated
+                                                  kw.get('strict', None)),
+                         checked_permission=kw.get('checked_permission', None))
   psyco.bind(__call__)
 
 PropertyGetter = DefaultPropertyGetter
-
-class RestrictedDefaultPropertyGetter(DefaultPropertyGetter):
-  """
-  Gets a default reference object
-  """
-  def __call__(self, instance, key, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getDefaultRelatedProperty(
-                         self._key, key,
-                         spec=kw.get('spec',()),
-                         filter=kw.get('filter', None),
-                         portal_type=kw.get('portal_type',()),
-                         strict_membership=kw.get('strict_membership', 
-                         kw.get('strict', None)), # 'strict' is deprecated
-                         query=instance.portal_catalog.getSecurityQuery(),)
-
-  psyco.bind(__call__)
-
-RestrictedPropertyGetter = RestrictedDefaultPropertyGetter
 
 class PropertyListGetter(Method):
   """
@@ -486,26 +337,10 @@
                            spec=kw.get('spec',()),
                            filter=kw.get('filter', None),
                            portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None))) # 'strict' is deprecated
-  psyco.bind(__call__)
-
-class RestrictedPropertyListGetter(PropertyListGetter):
-  """
-  Gets a list of reference objects
-  """
-  def __call__(self, instance, key, *args, **kw):
-    if self._warning:
-      LOG("ERP5Type Deprecated Getter Id:",0, self._id)
-    return instance._getRelatedPropertyList(
-                           self._key, key,
-                           spec=kw.get('spec',()),
-                           filter=kw.get('filter', None),
-                           portal_type=kw.get('portal_type',()),
-                           strict_membership=kw.get('strict_membership', 
-                           kw.get('strict', None)), # 'strict' is deprecated
-                           query=instance.portal_catalog.getSecurityQuery(),)
-
+                           strict_membership=kw.get('strict_membership',
+                                                    # 'strict' is deprecated
+                                                    kw.get('strict', None)),
+                           checked_permission=kw.get('checked_permission', None))
   psyco.bind(__call__)
 
 class PropertySetGetter(PropertyListGetter):
@@ -516,14 +351,3 @@
     result_list = PropertyListGetter.__call__(self, instance, *args, **kw)
     result_set = dict([(x, 0) for x in result_list]).keys()
     return result_set
-
-class RestrictedPropertySetGetter(RestrictedPropertyListGetter):
-  """
-  Gets a category value set
-  """
-  def __call__(self, instance, *args, **kw):
-    result_list = RestrictedPropertyListGetter.__call__(self, instance, 
-                                                        *args, **kw)
-    result_set = dict([(x, 0) for x in result_list]).keys()
-    return result_set
-

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=13559&r1=13558&r2=13559&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Thu Mar 22 14:29:58 2007
@@ -1576,15 +1576,15 @@
   security.declareProtected( Permissions.View, '_getDefaultRelatedValue' )
   def _getDefaultRelatedValue(self, id, spec=(), filter=None, portal_type=(),
                               strict_membership=0, strict="deprecated",
-                              query=None):
+                              checked_permission=None):
     # backward compatibility to keep strict keyword working
     if strict != "deprecated" : 
       strict_membership = strict
-    value_list =self._getRelatedValueList(
+    value_list = self._getRelatedValueList(
                                 id, spec=spec, filter=filter,
                                 portal_type=portal_type,
                                 strict_membership=strict_membership,
-                                query=query)
+                                checked_permission=checked_permission)
     try:
       return value_list[0]
     except IndexError:
@@ -1596,7 +1596,7 @@
   security.declareProtected( Permissions.View, '_getRelatedValueList' )
   def _getRelatedValueList(self, id, spec=(), filter=None, portal_type=(),
                            strict_membership=0, strict="deprecated", 
-                           query=None):
+                           checked_permission=None):
     # backward compatibility to keep strict keyword working
     if strict != "deprecated" : 
       strict_membership = strict
@@ -1604,7 +1604,7 @@
                           self, id,
                           spec=spec, filter=filter, portal_type=portal_type,
                           strict_membership=strict_membership,
-                          query=query)
+                          checked_permission=checked_permission)
 
   security.declareProtected(Permissions.View, 'getRelatedValueList')
   getRelatedValueList = _getRelatedValueList
@@ -1613,13 +1613,13 @@
                             '_getDefaultRelatedProperty')
   def _getDefaultRelatedProperty(self, id, property_name, spec=(), filter=None,
                                  portal_type=(), strict_membership=0,
-                                 query=None):
+                                 checked_permission=None):
     property_list = self._getCategoryTool().getRelatedPropertyList(self, id,
                           property_name=property_name,
                           spec=spec, filter=filter,
                           portal_type=portal_type,
                           strict_membership=strict_membership,
-                          query=query)
+                          checked_permission=checked_permission)
     try:
       return property_list[0]
     except IndexError:
@@ -1634,13 +1634,13 @@
                             '_getRelatedPropertyList')
   def _getRelatedPropertyList(self, id, property_name, spec=(), filter=None,
                               portal_type=(), strict_membership=0,
-                              query=None):
+                              checked_permission=None):
     return self._getCategoryTool().getRelatedPropertyList(self, id,
                           property_name=property_name,
                           spec=spec, filter=filter,
                           portal_type=portal_type,
                           strict_membership=strict_membership,
-                          query=query)
+                          checked_permission=checked_permission)
 
   security.declareProtected( Permissions.AccessContentsInformation,
                              'getRelatedPropertyList' )




More information about the Erp5-report mailing list