[Zope-Checkins] CVS: Zope3/lib/python/Persistence - _persistent.py:1.4
Jim Fulton
jim@zope.com
Sun, 23 Jun 2002 13:04:10 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence
In directory cvs.zope.org:/tmp/cvs-serv11667/lib/python/Persistence
Modified Files:
_persistent.py
Log Message:
Finished implementing
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/AddMenuProposalAndEndOfZmiNamespace
Updated the service manager to use a menu.
Ripped out the old adder registry code.
=== Zope3/lib/python/Persistence/_persistent.py 1.3 => 1.4 ===
from IPersistent import IPersistent
-class Persistent(object):
- """Mix-in class providing IPersistent support
- """
-
- __implements__ = IPersistent
-
- def _p_get_changed(self):
- return self._p_state
-
- def _p_set_changed(self, val):
- if self._p_jar is None or self._p_oid is None:
- return
-
- state = self._p_state
- if state is val: return
-
- if state:
- # changed
- if val==0:
- self._p_state = 0
- elif state==0:
- # unchanged, but not a ghost
- if val:
- self._p_state = 1
- self._p_jar.register(self)
- elif val is None:
- self._p_deactivate()
- self._p_state = None
- else:
- # Ghost. Note val can't be None, cuz then val would equal state.
- self._p_jar.setstate(self)
- self._p_state = 0
- def _p_del_changed(self):
- if self._p_jar is None or self._p_oid is None:
- return
+def _p_get_changed(self):
+ return self._p_state
- state = self._p_state
- if state is not None:
+def _p_set_changed(self, val):
+ if self._p_jar is None or self._p_oid is None:
+ return
+
+ state = self._p_state
+ if state is val: return
+
+ if state:
+ # changed
+ if val==0:
self._p_state = 0
+ elif state==0:
+ # unchanged, but not a ghost
+ if val:
+ self._p_state = 1
+ self._p_jar.register(self)
+ elif val is None:
self._p_deactivate()
self._p_state = None
+ else:
+ # Ghost. Note val can't be None, cuz then val would equal state.
+ self._p_jar.setstate(self)
+ self._p_state = 0
+
+def _p_del_changed(self):
+ if self._p_jar is None or self._p_oid is None:
+ return
+
+ state = self._p_state
+ if state is not None:
+ self._p_state = 0
+ self._p_deactivate()
+ self._p_state = None
+
+
+
+class Persistent(object):
+ """Mix-in class providing IPersistent support
+ """
+
+ __implements__ = IPersistent
_p_changed = property(_p_get_changed, _p_set_changed, _p_del_changed,
"set _p_changed to 1 to indicate a change")