Hi All,
turbogears newbie question. I've nearly finished a simple TG app as a
test run which collects some info about an Owner and their PC and
formats some data to be emailed to them based on the info. So far so
good. the app works, email works, life is good. But then I wanted to
save this data to a sqlite db.
I've looked at a few tutorials and while it seems straightforward, I
can't get talk to the DB.
I've defined a simple 2-table model (Owners & PCInfo), linked by a
simple join in the Model Designer, and I can instantiate it by:
'tg-admin sql create'
Peeking at the DB using sqlite3, the .schema looks good.
However, when I try to write a row to the DB using the following form:
[controllers.py]
----------------
import locale
from datetime import datetime
from sqlobject import *
from turbogears import controllers, expose, error_handler, validate,
flash, redirect, url,widgets, validators, identity
from cherrypy import request
from socket import gethostbyaddr
from re import sub
from os import mkdir, system, path
import model
import sys
from IPython.Shell import IPShellEmbed
dbg = IPShellEmbed() # and insert 'dbg()' where you want to break.
....
class Root(controllers.RootController):
....<collect info, process, mail out digest>
# now try to write row to DB
model.Owner.set(FirstName=kw["FIRSTNAME"],LastName=kw["LASTNAME"],UserID=kw["USERNAME"],
EmailGiven=kw["EMAIL"], PhoneNbr=kw["PHONE"],Password=kw["PASSWORD1"])
I get this error:
TypeError: unbound method set() must be called with Owner instance as
first argument (got nothing instead)
I thought that this meant I had to create an instance of the storage
class, but trying to do this:
o=model.Owner()
yeilds a long error ending with this:
<type 'exceptions.ValueError'>: Unknown SQL builtin type: <type
'classobj'> for <class sqlobject.sqlbuilder.NoDefault at 0x860ca1c>
and none of the tutorials I've looked at seems to require this.
using the ipython debugger, I can assign to the class fine:
In [1]: model.Owner.FirstName="Larry"
In [2]: model.Owner.LastName="Gelbart"
etc, but not at once, and I'm still unclear on how to commit the write
(and the suggestions from the SQLObject docs don't seem to work:
http://www.sqlobject.org/SQLObject.html#declaring-the-class
http://www.sqlobject.org/SQLObject.html#using-the-class
I'm clearly missing something important. Anyone care to rub my nose
in it?
TIA
Harry
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---