Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-04 Thread Cykooz
2012/7/4 Jan-Wijbrand Kolman 

> I guess Cykooz would know the revision of the common base?
>
> regards, jw
>

I do not remember the revision. But it certainly was from trunk branch. You
can see the old revisions from SVN and my new here -
https://bitbucket.org/cykooz/zope.intid/changesets
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-04 Thread Jan-Wijbrand Kolman
On 7/3/12 15:06 , Hanno Schlichting wrote:
> On Tue, Jul 3, 2012 at 1:56 PM, Jan-Wijbrand Kolman
>  wrote:
>> At the end of this post, I pasted the diff from the current zope.intid
>> trunk against your "fork" on bitbucket. Maybe this would make it easier
>> for others to comment on it?
> 
> It would be easier to read if you did the diff against the base
> version the fork was started from. Or otherwise update the fork with
> the changes done in the meantime.
> 
> I see a bunch of unrelated changes in there, like the
> implements/implementer changes. I'm not sure what else is unrelated to
> the proposed change.

Ow, well, yes you are right. I didn't investigate too deeply either and
I do not know the revision the fork was based on. Maybe I just didn't
look hard enough.

I just wanted to see if we could get a little feedback by posting the
diff over here, instead for others to have to go through this just see
what the proposed changes are. Being the messenger so to say.

Did you stop looking at the diff once you noticed it was created
suboptimally? Would it help to find out the base revision and post a
diff again? I guess Cykooz would know the revision of the common base?

regards, jw



___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-03 Thread Cykooz
2012/7/3 Roger 

> Hi Kirill
>
> Why not just implement your own package and use this
> enhanced IntIds utility from there in your project?
>

Do you think that anyone else does not need the fix that I did?

This error in the zope.intid completely negates the whole transparency
in working
with persistent objects. Due it is necessary to use various tricks, which
impairs the understanding of how the program works.
My patch does not break backwards compatibility and do not require
additional changes to the code of existing components. So why not merge it
into the "zope.intid", instead of create a "cykooz.intid"?
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-03 Thread Roger
Hi Kirill

Why not just implement your own package and use this
enhanced IntIds utility from there in your project?

Regards
Roger Ineichen
_
END OF MESSAGE

> -Ursprüngliche Nachricht-
> Von: zope-dev-boun...@zope.org [mailto:zope-dev-boun...@zope.org] Im
Auftrag
> von Cykooz
> Gesendet: Dienstag, 10. Januar 2012 23:28
> An: zope-dev
> Betreff: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet
exception
> (patch)
> 
> Hi,
> 
> I created a patch for a package zope.intid that almost completely
> solves the problem with the zope.keyreference.interfaces.NotYet
> exception.
> 
> I implemented a deferred indexing of objects added to the container
> which is not connected to the ZODB.
> As soon as the container is added to the ZODB - all deferred objects
> will be indexed.
> 
> I also added a marker IIntIdsDisabled for marking objects that must
> not be indexed.
> 
> 
> I would be grateful if someone could look at my changes and merge them
> into the main branch.
> My fork of zope.intid - https://bitbucket.org/cykooz/zope.intid/src
> 
> 
> PS: Sorry for my English.
> 
> ---
> Cykooz (Kirill Kuzminykh)
> ___
> Zope-Dev maillist  -  Zope-Dev@zope.org
> https://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  https://mail.zope.org/mailman/listinfo/zope-announce
>  https://mail.zope.org/mailman/listinfo/zope )


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-03 Thread Hanno Schlichting
On Tue, Jul 3, 2012 at 1:56 PM, Jan-Wijbrand Kolman
 wrote:
> At the end of this post, I pasted the diff from the current zope.intid
> trunk against your "fork" on bitbucket. Maybe this would make it easier
> for others to comment on it?

It would be easier to read if you did the diff against the base
version the fork was started from. Or otherwise update the fork with
the changes done in the meantime.

