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
class PatchedProxyBase(ProxyBase):
security = ClassSecurityInfo()
security = ClassSecurityInfo()
# Object attributes update method
# security.declarePrivate( '_edit' )
......@@ -48,68 +48,65 @@ class PatchedProxyBase(ProxyBase):
# rpath = utool.getRelativeUrl(self)
# px_tool._modifyProxy(self,rpath)
def manage_afterEdit(self):
"""
We have to notify the proxy tool we have modified
this object
"""
px_tool= getToolByName(self,'portal_proxies')
utool = getToolByName(self, 'portal_url')
rpath = utool.getRelativeUrl(self)
px_tool._modifyProxy(self,rpath)
def _propertyMap(self):
"""
Returns fake property sheet
"""
property_sheet = []
#property_sheet += self._properties
property_sheet += [
{
'id' : 'docid',
'type' : 'string'
},
# { 'id' : 'workflow_history', # XXX Added for ERP5 SyncML
# 'type' : 'pickle'
# },
{
'id' : 'default_language',
'type' : 'string'
},
{
'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')
def getSyncLanguageRevisions(self):
"""Get the mapping of language -> revision."""
return self._language_revs.copy()
security.declareProtected(View, 'setSyncLanguageRevisions')
def setSyncLanguageRevisions(self, dict):
"""Set the mapping of language -> revision."""
for lang in dict.keys():
self.setLanguageRevision(lang,dict[lang])
security.declareProtected(View, 'getSyncRepoHistory')
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])
def manage_afterEdit(self):
"""
We have to notify the proxy tool we have modified
this object
"""
px_tool= getToolByName(self,'portal_proxies')
utool = getToolByName(self, 'portal_url')
rpath = utool.getRelativeUrl(self)
px_tool._modifyProxy(self,rpath)
def _propertyMap(self):
"""
Returns fake property sheet
"""
property_sheet = []
#property_sheet += self._properties
property_sheet += [
{
'id' : 'docid',
'type' : 'string'
},
{
'id' : 'default_language',
'type' : 'string'
},
{
'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')
def getSyncLanguageRevisions(self):
"""Get the mapping of language -> revision."""
return self._language_revs.copy()
security.declareProtected(View, 'setSyncLanguageRevisions')
def setSyncLanguageRevisions(self, dict):
"""Set the mapping of language -> revision."""
for lang in dict.keys():
self.setLanguageRevision(lang,dict[lang])
security.declareProtected(View, 'getSyncRepoHistory')
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
......@@ -123,4 +120,4 @@ ProxyBase.setSyncLanguageRevisions = PatchedProxyBase.setSyncLanguageRevisions
ProxyBase.getSyncRepoHistory = PatchedProxyBase.getSyncRepoHistory
ProxyBase.setSyncRepoHistory = PatchedProxyBase.setSyncRepoHistory
ProxyFolder.asXML = Folder.asXML
\ No newline at end of file
ProxyFolder.asXML = Folder.asXML
......@@ -19,49 +19,80 @@
from Products.CPSDocument.CPSDocument import CPSDocument
from Products.CPSSchemas.BasicFields import CPSImageField, CPSFileField, CPSDateTimeField
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):
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 = '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', ())))
security = ClassSecurityInfo()
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.getProperty = Base.getProperty
CPSDocument.setProperty = Base.setProperty
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