Models are executed alphabetically. Make sure that

auth=Auth(...)
auth.define_tables()

are executed before your table definition.

On Sep 29, 1:13 am, johntynan <[email protected]> wrote:
> Thank you for the suggestions, Massimo.
>
> I've tried to update the model here:
>
> http://code.google.com/p/publicradioroadtrip/source/browse/models/db_...
>
> based on your suggestions, and the example app here:
>
> http://www.web2py.com/book/default/chapter/03#A-Wiki
>
> However, if I use the line:
>
> Field('created_by', db.auth_user, default=auth.user_id,
> writable=False, readable=False),
>
> I receive the error: KeyError: 'auth_user'
>
> http://pastie.textmate.org/1188236
>
> Tell me, is the issue with the user table related to the issue of
> making a many-to-many relationship between stories and roadtrips?
>
> Best regards,
>
> John T.
>
> On Sep 29, 6:42 am, mdipierro <[email protected]> wrote:
>
> > just use
>
> > auth.user_id
>
> > is the same
>
> > created_by should be type=db.auth_user
>
> > On Sep 28, 10:31 pm, johntynan <[email protected]> wrote:
>
> > > if auth.is_logged_in():
> > >     me=auth.user.id
> > > else:
> > >     me=None
>
> > > On Sep 29, 5:19 am, mdipierro <[email protected]> wrote:
>
> > > > what is me? Do you use auth? why the type of created_by is a string?
>
> > > > On Sep 28, 10:01 pm, johntynan <[email protected]> wrote:
>
> > > > > I would like to create a many-to-many relationship in the following
> > > > > model, where many "stories" can appear in many different
> > > > > "roadtrips" (think songs to mixtapes).
>
> > > > > db.define_table(
> > > > >     'roadtrip',
> > > > >     Field('name'),
> > > > >     Field('description', 'text'),
> > > > >     Field('created_by',default=me,writable=False,readable=False),
>
> > > > > Field('created_on','datetime',default=request.now,writable=False,readable=F
> > > > >  alse)
> > > > >     )
>
> > > > > db.define_table(
> > > > >     'story',
> > > > >     Field('user_id', db.users,readable=False,writable=False),
> > > > >     Field('roadtrip_id', db.roadtrip),
> > > > >     Field('story_id', 'integer'),
> > > > >     Field('title'),
> > > > >     Field('latitude'),
> > > > >     Field('longitude'),
> > > > >     Field('comment', 'text'),
> > > > >     Field('created_by',default=me,writable=False,readable=False),
>
> > > > > Field('created_on','datetime',default=request.now,writable=False,readable=F
> > > > >  alse)
> > > > >     )
>
> > > > > db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'road
> > > > >  trip.id','%
> > > > > (name)s')
>
> > > > > I am able to create a multiple-select element on the CRUD form by
> > > > > simply adding "multiple=True" to this
>
> > > > > db.story.roadtrip_id.requires=IS_IN_DB(db(db.roadtrip.created_by==me),'road
> > > > >  trip.id','%
> > > > > (name)s', multiple=True)
>
> > > > > However, I am receiving the error:
>
> > > > > TypeError: int() argument must be a string or a number, not 'list'
>
> > > > > I posted the traceback here:http://pastie.textmate.org/1187996
>
> > > > > (as an aside, is there a better way to post a traceback that is more
> > > > > readable, should I just copy/paste from the html error page, as
> > > > > opposed to the logged file under errors?)
>
>

Reply via email to