I see a bunch of unrelated changes in there, like the
implements/implementer changes. I'm not sure what else is unrelated to
the proposed change.

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-03 Thread Jan-Wijbrand Kolman
On 7/3/12 13:26 , Cykooz wrote:
> 2012/7/3 Jan-Wijbrand Kolman  >
> 
> Are you basically using a forked zope.keyreference for the time being?
> 
>  No, I do not use a forked zope.keyreference. I used my fork of the
> zope.intid.

Ah, yes of course, that's what I meant: zope.intid.

I would not consider myself in a position currently to vouch for you to
have comitter rights. I do however wonder if anyone else would like to
comment on your proposed change.

If the comments a favorable I could try to help apply the patch to
zope.intid. This would probably help me and you as you then would not
have to use a forked package anymore.

At the end of this post, I pasted the diff from the current zope.intid
trunk against your "fork" on bitbucket. Maybe this would make it easier
for others to comment on it?

regards, jw


Proposed patch:
===

diff -u zope.intid/trunk/src/zope/intid//__init__.py
zope.intid-cykooz/src/zope/intid//__init__.py
--- zope.intid/trunk/src/zope/intid//__init__.py2012-07-03
11:56:11.576511518 +0200
+++ zope.intid-cykooz/src/zope/intid//__init__.py   2012-07-03
11:55:17.261865415 +0200
@@ -19,12 +19,14 @@
 This functionality can be used in cataloging.
 """
 import random
+import threading
+from weakref import WeakKeyDictionary, WeakSet

 import BTrees
 from persistent import Persistent
 from zope.component import adapter, getAllUtilitiesRegisteredFor,
subscribers
 from zope.event import notify
-from zope.interface import implementer
+from zope.interface import implements
 from zope.keyreference.interfaces import IKeyReference, NotYet
 from zope.lifecycleevent.interfaces import IObjectAddedEvent
 from zope.lifecycleevent.interfaces import IObjectRemovedEvent
@@ -32,16 +34,16 @@
 from zope.location.interfaces import IContained
 from zope.security.proxy import removeSecurityProxy

-from zope.intid.interfaces import IIntIds, IIntIdEvent
+from zope.intid.interfaces import IIntIds, IIntIdEvent, IIntIdsDisabled
 from zope.intid.interfaces import IntIdAddedEvent, IntIdRemovedEvent

-@implementer(IIntIds, IContained)
 class IntIds(Persistent):
 """This utility provides a two way mapping between objects and
 integer ids.

 IKeyReferences to objects are stored in the indexes.
 """
+implements(IIntIds, IContained)

 __parent__ = __name__ = None

@@ -136,6 +138,10 @@
 del self.ids[key]


+thread_data = threading.local()
+thread_data.deferred_objects = WeakKeyDictionary()
+
+
 @adapter(ILocation, IObjectRemovedEvent)
 def removeIntIdSubscriber(ob, event):
 """A subscriber to ObjectRemovedEvent
@@ -143,9 +149,22 @@
 Removes the unique ids registered for the object in all the unique
 id utilities.
 """
+
 utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
 if utilities:
-key = IKeyReference(ob, None)
+try:
+key = IKeyReference(ob, None)
+except NotYet:
+deferred_objects = thread_data.deferred_objects
+if ob in deferred_objects:
+del deferred_objects[ob]
+parent = getattr(ob, '__parent__', None)
+if parent in deferred_objects and ob in
deferred_objects[parent]:
+deferred_objects[parent].remove(ob)
+if len(deferred_objects[parent]) == 0:
+del deferred_objects[parent]
+return
+
 # Register only objects that adapt to key reference
 if key is not None:
 # Notify the catalogs that this object is about to be removed.
@@ -156,6 +175,7 @@
 except KeyError:
 pass

+
 @adapter(ILocation, IObjectAddedEvent)
 def addIntIdSubscriber(ob, event):
 """A subscriber to ObjectAddedEvent
