[ZODB-Dev] Re: property broken with/by ZODB?
Chris Cioffi
evenprimes at gmail.com
Tue Aug 17 14:52:45 EDT 2004
I guess I should mention that I'm using ActivePython 2.3.2 and ZODB 3.2.3.
Chris
On Tue, 17 Aug 2004 14:39:41 -0400, Chris Cioffi <evenprimes at gmail.com> wrote:
> I'm converting a bunch of dicts into proper classes and am having some
> problems using the property builtin. When I derive the class from
> Persistent my properties don't work. Here's an example:
>
> import os.path
>
> import ZODB
> from Persistence import Persistent
>
> class PersistentProp(Persistent):
> def __init__(self):
> self.filename = 'c:\\somedir\\somefile.txt'
>
> def get_basename(self):
> return os.path.basename(self.filename)
>
> basename = property(get_basename)
>
> class ObjectProp(object):
> def __init__(self):
> self.filename = 'c:\\somedir\\somefile.txt'
>
> def get_basename(self):
> return os.path.basename(self.filename)
>
> basename = property(get_basename)
>
> if __name__ == '__main__':
> obj = PersistentProp()
> print 'The Persistent aware object'
> print obj.basename
>
> obj = ObjectProp()
> print 'The "normal" object'
> print obj.basename
>
> When I run this I get:
> The Persistent aware object
> <property object at 0x00891288>
> The "normal" object
> somefile.txt
>
> Since the whole point is to keep this as transparent as possible to
> the rest of the code having to go back in and make some things method
> calls and others attribute references it rather hurts long term
> maintainability.
>
> Any ideas on what's going on here?
>
> Thanks!
>
> Chris
> --
> Still searching for an even prime > 2!
>
--
Still searching for an even prime > 2!
More information about the ZODB-Dev
mailing list