db.define_table not db.define.table

-Thadeus





On Thu, Feb 18, 2010 at 7:01 PM, Wayne <[email protected]> wrote:
> I have been working on section 3.6 of the book but cannot get past the
> initial database sample.  When I enter the following into db.py and
> click on 'database administration' I get an error.  The code entered
> is:
>
> *****
> db = DAL("sqlite://storage.db")
>
> db.define.table('image',
>    Field('title'),
>    Field('file','upload'))
>
> db.define.table('comment',
>    Field('image_id', db.image),
>    Field('author'),
>    Field('email'),
>    Field('body', 'text'))
>
> db.image.title.requires = [IS_NOT_EMPTY(),
>                            IS_NOT_IN_DB(db, db.image.title)]
>
> db.comment.image_id.requires = IS_IN_DB(db, db.image.id, '%(title)s')
> db.comment.author.requires = IS_NOT_EMPTY()
> db.comment.email.requires = IS_EMAIL()
> db.comment.body.requires = IS_NOT_EMPTY()
>
> db.comment.image_id.writable = db.comment.image_id.readable = False
> ****
> When clicking 'database administration' I get the following error:
>
> Traceback (most recent call last):
>  File "gluon/restricted.py", line 173, in restricted
>  File "C:/Code/web2py/applications/MyApp/models/db.py", line 5, in
> <module>
>  File "gluon/sql.py", line 1295, in __getattr__
> KeyError: 'define'
>
> I am running Python 2.6 on Windows 7 with version 1.75.1 of web2py.
> Before I added the database code from section 3.6 I was able to access
> the database administration for the initial tables.
>
> Does anyone have suggestions on where I should be looking?  I thought
> I might be missing sqlite (haven't used Python on a while), but that
> is built-in now.
>
> Wayne
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" 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/web2py?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en.

Reply via email to