I have tried to follow the bookmarker example in chapter 5 of the
TurboGears Book. Adding new bookmarks works fine, but I get the
following error message when trying to update one of the bookmarks:
I' using an sqlite database.
File "C:\Python24\Scripts\bookmarker\bookmarker\controllers.py", line
84, in save_bookmark
description=kwargs["description"])
File
"C:\Python24\lib\site-packages\sqlobject-0.7.1dev_r1860-py2.4.egg\sqlobject\declarative.py",
line 93, in _wrapper
return fn(self, *args, **kwargs)
File
"C:\Python24\lib\site-packages\sqlobject-0.7.1dev_r1860-py2.4.egg\sqlobject\main.py",
line 1197, in __init__
self._create(id, **kw)
File
"C:\Python24\lib\site-packages\sqlobject-0.7.1dev_r1860-py2.4.egg\sqlobject\main.py",
line 1224, in _create
self._SO_finishCreate(id)
File
"C:\Python24\lib\site-packages\sqlobject-0.7.1dev_r1860-py2.4.egg\sqlobject\main.py",
line 1248, in _SO_finishCreate
id, names, values)
File
"C:\Python24\lib\site-packages\sqlobject-0.7.1dev_r1860-py2.4.egg\sqlobject\dbconnection.py",
line 764, in queryInsertID
return self._dbConnection._queryInsertID(
File
"C:\Python24\lib\site-packages\sqlobject-0.7.1dev_r1860-py2.4.egg\sqlobject\sqlite\sqliteconnection.py",
line 167, in _queryInsertID
c.execute(q)
IntegrityError: column bookmark_name is not unique
In think the bug must be in the 'bookmark' or 'save_bookmark', which
look like:
@expose(template="bookmarker.templates.form")
def bookmark(self, *args, **kwargs):
if args and args[0] == "add":
values=""
submit_action="/save_bookmark/"
if args and args[0] == "edit":
from sqlobject import SQLObjectNotFound
try:
b= Bookmarks.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,
"categories" : default_options}
except SQLObjectNotFound:
values=""
flash("That's not an valid Bookmark,do you want to add
one?")
submit_action="/save_bookmark/edit/%s" % args[1]
return dict(form=bookmark_form, values=values,
action=submit_action)
@expose()
@error_handler(bookmark)
@validate(form=bookmark_form)
def save_bookmark(self, *args, **kwargs):
try:
b=Bookmarks.get(args[1])
b.bookmarkName = kwargs["bookmarkName"]
b.link =kwargs["link"]
b.description = kwargs["description"]
Bookmarks.updateCategories(b,kwargs["categories"])
except:
b=Bookmarks(bookmarkName=kwargs["bookmarkName"],
link=kwargs["link"],
description=kwargs["description"])
for item in kwargs["categories"]:
b.addCategories(Categories.get(item))
raise redirect("/index")
Does anybody have an idea what's missing ?
Besides the form validators do not work.
Regards,
Markus
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---