I made an improvement and re-posted it.
The references are stored as |1|3|...| i.e. as ids separated by | in a
text field. This way it is easy to edit them manually.
Invalid references are deleted when the field is edited, ignored
otherwise.
Values can be searched efficiently with db.table.field.like('%|4|%').
Too mad the LIKE operator is not supported (yet) on GAE.
We could store as 1,3,... instead of |1|3|...| but this would make
searching more difficult because 12 contains 1 as a substring but |12|
does not contain |1| as a substring.
Thoughts?
Massimo
On Dec 30, 5:37 pm, mdipierro <[email protected]> wrote:
> New in trunk. Please give this a try:
>
> db=SQLDB('sqlite://storage.db')
> db.define_table('person',SQLField('name'))
> db.define_table('dog',SQLField('name'),SQLField('person','text'))
> db.dog.person.requires=IS_IN_DB
> (db,'person.id','person.name',multiple=True)
>
> This is not the same many2many as Django and Rails do it (because does
> not use an intermediate table) but for practical purposes it works the
> same, if not better, and works on GAE too. It will possible to change
> the widget to make it look different.
>
> The trick is to turn a reference into a 'text' field and set the
> IS_IN_DB or IS_IN_SET validator to multiple=True.
>
> If you like it and if nothing breaks, this will go in 1.55.
>
> Mind that I had to make quite a lot of changes to make this work
> seamlessly.
>
> Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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
-~----------~----~----~----~------~----~------~--~---