Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
persistent
Commits
5b4e713b
Commit
5b4e713b
authored
Feb 17, 2011
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move in-package docs out to the docs directory.
parent
508724f3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
19 deletions
+58
-19
docs/index.rst
docs/index.rst
+1
-0
docs/using.rst
docs/using.rst
+57
-0
persistent/README.txt
persistent/README.txt
+0
-19
No files found.
docs/index.rst
View file @
5b4e713b
...
...
@@ -10,6 +10,7 @@ Contents:
.. toctree::
:maxdepth: 2
using
api
Indices and tables
...
...
docs/using.rst
0 → 100644
View file @
5b4e713b
Using :mod:`persistent` in your application
===========================================
.. note::
This document is under construction. More basic documentation will
eventually appear here.
Inheriting from :class:`persistent.Persistent`
----------------------------------------------
The basic mechanism for making your application's objects persistent
is mix-in interitance. Instances whose classes derive from
:class:`persistent.Persistent` are automatically capable of being
created as :term:`ghost` instances, being associated with a database
connection (called :term:`jar`), and notifying the connection when they
have been changed.
Overriding the attribute protocol
---------------------------------
Subclasses can override the attribute-management methods provided by
:class:`persistent.Persistent`. For the `__getattr__` method, the behavior
is like that for regular Python classes and for earlier versions of ZODB 3.
When overriding `__getattribute__`, the derived class implementation
**must** first call :meth:`persistent.Persistent._p_getattr`, passing the
name being accessed. This method ensures that the object is activated,
if needed, and handles the "special" attributes which do not require
activation (e.g., ``_p_oid``, ``__class__``, ``__dict__``, etc.)
If ``_p_getattr`` returns ``True``, the derived class implementation
**must** delegate to the base class implementation for the attribute.
When overriding `__setattr__`, the derived class implementation
**must** first call :meth:`persistent.Persistent._p_setattr`, passing the
name being accessed and the value. This method ensures that the object is
activated, if needed, and handles the "special" attributes which do not
require activation (``_p_*``). If ``_p_setattr`` returns ``True``, the
derived implementation must assume that the attribute value has been set by
the base class.
When overriding `__detattr__`, the derived class implementation
**must** first call :meth:`persistent.Persistent._p_detattr`, passing the
name being accessed. This method ensures that the object is
activated, if needed, and handles the "special" attributes which do not
require activation (``_p_*``). If ``_p_delattr`` returns ``True``, the
derived implementation must assume that the attribute has been deleted
base class.
More Examples
-------------
Detailed examples are provided in the test module,
`persistent.tests.test_overriding_attrs`.
persistent/README.txt
deleted
100644 → 0
View file @
508724f3
===================
Persistence support
===================
(This document is under construction. More basic documentation will eventually
appear here.)
Overriding `__getattr__`, `__getattribute__`, `__setattr__`, and `__delattr__`
------------------------------------------------------------------------------
Subclasses can override the attribute-management methods. For the
`__getattr__` method, the behavior is like that for regular Python
classes and for earlier versions of ZODB 3.
For `__getattribute__`, __setattr__`, and `__delattr__`, it is necessary
to call certain methods defined by `persistent.Persistent`. Detailed
examples and documentation is provided in the test module,
`persistent.tests.test_overriding_attrs`.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment