Hi,

Santi Camps wrote:
> 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 ?

I'll move the nuxeo.persistent.queue to the public svn this afternoon.
We forgot to do so while adding the zasync 2.9 branch.

        J.


> ------------------------------------------------------------------------
> 
> --- /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


-- 
Julien Anguenot | Nuxeo R&D (Paris, France)
Open Source ECM - www.nuxeo.com
CPS Platform - http://www.cps-project.org
Mobile: +33 (0) 6 72 57 57 66

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to