Re: [Zope-dev] ZCatalog API

2001-10-05 Thread Steve Alexander

E. Seifert wrote:

 Hi list,
 
 as I'm not very familiar with the internals of ZCatalog I have a question to
 all you API experts:
 
 Why does ZCatalog.py (under Zope 2.4.1) specify a 'addIndex' permission for
 a method called 'manage_delIndexes' although there is no such method? The
 only method I could find to delete Indexes is 'manage_deleteIndex'.
 
 Can anyone comment on this?


Thanks for pointing this out. There was some cruft in ZCatalog.py, which 
has now has been cleaned up. The changes are in CVS, and will be in the 
next release of Zope.


The method manage_deleteIndex is still there, but is deprecated, and 
will issue a warning the first time it is called.

You can use manage_delIndex instead.

Both are protected by the addIndex permission.


--

Steve Alexander
Software Engineer
Cat-Box limited




___
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 )



Re: [Zope-dev] ZCatalog API

2001-09-30 Thread Steve Alexander

E. Seifert wrote:

 Hi list,
 
 as I'm not very familiar with the internals of ZCatalog I have a question to
 all you API experts:
 
 Why does ZCatalog.py (under Zope 2.4.1) specify a 'addIndex' permission for
 a method called 'manage_delIndexes' although there is no such method? The
 only method I could find to delete Indexes is 'manage_deleteIndex'.
 
 Can anyone comment on this?


Well, considering that there's these methods in ZCatalog:

   manage_addColumn
   manage_delColumns
   manage_addIndex
   manage_deleteIndex

... manage_deleteIndex is obviously the odd one out.

Especially as it allows you to delete several indexes in one go.

I suggest it be renamed manage_delIndices or manage del_Indexes.


manage_clearIndex also operates on multiple indexes, so that should 
become manage_clearIndexes.

Funnily enough, the ZCatalog regression test at
./regressiontests/regressionCatalogTiming.py uses this call:

   manage_delIndexes([x])

which supports renaming manage_deleteIndex to manage_delIndexes.

However,  while dtml/catalogIndexes.dtml uses manage_delIndexes,
./dtml/manageIndex.dtml uses manage_deleteIndex.

manage_reindexIndex should also become manage_reindexIndexes, as it 
requires a sequence of ids. Also, manage_reindexIndex doesn't have an 
associated permission.

There's a few more place this touches, although all the changes are in 
ZCatalog.py and manageIndex.dtml.


Congratulations, you've found a bug!

This would have been more obvious if ZCatalog were using the new 
declarative security assertions, as the declaration would be right next 
to the method definition.


Here's a first-draft patch, for comments etc.
I haven't looked at the documentation of the API, so that might need 
changing too.


--
Steve Alexander
Software Engineer
Cat-Box limited


*** ZCatalog.py.orig
--- ZCatalog.py
***
*** 196,202 
'manage_catalogView', 'manage_catalogFind',
'manage_catalogSchema', 'manage_catalogIndexes',
'manage_catalogAdvanced', 'manage_objectInformation',
!   
'manage_catalogReindex', 'manage_catalogFoundItems',
'manage_catalogClear', 'manage_addColumn', 'manage_delColumns',
'manage_addIndex', 'manage_delIndexes', 'manage_main',
--- 196,202 
'manage_catalogView', 'manage_catalogFind',
'manage_catalogSchema', 'manage_catalogIndexes',
'manage_catalogAdvanced', 'manage_objectInformation',
!   'manage_reindexIndexes', 'manage_clearIndexes',
'manage_catalogReindex', 'manage_catalogFoundItems',
'manage_catalogClear', 'manage_addColumn', 'manage_delColumns',
'manage_addIndex', 'manage_delIndexes', 'manage_main',
***
*** 422,430 
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Added')
  
  
! def manage_deleteIndex(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
!  del an index 
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items were specified!',
--- 422,430 
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Added')
  
  
! def manage_delIndexes(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
!  del indexes 
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items were specified!',
***
*** 436,444 
  if REQUEST and RESPONSE:
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Deleted')
  
! def manage_clearIndex(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
!  del an index 
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items were specified!',
--- 436,444 
  if REQUEST and RESPONSE:
  RESPONSE.redirect(URL1 + 
'/manage_main?manage_tabs_message=Index%20Deleted')
  
! def manage_clearIndexes(self, ids=None, REQUEST=None, RESPONSE=None,
  URL1=None):
!  clear indexes 
  if not ids:
  return MessageDialog(title='No items specified',
  message='No items were specified!',
***
*** 462,468 
  if obj is not None:
  self.catalog_object(obj, p, idxs=[name]) 
  
! def manage_reindexIndex(self, ids=None, REQUEST=None, RESPONSE=None, URL1=None):
   Reindex indexes from a ZCatalog
  if not ids:
  return MessageDialog(title='No items specified',
--- 462,468 
  if obj is not None:
  self.catalog_object(obj, p, idxs=[name]) 
  
! def manage_reindexIndexes(self, ids=None, REQUEST=None, RESPONSE=None, 
URL1=None):
   Reindex indexes from a ZCatalog
  if not ids: