I answer to myself :-)
Here there is a patch to make nuxeo.persistentqueue optional in ZAsync
Z29 branch, and to user OOBTree otherwise.
Perhaps it could be useful to someone else. Do you think It could be
commited to the branch ?
Thanks a lot
--
Santi Camps
Earcon S.L. - http://www.earcon.com
- http://www.kmkey.com
On 8/18/06, Santi Camps <[EMAIL PROTECTED]> wrote:
Hi all,
I'm trying to use Zasync on Zope 2.9, from the branch:
http://svn.nuxeo.org/trac/pub/browser/vendor/zasync/branches/z29-nux
But it seems to be a dependence with nuxeo.persisentqueue, which I'm
not able to find. Is this software public ? If yes, where I can get
it ?
" import manager
File "/usr/local/kmcps/zope/Products/zasync/manager.py", line 45, in ?
from nuxeo.persistentqueue.persistentqueue import PersistentQueue
ImportError: No module named nuxeo.persistentqueue.persistentqueue
"
Thanks in advance
--
Santi Camps
Earcon S.L. - http://www.earcon.com
- http://www.kmkey.com
--- /tmp/z29-nux/manager.py 2006-08-21 11:51:10.000000000 +0200
+++ manager.py 2006-08-21 11:00:55.000000000 +0200
@@ -42,7 +42,10 @@
from Products.Sessions.BrowserIdManager import BROWSERID_MANAGER_NAME
from AccessControl.SecurityInfo import allow_class
-from nuxeo.persistentqueue.persistentqueue import PersistentQueue
+try:
+ from nuxeo.persistentqueue.persistentqueue import PersistentQueue
+except ImportError:
+ PersistentQueue = None
import permissions, bforests, interfaces
@@ -466,7 +469,7 @@
def getDeferredInfo(context, info, sort_field=None, reverse=False):
res = []
- if isinstance(info, PersistentQueue):
+ if PersistentQueue and isinstance(info, PersistentQueue):
ditems = info
else:
ditems = info.values()
@@ -542,7 +545,10 @@
if id is not None:
self.id = id
# items to be picked up by zasync
- self._new = PersistentQueue()
+ if PersistentQueue:
+ self._new = PersistentQueue()
+ else:
+ self._new = OOBTree.OOBTree()
# items collected by zasync from the queue
self._accepted = OOBTree.OOBTree()
# long term cache
@@ -663,7 +669,8 @@
d.key = key
d.id = repr(key)
d.local_key = randomizer
- self._new.append(d)
+ if PersistentQueue: self._new.append(d)
+ else: self._new[key] = d
wrapped = d.__of__(self)
wrapped.manage_fixupOwnershipAfterAdd()
user=getSecurityManager().getUser()
@@ -688,10 +695,14 @@
security.declareProtected(
permissions.MakeAsynchronousApplicationCalls, 'getDeferred')
def getDeferred(self, d_id, default=None):
- for src in self._new:
- if src.key == d_id:
- return src.__of__(self)
- for src in (self._accepted, self._resolved):
+ if PersistentQueue:
+ for src in self._new:
+ if src.key == d_id:
+ return src.__of__(self)
+ where_to_search = (self._accepted, self._resolved)
+ else:
+ where_to_search = (self._new, self._accepted, self._resolved)
+ for src in where_to_search:
res = src.get(d_id)
if res is not None:
return res.__of__(self)
@@ -768,15 +779,21 @@
security.declarePrivate('acceptAll')
def acceptAll(self):
- new = self._new
- for d in new:
- self._accepted[d.key] = d
- res = []
- if new:
- res = new[:]
- while new:
- new.pop(0)
- return res
+ if PersistentQueue:
+ new = self._new
+ for d in new:
+ self._accepted[d.key] = d
+ res = []
+ if new:
+ res = new[:]
+ while new:
+ new.pop(0)
+ return res
+ else:
+ self._accepted.update(self._new)
+ res = self._new.values()
+ self._new.clear()
+ return res
security.declarePrivate('getAcceptedCalls')
def getAcceptedCalls(self):
_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel