[Zope] Zope Persistence (was: XML-RPC within ZOPE)
Lennart Regebro
regebro at gmail.com
Sun Dec 18 11:00:22 EST 2005
On 12/18/05, Jan-Ole Esleben <esleben at gmail.com> wrote:
> > > To simplify, in ZOPE, for any given product, during a
> > > transaction the product is effectively locked.
> > This statement is incorrect.
>
> You're right. It should be "during any transaction where there are
> potential changes to the object".
No, this statement is still correct. Replace "product" with "object"
and you are right.
> And I agree, it's actually a lot more complicated than I'd thouht at first.
Or simpler. ;-)
> but it happens under rather magical circumstances. I have an example
> where it actually happens; this is code from a product that is
> instantiated twice, one of those instances called TPCDest, the other
> TestPChanged; the method called directly is "TestPChanged.test()":
>
> security.declareProtected("Use TestPChanged", "test_internal")
> def test_internal(self, args=None, args2=None):
> "Called by test via XML-RPC"
> if args2:
> self.a.append(1)
> self._p_changed = 1
> if not args:
> import xmlrpclib
> s = xmlrpclib.ServerProxy("http://USER:PASSWORD@localhost:8080/",
> allow_none=True)
> s.TestPChanged.test_internal(1)
> return self.a
>
> security.declareProtected("Use TestPChanged", "test")
> def test(self, args2=None):
> "Called directly via ZOPE"
> if args2:
> self.a.append(1)
> self._p_changed = 1
> import xmlrpclib
> s = xmlrpclib.ServerProxy("http://USER:PASSWORD@localhost:8080/",
> allow_none=True)
> return s.TPCDest.test_internal()
>
> Zope obviously looks at the code, because if you remove the "if args2"
> (which is _never_ true), then a ConflictError happens.
>
> Maybe I'm stupid, but could someone point out _where_ exactly I am?
I don't understand the question. I would like to point out that you
set self._p_changed even when you don't change anything. :-)
It seems to me that you say that if you process calls test and another
calls test_internal, you get a conflict error. This is correct, and as
noted before, that code would create a conflict in any type of
environment. If you have two processes trying to modify the same
dataset, which is what your example seems to do, then you get a
conflict.
What you claim, is that if you have two processes in Zope change two
different datasets, you get a conflict. That statement is still false.
> > Yes. You said "different sets of data". That reasonably means
> > different objects. If it doesn't, yuo need to take a long hard look at
> > your object hierarchy.
>
> Simply not true. What if I have a field titles (that is a hash of
> titles to Book objects)
> and a field comments (that is an array of comments on the library)? Is
> that so obviously
> not a sane example?
Yes, sorry, having non-persistent aware dictionaries or arrays, and
then complaining that you have problems with persitency...
> > > In ordinary systems, you would have to find a way to store the
> > > data and retrieve it, thus having a model that isn't implicit and
> > > entangled with your code.
> >
> > What is implicit with it?
>
> See the example for some major implicitness.
What is implicit with it?
> It's also implicit
> because you have no control over what a transaction considers a
> tainted object. (You have no real control over the transaction).
Thats still not true.
> I am explicitly talking about changing different sets of data within
> the same object. You noted that above yourself.
Then these different sets should be different objects, and the object
should be an object container: Problem solved.
> > You claim that you can't control what a persistent class store. That is false.
>
> I don't. I say that if I want to avoid such problems as I describe
> altogether, I cannot store anything in a persistent class and thus
> lose most of what makes ZOPE so interesting.
This is still not correct.
> > You claim that things get locked that shouldn't be locked in Zope. It
> > is not clear to me why you say that.
>
> See the example.
I don't see how the example examplifies this.
It is obvious to me that you have misunderstood something. I don't
know what yet, though.
--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
More information about the Zope
mailing list