CPSCorePatch.py 3.97 KB
Newer Older
Sebastien Robin's avatar
Sebastien Robin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# (C) Copyright 2004 Nexedi SARL <http://nexedi.com>
# Authors: Sebastien Robin <seb@nexedi.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#

19
from Products.CPSCore.ProxyBase import ProxyBase, ProxyFolder
Sebastien Robin's avatar
Sebastien Robin committed
20 21 22 23
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Globals import InitializeClass
from Products.ERP5Type.Base import Base
24
from Products.ERP5Type.Document.Folder import Folder
Sebastien Robin's avatar
Sebastien Robin committed
25 26 27
from Products.CMFCore.CMFCorePermissions import View
from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.CMFCorePermissions import ViewManagementScreens
28
from Products.CMFCore.utils import getToolByName
Sebastien Robin's avatar
Sebastien Robin committed
29 30 31 32 33 34 35 36 37
from zLOG import LOG

# First we should make ProxyBase a subclass of Base
# XXX doesn't works at all
#ProxyBase.__bases__ += (ERP5Base,)
#ProxyDocument.__bases__ += (ERP5Base,)

class PatchedProxyBase(ProxyBase):

Sebastien Robin's avatar
Sebastien Robin committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    security = ClassSecurityInfo()


    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])
Sebastien Robin's avatar
Sebastien Robin committed
100 101 102 103


ProxyBase.getPath = Base.getPath
ProxyBase.getProperty = Base.getProperty
104
ProxyBase._setProperty = Base._setProperty
105 106
ProxyBase._edit = Base._edit
ProxyBase.asXML = Base.asXML
Sebastien Robin's avatar
Sebastien Robin committed
107
ProxyBase._propertyMap = PatchedProxyBase._propertyMap
108
ProxyBase.manage_afterEdit = PatchedProxyBase.manage_afterEdit
Sebastien Robin's avatar
Sebastien Robin committed
109 110 111 112
ProxyBase.getSyncLanguageRevisions = PatchedProxyBase.getSyncLanguageRevisions
ProxyBase.setSyncLanguageRevisions = PatchedProxyBase.setSyncLanguageRevisions
ProxyBase.getSyncRepoHistory = PatchedProxyBase.getSyncRepoHistory
ProxyBase.setSyncRepoHistory = PatchedProxyBase.setSyncRepoHistory
113

114
ProxyFolder.asXML = Folder.asXML