Hi all I used the catalog anything manual to do have my sql data from postgres to be indexed into zope but i ran into trouble. I must warn you i am a newbie so it must be a very silly mistake somewhere. Let me explain what I did My config Linux OS Zope 2.3.0 Postgres 7.0.3 ZPyGreSQL DA The process Since i am a newbie i was not sure what you meant in the cataloganything doc when you said... ============= Setting Up the Catalog The first step in any search is to set up the catalog. There is no difference in setting up a catalog for "normal" searches and setting one up for a search of SQL data, so I'm not going to go into detail here on how to do that. Just make sure you have created a catalog with the desired indexes and meta data. ============== So i just used the chapter 9 reference that was provided earlier and i created a ZCatalog called Products. I was not sure what else to do so i just let the defaults remain as it is - the AnimalTracker example in chap 9 didnt seem relevant to me since i have no dtml methods to search for - only products info from the 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 SELECT prodid as Number, Title, Descr || ' ' || Title as 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 getProdtoCatalog zsql method and added to 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 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.... =================== Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: getProdToCatalog -------------------------------------------------------------------------- Troubleshooting Suggestions a.. The URL may be incorrect. b.. The parameters passed to this resource may be incorrect. c.. 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 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) ===================
Bobby Mathew wrote:
[snip]
Now i went into the Find Objects section and searched for the getProdtoCatalog zsql method and added to the catalog
This should not be necessary, the ZSQL method itself should not be cataloged
Next i went and created the python script (again under the Products ZCatalog itself) and i called it catalogProducts this is the code inside
So, both the ZSQL method and the python script are contained by the ZCatalog correct? In other words they are listed under the Contents tab of the Products catalog. [snip]
Zope Error
Zope has encountered an error while publishing this resource.
Error Type: AttributeError Error Value: getProdToCatalog
This means the ZSQL method is not in the same container as the Python script, or the container binding in the Python script is messed up. Have the bindings been changed? P.S. Please do not post HTML formatted emails to the list! Thanks. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
-----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
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
Bobby Mathew wrote:
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
[snip] Try Product.number, Databases often return field names in all lower case regardless of the case specified in the SQL. hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
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()
I may have misled you as far as where to put the ZSQL Method. It's okay to have the method in the contents part of the catalog where the Python Script is, you just don't want to use the 'Find Objects' to add it to the catalog's search index. Of course, with acquisition, it works all the same where you put it.
Try Product.number, Databases often return field names in all lower case regardless of the case specified in the SQL.
I can't think of any reason for the error, but this sounds like a good thing to try. MySQL is case sensitive so I've always stuck to the case as defined in the table. If changing the case works, let me know. _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
THANKS GUYS It worked once i changed the case... Once again you guys are genius's thanks a lot bobby ----- Original Message ----- From: Ron Bickers <rbickers@logicetc.com> To: <cduncan@kaivo.com>; Bobby Mathew <bobby@dialognet.com> Cc: <zope@zope.org> Sent: Thursday, May 03, 2001 8:02 PM Subject: RE: [Zope] Re: Catalog Anything Problem
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()
I may have misled you as far as where to put the ZSQL Method. It's okay
to
have the method in the contents part of the catalog where the Python Script is, you just don't want to use the 'Find Objects' to add it to the catalog's search index. Of course, with acquisition, it works all the same where you put it.
Try Product.number, Databases often return field names in all lower case regardless of the case specified in the SQL.
I can't think of any reason for the error, but this sounds like a good thing to try. MySQL is case sensitive so I've always stuck to the case as defined in the table. If changing the case works, let me know. _______________________
Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
participants (4)
-
Bobby Mathew -
Bobby Mathew -
Casey Duncan -
Ron Bickers