[Zope-CMF] Relocating the files in a ZOPE product

Dieter Maurer dieter at handshake.de
Mon Jan 12 13:58:44 EST 2004


suresh_vv wrote at 2004-1-12 08:10 -0000:
> ...
>>   2.  use the "__module_aliases__" feature in the product's
>>       "__init__.py" file.
>> 
>>       I am not sure, whether this feature is documented (if it is,
>>       it is probably in the Zope Developper Guide).
>>       You find an example (e.g.) in "PythonScripts".
> ...
>Option 2. This would be nice if it worked. As I understand, I need to 
>mention only .py files (not individual classes) and only .py files 
>that contain the class definitions (not utility files and such). 

Yes, but the classes must not have gotten different names...

>There are 2 .py files (one with 3 class definitions and the other 
>with 2).  I tried listing both, checked that the Product was loaded 
>correctly in the Conterol panel, and still the objects are not loaded 
>from the ZODB.

I can assure you that "__module_aliases__" works in principle
(I used it).

When "__module_aliases__" contains a pair "module_path, module",
then "sys.modules" is extended by

     sys.modules[module_path] = module


It might be necessary that "package_path" must have
an entry as well in "sys.modules" if "module_path" is
"package_path.module_name".


>Any other ideas?

Check that the "__module_alias__" works as expected:

  *  make an External Method

  *  import the class from its old place in the External Method

  *  see what exception you get

If you do not get an exception, the object should be loaded...


-- 
Dieter



More information about the Zope-CMF mailing list