Commit e7be2a3d authored by Nicolas Dumazet's avatar Nicolas Dumazet

invert comparison to lose one level of indentation


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41738 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0a9b2d80
...@@ -1358,86 +1358,85 @@ def setDefaultProperties(property_holder, object=None, portal=None): ...@@ -1358,86 +1358,85 @@ def setDefaultProperties(property_holder, object=None, portal=None):
Permissions.ModifyPortalContent) Permissions.ModifyPortalContent)
if isinstance(write_permission, Expression): if isinstance(write_permission, Expression):
write_permission = write_permission(econtext) write_permission = write_permission(econtext)
if prop['type'] in type_definition: if prop['type'] not in type_definition:
if 'base_id' in prop: raise TypeError, '"%s" is invalid type for propertysheet' % \
continue prop['type']
if not converted_prop_keys.has_key(prop['id']): if 'base_id' in prop:
if prop['type'] != 'content': continue
converted_prop_list += [prop] if not converted_prop_keys.has_key(prop['id']):
converted_prop_keys[prop['id']] = 1 if prop['type'] != 'content':
converted_prop_list += [prop]
# Create range accessors, if this has a range. converted_prop_keys[prop['id']] = 1
if prop.get('range', 0):
for value in ('min', 'max'): # Create range accessors, if this has a range.
range_prop = prop.copy() if prop.get('range', 0):
del range_prop['range'] for value in ('min', 'max'):
if 'storage_id' in range_prop: range_prop = prop.copy()
del range_prop['storage_id'] del range_prop['range']
if range_prop.get('acquisition_accessor_id', 0): if 'storage_id' in range_prop:
range_prop['acquisition_accessor_id'] = '%sRange%s' % ( del range_prop['storage_id']
range_prop['acquisition_accessor_id'], value.capitalize()) if range_prop.get('acquisition_accessor_id', 0):
range_prop['alt_accessor_id'] = ( range_prop['acquisition_accessor_id'] = '%sRange%s' % (
'get' + convertToUpperCase(prop['id']),) range_prop['acquisition_accessor_id'], value.capitalize())
createDefaultAccessors( range_prop['alt_accessor_id'] = (
property_holder, 'get' + convertToUpperCase(prop['id']),)
'%s_range_%s' % (prop['id'], value),
prop=range_prop,
read_permission=read_permission,
write_permission=write_permission,
portal=portal)
# Create translation accesor, if translatable is set
if prop.get('translatable', 0):
# make accessors like getTranslatedProperty
createTranslationAccessors(
property_holder,
'translated_%s' % (prop['id']),
prop,
read_permission=read_permission,
write_permission=write_permission)
createTranslationLanguageAccessors(
property_holder,
prop,
read_permission=read_permission,
write_permission=write_permission,
portal=portal)
# make accessor to translation_domain
# first create default one as a normal property
txn_prop = {}
txn_prop['description'] = ''
txn_prop['default'] = ''
txn_prop['id'] = 'translation_domain'
txn_prop['type'] = 'string'
txn_prop['mode'] = 'w'
createDefaultAccessors( createDefaultAccessors(
property_holder, property_holder,
'%s_%s' %(prop['id'], txn_prop['id']), '%s_range_%s' % (prop['id'], value),
prop=txn_prop, prop=range_prop,
read_permission=read_permission, read_permission=read_permission,
write_permission=write_permission, write_permission=write_permission,
portal=portal) portal=portal)
# then overload accesors getPropertyTranslationDomain
if prop.has_key('translation_domain'): # Create translation accesor, if translatable is set
default = prop['translation_domain'] if prop.get('translatable', 0):
else: # make accessors like getTranslatedProperty
default = '' createTranslationAccessors(
createTranslationAccessors( property_holder,
property_holder, 'translated_%s' % (prop['id']),
'%s_translation_domain' % (prop['id']), prop,
prop, read_permission=read_permission,
read_permission=read_permission, write_permission=write_permission)
write_permission=write_permission, createTranslationLanguageAccessors(
default=default) property_holder,
prop,
read_permission=read_permission,
write_permission=write_permission,
portal=portal)
# make accessor to translation_domain
# first create default one as a normal property
txn_prop = {}
txn_prop['description'] = ''
txn_prop['default'] = ''
txn_prop['id'] = 'translation_domain'
txn_prop['type'] = 'string'
txn_prop['mode'] = 'w'
createDefaultAccessors( createDefaultAccessors(
property_holder,
'%s_%s' %(prop['id'], txn_prop['id']),
prop=txn_prop,
read_permission=read_permission,
write_permission=write_permission,
portal=portal)
# then overload accesors getPropertyTranslationDomain
if prop.has_key('translation_domain'):
default = prop['translation_domain']
else:
default = ''
createTranslationAccessors(
property_holder, property_holder,
prop['id'], '%s_translation_domain' % (prop['id']),
prop=prop, prop,
read_permission=read_permission, read_permission=read_permission,
write_permission=write_permission, write_permission=write_permission,
portal=portal) default=default)
else: createDefaultAccessors(
raise TypeError, '"%s" is invalid type for propertysheet' % \ property_holder,
prop['type'] prop['id'],
prop=prop,
read_permission=read_permission,
write_permission=write_permission,
portal=portal)
# Create Category Accessors # Create Category Accessors
for cat in cat_list: for cat in cat_list:
# Create free text accessors. # Create free text accessors.
...@@ -1560,25 +1559,24 @@ def setDefaultProperties(property_holder, object=None, portal=None): ...@@ -1560,25 +1559,24 @@ def setDefaultProperties(property_holder, object=None, portal=None):
# We remove such properties here # We remove such properties here
#from Base import Base as BaseClass #from Base import Base as BaseClass
for prop in converted_prop_list: for prop in converted_prop_list:
if prop['type'] in type_definition: if prop['type'] not in type_definition:
#if not hasattr(property_holder, prop['id']): raise TypeError, '"%s" is invalid type for propertysheet' % \
# setattr(property_holder, prop['id'], None) # This makes sure no acquisition will happen prop['type']
# but is wrong when we use storage_id ..... #if not hasattr(property_holder, prop['id']):
storage_id = prop.get('storage_id', prop['id']) # setattr(property_holder, prop['id'], None) # This makes sure no acquisition will happen
#if not hasattr(BaseClass, storage_id): # but is wrong when we use storage_id .....
# setattr(property_holder, storage_id, None) # This breaks things with aq_dynamic storage_id = prop.get('storage_id', prop['id'])
#setattr(BaseClass, storage_id, None) # This blocks acquisition #if not hasattr(BaseClass, storage_id):
# setattr(property_holder, storage_id, None) # This breaks things with aq_dynamic
#setattr(BaseClass, storage_id, None) # This blocks acquisition
#else:
#LOG('existing property',0,str(storage_id))
#if prop.get('default') is not None:
# # setattr(property_holder, prop['id'], prop.get('default'))
# pass
#else: #else:
#LOG('existing property',0,str(storage_id)) # # setattr(property_holder, prop['id'], defaults[prop['type']])
#if prop.get('default') is not None: # pass
# # setattr(property_holder, prop['id'], prop.get('default'))
# pass
#else:
# # setattr(property_holder, prop['id'], defaults[prop['type']])
# pass
else:
raise TypeError, '"%s" is invalid type for propertysheet' % \
prop['type']
# Create for every portal type group an accessor (like isPortalDeliveryType) # Create for every portal type group an accessor (like isPortalDeliveryType)
# In the future, this should probalby use categories # In the future, this should probalby use categories
......
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