Commit 9c146950 authored by Sebastien Robin's avatar Sebastien Robin

indent of 4 for ERP5CPS


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@577 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1bdface3
...@@ -35,79 +35,68 @@ from zLOG import LOG ...@@ -35,79 +35,68 @@ from zLOG import LOG
class PatchedProxyBase(ProxyBase): class PatchedProxyBase(ProxyBase):
security = ClassSecurityInfo() security = ClassSecurityInfo()
# Object attributes update method
# security.declarePrivate( '_edit' ) def manage_afterEdit(self):
# def _edit(self, REQUEST=None, force_update = 0, **kw): """
# """ We have to notify the proxy tool we have modified
# call also the proxytool this object
# """ """
# Base._edit(self, REQUEST=REQUEST,force_update=force_update, **kw) px_tool= getToolByName(self,'portal_proxies')
# px_tool= getToolByName(self,'portal_proxies') utool = getToolByName(self, 'portal_url')
# utool = getToolByName(self, 'portal_url') rpath = utool.getRelativeUrl(self)
# rpath = utool.getRelativeUrl(self) px_tool._modifyProxy(self,rpath)
# px_tool._modifyProxy(self,rpath)
def manage_afterEdit(self):
""" def _propertyMap(self):
We have to notify the proxy tool we have modified """
this object Returns fake property sheet
""" """
px_tool= getToolByName(self,'portal_proxies') property_sheet = []
utool = getToolByName(self, 'portal_url')
rpath = utool.getRelativeUrl(self) #property_sheet += self._properties
px_tool._modifyProxy(self,rpath)
property_sheet += [
{
'id' : 'docid',
def _propertyMap(self): 'type' : 'string'
""" },
Returns fake property sheet {
""" 'id' : 'default_language',
property_sheet = [] 'type' : 'string'
},
#property_sheet += self._properties {
'id' : 'sync_language_revisions', # XXX we have to manage dict type
property_sheet += [ 'type' : 'dict'
{ }
'id' : 'docid', ]
'type' : 'string' return tuple(property_sheet + list(getattr(self, '_local_properties', ())))
},
{ security.declareProtected(View, 'getSyncLanguageRevisions')
'id' : 'default_language', def getSyncLanguageRevisions(self):
'type' : 'string' """Get the mapping of language -> revision."""
}, return self._language_revs.copy()
{
'id' : 'sync_language_revisions', # XXX we have to manage dict type security.declareProtected(View, 'setSyncLanguageRevisions')
'type' : 'dict' def setSyncLanguageRevisions(self, dict):
} """Set the mapping of language -> revision."""
] for lang in dict.keys():
return tuple(property_sheet + list(getattr(self, '_local_properties', ()))) self.setLanguageRevision(lang,dict[lang])
security.declareProtected(View, 'getSyncLanguageRevisions') security.declareProtected(View, 'getSyncRepoHistory')
def getSyncLanguageRevisions(self): def getSyncRepoHistory(self):
"""Get the mapping of language -> revision.""" """Get the mapping of language -> revision."""
return self._language_revs.copy() return self._language_revs.copy()
security.declareProtected(View, 'setSyncLanguageRevisions') security.declareProtected(View, 'setSyncRepoHistory')
def setSyncLanguageRevisions(self, dict): def setSyncRepoHistory(self, dict):
"""Set the mapping of language -> revision.""" """Set the mapping of language -> revision."""
for lang in dict.keys(): repotool = getToolByName(self, 'portal_repository')
self.setLanguageRevision(lang,dict[lang]) #repotool.
for lang in dict.keys():
security.declareProtected(View, 'getSyncRepoHistory') self.setLanguageRevision(lang,dict[lang])
def getSyncRepoHistory(self):
"""Get the mapping of language -> revision."""
return self._language_revs.copy()
security.declareProtected(View, 'setSyncRepoHistory')
def setSyncRepoHistory(self, dict):
"""Set the mapping of language -> revision."""
repotool = getToolByName(self, 'portal_repository')
#repotool.
for lang in dict.keys():
self.setLanguageRevision(lang,dict[lang])
ProxyBase.getPath = Base.getPath ProxyBase.getPath = Base.getPath
......
...@@ -28,193 +28,190 @@ from zLOG import LOG ...@@ -28,193 +28,190 @@ from zLOG import LOG
class PatchedCPSDocument(CPSDocument): class PatchedCPSDocument(CPSDocument):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareProtected( View, '_propertyMap' ) security.declareProtected( View, '_propertyMap' )
def _propertyMap(self): def _propertyMap(self):
""" """
Returns fake property sheet Returns fake property sheet
""" """
property_sheet = [] property_sheet = []
property_sheet.append(
{
'id' : 'layout_and_schema',
'type' : 'object'
}
)
type_info = self.getTypeInfo()
field_list = []
if type_info is not None:
if hasattr(type_info,'getDataModel'):
data_model = type_info.getDataModel(self)
if data_model is not None:
field_list = data_model._fields.items()
field_list.sort()
for (prop_id,field) in field_list:
#for field in schema.objectValues():
#LOG('testjp',0,'field: %s' % str(field))
f_type = None
#for p in field._properties:
# if p['id'] == 'default':
# f_type = p['type']
if isinstance(field,CPSImageField):
f_type = 'object'
elif isinstance(field,CPSStringField):
f_type = 'string'
elif isinstance(field,CPSDateTimeField):
f_type = 'date'
elif isinstance(field,CPSFileField):
f_type = 'object'
elif isinstance(field,CPSIntField):
f_type = 'int'
elif isinstance(field,CPSDocument):
pass
if prop_id.find('attachedFile')==0:
f_type='object' # In a flexible content, we do have some attachedFile_f1
# which are CPStringFiels with some binary data
# XXX This should NOT BE NEEDED!!
if f_type is not None:
property_sheet.append( property_sheet.append(
{ {
'id' : prop_id, 'id' : 'layout_and_schema',
'type' : f_type 'type' : 'object'
} }
) )
return tuple(property_sheet + list(getattr(self, '_local_properties', ()))) type_info = self.getTypeInfo()
field_list = []
if type_info is not None:
if hasattr(type_info,'getDataModel'):
data_model = type_info.getDataModel(self)
if data_model is not None:
field_list = data_model._fields.items()
field_list.sort()
for (prop_id,field) in field_list:
f_type = None
if isinstance(field,CPSImageField):
f_type = 'object'
elif isinstance(field,CPSStringField):
f_type = 'string'
elif isinstance(field,CPSDateTimeField):
f_type = 'date'
elif isinstance(field,CPSFileField):
f_type = 'object'
elif isinstance(field,CPSIntField):
f_type = 'int'
elif isinstance(field,CPSDocument):
pass
if prop_id.find('attachedFile')==0:
f_type='object' # In a flexible content, we do have some attachedFile_f1
# which are CPStringFiels with some binary data
# XXX This should NOT BE NEEDED!!
if f_type is not None:
property_sheet.append(
{
'id' : prop_id,
'type' : f_type
}
)
return tuple(property_sheet + list(getattr(self, '_local_properties', ())))
security.declareProtected( View, 'getProperty' )
def getProperty(self, key, d=None):
"""
Previous Name: getValue
Generic accessor. Calls the real accessor
"""
data_model = self.getTypeInfo().getDataModel(self)
accessor_name = 'get' + UpperCase(key)
base = aq_base(self)
if data_model.has_key(key):
return data_model.get(key)
elif hasattr(base,accessor_name):
method = getattr(base,accessor_name)
return method()
return None
security.declarePrivate('getLayoutAndSchema' )
def getLayoutAndSchema(self):
if hasattr(self,'.cps_layouts') and hasattr(self,'.cps_schemas'):
return (aq_base(self._getOb(".cps_layouts")),aq_base(self._getOb(".cps_schemas")))
return None
security.declarePrivate('setLayoutAndSchema' )
def setLayoutAndSchema(self, data):
"""
data must be : (layout,schema)
"""
if data is not None:
self._setOb(".cps_layouts",data[0])
self._setOb(".cps_schemas",data[1])
security.declarePrivate('_setProperty' )
def _setProperty(self, key, value, type='string'):
"""
Set the property for cps objects
"""
LOG('PatchCPSDoc._setProperty',0,'key: %s, value: %s' % (repr(key),repr(value)))
accessor_name = 'set' + UpperCase(key)
if hasattr(aq_base(self),accessor_name):
method = getattr(self, accessor_name)
return method(value)
else:
setattr(self,key,value)
# This solution below doesn't works well, it is better
# to just set the attribute.
#data_model = self.getTypeInfo().getDataModel(self)
#type_info = self.getTypeInfo()
#kw = {key:value}
#type_info.editObject(self,kw)
security.declarePrivate('edit' )
def edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw):
return self._edit(REQUEST=REQUEST, force_update=force_update, reindex_object=reindex_object, **kw)
# Object attributes update method
security.declarePrivate( '_edit' )
def _edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw):
"""
Generic edit Method for all ERP5 object
The purpose of this method is to update attributed, eventually do
some kind of type checking according to the property sheet and index
the object.
Each time attributes of an object are updated, they should
be updated through this generic edit method
"""
LOG('PatchCPSDoc._edit, kw: ',0,kw)
try:
categoryIds = self._getCategoryTool().getBaseCategoryIds()
except:
categoryIds = []
#if kw.has_key('layout_and_schema'):
# self.setLayoutAndSchema(kw['layout_and_schema'])
for key in kw.keys():
accessor = 'get' + UpperCase(key)
#if key in categoryIds:
# self._setCategoryMembership(key, kw[key])
#if key != 'id' and key!= 'layout_and_schema':
if key != 'id' :
# We only change if the value is different
# This may be very long....
self._setProperty(key, kw[key])
def getCoverage(self):
security.declareProtected( View, 'getProperty' )
def getProperty(self, key, d=None):
""" """
Previous Name: getValue
Generic accessor. Calls the real accessor
""" """
data_model = self.getTypeInfo().getDataModel(self) if hasattr(self,'coverage'):
accessor_name = 'get' + UpperCase(key) return self.coverage
base = aq_base(self)
if data_model.has_key(key):
return data_model.get(key)
elif hasattr(base,accessor_name):
method = getattr(base,accessor_name)
return method()
return None return None
security.declarePrivate('getLayoutAndSchema' )
def getLayoutAndSchema(self):
if hasattr(self,'.cps_layouts') and hasattr(self,'.cps_schemas'):
return (aq_base(self._getOb(".cps_layouts")),aq_base(self._getOb(".cps_schemas")))
return None
security.declarePrivate('setLayoutAndSchema' )
def setLayoutAndSchema(self, data):
"""
data must be : (layout,schema)
"""
if data is not None:
self._setOb(".cps_layouts",data[0])
self._setOb(".cps_schemas",data[1])
security.declarePrivate('_setProperty' )
def _setProperty(self, key, value, type='string'):
"""
Set the property for cps objects
"""
LOG('PatchCPSDoc._setProperty',0,'key: %s, value: %s' % (repr(key),repr(value)))
accessor_name = 'set' + UpperCase(key)
if hasattr(aq_base(self),accessor_name):
method = getattr(self, accessor_name)
return method(value)
else:
setattr(self,key,value)
#data_model = self.getTypeInfo().getDataModel(self)
#type_info = self.getTypeInfo()
#kw = {key:value}
#type_info.editObject(self,kw)
security.declarePrivate('edit' )
def edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw):
return self._edit(REQUEST=REQUEST, force_update=force_update, reindex_object=reindex_object, **kw)
# Object attributes update method
security.declarePrivate( '_edit' )
def _edit(self, REQUEST=None, force_update = 0, reindex_object = 0, **kw):
"""
Generic edit Method for all ERP5 object
The purpose of this method is to update attributed, eventually do
some kind of type checking according to the property sheet and index
the object.
Each time attributes of an object are updated, they should
be updated through this generic edit method
"""
LOG('PatchCPSDoc._edit, kw: ',0,kw)
try:
categoryIds = self._getCategoryTool().getBaseCategoryIds()
except:
categoryIds = []
#if kw.has_key('layout_and_schema'):
# self.setLayoutAndSchema(kw['layout_and_schema'])
for key in kw.keys():
accessor = 'get' + UpperCase(key)
#if key in categoryIds:
# self._setCategoryMembership(key, kw[key])
#if key != 'id' and key!= 'layout_and_schema':
if key != 'id' :
# We only change if the value is different
# This may be very long....
self._setProperty(key, kw[key])
def getCoverage(self):
"""
"""
if hasattr(self,'coverage'):
return self.coverage
return None
def getCreator(self): def getCreator(self):
""" """
""" """
#if hasattr(self,'coverage'): #if hasattr(self,'coverage'):
# return self.coverage # return self.coverage
return None return None
def getRelation(self): def getRelation(self):
""" """
""" """
if hasattr(self,'relation'): if hasattr(self,'relation'):
return self.relation return self.relation
return None return None
def setRelation(self,value): def setRelation(self,value):
""" """
""" """
setattr(self,'relation',value) setattr(self,'relation',value)
def getSource(self): def getSource(self):
""" """
""" """
if hasattr(self,'source'): if hasattr(self,'source'):
return self.source return self.source
return None return None
def getPreview(self): def getPreview(self):
""" """
""" """
if hasattr(self,'preview'): if hasattr(self,'preview'):
return self.preview return self.preview
return None return None
def setCreator(self,value): def setCreator(self,value):
""" """
""" """
setattr(self,'creator',value) setattr(self,'creator',value)
def setCreationDate(self,value): def setCreationDate(self,value):
""" """
""" """
setattr(self,'creation_date',value) setattr(self,'creation_date',value)
CPSDocument.getCoverage = getCoverage CPSDocument.getCoverage = getCoverage
CPSDocument.getCreator = getCreator CPSDocument.getCreator = getCreator
......
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