[Zope] making subclasses persistent

Jerry McRae Jerry McRae <jerry@usd1.com>
Tue, 11 Dec 2001 17:20:01 -0800


Hi Zopeople,

Sorry for the long post. I seem to spend 2 hours programming and 7 hours
searching the archives.

Things I have learned trying to convert my Python App to Zope:

I can place my un-pickled objects in the root of data.fs and then access
them from Zope. Works great, although it took me quite a while to figure
out how to access them from and External Method with self._p_jar.root()
(which wasn't intuitive or found in any documentation).

I was able to access my external database (non-SQL) from an External
Method, although I had to pre-set a list of dictionaries for access from
DTML. The built in sequence of C extension types caused the Zope
security prompt to prevent all access.

I also found the __setstate__ method for re-opening my files if my
objects get reloaded from ZODB (if I ever get them saved in the ZODB!)

Then I struggled for hours this morning trying to solve my 'first
parameter must be an instance' in my Product's __init__() where I was
trying to call the super class's __init__. I was elated to find
inheritedAttribute in the ML archives. Then my hopes of using the same
code as my Python ap were dashed when I found it didn't work for
super classes.

application class design (not necessarily the 'right' way):
class Ap() - repository for all files, tables, and common methods.  ONLY
             used as a super class.
     class com(Ap) - methods, files, and tables specific to the 'com'
               application.  Still only used for 'com' app. super class.
          class comtest(com) - objects specific to a running
                    application.  There is only one instance created,
                    but there is much custom methods in this class.

Running from Python (through aprun.py, which instanciates (sp?) the class,
        loads the tables, and runs the method:
        c:\> python aprun.py comtest run_this_method

>From Zope: ??.
   * I have attempted at making a Product, but I cannot include
     'comtest' as a super class, because I cannot initialize it.  Even
     though I would only need one instance of 'comtest', I don't see how
     to make it (or its class) persistent.
   * I thought of just using External Methods, but cannot figure out how
     to create instances from class definitions in External Methods.

My options at this point seem to be re-write my class structure to work
with Zope. Unfortunately, I would loose my class hierarchy and this
would then require two sets of classes, which would be inconvenient. Any
other suggestions? (if this makes any sense) would be much appreciated!

Does anyone else feel like they have been handed a Ferrari, and it's
really cool and great and all that.  Now if I could only find the
KEYS...

--Jerry
 /\_/\    Jerry McRae       \|||/       mail safely: The Bat! 1.53d
(~o o~)  (stuck in win98)   (. .)       Zope v2.4.1  - dryer than golf
 )'Y'(   _______________-o00-(_)-00o-____________________________________
(     ) / Habit, if not resisted, soon becomes necessity.  --St. Augustine