I think it is complaining because you passed something as an argument
that was supposed to be a function. This just happened to someone the
other day. I think this line is wrong:
@turbogears.error_handler(Bookmark)
Bookmark is an sqlobject class most likely. You want to pass the
function 'bookmark' (lower case instead of upper case).
-Ian
On 2/14/07, Theterminator <[EMAIL PROTECTED]> wrote:
>
> hi guys,
>
> iam working on the code ch5 of the turbogears book...i get the
> following error when i try to add a mew bookmark(the edit works
> perfectly fine):
>
> File "c:\python24\lib\site-packages\TurboGears-1.0-py2.4.egg
> \turbogears\util.py", line 215, in inject_args
> args, kw = inject_arg(func, argname, argval, args, kw, start)
> File "c:\python24\lib\site-packages\TurboGears-1.0-py2.4.egg
> \turbogears\util.py", line 201, in inject_arg
> argnames, defaults = getargspec(func)[::3]
> File "C:\python24\lib\inspect.py", line 677, in getargspec
> raise TypeError('arg is not a Python function')
> TypeError: arg is not a Python function
>
> this are my bookmark and save_bookmark methods respectively:
>
> @expose(template="wiki20.templates.form")
> def bookmark(self, *args, **kwargs):
> from sqlobject import SQLObjectNotFound
> if args and args[0] == "add":
> values = []
> submit_action= "/save_bookmark/"
> if args and args[0] == "edit":
> try:
> b = model.Bookmark.get(args[1])
> default_options = []
> for a in b.categories:
> default_options.append(a.id)
> values = {"bookmarkName" : b.bookmarkName, "link":
> b.link, "description": b.description, "select_categories":
> default_options}
> except SQLObjectNotFound:
> values = ""
> turbogears.flash = "That's not a valid Bookmark, do
> you want to add one now?"
> submit_action = "/save_bookmark/edit/%s" %args[1]
> return dict(form=bookmark_form, values=values,
> action=submit_action)
>
> @expose()
> @turbogears.error_handler(Bookmark)
> @turbogears.validate(form=bookmark_form)
> def save_bookmark(self, *args, **kwargs):
> try:
> b=model.Bookmark.get(args[1])
> b.bookmarkName=kwargs["bookmarkName"]
> b.link = kwargs["link"]
> b.description = kwargs["description"]
>
> model.Bookmark.UpdateCategories(b,kwargs["select_categories"])
> except:
> b=model.Bookmark(bookmarkName=kwargs["bookmarkName"], link
> = kwargs["link"], description = kwargs["description"])
> for item in kwargs["select_categories"]:
> b.addCategories(model.Categories.get(item))
> raise redirect("/list")
>
> any help guys??don't understand what am i doing wrong here....its the
> same code as from the website(www.turbogearsbook/code)
>
> cheers
> The terminator
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---