I am trying to catalog mysql database items in a plone site using python.

The function that catalogs the SQL query results takes 2 arguments. First is the item returned by the query (for example Select * from books would return many book objects) and second argument is the string url on the site where the details for that mysql object is displayed.

Here is the line of code that throws the error. Here container object just refers to the containing folder on the server and book is the object returned by the SQL query

books = container.getBookTitleToCatalog()

for book in books:
params=urlencode({'code':book.id})
container.catalog_object(book, '/APP_New/app-home/app-information/Publications/showBookDetails?%s'%params)

This throws type error "str object is not callable". Would appreciate if anyone can help me figure out the cause of this error

Thanks
Keshav

Recommended Answers

All 4 Replies

For readability please wrap your code in

#your code here

it makes it a lot easier to read

Can you give us more details of the error, such as what line it was and stuff like that. See that error means your doing something like this:

s = "hello world"
s()
#error made, string object is not callable, so you cant try and call a function with it.

It acts like container.catalog_object has been used as the variable name for a string somewhere in your code.

books = container.getBookTitleToCatalog()

for book in books:
    params=urlencode({'code':book.id})
    container.catalog_object(book, 
        '/APP_New/app-home/app-information/Publications/showBookDetails?%s'%params)

actually i am new in django.And i have this error for my first basic application :-
'str' object is not callable
Exception Location: C:\Python26\lib\site-packages\django\core\handlers\base.py in get_response, line 92


Please help me to fix this

# naming a variable str
str = "my string"

# later calling function str()
# will give
# TypeError: 'str' object is not callable
numeric = str(123)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.