Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install lovely.persistent

How to install lovely.persistent

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install lovely.persistent
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.1 Available View build log
Windows (64-bit)
0.1.1 Available View build log
Mac OS X (10.5+)
0.1.1 Available View build log
Linux (32-bit)
0.1.1 Available View build log
Linux (64-bit)
0.1.1 Available View build log
ZPL 2.1
Lastest release
version 0.1.1 on Jan 5th, 2011


This package provides a base class for persistent objects with the advantage that the object is only marked as changed if an attribute has really changed.

>>> import transaction
>>> from ZODB.tests.util import DB
>>> from lovely import persistent
>>> p = LovelyPersistent()
>>> p._p_changed
>>> p.a = 1
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['p'] = p
>>> transaction.commit()

After commiting the changes the object is no longer in changed state.

>>> p._p_changed

Setting a with its existing value doesn't put the object in cahnged state.

>>> p.a
>>> p.a = 1
>>> p._p_changed

But modifying a :

>>> p.a = 2
>>> p._p_changed
>>> transaction.commit()
>>> p._p_changed

Deleting an attribute also put the object into changed state.

>>> del p.a
>>> p._p_changed
Special Properties

Special property implementations do work too. To show this we use the fieldproperties from zope.schema.

>>> from zope.schema.fieldproperty import FieldProperty
>>> from zope import schema, interface
>>> class IMyFace(interface.Interface):
...     eyesOpen = schema.Bool(default=True, required=False)
>>> class MyFace(persistent.Persistent):
...     eyesOpen = FieldProperty(IMyFace['eyesOpen'])
>>> persistent.tests.MyFace = MyFace
>>> MyFace.__module__ = persistent.tests.setUp.__module__
>>> myFace = conn.root()['myFace'] = MyFace()
>>> transaction.commit()

Default values.

>>> myFace.eyesOpen


>>> myFace.eyesOpen = 'not always'
Traceback (most recent call last):
WrongType: ('not always', <type 'bool'>)

Note, setting to default value does not change the object.

>>> transaction.commit()
>>> myFace.eyesOpen = True
>>> myFace._p_changed
>>> transaction.commit()
>>> myFace.eyesOpen = False
>>> myFace._p_changed

Changes in lovely.persistent

2007/12/10 0.1.1
  • moved to zope.org
2007/06/19 0.1.0a1
  • added zodb to dependencies
  • added support for fieldproperties

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.