replace
Field('media', 'string', length=2048,
requires=IS_IN_DB(db, db.media.id, '%(url)s',
multiple=True)),
with
Field('media', 'list:reference media', length=2048)
and
in db.define_table('media',...) add format='%(url)s'
Massimo
On Nov 17, 2:01 am, howesc <[email protected]> wrote:
> i upgraded from 1.74.5 to 1.88.2 (so a little bit out of date as of
> this week).
>
> an example model with the problem is below. the media field is the
> problem.
>
> db.define_table('song',
> #...@todo: add proper requires for each field
> Field('duration', 'integer',
> requires=IS_NULL_OR(IS_INT_IN_RANGE(0,36001))),
> Field('last_modified', 'datetime', default=now, update=now),
> Field('title', 'string', length=256, requires=IS_NOT_EMPTY()),
> Field('artist', 'string', length=256,
> requires=IS_IN_DB(db, db.artist.name, '%(name)s')),
> Field('genre', 'string',
> requires=IS_IN_DB(db, db.genre.name, '%(name)s')),
> Field('song_key', 'string',
> requires=IS_NULL_OR(IS_IN_DB(db, db.song_key.name, '%
> (name)s'))),
> Field('song_scale', 'string',
> requires=IS_NULL_OR(IS_IN_DB(db, db.song_scale.name, '%
> (name)s'))),
> Field('publisher_song_code', 'string', length=100),
> Field('label', 'string',
> requires=IS_IN_DB(db, db.label.name, '%(name)s')),
> #...@todo: not sure that i like this string of ID's seperated by |
> Field('media', 'string', length=2048,
> requires=IS_IN_DB(db, db.media.id, '%(url)s',
> multiple=True)),
> Field('isrc', 'string', length=12, unique=True),
> Field('orig_publish_year', 'integer',
> requires=IS_NULL_OR(IS_INT_IN_RANGE(1800, 2100))),
> Field('tempo', 'integer',
> requires=IS_NULL_OR(IS_INT_IN_RANGE(0, 250))),
> Field('written_by', 'string'),
> #...@todo: add optional parameters
> #keywords, description, status,thumbnail,name
> migrate=migrate)
>
> thanks,
>
> cfh
>
> On Nov 16, 7:20 pm, mdipierro <[email protected]> wrote:
>
> > Which version did you upgrade from?
> > Can you show the model that causes problem?
>
> > On Nov 16, 8:42 pm, howesc <[email protected]> wrote:
>
> > > Hi all,
>
> > > sorry if i missed the discussion on this, but i was just bitten by an
> > > upgrade issue that i'm not sure the best way to solve.
>
> > > i have an existing app running on the google app engine that uses
> > > several String fields with IS_IN_DB(... multiple=True). I upgraded
> > > web2py and now those fields are not working properly (the forms don't
> > > see the existing data, and then they update the field incorrectly
> > > based on the old pipe-delimited string). This is wrecking havoc in
> > > the system.
>
> > > as far as i can tell the best solution is:
> > > - change the field type to 'list:reference <table_name>' since they
> > > are references
> > > - update my code that expects the pipe-delimited string and make it
> > > expect a list of IDs (yea!!)
> > > - write a task that i can run in the GAE task-queue to query each row
> > > (around 200,000 of them at least), parse the string, convert it to the
> > > list, and write back the new entry.
>
> > > is this correct? has anyone else done this and have a better
> > > suggestion?
>
> > > thanks!
>
> > > christian
>
>