[Zope-dev] Adding ZCatalog capability for a (Python) product, and using it.

Ender kthangavelu@earthlink.net
Mon, 23 Oct 2000 16:56:11 -0700


"Morten W. Petersen" wrote:
> 
> Is there any documentation that explains this?  Or, maybe some
> *understandable* and *well-written* product?


i found using a zcatalog with composition fairly straight forward. i
like to recommend a product that i wrote:), but sadly the code on a
whole is a mess, which i'm looking forward to rewriting someday, ahh....
patterns.

anyways some relevant code snip


	def setup_catalog(self):
		''' setups catalog for searching news channels '''
		
		id = 'news_catalog'
		catalog = Products.ZCatalog.ZCatalog.ZCatalog(id)
		self._setObject(id, catalog)
		
		# setup indexes and such
		self.news_catalog.manage_addColumn('description')
		self.news_catalog.manage_addColumn('Date')

		self.news_catalog.manage_addIndex('Date', 'FieldIndex')
		self.news_catalog.manage_addIndex('SearchableText', 'TextIndex')

		# get rid of defaults
		self.news_catalog.manage_delColumns(['bobobase_modification_time',
'summary'])
		self.news_catalog.manage_delIndexes(['bobobase_modification_time',
'PrincipiaSearchSource'])
		
		return 1


i'd recommend composition, although maybe with a custom wrapper to
facilitate searches. i tend to feel that the zcatalog stuff should be
handled transparently by the storage not the object.

reading the source is probably the best way to examine the interface
(catalog and zcatalog) 


kapil