[web2py] Web2py CAS auth.username does not exist. Multiple application with one CAS provider.

2013-04-05 Thread joe smith

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 

[web2py] Web2py CAS auth.username does not exist. Multiple applications, one CAS provider.

2013-04-05 Thread joe smith
I am writing a number of Web2py applications. The base CAS application is 
an administration system to keep track of users, organizations, groups, 
etc. That part is working fine, but now I want to add additional 
applications that use this administration system as a CAS provider. I have 
been trying to get things to work properly for a week or so without having 
a nice solution. I am using a single Postgres database and trying to use 
the CAS to authenticate. It seems that when I try to use the CAS provider 
from one of the applications I get an 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')

Can anyone tell me the correct way of integrating multiple applications to 
use a single CAS provider. I have been through all the forum posts and book 
examples. I am always getting table conflicts. In this case it is looking 
for auth.username. But in all applications including this one I have 
auth.define_tables(username=False), but it still looks for it.

Here is my db.py file for cas_provider:


# -*- 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 = 

[web2py] Re: Web2py CAS auth.username does not exist. Multiple applications, one CAS provider.

2013-04-05 Thread joe smith
Ok thank you for your help. Does that mean I have to allow usernames for 
login for CAS to work? All of our users now use email addresses. I can get 
around the issue by manually creating a auth_user.username column in 
Postgres, but a cleaner fix would be as Anthony posted somewhere else: 
auth.settings.login_userfield 
= 'email'? This would allow a username so that the tables are created, but 
not used unless I expose that field?



On Friday, 5 April 2013 14:37:04 UTC-7, Massimo Di Pierro wrote:

 If you use CAS you must change:

 auth = Auth(db)

 into

 auth = Auth(db, username=True)


 CAS requires a username.

 On Friday, 5 April 2013 11:26:50 UTC-5, joe smith wrote:

 I am writing a number of Web2py applications. The base CAS application is 
 an administration system to keep track of users, organizations, groups, 
 etc. That part is working fine, but now I want to add additional 
 applications that use this administration system as a CAS provider. I have 
 been trying to get things to work properly for a week or so without having 
 a nice solution. I am using a single Postgres database and trying to use 
 the CAS to authenticate. It seems that when I try to use the CAS provider 
 from one of the applications I get an 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')

 Can anyone tell me the correct way of integrating multiple applications 
 to use a single CAS provider. I have been through all the forum posts and 
 book examples. I am always getting table conflicts. In this case it is 
 looking for auth.username. But in all applications including this one I 
 have auth.define_tables(username=False), but it still looks

[web2py] smartgrid button placement 'left' 'right', 'both'

2012-12-21 Thread joe smith
I am trying to set the button placement of the View, Edit, Delete 
buttons in the smartgrid table to be 'left'. I am using: button_placement = 
'left' in my controller when I set a smartgrid. It works in web2py 2.3.2 on 
my local machine, but won't work in 2.2.1 on our server. Is that setting 
not compatible with 2.2.1? If not, how can I do it in that version?

--