[Zope-dev] feedback wanted on ZCatalog changes...
Anthony Baxter
Anthony Baxter <anthony@interlink.com.au>
Wed, 05 Jan 2000 09:28:58 +1100
This is a multipart MIME message.
--==_Exmh_-13157793310
Content-Type: text/plain; charset=us-ascii
>>> Michel Pelletier wrote
> WRT the first bug, returning a list for uniqueValuesFor, I suspect this
> would break alot of existing code, but I'm not sure. Perhaps a good
> workaround would be an _.list() so that the tuple can be converted
> outside the index instead of in?
The alternative would be to allow any form of sequence as an argument
to the ZCatalog search. Hm - though I guess someone _could_ want an
attribute that's a tuple, I guess...
> The second bug involving string.find I fixed and checked in. Thanks.
Excellent. The other two changes in there were:
make REQUEST and RESPONSE optional for the various manage_ functions,
and
fixing the "can't index attributes acquired from higher than the enclosing
folder" from ZopeFindAndApply.
The latter in particular is a complete pig when it bites.
I've attached two patches, one for each of these, to this message.
Anthony
--==_Exmh_-13157793310
Content-Type: text/plain; name="patch01"; charset=us-ascii
Content-Description: zcatalog patch making request, response optional
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="p"
diff -u -r1.44 ZCatalog.py
@@ -269,11 +273,12 @@
urllib.quote('Catalog Updated<br>Total time: %=
s<br>Total CPU time: %s' % (`elapse`, `c_elapse`)))
=
=
- def manage_catalogClear(self, REQUEST, RESPONSE, URL1):
+ def manage_catalogClear(self, REQUEST=3DNone, RESPONSE=3DNone, URL1=3D=
None):
""" clears the whole enchelada """
self._catalog.clear()
=
- RESPONSE.redirect(URL1 + '/manage_catalogView?manage_tabs_messag=
e=3DCatalog%20Cleared')
+ if REQUEST and RESPONSE:
+ RESPONSE.redirect(URL1 + '/manage_catalogView?manage_tabs_me=
ssage=3DCatalog%20Cleared')
=
=
def manage_catalogFoundItems(self, REQUEST, RESPONSE, URL2, URL1,
@@ -313,31 +318,35 @@
urllib.quote('Catalog Updated<br>Total time: %=
s<br>Total CPU time: %s' % (`elapse`, `c_elapse`)))
=
=
- def manage_addColumn(self, name, REQUEST, RESPONSE, URL1):
+ def manage_addColumn(self, name, REQUEST=3DNone, RESPONSE=3DNone, UR=
L1=3DNone):
""" add a column """
self._catalog.addColumn(name)
=
- RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_mess=
age=3DColumn%20Added')
+ if REQUEST and RESPONSE:
+ RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_=
message=3DColumn%20Added')
=
- def manage_delColumns(self, names, REQUEST, RESPONSE, URL1):
+ def manage_delColumns(self, names, REQUEST=3DNone, RESPONSE=3DNone, =
URL1=3DNone):
""" del a column """
for name in names:
self._catalog.delColumn(name)
=
- RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_mess=
age=3DColumn%20Deleted')
+ if REQUEST and RESPONSE:
+ RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_=
message=3DColumn%20Deleted')
=
- def manage_addIndex(self, name, type, REQUEST, RESPONSE, URL1):
+ def manage_addIndex(self, name, type, REQUEST=3DNone, RESPONSE=3DNon=
e, URL1=3DNone):
""" add an index """
self._catalog.addIndex(name, type)
=
- RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_mes=
sage=3DIndex%20Added')
+ if REQUEST and RESPONSE:
+ RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs=
_message=3DIndex%20Added')
=
- def manage_delIndexes(self, names, REQUEST, RESPONSE, URL1):
+ def manage_delIndexes(self, names, REQUEST=3DNone, RESPONSE=3DNone, =
URL1=3DNone):
""" del an index """
for name in names:
self._catalog.delIndex(name)
=
- RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_mes=
sage=3DIndex%20Deleted')
+ if REQUEST and RESPONSE:
+ RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs=
_message=3DIndex%20Deleted')
=
=
def catalog_object(self, obj, uid):
@@ -406,6 +415,7 @@
query_map=3D{
type(regex.compile('')): Query.Regex,
type([]): orify,
+ type(()): orify,
type(''): Query.String,
}, **kw):
"""
--==_Exmh_-13157793310
Content-Type: text/plain ; name="patch02"; charset=us-ascii
Content-Description: patch for ZCatalog fixing ZopeFindAndApply's handling of acquired attributes
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="patch02"
diff -u -r1.44 ZCatalog.py
@@ -533,14 +543,16 @@
role_match(ob, obj_permission, obj_roles)
)
):
+ ob_real =3D getattr(obj, id)
if apply_func:
- apply_func(ob, (apply_path+'/'+p))
+ apply_func(ob_real, (apply_path+'/'+p))
else:
- add_result((p, ob))
+ add_result((p, ob_real))
dflag=3D0
=
if search_sub and hasattr(bs, 'objectItems'):
- self.ZopeFindAndApply(ob, obj_ids, obj_metatypes,
+ ob_real =3D getattr(obj, id)
+ self.ZopeFindAndApply(ob_real, obj_ids, obj_metatypes,
obj_searchterm, obj_expr,
obj_mtime, obj_mspec,
obj_permission, obj_roles,
--==_Exmh_-13157793310--