[ZODB-Dev] BTrees and pop() method - branch

2005-08-31 Thread Ruslan Spivak
Hello.

To inform you, i created branch alienoid-btrees_pop with pop() method 
implementation. Tim was kind :) and told me he will review it on Thursday.
But if someone wants to take a look or have any suggestions - you are very 
welcome.

Regards,
Ruslan

___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] Ordering before commit hooks

2005-08-31 Thread Julien Anguenot
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jim Fulton wrote:
 Julien Anguenot wrote:
 
 I'm gonna respond to a number of emails at once. :)
 
 Tim Peters wrote:

 [Tim]


 ...
 Julien provided links to code that already uses the new feature:

  As an Indexation Manager :
 http://svn.nuxeo.org/trac/pub/file/CPSCore/trunk/IndexationManager.py

 As an Event Manager :
 http://svn.nuxeo.org/trac/pub/file/CPSSubscriptions/trunk/EventManager.py

 

 He appears to use (just) two distinct `order` levels there, and seems
 just to want to make sure one class of hook gets run before the other
 class of hook.  The new scheme does give an easy way to do that.



 OTOH, while picking levels of -100 and 100 works for that specific
 use case,
 looks like it threatens to become a mess if multiple subsystems try
 to use
 this scheme simultaneously.  



 We discussed quickly about this with Florent. This can be expressed by
 having a coding guide for the given framework (for instance CPS). We
 will provide ranges in which hooks are executed. Then if someone wants
 to register another one he can check the existing ones and the ranges
 they are using and what they are doing. Just a matter of documentation.
 
 
 Of course, this doesn't work across projects.
 

ok here we agree :)


 For example, someone who wants to be the last
 kind of hook invoked has no way to force that, at least not short of
 passing sys.maxint as the `order`.  But if that's what's needed,
 `sys.maxint` is a strange way to spell it.



 I understand it but this is something that could be done by extending
 the transaction hooks sub-system.  But again we don't have YAGNI yet for
 a bigger sub-system that could include this.
 
 
 The very fact that to really do what you need to do today would require an
 extension indicates that the current API isn't what we should be doing.
 
 We'll never have what every application needs anyway, which is why this
 ordering logic should be at the application level where it's easy to
 control.
 
 
 I don't understand why keeping the order paremeter is such a big deal ?
 
 
 Because it clutters the ZODB API with something that is, fundamentally
 application policy.

Here we disagree.

I could agree if only one hook could be registred instead of a severals
(within a tiny little tuple :) ).
Then you could say : It's application logic just register your object
as *the* hook that will deal with the order of execution of other
sub-hooks your system defines

Here, it's not the case because you can register several within a
transaction and actually the ZODB has already a policy regarding this
which is executing it in the order they've been registred.

Thus my proposal could be seen as well as a request to change (or to
make more flexible) the policy already in place. (Which was my use case)

 
 It prevents me having to code my own specific object dealing with this
 
 
 Dealing with what?  

Dealing with the order of execution.

 Your original need was to make something go last.

Well yes and no. What if I want to go first instead ? Or in the middle
of 2 independently (external to my system) defined hooks ?

 As Tim pointed out, the order api doesn't do that and, as I've pointed out,
 the existing API does deal with that.

no. not enough flexibility.

 
 and I'm sure other people will benefit from this later on when they will
 have to use this transaction feature.

 
 That's hypothetical. In any case, if you are so sure, provide a system
 that does this and let people use it. You don't need to make ZODB more
 complicated to address this use case.

Jim, honestly where is the complication ?

 
 Dieter Maurer wrote:
 Tim Peters wrote at 2005-8-22 16:48 -0400:

...
Jim still wonders, and he got me wondering too, whether the `order=`
 gimmick
is really needed.


 But, it is a very easy concept -- both easy to grasp as well as easy
 to implement.
 
 Just because it's an easy concept, doesn't mean it belongs in
 in the transaction layer.  It would be just as easy a concept
 as a ZODB add-on.  I wouldn't object to such a thing in Zope, for
 example.

