Well, you have:

db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])

defined, then you initiate auth with:

auth.define_tables(username=True, signature=True)

which sets up auth tables etc. in the above database. But then you override 
the previously set db with:

db = DAL('sqlite://webform.sqlite')

in which you define your own tables. So basically you have set up auth in 
one database, then you stop using it and use another database, which has no 
auth set up. That can't work.

Simply define db just once, not twice. Use the definition web2py has 
suggested for you and change the database name if you want to.

Regards,
Ales


On Friday, June 28, 2013 5:05:50 PM UTC+2, Tom Russell wrote:
>
> I am confused about how I have my db.py set up for tables etc.
>
> At the top I have what is generated for me:
>
> 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'])
> 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()))
>
>     from gluon.tools import Auth, Crud, Service, PluginManager, 
> prettydate, Mail
> auth = Auth(db)
> crud, service, plugins = Crud(db), Service(), PluginManager()
> db._common_fields.append(auth.signature) ## adds signature fields to all 
> tables
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=True, signature=True)
>
> And then from examples I have for my db down a ways is:
>
> db = DAL('sqlite://webform.sqlite')
>
> then I define my tables...
>
>
> Problem with this is though I am trying to use 
> http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-formbecause
>  I need that feature but when trying to use it I get an error cause 
> auth_user doesnt exist. Well it doesnt because I set db = 
> DAL('sqlite://webform.sqlite') but in default.py I do have:
>
> def user():
>     """
>     exposes:
>     http://..../[app]/default/user/login
>     http://..../[app]/default/user/logout
>     http://..../[app]/default/user/register
>     http://..../[app]/default/user/profile
>     http://..../[app]/default/user/retrieve_password
>     http://..../[app]/default/user/change_password
>     http://..../[app]/default/user/manage_users (requires membership in 
>     use @auth.requires_login()
>         @auth.requires_membership('group name')
>         @auth.requires_permission('read','table name',record_id)
>     to decorate functions that need access control
>     """
>     return dict(form=auth())
>
> So bottom line, how do I get around or use auth_user in my app. If I 
> comment out my 
> db = DAL('sqlite://webform.sqlite') but in default.py, nothing works.
>
> Any help?
>
> Thanks
>
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to