Commit da2119cc authored by Sebastien Robin's avatar Sebastien Robin

no modification of cps is needed now


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@328 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 30613722
...@@ -34,7 +34,7 @@ from zLOG import LOG ...@@ -34,7 +34,7 @@ from zLOG import LOG
class PatchedProxyBase(ProxyBase): class PatchedProxyBase(ProxyBase):
security = ClassSecurityInfo() security = ClassSecurityInfo()
# Object attributes update method # Object attributes update method
# security.declarePrivate( '_edit' ) # security.declarePrivate( '_edit' )
...@@ -48,68 +48,65 @@ class PatchedProxyBase(ProxyBase): ...@@ -48,68 +48,65 @@ class PatchedProxyBase(ProxyBase):
# rpath = utool.getRelativeUrl(self) # rpath = utool.getRelativeUrl(self)
# px_tool._modifyProxy(self,rpath) # px_tool._modifyProxy(self,rpath)
def manage_afterEdit(self): def manage_afterEdit(self):
""" """
We have to notify the proxy tool we have modified We have to notify the proxy tool we have modified
this object this object
""" """
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 _propertyMap(self): def _propertyMap(self):
""" """
Returns fake property sheet Returns fake property sheet
""" """
property_sheet = [] property_sheet = []
#property_sheet += self._properties #property_sheet += self._properties
property_sheet += [ property_sheet += [
{ {
'id' : 'docid', 'id' : 'docid',
'type' : 'string' 'type' : 'string'
}, },
# { 'id' : 'workflow_history', # XXX Added for ERP5 SyncML {
# 'type' : 'pickle' 'id' : 'default_language',
# }, 'type' : 'string'
{ },
'id' : 'default_language', {
'type' : 'string' 'id' : 'sync_language_revisions', # XXX we have to manage dict type
}, 'type' : 'dict'
{ }
'id' : 'sync_language_revisions', # XXX we have to manage dict type ]
'type' : 'dict' return tuple(property_sheet + list(getattr(self, '_local_properties', ())))
}
] security.declareProtected(View, 'getSyncLanguageRevisions')
return tuple(property_sheet + list(getattr(self, '_local_properties', ()))) def getSyncLanguageRevisions(self):
"""Get the mapping of language -> revision."""
security.declareProtected(View, 'getSyncLanguageRevisions') return self._language_revs.copy()
def getSyncLanguageRevisions(self):
"""Get the mapping of language -> revision.""" security.declareProtected(View, 'setSyncLanguageRevisions')
return self._language_revs.copy() def setSyncLanguageRevisions(self, dict):
"""Set the mapping of language -> revision."""
security.declareProtected(View, 'setSyncLanguageRevisions') for lang in dict.keys():
def setSyncLanguageRevisions(self, dict): self.setLanguageRevision(lang,dict[lang])
"""Set the mapping of language -> revision."""
for lang in dict.keys(): security.declareProtected(View, 'getSyncRepoHistory')
self.setLanguageRevision(lang,dict[lang]) def getSyncRepoHistory(self):
"""Get the mapping of language -> revision."""
security.declareProtected(View, 'getSyncRepoHistory') return self._language_revs.copy()
def getSyncRepoHistory(self):
"""Get the mapping of language -> revision.""" security.declareProtected(View, 'setSyncRepoHistory')
return self._language_revs.copy() def setSyncRepoHistory(self, dict):
"""Set the mapping of language -> revision."""
security.declareProtected(View, 'setSyncRepoHistory') repotool = getToolByName(self, 'portal_repository')
def setSyncRepoHistory(self, dict): #repotool.
"""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():
self.setLanguageRevision(lang,dict[lang])
ProxyBase.getPath = Base.getPath ProxyBase.getPath = Base.getPath
...@@ -123,4 +120,4 @@ ProxyBase.setSyncLanguageRevisions = PatchedProxyBase.setSyncLanguageRevisions ...@@ -123,4 +120,4 @@ ProxyBase.setSyncLanguageRevisions = PatchedProxyBase.setSyncLanguageRevisions
ProxyBase.getSyncRepoHistory = PatchedProxyBase.getSyncRepoHistory ProxyBase.getSyncRepoHistory = PatchedProxyBase.getSyncRepoHistory
ProxyBase.setSyncRepoHistory = PatchedProxyBase.setSyncRepoHistory ProxyBase.setSyncRepoHistory = PatchedProxyBase.setSyncRepoHistory
ProxyFolder.asXML = Folder.asXML ProxyFolder.asXML = Folder.asXML
\ No newline at end of file
...@@ -19,49 +19,80 @@ ...@@ -19,49 +19,80 @@
from Products.CPSDocument.CPSDocument import CPSDocument from Products.CPSDocument.CPSDocument import CPSDocument
from Products.CPSSchemas.BasicFields import CPSImageField, CPSFileField, CPSDateTimeField from Products.CPSSchemas.BasicFields import CPSImageField, CPSFileField, CPSDateTimeField
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import UpperCase
from Acquisition import aq_base, aq_inner
from AccessControl import ClassSecurityInfo
from Products.CMFCore.CMFCorePermissions import View
class PatchedCPSDocument(CPSDocument): class PatchedCPSDocument(CPSDocument):
def _propertyMap(self): security = ClassSecurityInfo()
"""
Returns fake property sheet
"""
property_sheet = []
for schema in self.getTypeInfo().getSchemas():
for field in schema.objectValues():
#LOG('testjp',0,'field: %s' % str(field))
f_type = ''
for p in field._properties:
if p['id'] == 'default':
f_type = p['type']
if isinstance(field,CPSImageField):
#f_type = 'image'
f_type = 'pickle'
if isinstance(field,CPSDateTimeField):
f_type = 'date'
if isinstance(field,CPSFileField):
#f_type = 'file'
f_type = 'pickle'
if isinstance(field,CPSDocument):
#f_type = 'document'
f_type = 'pickle'
prop_id = schema.getIdUnprefixed(field.id)
if prop_id in ('file_text','content','attachedFile',
'attachedFile_html','attachedFile_text', 'content'):
f_type = 'pickle' # this should be string, but this strings
# do so bad xml
#if not (prop_id in ('file_text','content','attachedFile','attachedFile_html','attachedFile_text')):
#if not (prop_id in ('content',)):
if 1:
property_sheet.append(
{
'id' : prop_id,
'type' : f_type
}
)
return tuple(property_sheet + list(getattr(self, '_local_properties', ())))
def _propertyMap(self):
"""
Returns fake property sheet
"""
property_sheet = []
for schema in self.getTypeInfo().getSchemas():
for field in schema.objectValues():
#LOG('testjp',0,'field: %s' % str(field))
f_type = ''
for p in field._properties:
if p['id'] == 'default':
f_type = p['type']
if isinstance(field,CPSImageField):
#f_type = 'image'
f_type = 'object'
if isinstance(field,CPSDateTimeField):
f_type = 'date'
if isinstance(field,CPSFileField):
#f_type = 'file'
f_type = 'object'
if isinstance(field,CPSDocument):
#f_type = 'document'
f_type = 'object'
prop_id = schema.getIdUnprefixed(field.id)
if prop_id in ('file_text','content','attachedFile',
'attachedFile_html','attachedFile_text', 'content'):
f_type = 'object' # this should be string, but this strings
# do so bad xml
#if not (prop_id in ('file_text','content','attachedFile','attachedFile_html','attachedFile_text')):
#if not (prop_id in ('content',)):
if 1:
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
"""
accessor_name = 'get' + UpperCase(key)
aq_self = aq_base(self)
if hasattr(aq_self, accessor_name):
method = getattr(self, accessor_name)
return method()
prop_type = self.getPropertyType(key) # XXX added by Seb
if prop_type in ('object',):
if hasattr(aq_self, key):
value = getattr(aq_self, key)
value = aq_base(value)
return value
return None
elif hasattr(aq_self, key):
value = getattr(aq_self, key)
if callable(value): value = value()
return value
CPSDocument.getProperty = PatchedCPSDocument.getProperty
CPSDocument._propertyMap = PatchedCPSDocument._propertyMap CPSDocument._propertyMap = PatchedCPSDocument._propertyMap
CPSDocument.getProperty = Base.getProperty
CPSDocument.setProperty = Base.setProperty CPSDocument.setProperty = Base.setProperty
CPSDocument.asXML = Base.asXML CPSDocument.asXML = Base.asXML
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