[ZODB-Dev] persistent.py? transaction.py? deriving from PersistentList?

Kapil Thangavelu hazmat at objectrealms.net
Sun Nov 7 18:35:45 EST 2004


On Sun, 2004-11-07 at 15:25 -0800, Alan Ezust wrote:
> 1. Is it possible to derive from PersistentList and give other attributes to 
> derived classes?
> 
> 2. where is transaction.py?
> The http://zope.org/Wikis/ZODB/FrontPage/guide/zodb.html makes reference to an
> import transaction
> so you can do 
> transaction.commit() method, 
> 
> but transaction.py
> 
> I was told on an IRC that there is a __builtin__ get_transaction() method we 
> use instead, but where is that documented in the programming guide?


there were some major changes between the zodb3.2 version that ships
currently with zope and the standalone zodb 3.3 that will ship with
zope2.8

ie. lower case modules and packages like persistent and transacation are
from zodb 3.3

if your using zodb in a standalone fashion its probably best to start
with zodb3.3

> 
> 3. where is persistent.py?
> I see ZODB.PersistentList.PersistentList
> but not persistent.list.PersistentList (as referenced in 
> http://zope.org/Wikis/ZODB/FrontPage/guide/node6.html). Is that another 
> package-movement that happened since the last version of that guide?
> 
> 4. Transaction and PersistentList are both modules with capitalized names, as 
> well as classnames. Why? Shouldn't modules be lowercase and classnames 
> uppercase? Very Confusing. 

its a style, things are more consistent with the style you suggest in
zodb 3.3

> 
> 4. I'm having problems with PersistentList.__setslice__. It seems to throw 
> exceptions from line 38 of UserList.py
> 
> UserList.__setslice__
> 
>     def __setslice__(self, i, j, other):
>         i = max(i, 0); j = max(j, 0)
>         if isinstance(other, UserList):
>             self.data[i:j] = other.data
>        elif isinstance(other, type(self.data)): # line 38 - self.data is null
>             self.data[i:j] = other
> 
> It is at this point, self.data is null - does not get properly initialized.
> 
> I am calling setslice from a derived class constructor. Perhaps the object is 
> not fully initialized yet?
> 

> class WebPage(PersistentList)
>     """Class WebPage - abstraction for a web page in the database.
>         Does not hold onto the contents of the referred page, but does
>         cache the links.
>     """
>     _url = None
>     
>     def __init__(self, url):
>  # at this point, self.data is null - base class ctor not called?
>  self[0:3] = ["webpage", {"url" : url}, [], None] 
>         self._url = url
> 
> I get a null pointer exception here.

> How can I derive and extend the PersistentList?
> 

python doesn't call base constructors automatically for you. you need to
manually do so.

hth,

-kapil



More information about the ZODB-Dev mailing list