Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Writing persistent objects #22

Merged
merged 12 commits into from
Sep 5, 2016
Merged

Conversation

jimfulton
Copy link
Member

Plus:

  • Added machinery to text documentation examples
  • Cleaned up config a bit

@jimfulton jimfulton changed the base branch from master to new-guide August 26, 2016 15:56

Two of the main jobs of the ``Persistent`` base class is to detect
when an object has been accessed and when it has been modified. When
an object is accessed, it's state may need to be loaded from the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its

Special attributes
==================

There are some attributes that are treated specially.
Copy link
Member

@jamadden jamadden Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is persistent documentation generated somewhere (e.g., readthedocs)? The IPersistent interface has a nice expanded discussion of these attributes that might be nice to link to if so. The discussion here and below pretty much covers it all, but I assume the IPersistent interface is canonical.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I can see.

Copy link
Member

@jamadden jamadden Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, I wonder why I didn't see that.

The problem I have with those docs is that they're too low level and deal too much with internal aspects (e.g. stickiness).

I have no problem with linking to them though.

@jamadden
Copy link
Member

jamadden commented Aug 26, 2016

The text looks pretty good to me, other than the occasional minor typo or possibility to add a link. I didn't look at the build, but it passed, and I like the idea of tests!

Here's why I think linking to zope.cachedesciptors, etc, might be a good idea: One of the good things about ZODB is that there are packages that can handle many different problems you might run into (e.g., zope.cachedescriptors handles _v_ attributes for you) but there's never been a central place telling you what's out there, what it's good for, and when you might want to use it. This document might be a good place to pull some of those things together.

record from the book record and is managed by ZODB independent of the
management of the book.

In addition to ``PersistentList`` and ``PersistentMapping``, general
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is zc.blist worth a mention?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK, is it? I never used it myself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to use it, but even with it resolving conflicts, our (pretty high-volume write) use case turned out to be better served by Redis. But it works for what it does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a reference to it

@jimfulton
Copy link
Member Author

jimfulton commented Aug 27, 2016

I like the idea of including some links. I'll add some at the end of the topic. Please feel free to suggest/add more.

Update: added

@mauritsvanrees
Copy link
Member

Clear and concise.

I have fixed a few minor typos on the branch.


If you modify a non-persistent mutable value of a persistent-object
attribute, you need to mark the persistent object as changed yourself
by setting ``_p_changed`` to True::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact it is not set, but setting it to something triggers some functionality behind. If one reads _p_changed it does not return the value prior set. When I used this feature first several years ago I was kind of confused and only digging through the source helped me to understand what it is about. So I would phrase it:

If you modify a non-persistent mutable value of a persistent-object attribute, 
you need to tell the persistent object that it has changed by assigning ``_p_changed`` a value.
The assignment marks the object as modified 
(reading ``_p_changed`` does not tell you anything, since its just a trigger)::

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment. You seem to be saying that reading _p_changed doesn't give an accurate result.

_p_changed is computed from and thus reflects the internal object state. Can you provide an example where reading _p_changed doesn't give the expected result?

@jimfulton jimfulton merged commit 73248f6 into new-guide Sep 5, 2016
@tseaver
Copy link
Member

tseaver commented Sep 10, 2016

This issue was moved to zopefoundation/ZODB#113

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants