Commit 92cd18db authored by Alexandre Boeglin's avatar Alexandre Boeglin

(alex) JP corrected the acquisition.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2072 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3f9e6bdb
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
from ZPublisher.HTTPRequest import FileUpload from ZPublisher.HTTPRequest import FileUpload
from TypeDefinition import type_definition, list_types, ATTRIBUTE_PREFIX from TypeDefinition import type_definition, list_types, ATTRIBUTE_PREFIX
from Accessor import Accessor as Method from Accessor import Accessor as Method
#from MethodObject import Method from Acquisition import aq_base
from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Cache import CachingMethod
...@@ -131,7 +131,7 @@ class Getter(Method): ...@@ -131,7 +131,7 @@ class Getter(Method):
default = args[0] default = args[0]
else: else:
default = self._default default = self._default
value = getattr(instance, self._storage_id, None) value = getattr(aq_base(instance), self._storage_id, None) # No acquisition on properties
if value is not None: if value is not None:
if self._is_tales_type and kw.get('evaluate', 1): if self._is_tales_type and kw.get('evaluate', 1):
return evaluateTales(instance, value) return evaluateTales(instance, value)
...@@ -164,4 +164,4 @@ class Tester(Method): ...@@ -164,4 +164,4 @@ class Tester(Method):
def __call__(self, instance, *args, **kw): def __call__(self, instance, *args, **kw):
#return getattr(instance, self._key, None) not in self._null #return getattr(instance, self._key, None) not in self._null
return getattr(instance, self._storage_id, None) is not None return getattr(aq_base(instance), self._storage_id, None) is not None # No acquisition on properties
...@@ -91,7 +91,8 @@ def getClassPropertyList(klass): ...@@ -91,7 +91,8 @@ def getClassPropertyList(klass):
ps_list = getattr(klass, 'property_sheets', ()) ps_list = getattr(klass, 'property_sheets', ())
ps_list = tuple(ps_list) ps_list = tuple(ps_list)
for super_klass in klass.__bases__: for super_klass in klass.__bases__:
if getattr(super_klass, 'isRADContent', 0): ps_list = ps_list + getClassPropertyList(super_klass) if getattr(super_klass, 'isRADContent', 0): ps_list = ps_list + tuple(filter(lambda p: p not in ps_list,
getClassPropertyList(super_klass)))
return ps_list return ps_list
def initializeClassDynamicProperties(self, klass, recursive=0): def initializeClassDynamicProperties(self, klass, recursive=0):
...@@ -136,7 +137,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -136,7 +137,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
# 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:
...@@ -160,6 +161,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -160,6 +161,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
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__))
# 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')
......
...@@ -100,13 +100,13 @@ class CachingMethod: ...@@ -100,13 +100,13 @@ class CachingMethod:
if cache_check_time + CACHE_CHECK_TIMEOUT < now: if cache_check_time + CACHE_CHECK_TIMEOUT < now:
# If the time reachs the timeout, expire all old entries. # If the time reachs the timeout, expire all old entries.
# XXX this can be quite slow, if many results are cached. # XXX this can be quite slow, if many results are cached.
LOG('CachingMethod', 0, 'checking all entries to expire') # LOG('CachingMethod', 0, 'checking all entries to expire')
cache_check_time = now cache_check_time = now
try: try:
for index in cached_object_dict.keys(): for index in cached_object_dict.keys():
obj = cached_object_dict[index] obj = cached_object_dict[index]
if obj.time + obj.duration < now: if obj.time + obj.duration < now:
LOG('CachingMethod', 0, 'expire %s' % index) # LOG('CachingMethod', 0, 'expire %s' % index)
del cached_object_dict[index] del cached_object_dict[index]
except: except:
# This is necessary for multi-threading, because two threads can # This is necessary for multi-threading, because two threads can
......
...@@ -101,16 +101,21 @@ class FolderMixIn(ExtensionClass.Base): ...@@ -101,16 +101,21 @@ class FolderMixIn(ExtensionClass.Base):
my_id = None my_id = None
if id_group is None: if id_group is None:
id_group = self.getIdGroup() id_group = self.getIdGroup()
LOG('newId', 0, repr(( 'id_group was None', id_group )))
if id_group is None or id_group=='None': if id_group is None or id_group=='None':
try: try:
my_id = int(self.getLastId()) my_id = int(self.getLastId())
LOG('newId', 0, repr(( 'id_group is None, my_id', my_id )))
except: except:
my_id = 1 my_id = 1
LOG('newId', 0, repr(( 'id_group is None, my_id failed', my_id )))
while self.hasContent(str(my_id)): while self.hasContent(str(my_id)):
LOG('newId', 0, repr(( 'my_id already there', my_id )))
my_id = my_id + 1 my_id = my_id + 1
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)
LOG('newId', 0, repr(( 'id_group is', id_group, my_id )))
return str(my_id) return str(my_id)
......
...@@ -998,7 +998,7 @@ def setDefaultProperties(klass, object=None): ...@@ -998,7 +998,7 @@ def setDefaultProperties(klass, object=None):
# but is wrong when we use storage_id ..... # but is wrong when we use storage_id .....
storage_id = prop.get('storage_id', prop['id']) storage_id = prop.get('storage_id', prop['id'])
if not hasattr(klass, storage_id): if not hasattr(klass, storage_id):
setattr(klass, storage_id, None) setattr(klass, storage_id, None) # This breaks things with aq_dynamic XXX
#else: #else:
#LOG('existing property',0,str(storage_id)) #LOG('existing property',0,str(storage_id))
#if prop.get('default') is not None: #if prop.get('default') is not None:
......
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