[Grok-dev] Re: avoiding ZODB breakage

Martijn Faassen faassen at startifact.com
Wed Jun 11 06:30:56 EDT 2008

Philipp von Weitershausen wrote:
> Martijn Faassen wrote:
>>> a) introduce a module alias (if you've moved a whole module)
>>> b) or provide BBB imports in the old module
>>> Both aren't hard, in fact b) is pretty straight-forward. I don't 
>>> think it gets any easier. You just have to *know* that you have to do 
>>> it. That's really the trickiest part, I think.
>> The trickiest part will be easier if we make it absolutely trivial. I 
>> think we should make it so the user doesn't have to care whether they 
>> moved the whole module or not. I also don't want to tell people how 
>> they should mess around sys.modules themselves to make module aliases 
>> (as I understand a) still requires).
>> What about something like this?
>> class Foo(grok.Model):
>>     grok.moved('foo.bar.baz', class_name='Bar')
>> so, if you move any class, you can indicate with grok.moved that you 
>> moved it.
> Yup, why not. Could also be a module-level directive, then it would set 
> up a module alias for the whole module.

Yes, so the rule could be:

in a class:

* grok.moved('foo.bar.baz')

   The class was moved from that module, the name of the class remained
   the same.

* grok.moved('foo.bar.baz', 'Bar')

   The class was moved from that module, the name of the class was
   originally Baz.

in a module:

* grok.moved('foo.bar.baz')

    Everything in this module was originally in 'foo.bar.baz'. Adding a
    class name argument here is forbidden.

I'd say though that whole module moves are of secondary importance. 
Granted they happen a lot for Zope libraries, but typical intra-package 
refactoring will just move a class around.

It'd also be nice to have some way to guarantee everything has been 
moved now, so the 'grok.moved' can be removed again. Another question is 
what we do if something moves *twice*. :)



More information about the Grok-dev mailing list