[Zope] converting Python ap to Zope

zope-mailinglist zope-mailinglist@mopa.at
Sat, 01 Dec 2001 07:51:20 +0100


Jerry McRae wrote:

> Hi ZoPeople,
> 
> I have searched and read everything I could find for weeks, I still
> need help.
> 
> I am attempting to convert a Python application into Zope.  I am having
> much trouble creating a Product from this application because of some of
> its dependances.  The user interface is completely separate, so that is
> not an issue.
> 
> I have tried loading the whole app as an external method, which didn't
> work, but I learned to make a copy of ALL modules and place them in a
> Zope sub-folder.  The python path from my stand-alone python 2.1 didn't
> get searched.
> 
> I am attempting to write a Product to access my application, but have
> run into several errors mostly due to pickleing.
> 
> I would like to have the same code for my base classes, but I have the
> following conundrums.  Any pointers would be much appreciated.
> 
> 1) There are a lot of classes and tables.  Each user can create multiple
> sets of the application classes and tables.  Each set of instances and
> attributes is pickled as a file.  The application is basically just a
> wrapper for the pickled instances.  I can think of no way to convert the
> pickle file into classes and attributes that Zope can see and/or modify.
> It seems I will have to re-factor each and every python class as a Zope
> class.
> 
> 2) several specialized data files are involved, which are opened and
> positioned based on the classes and parameters.  The files are needed
> for all aspects of the application.  Since Zope cannot pickle open file
> handles, I could store file names, positions, and other attributes, but
> I don't know how to re-open the files any time Zope restarts so that the
> user just references my object name (and methods) to access the data.
> 
> 3) the key to accessing these specialized files is a windows .DLL file
> that works great in Python, but is unpickleable (is that a word?) in
> Zope.  I think I want to create a function that gets loaded when the
> Product does, but I cannot find any examples of Products that do this:
> allow instanciated objects to call custom functions created from __init__.py in
> a Product.  There must be someplace to add globally available functions
> to Zope outside of ZODB, yes?
> 
> --Jerry
> 
> --
>  /\_/\    Jerry McRae       \|||/       mail safely: The Bat! 1.53d
> (~o o~)  (stuck in win98)   (. .)       Zope v2.4.1  - dryer than golf
>  )'Y'(   _______________-o00-(_)-00o-____________________________________
> (     ) / Imagination rules the world.  --Napoleon
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
> 


when you place your non zope stuff into a subdir in the products folder 
you can import it via:
from Products.<yourProductFolder>.<Module> import <ClassName>

if something is not pickleable you have to avoid that you don't asign it 
via "self." to a zope object instance, because zope tries to pickle it 
to zopedb. i got the same problem with a db connection in a module.

another way could be to disable persistence for the particular python 
product - but i never tried this till now.

hope this helps, bernd dorn