Hello Guys,

I'm a newbie about python and zope (about a week and a half till now), so
probably most of what I say now is probably wrong.

I was trying to customize the ZDiscussion product with file upload, editing
of previous posts and deletes of old posts and I guess I've find a bug in
the ZCatalog.uncatalogObject method.

In the code there is:

            for btree in (data, paths):
                try:
                    del btree[rid]
                except KeyError:
                    LOG('Catalog', ERROR, ('uncatalogObject unsuccessfully '
                                           'attempted to delete rid %s '
                                           'from paths or data btree.' %
rid))
                else:
                    try: self.__len__.change(-1)
              except AttributeError:
                      pass # No managed length

that means for each successfull unindex item, the __len__ counter will be
decreased by 2, that's wrong.
The correct code should look like:

            for btree in (data, paths):
                try:
                    del btree[rid]
                except KeyError:
                    LOG('Catalog', ERROR, ('uncatalogObject unsuccessfully '
                                           'attempted to delete rid %s '
                                           'from paths or data btree.' %
rid))
            try: self.__len__.change(-1)
            except AttributeError:
              pass # No managed length

Or if we want to handle situations where the unindexs are unsuccessfull, we
have to rewrite better the method with the use of transactions.

That's all.

Regards,

Marco Nova
Tera S.p.A.


P.S.

Zope Version  Zope 2.3.1b2 (binary release, python 1.5.2, win32-x86)  
Python Version  1.5.2 (#0, Jul 30 1999, 09:52:18) [MSC 32 bit (Intel)]  
System Platform  win32  

_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to