gluon/contrib/gql.py no longer works with web2py.

and you do not need it any more because its functions are now provided
in the new DAL.

db=DAL('gae')
db.define_table('mytable',Field('name'))

etc.

Yet you raise a good issue. You are probably using the very old syntax

from gluon.contrib import gql
db=gql.GQLDB()
db.define_table('mytable',gql.Field('name'))

I forgot about this and I did not add a compatibility layer.
I suggest you change your code you can also edit gql.py and replace
its entire content with

---- begin ----
__all__ = ['DAL','Field','drivers']
from dal import DAL, Field, Table, Query, Set, Expression, Row, Rows,
drivers, BaseAdapter, SQLField, SQLTable, SQLXorable, SQLQuery,
SQLSet, SQLRows, SQLStorage, SQLDB, GQLDB, SQLALL, SQLCustomType
----- end -----

and your code should work as it is.



On Dec 26, 6:38 pm, jinlin <wilkin...@gmail.com> wrote:
> Could you tell me an older version of web2py that has working gql
> support, and where to get it?  I only have gae as a hosting option,
> and I need to complete a small project asap.
>
> At first I am getting errors because contrib/gql.py is refering to
> gluon.sql.DEFAULT
> gluon.sql.Reference
> gluon.sql.validators
>
> which is not imported in gluon/sql.py
>
> After adding these three, I am getting this error  (gql.Field class
> doesn't have db attribute)
>
>   File "/Users/wilkin_ng/Documents/project/appengine/web2py/web2py/
> applications/redditpy/models/db.py", line 7, in <module>
>     session.connect(request,response,db=db)
>   File "/Users/wilkin_ng/Documents/project/appengine/web2py/web2py/
> gluon/globals.py", line 319, in connect
>     migrate=table_migrate,
>   File "/Users/wilkin_ng/Documents/project/appengine/web2py/web2py/
> gluon/contrib/gql.py", line 136, in define_table
>     t = self[tablename] = Table(self, tablename, *fields)
>   File "/Users/wilkin_ng/Documents/project/appengine/web2py/web2py/
> gluon/contrib/gql.py", line 219, in __init__
>     field.requires = gluon.sql.sqlhtml_validators(field)
>   File "/Users/wilkin_ng/Documents/project/appengine/web2py/web2py/
> gluon/dal.py", line 2993, in sqlhtml_validators
>     elif field.db and field_type.startswith('reference') and \
> AttributeError: 'Field' object has no attribute 'db'
>
> Thanks

Reply via email to