[ZODB-Dev] persistent.py? transaction.py? deriving from
PersistentList?
Alan Ezust
zodb at oddiofile.com
Sun Nov 7 18:25:04 EST 2004
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?
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.
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?
--
Alan Ezust
Victoria, BC
More information about the ZODB-Dev
mailing list