@@ -163,16 +183,46 @@
 Registers the object added in all unique id utilities and fires
 an event for the catalogs.
 """
+
 utilities = tuple(getAllUtilitiesRegisteredFor(IIntIds))
 if utilities: # assert that there are any utilites
+register_object(ob, utilities, event)
+
+
+def register_object(ob, utilities, event):
+deferred_objects = thread_data.deferred_objects
+intids_enabled = not IIntIdsDisabled.providedBy(ob)
+try:
 key = IKeyReference(ob, None)
-# Register only objects that adapt to key reference
-if key is not None:
-idmap = {}
-for utility in utilities:
-idmap[utility] = utility.register(key)
-# Notify the catalogs that this object was added.
-notify(IntIdAddedEvent(ob, event, idmap))
+except NotYet:
+if intids_enabled:
+parent = getattr(ob, '__parent__', None)
+if parent is None:
+raise
+if parent not in deferred_objects:
+deferred_objects[parent] = WeakSet()
+deferred_objects[parent].add(ob)
+return
+
+# Register only objects that adapt to key reference
+if 

Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-03 Thread Cykooz
2012/7/3 Jan-Wijbrand Kolman 

> Are you basically using a forked zope.keyreference for the time being?
>

 No, I do not use a forked zope.keyreference. I used my fork of the
zope.intid.
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-07-03 Thread Jan-Wijbrand Kolman
On 1/24/12 23:49 , Cykooz wrote:
> 2012/1/25 Marius Gedminas :
>>
>> http://foundation.zope.org/agreements is where you can find the
>> committer agreement form.
> 
> Thanks.
> But I have one problem. I do not know any of the existing Committer
> who can vouch for me.

Bringing up a rather old thread:

Cykooz, was there any kind of follow up on this discussion? Are you
basically using a forked zope.keyreference for the time being?

Kind regards, jw


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-01-24 Thread Cykooz
2012/1/25 Marius Gedminas :
>
> http://foundation.zope.org/agreements is where you can find the
> committer agreement form.

Thanks.
But I have one problem. I do not know any of the existing Committer
who can vouch for me.
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-01-24 Thread Marius Gedminas
On Tue, Jan 24, 2012 at 03:10:15PM +0100, Charlie Clark wrote:
> Am 23.01.2012, 23:20 Uhr, schrieb Cykooz :
> 
> >Oh ...
> >Or there is no one who is engaged in package zope.intid, or no one
> >gets an NotYet exception on the fault  this package.
> >Who can give me write access into SVN for the package zope.intid?
> 
> You must apply to the Zope Foundation for access to the repository.

http://foundation.zope.org/agreements is where you can find the
committer agreement form.

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3/BlueBream consulting and development


signature.asc
Description: Digital signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-01-24 Thread Charlie Clark

Hiya,

Am 23.01.2012, 23:20 Uhr, schrieb Cykooz :


Oh ...
Or there is no one who is engaged in package zope.intid, or no one
gets an NotYet exception on the fault  this package.
Who can give me write access into SVN for the package zope.intid?


You must apply to the Zope Foundation for access to the repository.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] zope.intid and zope.keyreference.interfaces.NotYet exception (patch)

2012-01-23 Thread Cykooz
Oh ...
Or there is no one who is engaged in package zope.intid, or no one
gets an NotYet exception on the fault  this package.

Who can give me write access into SVN for the package zope.intid? And
also the right to add release into pypi.python.org?

PS: Sorry for my English.
---
Cykooz (Kirill Kuzminykh)


2012/1/11 Cykooz :
> Hi,
>
> I created a patch for a package zope.intid that almost completely
> solves the problem with the zope.keyreference.interfaces.NotYet
> exception.
>
> I implemented a deferred indexing of objects added to the container
> which is not connected to the ZODB.
> As soon as the container is added to the ZODB - all deferred objects
> will be indexed.
>
> I also added a marker IIntIdsDisabled for marking objects that must
> not be indexed.
>
>
> I would be grateful if someone could look at my changes and merge them
> into the main branch.
> My fork of zope.intid - https://bitbucket.org/cykooz/zope.intid/src
>
>
> PS: Sorry for my English.
>
> ---
> Cykooz (Kirill Kuzminykh)
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )