Setting Up the Catalog
The first step in any search is to set up the catalog. There is no =
difference=20
in setting up a catalog for "normal" searches and setting one up for a =
search of=20
SQL data, so I'm not going to go into detail here on how to do that. =
Just make=20
sure you have created a catalog with the desired indexes and meta =
data.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
So i just used the chapter 9 reference that was provided earlier and =
i=20
created a ZCatalog called Products. I was not sure what else to do so i =
just let=20
the defaults remain as it is - the AnimalTracker example in chap 9 didnt =
seem=20
relevant to me since i have no dtml methods to search for - only =
products info=20
from the postgres. So i just didnt do anything further. I have a =
products table=20
in the postgres rdbms that i want to search by title and description. So =
after=20
this i created a zsql method called getProdtoCatalog under the ZCatalog =
itself -=20
the query i used is
SELECT prodid as Number, Title,
Descr || ' ' || Title as=20
PrincipiaSearchSource,
'Product' as meta_type, prodid as id, Descr as =
summary
FROM products
Now i went into the Find Objects section and searched for the=20
getProdtoCatalog zsql method and added to the catalog
Next i went and created the python script (again under the Products =
ZCatalog=20
itself) and i called it catalogProducts this is the code inside
for book in container.getProdToCatalog():
=20
container.catalog_object(Product,
=20
'/learn/search/Products/'+Product.Number+'/proddetails.html')
&n=
bsp; =20
print 'Product #' + Product.Number
return printed
The moment i test it i run into trouble - Can any one help please =
regards
bobby
For the error message this is what i get....
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Zope Error
Zope has encountered an error while publishing this =
resource.
Error Type: AttributeError Error =
Value:=20
getProdToCatalog
Troubleshooting Suggestions
- The URL may be incorrect.=20
- The parameters passed to this resource may be incorrect.=20
- A resource that this resource relies on may be encountering =
an=20
error.
For more detailed information about the error, please refer to =
the HTML=20
source for this page.
If the error persists please contact the site maintainer. Thank =
you for=20
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 8d02630>, 'container': =
<ZCatalog instance at 8d02630>, 'traverse_subpath': []}, (), {}, =
None))
File Script (Python), line 2, in catalogProducts
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: Traversable)
AttributeError: (see above)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 =
;