Then don't allow the registration of several hooks. Just provide one
slot to register only one. Then I could be fine with this.

Let's imagine :

I got the following hypotetical architecture :

Let's say I follow what you're saying.

- --
ZODB

Zope3 - defines hook A (managing perhaps other hooks and manage the
order of execution of its sub-hooks)
z3ecm - define hook B (idem A)
CPS4 - define hook C (idem A)
- ---

Imagine within the top layer (CPS4) I want to execute one of my hook in
between two of the Zope3 and z3ecm hooks ? I definitely Can't...

 Julien Anguenot wrote:
 Jim Fulton wrote:
 ...
Do we have evidence that such applications exist? So far, the
only example I've seen is one where an application wanted a handler
to go last. As I've pointed out in a separate note, this is achievable
without the change.



 We have. We are thinking of adding another hook within CPS to 

[ZODB-Dev] Re: Ordering before commit hooks

2005-08-31 Thread Florent Guillaume

Jim Fulton wrote:

I don't understand why keeping the order paremeter is such a big deal ?


Because it clutters the ZODB API with something that is, fundamentally
application policy.


Ok seen that way I agree. That's not the ZODB's job to decide what kind of 
API is provided to enforce policy.


[...]

  But that only works if you have all the code in a single framework. If
  Zope had a commit hook, and that CPS wanted to add another one that ran
  after Zope's, there would be no way to do it.

Right, they have to agree on a common API.  With the order gimmic,
this is a ZODB API. It could as easily be a higher-level API.

Since CPS in built on Zope, it could even be a Zope API that
CPS used.


Ok. We can go back to a simple API for the ZODB before commit hook (the one 
I originally checked in seems enough), but we need to decide what kind of 
higher level API we provide at the Zope level. Would an integer order be ok 
there ? And where should the code go ?


Florent

--
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] BTrees and setdefault

2005-08-31 Thread Dmitry Vasiliev

Tim Peters wrote:

[Dmitry Vasiliev]


Since then I've changed my mind and almost haven't used setdefault(). So
now I'm only +0 on the idea. :-) I think pop() is even more useful than
setdefault(), I've planned to use it for some persistent queue
implementation (based on BTrees). So if setdefault() will be added I
think it would be also useful to add the pop() method.



Since setdefault() is going into ZODB 3.5 (I'm going to merge Ruslan's
branch into the trunk today), if anyone hint would like to code up pop()
implementations too, I won't object.  Overall, I like pop() better than
setdefault() too.


Wow, Ruslan already has made an implementation!

--
Dmitry Vasiliev (dima at hlabs.spb.ru)
http://hlabs.spb.ru

___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] Setting _p_changed on a ghost

2005-08-31 Thread Dieter Maurer
Tim Peters wrote at 2005-8-26 14:59 -0400:
 ...
I would like to make it an error (raise a ValueError exception) to attempt
to set obj._p_changed to a true value when obj is a ghost.  Does anyone
object?

I came along an argument against this change:

  Assume, you have a persistent object o with a mutable
  non persistent attribute a.

  One of the idioms for changing a looks like:

  ... modify o.a ...
  o._p_changed = True

  However, as Shane pointed out, this may cause ZODB inconsistencies:

  When ... modify o.a ... raises an exception,
  then a may or may not already have been modified.
  Such changes may be committed in a future transaction
  (not the current one, as this is aborted).

  Therefore, he proposed to change the idiom to:

  o._p_changed = True
  ... modify o.a ...

  Now, the persistence subsystem (hopefully) already knows the o is changed
  and invalidates it on abort. The inconsistency cannot occur.

  Of course, raising an exception when o happens to be
  a ghost, would not be appropriate for this idiom -- neither
  is the current behaviour to just ignore the assignment
  to _p_changed.


-- 
Dieter
___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev