Believe this is fixed in trunk. Did you try that. If so I will post to
stable soon.

On Dec 24, 6:24 am, Lisandro <[email protected]> wrote:
> I've been working with web2py for a while. Lastnight I updated to last
> version, and my webforms just collapsed (sorry for my poor english).
> Anyway. After some minutes searching for the cause of the problem,
> I've decided to start from scratch with an example. I downloaded the
> version 1.91.4 (I'm using Ubuntu 10.04). I created a new application.
>
> The model (very simple, I took it from web2py examples):
> ------------------------------------------------------------------------------
> db.define_table('person',
>     Field('name'))
> db.define_table('dog',
>     Field('name'),
>     Field('owner', db.person))
> ------------------------------------------------------------------------------
>
> Then, I wrote the "index" function on "default.py" controller:
> ------------------------------------------------------------------------------
> def index():
>     form = SQLFORM.factory(db.dog)
>     if form.accepts(request.vars, keepvalues=True):
>         response.flash = 'New dog inserted'
>     dogs = db(db.dog.id>0).select()
>     return dict(form=form, dogs=dogs)
> ------------------------------------------------------------------------------
> In the view I just added {{=form}} and {{=BEAUTIFY(dogs)}}, just to
> see the result of the function.
>
> When I try to run the function, I receive the following error:
> ------------------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/home/lisandro/pylicencias/gluon/restricted.py", line 188, in
> restricted
>     exec ccode in environment
>   File "/home/lisandro/pylicencias/applications/prueba/controllers/
> default.py", line 20, in <module>
>   File "/home/lisandro/pylicencias/gluon/globals.py", line 95, in
> <lambda>
>     self._caller = lambda f: f()
>   File "/home/lisandro/pylicencias/applications/prueba/controllers/
> default.py", line 14, in index
>     form = SQLFORM.factory(db.dog)
>   File "/home/lisandro/pylicencias/gluon/sqlhtml.py", line 1182, in
> factory
>     return SQLFORM(SQLDB(None).define_table(table_name, *fields),
>   File "/home/lisandro/pylicencias/gluon/dal.py", line 3314, in
> define_table
>     t._create_references()
>   File "/home/lisandro/pylicencias/gluon/dal.py", line 3607, in
> _create_references
>     rtable = self._db[rtablename]
>   File "/home/lisandro/pylicencias/gluon/dal.py", line 3335, in
> __getitem__
>     return dict.__getitem__(self, str(key))
> KeyError: 'person'
> ------------------------------------------------------------------------------
>
> The SAME code, but using SQLFORM(db.dog) instead of
> SQLFORM.factory(db.dog), works just fine.
> The SAME code, but with an older version of web2py, works just fine.
> What happened to SQLFORM.factory? Some bug? Or it's just me that I'm
> doing something wrong?
>
> Thanks in advance.

Reply via email to