alfonsodg / demo-web2py

Apache License 2.0
0 stars 0 forks source link

errors of define_table on Google app engine #22

Closed alfonsodg closed 10 years ago

alfonsodg commented 10 years ago

From mistapos...@gmail.com on August 25, 2008 22:29:15

What steps will reproduce the problem? 1. I am using web2py on google app engine : from gluon.contrib import gql dba=gql.GQLDB() dba.define_table('users', SQLField('name'), SQLField('email'))

dba.define_table('comments',SQLField('content'),SQLField('writer',dba.users))

the I get these error logs :

dba.define_table('comments',SQLField('content'),SQLField('writer',dba.users) ) File "D:\pythons\web2py\gluon\sql.py", line 856, in init if requires==sqlhtml_validators: requires=sqlhtml_validators(type,length) File "D:\pythons\web2py\gluon\sql.py", line 201, in sqlhtml_validators try: return v[field_type[:9]] TypeError: unhashable type What is the expected output? What do you see instead? What version of the product are you using? On what operating system? i am base on the latest code from svn Please provide any additional information below. i think it is cause by line 844 in gluon/sql.py :

if isinstance(type,SQLTable): type='reference '+type._tablename

here type is instance of gluon.contrib.gql.SQLTable not a gluon.sql.SQLTable , so the following code : type='reference '+type._tablename ; won't run , and it make the error

I think 2 way to fix this : 1) just change that line of code to : if not isinstance(type,str) : type='reference ' + type._tablename

but I don't think this way is good enough , since i found these code : isinstance(left,SQLField) , isinstance(left,SQLTable) , appear in sql.py more than one times

2) make gluon.contrib.gql.SQLTable extends gluon.sql.SQLTable and the same on SQLField , but I not sure if i will create other bugs

Original issue: http://code.google.com/p/web2py/issues/detail?id=22

alfonsodg commented 10 years ago

From mistapos...@gmail.com on August 25, 2008 21:01:58

Sorry about these post . I think I found out the real reason ,that i use a gluon.sql.SQLField to define_table : dba.define_table('comments',SQLField('content'),SQLField('writer',dba.users))

and it should be : dba.define_table('comments',gql.SQLField('content'),gql.SQLField('writer',dba.users))

please close this Issue

alfonsodg commented 10 years ago

From massimod...@gmail.com on August 26, 2008 00:35:28

Status: Invalid