class ListGetter(BaseGetter): """ Gets a list of reference objects """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, warning=0): """ 'warning' argument means that this category is deprecated in the property sheet, so the generated method will also be deprecated """ self._id = id self.__name__ = id self._key = key self._warning = warning def __call__(self, instance, *args, **kw): assert not 'validation_state' in kw, "validation_state parameter is not supported" assert not 'simulation_state' in kw, "simulation_state parameter is not supported" if self._warning: LOG("ERP5Type", WARNING, "Deprecated Getter Id: %s" % self._id) return instance._getRelatedValueList(self._key, *args, **kw) psyco.bind(__call__)
class Tester(Method): """ Tests if an attribute value exists """ _need__name__=1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self',) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, storage_id=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id def __call__(self, instance, *args, **kw): #return getattr(instance, self._key, None) not in self._null return getattr(instance, self._storage_id, None) is not None
class ListGetter(BaseGetter): """ Gets a list of reference objects """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, warning=0): self._id = id self.__name__ = id self._key = key self._warning = warning def __call__(self, instance, *args, **kw): if self._warning: LOG("ERP5Type", WARNING, "Deprecated Getter Id: %s" % self._id) assert not 'validation_state' in kw, "validation_state parameter is not supported" assert not 'simulation_state' in kw, "simulation_state parameter is not supported" return instance._getRelatedPropertyList( 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__)
class ItemListGetter(BaseGetter): """ Gets a category value list """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ( 'self', 'args', 'kw', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key): self._id = id self.__name__ = id self._key = key def __call__(self, instance, *args, **kw): return instance._getAcquiredCategoryMembershipItemList(self._key, base=0, **kw) psyco.bind(__call__)
class DefaultGetter(BaseGetter): """ Gets a default category value """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key): self._id = id self.__name__ = id self._key = key def __call__(self, instance, *args, **kw): if len(args) > 0: default = args[0] kw['default'] = default else: default = None return instance._getDefaultAcquiredCategoryMembership(self._key, **kw) psyco.bind(__call__)
class ListGetter(BaseGetter): """ Gets a list of reference objects """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web # XXX This does not work yet completely in URL mode func_code = func_code() func_code.co_varnames = ('self', 'args', 'kw') func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, warning=0): self._id = id self.__name__ = id self._key = key self._warning = warning def __call__(self, instance, *args, **kw): if self._warning: LOG("ERP5Type Deprecated Getter Id:", 0, self._id) if args: kw['default'] = args[0] return instance.getAcquiredValueList(self._key, **kw) psyco.bind(__call__)
class DefaultGetter(BaseGetter): """ Gets a default reference object """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', 'args', 'kw') func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, warning=0): self._id = id self.__name__ = id self._key = key self._warning = warning def __call__(self, instance, *args, **kw): if self._warning: LOG("ERP5Type Deprecated Getter Id:", 0, self._id) return instance._getDefaultAcquiredValue(self._key, **kw) psyco.bind(__call__)
class DefaultSetter(BaseSetter): """ Sets a category """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', 'category') func_code.co_argcount = 2 func_defaults = () def __init__(self, id, key): self._id = id self.__name__ = id self._key = key def __call__(self, instance, *args, **kw): instance._setDefaultCategoryMembership( self._key, args[0], spec=kw.get('spec', ()), filter=kw.get('filter', None), portal_type=kw.get('portal_type', ()), base=kw.get('base', 0), checked_permission=kw.get('checked_permission', None)) return (instance, )
class ValueListGetter(Base.Getter): """ Gets an attribute value. A default value can be provided if needed """ _need__name__=1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self',) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, portal_type=None, storage_id=None, default=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] self._default = default if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) elif type(storage_id) is not type([]): storage_id = [storage_id] self._storage_id = storage_id self._portal_type = portal_type def __call__(self, instance, *args, **kw): # We return the list of matching objects return instance.contentValues(filter = {'portal_type': self._portal_type, 'id' : self._storage_id}) psyco.bind(__call__)
class SetSetter(Base.Setter): """ Sets the default attribute in a list """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web # More information at http://www.zope.org/Members/htrd/howto/FunctionTemplate func_code = func_code() func_code.co_varnames = ('self', 'value') func_code.co_argcount = 2 func_defaults = () def __init__(self, id, key, property_type, storage_id=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type if property_type in list_types: # classic list self._cast = type_definition[property_type]['cast'] self._item_cast = identity else: # Multivalued self._cast = asList self._item_cast = type_definition[property_type]['cast'] self._null = type_definition[property_type]['null'] if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id self._is_tales_type = (property_type == 'tales') def __call__(self, instance, *args, **kw): # Turn the value into a list value = args[0] # Modify the property if self._is_tales_type: setattr(instance, self._storage_id, str(value)) elif value in self._null: setattr(instance, self._storage_id, ()) else: value = self._cast(value) if self._item_cast is not identity: value = map(self._item_cast, value) if value: value = set(value) list_value = getattr(instance, self._storage_id, None) if list_value: default_value = list_value[0] if default_value in value: # If we change the set, # the default value must be in the new set value.remove(default_value) value = (default_value, ) + tuple(value) setattr(instance, self._storage_id, tuple(value)) return (instance, )
class ValueGetter(Base.Getter): """ Gets an attribute value. A default value can be provided if needed """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, acquired_property, portal_type=None, storage_id=None, default=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] self._default = default if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) elif type(storage_id) not in (type([]), type(())): storage_id = [storage_id] self._storage_id_list = storage_id if type(portal_type) is type('a'): portal_type = (portal_type, ) self._portal_type = portal_type self._acquired_property = acquired_property def __call__(self, instance, *args, **kw): # We return the first available object in the list if len(args) > 0: default_result = args[0] else: default_result = self._default o = None for k in self._storage_id_list: o = getattr(instance, k, None) if o is not None and (o.portal_type is None or o.portal_type in self._portal_type): return o return default_result psyco.bind(__call__)
class DefaultGetter(Base.Getter): """ Gets the first item of a list """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, default=None, storage_id=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] self._default = default if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id self._is_tales_type = (property_type == 'tales') def __call__(self, instance, *args, **kw): if len(args) > 0: default = args[0] else: default = self._default list_value = getattr(aq_base(instance), self._storage_id, default) if list_value is not None: if self._is_tales_type: if kw.get('evaluate', 1): list_value = evaluateTales(instance=instance, value=list_value) else: return list_value if type(list_value) in (ListType, TupleType): if len(list_value) > 0: return list_value[0] else: return None # This should not happen though return list_value if default and len(default): return default[0] return None psyco.bind(__call__)
class ListGetter(Base.Getter): """ Gets an attribute value. A default value can be provided if needed """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, acquired_property, portal_type=None, storage_id=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) elif type(storage_id) is not type([]): storage_id = [storage_id] self._storage_id_list = storage_id self._portal_type = portal_type self._acquired_property = acquired_property def __call__(self, instance, *args, **kw): # We return the list of matching objects return [ o.relative_url for o in self.searchFolder(portal_type=self._portal_type, id=self._storage_id_list) ] psyco.bind(__call__)
class Tester(Method): """ Tests if an attribute value exists """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, acquired_property, portal_type=None, storage_id=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) elif type(storage_id) is not list: storage_id = [storage_id] self._storage_id_list = storage_id if type(portal_type) is str: portal_type = (portal_type, ) self._portal_type = portal_type self._acquired_property = acquired_property def __call__(self, instance, *args, **kw): o = None for k in self._storage_id_list: o = getattr(instance, k, None) if o is not None and o.portal_type in self._portal_type: return o.hasProperty(self._acquired_property) return False
class DefaultGetter(BaseGetter): """ Gets a default reference object """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, warning=0): """ 'warning' argument means that this category is deprecated in the property sheet, so the generated method will also be deprecated """ self._id = id self.__name__ = id self._key = key self._warning = warning def __call__(self, instance, *args, **kw): if self._warning: LOG("ERP5Type", WARNING, "Deprecated Getter Id: %s" % self._id) assert not 'validation_state' in kw, "validation_state parameter is not supported" assert not 'simulation_state' in kw, "simulation_state parameter is not supported" 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', # 'strict' is deprecated kw.get('strict', None)), checked_permission=kw.get('checked_permission', None)) psyco.bind(__call__)
class Setter(BaseSetter): """ Sets a value of a property wich can be acquired. Since we set here the property, we must not call acquisition. """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', 'value', 'args', 'kw') func_code.co_argcount = 2 func_defaults = None def __init__( self, id, key, property_type, portal_type, acquired_property, acquisition_base_category, acquisition_portal_type, acquisition_accessor_id, acquisition_copy_value, acquisition_mask_value, storage_id=None, alt_accessor_id=None, acquisition_object_id=None, is_list_type=0, is_tales_type=0, ): if type(portal_type) == type('a'): portal_type = (portal_type, ) self._id = id self.__name__ = id self._key = key self._property_type = property_type self._portal_type = portal_type self._null = type_definition[property_type]['null'] # These values are hashed by _get*AcquiredProperty: to be # hashable, they need to be converted to tuples if isinstance(acquisition_base_category, list): acquisition_base_category = tuple(acquisition_base_category) if isinstance(acquisition_portal_type, list): acquisition_portal_type = tuple(acquisition_portal_type) if isinstance(acquisition_object_id, list): acquisition_object_id = tuple(acquisition_object_id) if isinstance(alt_accessor_id, list): alt_accessor_id = tuple(alt_accessor_id) self._acquisition_base_category = acquisition_base_category self._acquisition_portal_type = acquisition_portal_type self._acquisition_accessor_id = acquisition_accessor_id self._acquisition_copy_value = acquisition_copy_value self._acquisition_mask_value = acquisition_mask_value self._acquired_property = acquired_property if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id self._alt_accessor_id = alt_accessor_id self._acquisition_object_id = acquisition_object_id self._is_list_type = is_list_type self._is_tales_type = is_tales_type def __call__(self, instance, value, *args, **kw): from Products.ERP5Type.Utils import assertAttributePortalType assertAttributePortalType(instance, self._storage_id, self._portal_type) o = instance._getOb(self._storage_id, None) if o is None: if self._acquired_property == 'file': if isinstance(value, FileUpload) or \ getattr(aq_base(value), 'tell', None) is not None: # When editing through the web interface, we are always provided a # FileUpload, and when no file has been specified, the file is empty. # In the case of empty file, we should not create the sub document. value.seek(0, 2) is_empty_file = not value.tell() value.seek(0) if is_empty_file: return () o = instance.newContent(id=self._storage_id, portal_type=self._portal_type[0]) o._setProperty(self._acquired_property, value, *args, **kw) return (o, )
class Getter(BaseGetter): """ Gets the default reference of a relation """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', 'args', 'kw') func_code.co_argcount = 1 func_defaults = None def __init__(self, id, key, property_type, portal_type, acquired_property, acquisition_base_category, acquisition_portal_type, acquisition_accessor_id, acquisition_copy_value, acquisition_mask_value, storage_id=None, alt_accessor_id=None, acquisition_object_id=None, is_list_type=0, is_tales_type=0): if type(portal_type) == type('a'): portal_type = (portal_type, ) self._id = id self.__name__ = id self._key = key self._property_type = property_type self._portal_type = portal_type self._null = type_definition[property_type]['null'] # These values are hashed by _get*AcquiredProperty: to be # hashable, they need to be converted to tuples if isinstance(acquisition_base_category, list): acquisition_base_category = tuple(acquisition_base_category) if isinstance(acquisition_portal_type, list): acquisition_portal_type = tuple(acquisition_portal_type) if isinstance(acquisition_object_id, list): acquisition_object_id = tuple(acquisition_object_id) if isinstance(alt_accessor_id, list): alt_accessor_id = tuple(alt_accessor_id) self._acquisition_base_category = acquisition_base_category self._acquisition_portal_type = acquisition_portal_type self._acquisition_accessor_id = acquisition_accessor_id self._acquisition_copy_value = acquisition_copy_value self._acquisition_mask_value = acquisition_mask_value self._acquired_property = acquired_property if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id self._alt_accessor_id = alt_accessor_id self._acquisition_object_id = acquisition_object_id self._is_list_type = is_list_type self._is_tales_type = is_tales_type def __call__(self, instance, *args, **kw): if len(args) > 0: default = args[0] else: default = None value = instance._getDefaultAcquiredProperty( self._key, None, self._null, base_category=self._acquisition_base_category, portal_type=self._acquisition_portal_type, accessor_id=self._acquisition_accessor_id, copy_value=self._acquisition_copy_value, mask_value=self._acquisition_mask_value, storage_id=self._storage_id, alt_accessor_id=self._alt_accessor_id, acquisition_object_id=self._acquisition_object_id, is_list_type=self._is_list_type, is_tales_type=self._is_tales_type, checked_permission=kw.get('checked_permission', None)) if value is not None: return value.getProperty(self._acquired_property, default, **kw) else: return default psyco.bind(__call__)
class Setter(Base.Setter): """ Gets an attribute value. A default value can be provided if needed """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', 'value', 'args', 'kw') func_code.co_argcount = 2 func_defaults = () def __init__(self, id, key, property_type, acquired_property, portal_type=None, storage_id=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) elif type(storage_id) is not type([]): storage_id = [storage_id] self._storage_id_list = storage_id if type(portal_type) is type('a'): portal_type = (portal_type, ) self._portal_type = portal_type self._acquired_property = acquired_property def __call__(self, instance, value, *args, **kw): # We return the first available object in the list o = None available_id = None modified_object_list = () for k in self._storage_id_list: o = instance._getOb(k, None) if o is None: available_id = k if o is not None and o.portal_type in self._portal_type: o._setProperty(self._acquired_property, value, *args, **kw) modified_object_list = (o, ) if o is None and available_id is not None: from Products.ERP5Type.Utils import assertAttributePortalType assertAttributePortalType(instance, available_id, self._portal_type) if self._acquired_property == 'file': if isinstance(value, FileUpload) or \ getattr(aq_base(value), 'tell', None) is not None: # When editing through the web interface, we are always provided a # FileUpload, and when no file has been specified, the file is empty. # In the case of empty file, we should not create the sub document. value.seek(0, 2) is_empty_file = not value.tell() value.seek(0) if is_empty_file: return () o = instance.newContent(id=available_id, portal_type=self._portal_type[0]) o._setProperty(self._acquired_property, value, *args, **kw) modified_object_list = (o, ) return modified_object_list
class DefaultGetter(BaseGetter): """ Gets the default reference of a relation """ _need__name__=1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self',) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, default, acquisition_base_category, acquisition_portal_type, acquisition_accessor_id, acquisition_copy_value, acquisition_mask_value, storage_id=None, alt_accessor_id = None, acquisition_object_id=None, is_list_type = 0, is_tales_type = 0 ): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] self._default = default # These values are hashed by _get*AcquiredProperty: to be # hashable, they need to be converted to tuples if isinstance(acquisition_base_category, list): acquisition_base_category = tuple(acquisition_base_category) if isinstance(acquisition_object_id, list): acquisition_object_id = tuple(acquisition_object_id) if isinstance(acquisition_portal_type, list): acquisition_portal_type = tuple(acquisition_portal_type) if isinstance(alt_accessor_id, list): alt_accessor_id = tuple(alt_accessor_id) self._acquisition_base_category = acquisition_base_category self._acquisition_portal_type = acquisition_portal_type self._acquisition_accessor_id = acquisition_accessor_id self._acquisition_copy_value = acquisition_copy_value self._acquisition_mask_value = acquisition_mask_value if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id self._alt_accessor_id = alt_accessor_id self._acquisition_object_id = acquisition_object_id self._is_list_type = is_list_type self._is_tales_type = is_tales_type def __call__(self, instance, *args, **kw): if len(args) > 0: default = args[0] else: default = self._default # If this is a TALES expression and the option 'evaluate' is false, # deal with the value as a simple object. if self._is_tales_type and not kw.get('evaluate', 1): is_list_type = 0 is_tales_type = 0 else: is_list_type = self._is_list_type is_tales_type = self._is_tales_type return instance._getDefaultAcquiredProperty(self._key, default, self._null, base_category=self._acquisition_base_category, portal_type=self._acquisition_portal_type, accessor_id=self._acquisition_accessor_id, copy_value=self._acquisition_copy_value, mask_value=self._acquisition_mask_value, storage_id=self._storage_id, alt_accessor_id=self._alt_accessor_id, acquisition_object_id=self._acquisition_object_id, is_list_type=is_list_type, is_tales_type=is_tales_type, checked_permission=kw.get('checked_permission', None), ) psyco.bind(__call__)
class ListGetter(Base.Getter): """ Gets an attribute value. A default value can be provided if needed """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, default=None, storage_id=None): self._id = id self.__name__ = id self._key = key self._property_type = property_type self._null = type_definition[property_type]['null'] self._default = default if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id self._is_tales_type = (property_type == 'tales') def __call__(self, instance, *args, **kw): if len(args) > 0: default = args[0] else: default = self._default list_value = getattr(aq_base(instance), self._storage_id, default) # We should not use here self._null but None instead XXX if list_value not in self._null: if self._is_tales_type: if kw.get('evaluate', 1): if type(list_value) != type(''): LOG( 'ListGetter', 0, 'instance = %r, self._storage_id = %r, list_value = %r' % ( instance, self._storage_id, list_value, ) ) # If we reach this point, something strange is going on list_value = evaluateTales(instance=instance, value=list_value) else: return list_value # Even if it is already a list, return a copy as callers # expect to be able to modify it on place if isinstance(list_value, (list, tuple, set)): return list(list_value ) # Make sure we return a list rather than a tuple return list_value if default is None: return None # nothing was defined as default so None is the appropriate value if isinstance(default, (list, tuple, set)): return list( default) # Make sure we return a list rather than a tuple return default psyco.bind(__call__)
class Tester(BaseTester): """ Tests if an attribute value exists """ _need__name__ = 1 # Generic Definition of Method Object # This is required to call the method form the Web func_code = func_code() func_code.co_varnames = ('self', ) func_code.co_argcount = 1 func_defaults = () def __init__(self, id, key, property_type, portal_type, acquired_property, acquisition_base_category, acquisition_portal_type, acquisition_accessor_id, acquisition_copy_value, acquisition_mask_value, storage_id=None, alt_accessor_id=None, acquisition_object_id=None, is_list_type=0, is_tales_type=0): if type(portal_type) == type('a'): portal_type = (portal_type, ) self._id = id self.__name__ = id self._key = key self._property_type = property_type self._portal_type = portal_type self._null = type_definition[property_type]['null'] # These values are hashed by _get*AcquiredProperty: to be # hashable, they need to be converted to tuples if isinstance(acquisition_base_category, list): acquisition_base_category = tuple(acquisition_base_category) if isinstance(acquisition_portal_type, list): acquisition_portal_type = tuple(acquisition_portal_type) if isinstance(acquisition_object_id, list): acquisition_object_id = tuple(acquisition_object_id) if isinstance(alt_accessor_id, list): alt_accessor_id = tuple(alt_accessor_id) self._acquisition_base_category = acquisition_base_category self._acquisition_portal_type = acquisition_portal_type self._acquisition_accessor_id = acquisition_accessor_id self._acquisition_copy_value = acquisition_copy_value self._acquisition_mask_value = acquisition_mask_value self._acquired_property = acquired_property if storage_id is None: storage_id = "%s%s" % (ATTRIBUTE_PREFIX, key) self._storage_id = storage_id self._alt_accessor_id = alt_accessor_id self._acquisition_object_id = acquisition_object_id self._is_list_type = is_list_type self._is_tales_type = is_tales_type def __call__(self, instance, *args, **kw): if self._storage_id: # If this property is supposed to be stored as a content subobject, # then we consider that if the subobject does not exist then the # property is not set, even if it is acquired from another document. o = instance._getOb(self._storage_id, None) if o is None: return False value = instance._getDefaultAcquiredProperty( self._key, None, self._null, base_category=self._acquisition_base_category, portal_type=self._acquisition_portal_type, accessor_id=self._acquisition_accessor_id, copy_value=self._acquisition_copy_value, mask_value=self._acquisition_mask_value, storage_id=self._storage_id, alt_accessor_id=self._alt_accessor_id, acquisition_object_id=self._acquisition_object_id, is_list_type=self._is_list_type, is_tales_type=self._is_tales_type, checked_permission=kw.get('checked_permission', None)) if value is not None: return value.hasProperty(self._acquired_property) return False