CPSCorePatch.py 4.19 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 28 29 30 31 32 33 34 35 36
from Products.CMFCore.CMFCorePermissions import View
from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.CMFCorePermissions import ViewManagementScreens
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):

37
  security = ClassSecurityInfo()
Sebastien Robin's avatar
Sebastien Robin committed
38 39

    # Object attributes update method
40 41 42 43 44 45 46 47 48 49 50
#     security.declarePrivate( '_edit' )
#     def _edit(self, REQUEST=None, force_update = 0, **kw):
#       """
#       call also the proxytool
#       """
#       Base._edit(self, REQUEST=REQUEST,force_update=force_update, **kw)
#       px_tool= getToolByName(self,'portal_proxies')
#       utool = getToolByName(self, 'portal_url')
#       rpath = utool.getRelativeUrl(self)
#       px_tool._modifyProxy(self,rpath)

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 100 101 102 103 104 105 106 107 108 109
  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
110 111 112 113


ProxyBase.getPath = Base.getPath
ProxyBase.getProperty = Base.getProperty
114
ProxyBase._setProperty = Base._setProperty
115 116
ProxyBase._edit = Base._edit
ProxyBase.asXML = Base.asXML
Sebastien Robin's avatar
Sebastien Robin committed
117
ProxyBase._propertyMap = PatchedProxyBase._propertyMap
118
ProxyBase.manage_afterEdit = PatchedProxyBase.manage_afterEdit
Sebastien Robin's avatar
Sebastien Robin committed
119 120 121 122
ProxyBase.getSyncLanguageRevisions = PatchedProxyBase.getSyncLanguageRevisions
ProxyBase.setSyncLanguageRevisions = PatchedProxyBase.setSyncLanguageRevisions
ProxyBase.getSyncRepoHistory = PatchedProxyBase.getSyncRepoHistory
ProxyBase.setSyncRepoHistory = PatchedProxyBase.setSyncRepoHistory
123

124
ProxyFolder.asXML = Folder.asXML