Answered in other thread. On Friday, 5 April 2013 13:19:46 UTC-5, joe smith wrote: > > > I am trying to create a single web2py server with multiple applications > that each use a single CAS provider to handle user authentication. I keep > running into a wall when it comes to getting the applications to work with > the CAS. In particular I get an error from the consumer app that > auth.username table does not exist. In all my applications I user > auth.define_tables with username=False and it still tries to look for a > username. This is true even if all .tables are deleted and reconstructed. I > read on other posts that copying the .tables from the provider app to the > consumer app will solve the problem. This does fix it, but is that the best > solution? It seems to me that it should not be looking for auth.username? > Any help is appreciated. I am providing an example with two applications > one a CAS provider, the other a consumer. Only the db.py files have been > modified from the original scaffold. I am using Web2py2.3.2 (2012-12-17 > 15:03:30), Postgres 9.1 > ****The error:***** > > <class 'gluon.contrib.pg8000.errors.ProgrammingError'> ('ERROR', '42703', > 'column auth_user.username does not exist') Version web2py™ (2, 3, 2, > datetime.datetime(2012, 12, 17, 15, 3, 30), 'stable') Python Python > 2.7.3: C:\Python27\python.exe Traceback > > 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8. > 9. > 10. > 11. > 12. > 13. > 14. > 15. > 16. > 17. > 18. > 19. > 20. > 21. > 22. > 23. > 24. > 25. > 26. > 27. > 28. > 29. > 30. > 31. > 32. > 33. > 34. > 35. > 36. > 37. > 38. > 39. > 40. > 41. > 42. > 43. > 44. > > Traceback (most recent call last): > File "C:\wrk\PD\admingui\trunk\gluon\restricted.py", line 212, in restricted > exec ccode in environment > File "C:/wrk/PD/admingui/trunk/applications/app1/controllers/default.py" > <http://127.0.0.1:8000/admin/default/edit/app1/controllers/default.py>, line > 77, in <module> > File "C:\wrk\PD\admingui\trunk\gluon\globals.py", line 193, in <lambda> > self._caller = lambda f: f() > File "C:/wrk/PD/admingui/trunk/applications/app1/controllers/default.py" > <http://127.0.0.1:8000/admin/default/edit/app1/controllers/default.py>, line > 39, in user > return dict(form=auth()) > File "C:\wrk\PD\admingui\trunk\gluon\tools.py", line 1240, in __call__ > return getattr(self, args[0])() > File "C:\wrk\PD\admingui\trunk\gluon\tools.py", line 2090, in login > table_user._filter_fields(cas_user)) > File "C:\wrk\PD\admingui\trunk\gluon\tools.py", line 1714, in > get_or_create_user > user = table_user(**{fieldname: value}) > File "C:\wrk\PD\admingui\trunk\gluon\dal.py", line 7769, in __call__ > return self._db(query).select(limitby=(0,1),for_update=for_update, > orderby=orderby).first() > File "C:\wrk\PD\admingui\trunk\gluon\dal.py", line 8905, in select > return adapter.select(self.query,fields,attributes) > File "C:\wrk\PD\admingui\trunk\gluon\dal.py", line 1631, in select > return self._select_aux(sql,fields,attributes) > File "C:\wrk\PD\admingui\trunk\gluon\dal.py", line 1596, in _select_aux > self.execute(sql) > File "C:\wrk\PD\admingui\trunk\gluon\dal.py", line 1709, in execute > return self.log_execute(*a, **b) > File "C:\wrk\PD\admingui\trunk\gluon\dal.py", line 1703, in log_execute > ret = self.cursor.execute(*a, **b) > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\dbapi.py", line 246, in > _fn > return fn(self, *args, **kwargs) > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\dbapi.py", line 317, in > execute > self._execute(operation, args) > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\dbapi.py", line 322, in > _execute > self.cursor.execute(new_query, *new_args) > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\interface.py", line > 398, in execute > self._stmt = PreparedStatement(self.connection, query, statement_name="", > *[{"type": type(x), "value": x} for x in args]) > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\interface.py", line > 138, in __init__ > self._parse_row_desc = self.c.parse(self._statement_name, statement, > types) > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\protocol.py", line 943, > in _fn > return fn(self, *args, **kwargs) > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\protocol.py", line > 1104, in parse > return reader.handle_messages() > File "C:\wrk\PD\admingui\trunk\gluon\contrib\pg8000\protocol.py", line 929, > in handle_messages > raise exc > ProgrammingError: ('ERROR', '42703', 'column auth_user.username does not > exist') > > > > > *****My Provider Code:***** > > # -*- coding: utf-8 -*- > > ######################################################################### > ## This scaffolding model makes your app work on Google App Engine too > ## File is released under public domain and you can use without limitations > ######################################################################### > > if not request.env.web2py_runtime_gae: > ## if NOT running on Google App Engine use SQLite or other DB > #db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) > db = DAL('postgres://postgres:password@localhost/mydatabase', > pool_size=1, check_reserved=['all']) > session.connect(request, response, db = db, masterapp = None) > else: > ## connect to Google BigTable (optional 'google:datastore://namespace') > db = DAL('google:datastore') > ## store sessions and tickets there > session.connect(request, response, db=db) > > ## by default give a view/generic.extension to all actions from localhost > ## none otherwise. a pattern can be 'controller/function.extension' > response.generic_patterns = ['*'] if request.is_local else [] > > _migrate=True > _fake_migrate=False > > from gluon.tools import Auth, Crud, Service, PluginManager, prettydate > auth = Auth(db) > crud, service, plugins = Crud(db), Service(), PluginManager() > > # Object Types table > db.define_table('object_types', > Field('name', 'string', length=32), > format='%(name)s', migrate=_migrate) > > # Objects table > db.define_table('objects', > Field('name','string',length=64), > Field('object_type_id', 'reference object_types'), > format='%(name)s', migrate=_migrate) > > #Parent_id's must be existing object_id's > objects_table = db[db.object_types] # get the custom_auth_table > objects_table.name.requires = > IS_NOT_EMPTY(error_message=auth.messages.is_empty) > > ####### Custom Auth Field Definitions: ####### > auth.settings.extra_fields['auth_user']=[ > Field('work_phone','string',length=32), > Field('home_phone','string',length=32), > Field('cell_phone','string',length=32), > Field('photo','upload',autodelete=True), > Field('object_id', 'reference objects')] > > ## create all tables needed by auth if not custom tables > auth.define_tables(migrate=_migrate, fake_migrate=_fake_migrate, > username=False, signature=False) > > ## configure email > mail = auth.settings.mailer > mail.settings.server = 'logging' or 'smtp.gmail.com:587' > mail.settings.sender = 'y...@gmail.com <javascript:>' > mail.settings.login = 'username:password' > > ## configure auth policy > auth.settings.registration_requires_verification = False > auth.settings.registration_requires_approval = False > auth.settings.reset_password_requires_verification = True > > ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. > ## register with janrain.com, write your domain:api_key in > private/janrain.key > from gluon.contrib.login_methods.rpx_account import use_janrain > use_janrain(auth, filename='private/janrain.key') > > > > *****My Consumer Code:***** > > # -*- coding: utf-8 -*- > > ######################################################################### > ## This scaffolding model makes your app work on Google App Engine too > ## File is released under public domain and you can use without limitations > ######################################################################### > > ## if SSL/HTTPS is properly configured and you want all HTTP requests to > ## be redirected to HTTPS, uncomment the line below: > # request.requires_https() > _migrate=False > > if not request.env.web2py_runtime_gae: > ## if NOT running on Google App Engine use SQLite or other DB > db = DAL('postgres://postgres:password@localhost/mydatabase', > pool_size=1, check_reserved=['all'], auto_import=True) > session.connect(request, response, db = db, masterapp = > 'cas_provider') > else: > ## connect to Google BigTable (optional 'google:datastore://namespace') > db = DAL('google:datastore') > ## store sessions and tickets there > session.connect(request, response, db=db) > ## or store session in Memcache, Redis, etc. > ## from gluon.contrib.memdb import MEMDB > ## from google.appengine.api.memcache import Client > ## session.connect(request, response, db = MEMDB(Client())) > > ## by default give a view/generic.extension to all actions from localhost > ## none otherwise. a pattern can be 'controller/function.extension' > response.generic_patterns = ['*'] if request.is_local else [] > ## (optional) optimize handling of static files > # response.optimize_css = 'concat,minify,inline' > # response.optimize_js = 'concat,minify,inline' > > ######################################################################### > ## Here is sample code if you need for > ## - email capabilities > ## - authentication (registration, login, logout, ... ) > ## - authorization (role based authorization) > ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) > ## - old style crud actions > ## (more options discussed in gluon/tools.py) > ######################################################################### > > from gluon.tools import Auth, Crud, Service, PluginManager, prettydate > auth = Auth(db,cas_provider = ' > http://127.0.0.1:8000/cas_provider/default/user/cas') > crud, service, plugins = Crud(db), Service(), PluginManager() > > > ## create all tables needed by auth if not custom tables > auth.define_tables(migrate=_migrate, fake_migrate=False, username=False) > > ## configure email > mail = auth.settings.mailer > mail.settings.server = 'logging' or 'smtp.gmail.com:587' > mail.settings.sender = 'y...@gmail.com <javascript:>' > mail.settings.login = 'username:password' > > ## configure auth policy > auth.settings.registration_requires_verification = False > auth.settings.registration_requires_approval = False > auth.settings.reset_password_requires_verification = True > > ## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. > ## register with janrain.com, write your domain:api_key in > private/janrain.key > from gluon.contrib.login_methods.rpx_account import use_janrain > use_janrain(auth, filename='private/janrain.key') > > ######################################################################### > ## Define your tables below (or better in another model file) for example > ## > ## >>> db.define_table('mytable',Field('myfield','string')) > ## > ## Fields can be 'string','text','password','integer','double','boolean' > ## 'date','time','datetime','blob','upload', 'reference TABLENAME' > ## There is an implicit 'id integer autoincrement' field > ## Consult manual for more options, validators, etc. > ## > ## More API examples for controllers: > ## > ## >>> db.mytable.insert(myfield='value') > ## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL) > ## >>> for row in rows: print row.id, row.myfield > ######################################################################### > > ## after defining tables, uncomment below to enable auditing > # auth.enable_record_versioning(db)
-- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.