[Zope] Re: Catalog Anything Problem

Bobby Mathew bobby@dialognet.com
Thu, 3 May 2001 12:35:46 +0530


Hi Ron / Casey,

Thanks for your support, I have made those changes as you guys suggested.
Firstly i created a new catalog called prods under /learn/search/ and did
nothing further
secondly i kept the zsql method outside under the path /learn/search/
called it getProdtoCatalog()
it has this code...
SELECT prodid as Number, Title,
Descr || ' ' || Title as PrincipiaSearchSource,
'Product' as meta_type, prodid as id, Descr as summary
FROM products

now i went within /learn/search/prods and put catalogProducts (python
script) with this code
for Product in container.getProdtoCatalog():
    container.catalog_object(Product,
    '/learn/search/prods/'+ Product.Number +'/proddetails.html')
    print 'Product #' + Product.Number
return printed

The moment i test this it gives me this error

Zope Error
Zope has encountered an error while publishing this resource.

Error Type: AttributeError
Error Value: Number
----------------------------------------------------------------------------
----

Troubleshooting Suggestions

The URL may be incorrect.
The parameters passed to this resource may be incorrect.
A resource that this resource relies on may be encountering an error.
For more detailed information about the error, please refer to the HTML
source for this page.

If the error persists please contact the site maintainer. Thank you for your
patience.

Traceback (innermost last):
  File /home/bobby/Zope-2.3/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
  File /home/bobby/Zope-2.3/lib/python/ZPublisher/Publish.py, line 187, in
publish
  File /home/bobby/Zope-2.3/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
    (Object: Traversable)
  File /home/bobby/Zope-2.3/lib/python/ZPublisher/Publish.py, line 171, in
publish
  File /home/bobby/Zope-2.3/lib/python/ZPublisher/mapply.py, line 160, in
mapply
    (Object: catalogProducts)
  File /home/bobby/Zope-2.3/lib/python/ZPublisher/Publish.py, line 112, in
call_object
    (Object: catalogProducts)
  File /home/bobby/Zope-2.3/lib/python/Shared/DC/Scripts/Bindings.py, line
324, in __call__
    (Object: catalogProducts)
  File /home/bobby/Zope-2.3/lib/python/Shared/DC/Scripts/Bindings.py, line
353, in _bindAndExec
    (Object: catalogProducts)
  File
/home/bobby/Zope-2.3/lib/python/Products/PythonScripts/PythonScript.py, line
330, in _exec
    (Object: catalogProducts)
    (Info: ({'script': <PythonScript instance at 88d81b0>, 'context':
<ZCatalog instance at 8b75f30>, 'container': <ZCatalog instance at 8b75f30>,
'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 4, in catalogProducts
    (Object: NoBrains)
  File /home/bobby/Zope-2.3/lib/python/Products/PythonScripts/Guarded.py,
line 273, in __getattr__
  File /home/bobby/Zope-2.3/lib/python/Products/PythonScripts/Guarded.py,
line 143, in __careful_getattr__
    (Object: NoBrains)
AttributeError: (see above)


Any clues why ? I am baffled !!! I can see Number in the zsql method and the
case seems to be ok - what am i missing out ?

bobby



----- Original Message -----
From: Ron Bickers <rbickers@logicetc.com>
To: Bobby Mathew <bobby@dialognet.com>
Cc: <zope@zope.org>
Sent: Wednesday, May 02, 2001 9:29 PM
Subject: RE: Catalog Anything Problem


>
> > -----Original Message-----
> > From: Bobby Mathew [mailto:bobby@dialognet.com]
> > Sent: Wednesday, May 02, 2001 2:08 AM
> > To: rbickers@logicetc.com
> > Cc: zope@zope.org
> > Subject: Catalog Anything Problem
> >
>
> > Since i am a newbie i was not sure what you meant in the
> > cataloganything doc when you said...
> > =============
> > Setting Up the Catalog ...
>
> I meant exactly what you did, set up the catalog as you would for any type
> of search.
>
> > postgres. So i just didnt do anything further. I have a products
> > table in the postgres rdbms that i want to search by title and
> > description. So after this i created a zsql method called
> > getProdtoCatalog under the ZCatalog itself - the query i used is
>
> > Now i went into the Find Objects section and searched for the
> > getProdtoCatalog zsql method and added to the catalog
>
> As mentioned by Casey, this is not necessary.  In fact, you want these
*not*
> in the catalog.
>
> > Next i went and created the python script (again under the
> > Products ZCatalog itself) and i called it catalogProducts this is
> > the code inside
> > for book in container.getProdToCatalog():
> >     container.catalog_object(Product,
> >     '/learn/search/Products/'+Product.Number+'/proddetails.html')
> >     print 'Product #' + Product.Number
> > return printed
>
> Your first parameter to catalog_object is 'Product', but there is no such
> object.  It should probably read:
>
>   for Product in container.getProdToCatalog():
>
> This, BTW, pointed me to the same mistake in the catalogArticles() Python
> script of my HowTo, which I just fixed.
>
> Also, is it getProdToCatalog or getProdtoCatalog?  Case is important and
> this may be why you're getting the exception.
>
> _______________________
>
> Ron Bickers
> Logic Etc, Inc.
> rbickers@logicetc.com
>