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 @@
from ZPublisher.HTTPRequest import FileUpload
from TypeDefinition import type_definition, list_types, ATTRIBUTE_PREFIX
from Accessor import Accessor as Method
#from MethodObject import Method
from Acquisition import aq_base
from Products.ERP5Type.Cache import CachingMethod
......@@ -131,7 +131,7 @@ class Getter(Method):
default = args[0]
else:
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 self._is_tales_type and kw.get('evaluate', 1):
return evaluateTales(instance, value)
......@@ -164,4 +164,4 @@ class Tester(Method):
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
return getattr(aq_base(instance), self._storage_id, None) is not None # No acquisition on properties
......@@ -91,7 +91,8 @@ def getClassPropertyList(klass):
ps_list = getattr(klass, 'property_sheets', ())
ps_list = tuple(ps_list)
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
def initializeClassDynamicProperties(self, klass, recursive=0):
......@@ -136,7 +137,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
# Because of the order we generate accessors, it is still possible
# to overload data access for some accessors
ps_list = tuple(ps_list) + getClassPropertyList(klass)
#LOG('ps_list',0, str(ps_list))
LOG('ps_list',0, str(ps_list))
else:
ps_list = getClassPropertyList(klass)
for base in ps_list:
......@@ -160,6 +161,7 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
from Utils import initializeDefaultProperties
#LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__))
initializeDefaultProperties([prop_holder], object=self)
LOG('initializeDefaultProperties: %s' % ptype, 0, str(prop_holder.__dict__))
# We should now make sure workflow methods are defined
# and also make sure simulation state is defined
portal_workflow = getToolByName(self, 'portal_workflow')
......
......@@ -100,13 +100,13 @@ class CachingMethod:
if cache_check_time + CACHE_CHECK_TIMEOUT < now:
# If the time reachs the timeout, expire all old entries.
# 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
try:
for index in cached_object_dict.keys():
obj = cached_object_dict[index]
if obj.time + obj.duration < now:
LOG('CachingMethod', 0, 'expire %s' % index)
# LOG('CachingMethod', 0, 'expire %s' % index)
del cached_object_dict[index]
except:
# This is necessary for multi-threading, because two threads can
......
......@@ -101,16 +101,21 @@ class FolderMixIn(ExtensionClass.Base):
my_id = None
if id_group is None:
id_group = self.getIdGroup()
LOG('newId', 0, repr(( 'id_group was None', id_group )))
if id_group is None or id_group=='None':
try:
my_id = int(self.getLastId())
LOG('newId', 0, repr(( 'id_group is None, my_id', my_id )))
except:
my_id = 1
LOG('newId', 0, repr(( 'id_group is None, my_id failed', my_id )))
while self.hasContent(str(my_id)):
LOG('newId', 0, repr(( 'my_id already there', my_id )))
my_id = my_id + 1
self._setLastId(str(my_id)) # Make sure no reindexing happens
else:
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)
......
......@@ -998,7 +998,7 @@ def setDefaultProperties(klass, object=None):
# but is wrong when we use storage_id .....
storage_id = prop.get('storage_id', prop['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:
#LOG('existing property',0,str(storage_id))
#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