Ulrich Eck wrote:
I'm not shure however, what format this should be distributed .. for unix a CMF-ZPatterns-Patch would probably be best .. other plattforms do not have this .. any comments ??
Make it into a Product that patches the CMF classes at runtime.
See Zope Hotfixes fot a template to work from.
I have for example this modification of PortalContent: ## added for ZPatterns from Products.ZPatterns.DataSkins import DataSkin ## changed for ZPatterns class PortalContent(DataSkin, DynamicType, SimpleItem): """ Base class for portal objects. """ ..... so I need to completely replace the Products.CMFCore.PortalContent.PortalContent with a new class defined (mainly copied from original) in the __init__ of the Patch? can I do this with: -- import Products.CMFCore.PortalContent <<define myclass here >> InitializeClass(<<myclass>>) Products.CMFCore.PortalContent.PortalContent = <<myclass>> -- Is it the same to replace a class in a module than replacing a method/attribute in a Class ?? thanks Ulrich Eck
can I do this with: -- import Products.CMFCore.PortalContent
<<define myclass here >>
InitializeClass(<<myclass>>) Products.CMFCore.PortalContent.PortalContent = <<myclass>> --
ok this works but there is another tricky thing now ... I need to patch two products: CMFCore and CMFDefault. first i patch CMFCore and I think this works (at least a portalfolder is a customizerfolder :) I have now 2 new Classes PortalFolder and PortalContent .. but the CMFDefault.Document for example is still subclassed from CMFCore.PortalContent (the default) and therefore doesn't behave like a dataskin .. any ideas ? is the order in wich the modules are loaded known or changeable ?? if this doesn't work .. I need to release the patches as diffs or tarballs replacing CMFDefault and Core .. not as nice as just patching them .. thanks Ulrich Eck
On Wed, 11 Jul 2001, Ulrich Eck wrote:
the CMFDefault.Document for example is still subclassed from CMFCore.PortalContent (the default) and therefore doesn't behave like a dataskin ..
any ideas ?
You can hotpatch the __bases__ attribute of the derived class. --RDM
Would this approach be appropriate? http://dev.zope.org/Members/Caseman/Dynamic_HotFix_News/Dynamic_Hotfix
From: "Ulrich Eck" <ueck@net-labs.de> Date: Wed, 11 Jul 2001 19:33:15 +0200 To: "ZOPE-DEV Mailingliste" <zope-dev@zope.org> Subject: [Zope-dev] Patching Zope Products .. next Question
can I do this with: -- import Products.CMFCore.PortalContent
<<define myclass here >>
InitializeClass(<<myclass>>) Products.CMFCore.PortalContent.PortalContent = <<myclass>> --
ok this works but there is another tricky thing now ...
I need to patch two products: CMFCore and CMFDefault.
first i patch CMFCore and I think this works (at least a portalfolder is a customizerfolder :)
I have now 2 new Classes PortalFolder and PortalContent ..
but
the CMFDefault.Document for example is still subclassed from CMFCore.PortalContent (the default) and therefore doesn't behave like a dataskin ..
any ideas ?
is the order in wich the modules are loaded known or changeable ??
if this doesn't work .. I need to release the patches as diffs or tarballs replacing CMFDefault and Core .. not as nice as just patching them ..
thanks
Ulrich Eck
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Would this approach be appropriate?
http://dev.zope.org/Members/Caseman/Dynamic_HotFix_News/Dynamic_Hotfix
You can hotpatch the __bases__ attribute of the derived class.
ok .. I tried several different versions of patching .. 1st Try: Created a new class in the patch that subclassed the ZPatterns-Stuff directly: ############################ ### CMFCore.PortalFolder ### ############################ import CMFCore class PortalFolder( CustomizerFolder, CMFCore.PortalFolder.PortalFolder): """ Implements portal content management, but not UI details. """ meta_type = 'Portal Folder' portal_type = 'Folder' def __init__( self, id, title='' ): CustomizerFolder.__init__(self,id) self.id = id self.title = title CMFCore.PortalFolder.PortalFolder = PortalFolder InitializeClass(CMFCore.PortalFolder.PortalFolder) This works fine except the DataSkin-derived classes don't show up in the CustomizerFolder for customization (they're not properly initialized) 2nd Try: modify __bases__ directly .. ############################ ### CMFCore.PortalFolder ### ############################ def PortalFolder__init__( self, id, title='' ): CustomizerFolder.__init__(self,id) self.id = id self.title = title import Products.CMFCore.PortalFolder Products.CMFCore.PortalFolder.PortalFolder.__bases__ = tuple((CustomizerFolder,) + Products.CMFCore.PortalFolder.PortalFolder.__bases__) # the next line works only if i use the im_func # otherwise i get this error: # Error Type: TypeError # Error Value: unbound Python method must be called with PlugInContainer 1st argument Products.CMFCore.PortalFolder.PortalFolder.__init__ = PortalFolder__init__.im_func InitializeClass(Products.CMFCore.PortalFolder.PortalFolder) this one doesn't do anything ... do you see the failure .. have a hint what I'm doing wrong ??? thanks for your patience Ulrich Eck net-labs
sorry for bothering you again .. I'ld like to release the CMFZPatternsPatch as Patch but still have troubles with that. I have this in my __init__.py of the PatchProduct: ############################ ### CMFCore.PortalFolder ### ############################ import Products.CMFCore.DynamicType def PortalFolder__init__( self, id, title='' ): CustomizerFolder.__init__(self,id) self.id = id self.title = title import Products.CMFCore.PortalFolder Products.CMFCore.PortalFolder.PortalFolder.__bases__ = tuple([CustomizerFolder,Products.CMFCore.DynamicType.DynamicType]) Products.CMFCore.PortalFolder.PortalFolder.__init__ = PortalFolder__init__ reload(Products.CMFCore) raise "testerror",str(Products.CMFCore.PortalFolder.PortalFolder.__bases__) I tried this with and without the reload and when I start zope to see the bases I get: 2001-07-12T12:59:44 ERROR(200) Zope Couldn't import Products.CMFZPatternsPatch Traceback (innermost last): File /usr/share/zope/lib/python/OFS/Application.py, line 528, in import_products (Object: string) File /usr/share/zope/lib/python/Products/CMFZPatternsPatch/__init__.py, line 140, in ? testerror: (<extension class OFS.Folder.Folder at 83e9620>, <class Products.CMFCore.DynamicType.DynamicType at 855e5f8>) so .. the __bases__ don't get updated .. or did i miss something ?? thanks for your help Ulrich Eck net-labs
participants (4)
-
marc lindahl -
R. David Murray -
Ulrich Eck -
Ulrich Eck