[Zope-Coders] Re: [ZC] 239/ 3 Comment "Product Re-Factoring Impossible"
John Eikenberry
jae@kavi.com
Mon, 25 Feb 2002 13:20:58 -0800
Yes. I did this. Unfortunately it requires not just the creation of 1 file,
but of about 94. I even wrote up a script to generate the ones I needed.
It is possible, but considering the goal is to re-organize to clean things
up this doesn't help a ton. Though it is my best option at the moment.
Thanks.
Collector: Zope Bugs and Patches ... wrote:
> Issue #239 Update (Comment) "Product Re-Factoring Impossible"
> Status Pending, Database/bug critical
> To followup, visit:
> http://collector.zope.org/Zope/239
>
> ==============================================================
> = Comment - Entry #3 by htrd on Feb 25, 2002 6:57 am
>
> The old class name is Products.DotOrg.Members.MembersApp. You dont say what the new class name is, but for the sake of this example lets say it is Products.DotOrgMembers.MemberStuff.App
>
> An easy solution is to create a reference to the new class under the original name. If you have deleted the old MembersApp.py you will need to recreate it, then add to it:
>
> from Products.DotOrgMembers.MemberStuff import App as MembersApp
>
> All new instances will use the new name of course. Further, all old instances will switch over to the new name as soon as they are modified and repickled. You need to keep this legacy support file around for as long as you have unmodified legacy objects in the database.
>
>
>
> ________________________________________
> = Comment - Entry #2 by shane on Feb 22, 2002 1:17 pm
>
> I started a utility to do just this a few months ago:
>
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/zodbex/zodbex/ChangeModules/change_modules.py?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup
>
> It's not functional yet, but it's close. I wonder if I could hand off the work to someone who knows a lot about ZODB.
>
> ________________________________________
> = Request - Entry #1 by Anonymous User on Feb 21, 2002 8:11 pm
>
> We are currently re-organizaing our code base and have existing production sites using this code base we will need to update in the future. The ZODB provides no mechanism for updating the pickled objects to refer to the new layout. After the change, any existing site returns a slew of errors such as:
>
> 2002-02-21T22:26:36 PROBLEM(100) ZODB Could not import class 'MembersApp' from module 'Products.DotOrg.Members.MembersApp'
>
> I've read through the mailing list archives and any other docs I could find. They suggest __module_aliases__ which I've tried. It helps but doesn't work with classes which are very common. I've tried many other things like manually assigning the __class__ attribute and using a custom persistent_load() method.
>
> There either needs to be a tool for this or some documentation on massaging existing code to get the module_aliases trick to work (change class reference to module references in the pickled objects).
>
> This is critically important to the long term viability of Zope and any products built on Zope. If you can't restructure your code as it grows, it eventually becomes un-maintainable.
>
> ==============================================================
>
--
John Eikenberry [jae@kavi.com]
______________________________________________________________
"A society that will trade a little liberty for a little order
will deserve neither and lose both."
--B. Franklin