Commit 6a9d16cd authored by Yoshinori Okuji's avatar Yoshinori Okuji

Pass keyword arguments to activate.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2306 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 03ee62b3
...@@ -94,7 +94,7 @@ def getClassPropertyList(klass): ...@@ -94,7 +94,7 @@ def getClassPropertyList(klass):
if getattr(super_klass, 'isRADContent', 0): ps_list = ps_list + tuple(filter(lambda p: p not in ps_list, if getattr(super_klass, 'isRADContent', 0): ps_list = ps_list + tuple(filter(lambda p: p not in ps_list,
getClassPropertyList(super_klass))) getClassPropertyList(super_klass)))
return ps_list return ps_list
def initializeClassDynamicProperties(self, klass, recursive=0): def initializeClassDynamicProperties(self, klass, recursive=0):
id = '' id = ''
#LOG('before aq_method_generated %s' % id, 0, str(klass.__name__)) #LOG('before aq_method_generated %s' % id, 0, str(klass.__name__))
...@@ -115,7 +115,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -115,7 +115,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
#LOG('before aq_portal_type %s' % id, 0, str(ptype)) #LOG('before aq_portal_type %s' % id, 0, str(ptype))
if not aq_portal_type.has_key(ptype): if not aq_portal_type.has_key(ptype):
# Mark as generated # Mark as generated
aq_portal_type[ptype] = PropertyHolder() aq_portal_type[ptype] = PropertyHolder()
prop_holder = aq_portal_type[ptype] prop_holder = aq_portal_type[ptype]
# Recurse to parent object # Recurse to parent object
parent_object = self.aq_parent parent_object = self.aq_parent
...@@ -132,14 +132,14 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -132,14 +132,14 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
if ptype_object is not None and ptype_object.meta_type == 'ERP5 Type Information': if ptype_object is not None and ptype_object.meta_type == 'ERP5 Type Information':
# Make sure this is an ERP5Type object # Make sure this is an ERP5Type object
ps_list = map(lambda p: getattr(PropertySheet, p, None), ptype_object.property_sheet_list) ps_list = map(lambda p: getattr(PropertySheet, p, None), ptype_object.property_sheet_list)
ps_list = filter(lambda p: p is not None, ps_list) ps_list = filter(lambda p: p is not None, ps_list)
# Always append the klass.property_sheets to this list (for compatibility) # Always append the klass.property_sheets to this list (for compatibility)
# Because of the order we generate accessors, it is still possible # Because of the order we generate accessors, it is still possible
# to overload data access for some accessors # to overload data access for some accessors
ps_list = tuple(ps_list) + getClassPropertyList(klass) ps_list = tuple(ps_list) + getClassPropertyList(klass)
#LOG('ps_list',0, str(ps_list)) #LOG('ps_list',0, str(ps_list))
else: else:
ps_list = getClassPropertyList(klass) ps_list = getClassPropertyList(klass)
for base in ps_list: for base in ps_list:
if hasattr(base, '_properties'): if hasattr(base, '_properties'):
prop_list += base._properties prop_list += base._properties
...@@ -151,7 +151,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -151,7 +151,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
if hasattr(base, '_constraints'): if hasattr(base, '_constraints'):
constraint_list += base._constraints constraint_list += base._constraints
if ptype_object is not None and ptype_object.meta_type == 'ERP5 Type Information': if ptype_object is not None and ptype_object.meta_type == 'ERP5 Type Information':
cat_list += ptype_object.base_category_list cat_list += ptype_object.base_category_list
prop_holder._properties = prop_list prop_holder._properties = prop_list
prop_holder._categories = cat_list prop_holder._categories = cat_list
prop_holder._constraints = constraint_list prop_holder._constraints = constraint_list
...@@ -161,8 +161,8 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -161,8 +161,8 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
prop_holder.security = ClassSecurityInfo() # Is this OK for security XXX ? prop_holder.security = ClassSecurityInfo() # Is this OK for security XXX ?
from Utils import initializeDefaultProperties from Utils import initializeDefaultProperties
#LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__)) #LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__))
initializeDefaultProperties([prop_holder], object=self) initializeDefaultProperties([prop_holder], object=self)
#LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__)) #LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__))
# We should now make sure workflow methods are defined # We should now make sure workflow methods are defined
# and also make sure simulation state is defined # and also make sure simulation state is defined
portal_workflow = getToolByName(self, 'portal_workflow') portal_workflow = getToolByName(self, 'portal_workflow')
...@@ -282,35 +282,35 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -282,35 +282,35 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
global aq_portal_type global aq_portal_type
ptype = self.portal_type ptype = self.portal_type
#LOG('_propertyMap',0,ptype) #LOG('_propertyMap',0,ptype)
self._aq_dynamic('id') # Make sure aq_dynamic has been called once self._aq_dynamic('id') # Make sure aq_dynamic has been called once
if aq_portal_type.has_key(ptype): if aq_portal_type.has_key(ptype):
#LOG('_propertyMap ptype',0,list(getattr(aq_portal_type[ptype], '_properties', ()))) #LOG('_propertyMap ptype',0,list(getattr(aq_portal_type[ptype], '_properties', ())))
return tuple(list(getattr(aq_portal_type[ptype], '_properties', ())) + return tuple(list(getattr(aq_portal_type[ptype], '_properties', ())) +
list(getattr(self, '_local_properties', ()))) list(getattr(self, '_local_properties', ())))
return ERP5PropertyManager._propertyMap(self) return ERP5PropertyManager._propertyMap(self)
def _aq_dynamic(self, id): def _aq_dynamic(self, id):
global aq_portal_type global aq_portal_type
ptype = self.portal_type ptype = self.portal_type
# Is this is a portal_type property and everything is already defined # Is this is a portal_type property and everything is already defined
# for that portal_type, try to return a value ASAP # for that portal_type, try to return a value ASAP
if aq_portal_type.has_key(ptype): if aq_portal_type.has_key(ptype):
return getattr(aq_portal_type[ptype], id, None) return getattr(aq_portal_type[ptype], id, None)
# Proceed with property generation # Proceed with property generation
global aq_method_generated, aq_related_generated global aq_method_generated, aq_related_generated
klass = self.__class__ klass = self.__class__
generated = 0 # Prevent infinite loops generated = 0 # Prevent infinite loops
# Generate class methods # Generate class methods
if not aq_method_generated.has_key(klass): if not aq_method_generated.has_key(klass):
try: try:
initializeClassDynamicProperties(self, klass) initializeClassDynamicProperties(self, klass)
except: except:
LOG('_aq_dynamic',0,'error in initializeClassDynamicProperties', error=sys.exc_info()) LOG('_aq_dynamic',0,'error in initializeClassDynamicProperties', error=sys.exc_info())
generated = 1 generated = 1
# Generate portal_type methods # Generate portal_type methods
if not aq_portal_type.has_key(ptype): if not aq_portal_type.has_key(ptype):
try: try:
...@@ -318,31 +318,31 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -318,31 +318,31 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
#LOG('_aq_dynamic for %s' % ptype,0, aq_portal_type[ptype].__dict__.keys()) #LOG('_aq_dynamic for %s' % ptype,0, aq_portal_type[ptype].__dict__.keys())
except: except:
LOG('_aq_dynamic',0,'error in initializePortalTypeDynamicProperties', error=sys.exc_info()) LOG('_aq_dynamic',0,'error in initializePortalTypeDynamicProperties', error=sys.exc_info())
generated = 1 generated = 1
# Generate Related Accessors # Generate Related Accessors
if not aq_related_generated: if not aq_related_generated:
from Utils import createRelatedValueAccessors from Utils import createRelatedValueAccessors
aq_related_generated = 1 aq_related_generated = 1
generated = 1 generated = 1
portal_categories = getToolByName(self, 'portal_categories', None) portal_categories = getToolByName(self, 'portal_categories', None)
generated_bid = {} generated_bid = {}
for id, ps in PropertySheet.__dict__.items(): for id, ps in PropertySheet.__dict__.items():
if id[0] != '_': if id[0] != '_':
for bid in getattr(ps, '_categories', ()): for bid in getattr(ps, '_categories', ()):
if bid not in generated_bid: if bid not in generated_bid:
#LOG( "Create createRelatedValueAccessors %s" % bid,0,'') #LOG( "Create createRelatedValueAccessors %s" % bid,0,'')
createRelatedValueAccessors(Base, bid) createRelatedValueAccessors(Base, bid)
generated_bid[bid] = 1 generated_bid[bid] = 1
# Always try to return something after generation # Always try to return something after generation
if generated: if generated:
return getattr(self, id) return getattr(self, id)
# Proceed with standard acquisition # Proceed with standard acquisition
return None return None
# Constructor # Constructor
def __init__(self, id, uid=None, rid=None, sid=None, **kw): def __init__(self, id, uid=None, rid=None, sid=None, **kw):
self.id = id self.id = id
...@@ -623,7 +623,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -623,7 +623,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
if hasattr(aq_self, accessor_name): if hasattr(aq_self, accessor_name):
method = getattr(self, accessor_name) method = getattr(self, accessor_name)
return method(**kw) return method(**kw)
# Try to get a portal_type property (Implementation Dependent) # Try to get a portal_type property (Implementation Dependent)
global aq_portal_type global aq_portal_type
if not aq_portal_type.has_key(self.portal_type): if not aq_portal_type.has_key(self.portal_type):
try: try:
...@@ -701,8 +701,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -701,8 +701,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
#LOG("Calling: ",0, '%r %r ' % (public_accessor_name, key)) #LOG("Calling: ",0, '%r %r ' % (public_accessor_name, key))
method = getattr(self, public_accessor_name) method = getattr(self, public_accessor_name)
method(value, **kw) method(value, **kw)
return return
# Try to get a portal_type property (Implementation Dependent) # Try to get a portal_type property (Implementation Dependent)
global aq_portal_type global aq_portal_type
if not aq_portal_type.has_key(self.portal_type): if not aq_portal_type.has_key(self.portal_type):
self._aq_dynamic() self._aq_dynamic()
...@@ -714,7 +714,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -714,7 +714,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
method = getattr(self, public_accessor_name) method = getattr(self, public_accessor_name)
method(value, **kw) method(value, **kw)
return return
# Finaly use standard PropertyManager # Finaly use standard PropertyManager
#LOG("Changing attr: ",0, key) #LOG("Changing attr: ",0, key)
try: try:
ERP5PropertyManager._setProperty(self, key, value, type=type) ERP5PropertyManager._setProperty(self, key, value, type=type)
...@@ -751,7 +751,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -751,7 +751,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
method = getattr(self, public_accessor_name) method = getattr(self, public_accessor_name)
method(value, **kw) method(value, **kw)
return return
# Try to get a portal_type property (Implementation Dependent) # Try to get a portal_type property (Implementation Dependent)
global aq_portal_type global aq_portal_type
if not aq_portal_type.has_key(self.portal_type): if not aq_portal_type.has_key(self.portal_type):
self._aq_dynamic() self._aq_dynamic()
...@@ -763,7 +763,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -763,7 +763,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
method = getattr(self, public_accessor_name) method = getattr(self, public_accessor_name)
method(value, **kw) method(value, **kw)
return return
# Finaly use standard PropertyManager # Finaly use standard PropertyManager
#LOG("Changing attr: ",0, key) #LOG("Changing attr: ",0, key)
try: try:
ERP5PropertyManager._setPropValue(self, key, value) ERP5PropertyManager._setPropValue(self, key, value)
...@@ -1559,7 +1559,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1559,7 +1559,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
""" """
root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1)) root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1))
if self.isIndexable and root_indexable: if self.isIndexable and root_indexable:
self.activate().immediateReindexObject(*args, **kw) self.activate(**kw).immediateReindexObject(*args, **kw)
def immediateQueueCataloggedObject(self, *args, **kw): def immediateQueueCataloggedObject(self, *args, **kw):
if self.isIndexable: if self.isIndexable:
...@@ -1573,7 +1573,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1573,7 +1573,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
Index an object in a deferred manner. Index an object in a deferred manner.
""" """
if self.isIndexable: if self.isIndexable:
self.activate().immediateQueueCataloggedObject(*args, **kw) LOG('queueCataloggedObject', 0, 'activate immediateQueueCataloggedObject on %s' % self.getPath())
self.activate(**kw).immediateQueueCataloggedObject(*args, **kw)
security.declarePublic('recursiveQueueCataloggedObject') security.declarePublic('recursiveQueueCataloggedObject')
recursiveQueueCataloggedObject = queueCataloggedObject recursiveQueueCataloggedObject = queueCataloggedObject
...@@ -1759,7 +1760,7 @@ class TempBase(Base): ...@@ -1759,7 +1760,7 @@ class TempBase(Base):
def setUid(self, value): def setUid(self, value):
self.uid = value # Required for Listbox so that no casting happens when we use TempBase to create new objects self.uid = value # Required for Listbox so that no casting happens when we use TempBase to create new objects
def setTitle(self, value): def setTitle(self, value):
""" """
Required so that getProperty('title') will work on tempBase objects Required so that getProperty('title') will work on tempBase objects
The dynamic acquisition work very well for a lot of properties, but The dynamic acquisition work very well for a lot of properties, but
......
...@@ -111,8 +111,8 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -111,8 +111,8 @@ class FolderMixIn(ExtensionClass.Base):
my_id = 1 my_id = 1
while self.hasContent(str(my_id)): while self.hasContent(str(my_id)):
my_id = my_id + 1 my_id = my_id + 1
#LOG('_setLastId', 0, str(self)) #LOG('_setLastId', 0, str(self))
#LOG('_setLastId', 0, str(self.aq_base)) #LOG('_setLastId', 0, str(self.aq_base))
self._setLastId(str(my_id)) # Make sure no reindexing happens self._setLastId(str(my_id)) # Make sure no reindexing happens
else: else:
my_id = self.portal_ids.generateNewId(id_group=id_group,default=default,method=method) my_id = self.portal_ids.generateNewId(id_group=id_group,default=default,method=method)
...@@ -253,7 +253,7 @@ be a problem).""" ...@@ -253,7 +253,7 @@ be a problem)."""
_edit = Base._edit _edit = Base._edit
_setPropValue = Base._setPropValue _setPropValue = Base._setPropValue
_propertyMap = Base._propertyMap # are there any others XXX ? _propertyMap = Base._propertyMap # are there any others XXX ?
#security.declareProtected( Permissions.DeletePortalContent, 'manage_delObjects' ) #security.declareProtected( Permissions.DeletePortalContent, 'manage_delObjects' )
#manage_delObjects = CopyContainer.manage_delObjects #manage_delObjects = CopyContainer.manage_delObjects
...@@ -450,7 +450,7 @@ be a problem).""" ...@@ -450,7 +450,7 @@ be a problem)."""
XXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX
BUG here : when creating a new base category BUG here : when creating a new base category
""" """
self.activate().recursiveImmediateReindexObject(*args, **kw) self.activate(**kw).recursiveImmediateReindexObject(*args, **kw)
security.declarePublic( 'recursiveImmediateReindexObject' ) security.declarePublic( 'recursiveImmediateReindexObject' )
def recursiveImmediateReindexObject(self, *args, **kw): def recursiveImmediateReindexObject(self, *args, **kw):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment