[web2py] Re: Reddit development using web2py

2013-08-30 Thread Martin Barnard
Reddit does not run on web2py. It runs on python and (I think pylons?). 
However, if you do wish to peruse the reddit's source code, you could try 
their github repo:

https://github.com/reddit



On Thursday, August 29, 2013 6:18:30 PM UTC+3, nama...@gmail.com wrote:

 I want to develop replica of Reddit Website 
 http://www.reddit.com/
 using web2py framework.
 Can anyone please provide me with its source code so that i can study the 
 web2py code and understand, it will help me understand the concepts well
 Thanks in advance



-- 

--- 
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.


[web2py] Re: SQLFORM.factory and list:integer error

2013-06-20 Thread Martin Barnard
That code listing is from dal.py. I didn't really want to poke too much at 
that as I haven't had time to examine it too deeply. 

I should probably upgrade to latest web2py before trying anything else :)

*/scurries off to upgrade the server...*

On Thursday, June 20, 2013 12:45:28 AM UTC+3, Niphlod wrote:

 it's a bug reproduceable only if you leave one empty field.
 BTW, you're parsing it wrong given a single field filled with 1234, 
 you get [1,2,3,4] back.

 you should do

 vars = form.vars.employees
 if vars:
 if isinstance(vars, (list, tuple)):
 for a in vars:
 ids.append(a)
 else:
 ids.append(vars)

 Anyway, I'll submit an issue with the fix.


- 









-- 

--- 
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.




[web2py] Re: SQLFORM.factory and list:integer error

2013-06-20 Thread Martin Barnard
Upgraded, but the error is still there. It's failing at the SQLFORM 
validation in dal.py, I don't even get the chance to access session 
variables myself. Also, list:integer fields leave an empty field behind

Is there a way from within the DAL to remove empty entries on list:integer 
(as I can't rely on my users to not create empty entries when using the 
form)?

def index():


form=SQLFORM.factory(
Field('employees', 'list:integer' ),
)
my_emps=[]
if form.process(session=None).accepted:
mvars=form.vars.employees
if mvars:
response.flash=myvars
for a in mvars:
my_emps.append(a)
else:
my_emps.append(mvars)

return dict(form=form, my_emps=my_emps)


Error:


Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File /home/www-data/web2py/applications/experiment/controllers/default.py, 
line 196, in module
  File /home/www-data/web2py/gluon/globals.py, line 194, in lambda
self._caller = lambda f: f()
  File /home/www-data/web2py/applications/experiment/controllers/default.py, 
line 127, in index
if form.process(session=None).accepted:
  File /home/www-data/web2py/gluon/html.py, line 2188, in process
self.validate(**kwargs)
  File /home/www-data/web2py/gluon/html.py, line 2127, in validate
if self.accepts(**kwargs):
  File /home/www-data/web2py/gluon/sqlhtml.py, line 1571, in accepts
self.vars.id = self.table.insert(**fields)
  File /home/www-data/web2py/gluon/dal.py, line 8598, in insert
ret =  self._db._adapter.insert(self, self._listify(fields))
  File /home/www-data/web2py/gluon/dal.py, line 1203, in insert
query = self._insert(table,fields)
  File /home/www-data/web2py/gluon/dal.py, line 1194, in _insert
values = ','.join(self.expand(v, f.type) for f, v in fields)
  File /home/www-data/web2py/gluon/dal.py, line 1194, in genexpr
values = ','.join(self.expand(v, f.type) for f, v in fields)
  File /home/www-data/web2py/gluon/dal.py, line 1376, in expand
return str(self.represent(expression,field_type))
  File /home/www-data/web2py/gluon/dal.py, line 1805, in represent
obj = map(int,obj)
ValueError: invalid literal for int() with base 10: ''







On Thursday, June 20, 2013 2:31:51 PM UTC+3, Martin Barnard wrote:

 That code listing is from dal.py. I didn't really want to poke too much at 
 that as I haven't had time to examine it too deeply. 

 I should probably upgrade to latest web2py before trying anything else :)

 */scurries off to upgrade the server...*

 On Thursday, June 20, 2013 12:45:28 AM UTC+3, Niphlod wrote:

 it's a bug reproduceable only if you leave one empty field.
 BTW, you're parsing it wrong given a single field filled with 1234, 
 you get [1,2,3,4] back.

 you should do

 vars = form.vars.employees
 if vars:
 if isinstance(vars, (list, tuple)):
 for a in vars:
 ids.append(a)
 else:
 ids.append(vars)

 Anyway, I'll submit an issue with the fix.


- 









-- 

--- 
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.




[web2py] SQLFORM.factory and list:integer error

2013-06-19 Thread Martin Barnard
I'm trying to figure out why I get an error with the following code:

def index():
ids=[]
form=SQLFORM.factory(
Field('employees', 'list:integer'),
)
if form.process().accepts:
if form.vars.employees:
for v in form.vars.employees:
ids.append(v)


Generally gives me a typerror: 
type 'exceptions.ValueError' invalid literal for int() with base 10: ''
which is pointing to: web2py/gluon/dal.py, line 1779, in represent


172.16.180.10.2013-06-19.21-09-19.05836ac3-19f9-486a-9cae-a121a7c19593
type 'exceptions.ValueError' invalid literal for int() with base 10: ''
VERSIONweb2py™(2, 4, 2, 'stable', datetime.datetime(2013, 3, 4, 3, 26, 21))
PythonPython 2.7.3: /usr/bin/python (prefix: /usr)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.

Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File /home/www-data/web2py/applications/experiment/controllers/default.py 
https://172.16.180.11/admin/default/edit/experiment/controllers/default.py, 
line 193, in module
  File /home/www-data/web2py/gluon/globals.py, line 193, in lambda
self._caller = lambda f: f()
  File /home/www-data/web2py/applications/experiment/controllers/default.py 
https://172.16.180.11/admin/default/edit/experiment/controllers/default.py, 
line 128, in index
if form.accepts(request.vars):
  File /home/www-data/web2py/gluon/sqlhtml.py, line 1528, in accepts
self.vars.id = self.table.insert(**fields)
  File /home/www-data/web2py/gluon/dal.py, line 8442, in insert
ret =  self._db._adapter.insert(self, self._listify(fields))
  File /home/www-data/web2py/gluon/dal.py, line 1199, in insert
query = self._insert(table,fields)
  File /home/www-data/web2py/gluon/dal.py, line 1190, in _insert
values = ','.join(self.expand(v, f.type) for f, v in fields)
  File /home/www-data/web2py/gluon/dal.py, line 1190, in genexpr
values = ','.join(self.expand(v, f.type) for f, v in fields)
  File /home/www-data/web2py/gluon/dal.py, line 1366, in expand
return str(self.represent(expression,field_type))
  File /home/www-data/web2py/gluon/dal.py, line 1779, in represent
obj = map(int,obj)
ValueError: invalid literal for int() with base 10: ''

ERROR SNAPSHOT [image: help]

type 'exceptions.ValueError'(invalid literal for int() with base 10: '')

inspect attributes
Frames
   
   - 
   
   *File /home/www-data/web2py/gluon/restricted.py in restricted at line 212
   * code arguments variables
   - 
   
   *File 
   /home/www-data/web2py/applications/experiment/controllers/default.py in 
   module at line 193* code arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/globals.py in lambda at line 193* 
   code arguments variables
   - 
   
   *File 
   /home/www-data/web2py/applications/experiment/controllers/default.py in 
   index at line 128* code arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/sqlhtml.py in accepts at line 1528* 
   code arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in insert at line 8442* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in insert at line 1199* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in _insert at line 1190* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in genexpr at line 1190* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in expand at line 1366* code 
   arguments variables
   - 
   
   *File /home/www-data/web2py/gluon/dal.py in represent at line 1779* code 
   arguments variables
   Function argument list
   
   (self=gluon.dal.BaseAdapter object, obj=['4004', ''], 
   fieldtype='list:integer')
   Code listing
   
   1774.
   1775.
   1776.
   1777.
   1778.
   1779.
   
   1780.
   1781.
   1782.
   1783.
   
   elif not isinstance(obj, (list, tuple)):
   obj = [obj]
   if field_is_type('list:string'):
   obj = map(str,obj)
   else:
   obj = map(int,obj)
   
   # we don't want to bar_encode json objects
   if isinstance(obj, (list, tuple)) and (not fieldtype == json):
   obj = bar_encode(obj)
   if obj is None:
   
   Variablesbuiltininttype 'int'obj['4004', '']builtinmapbuilt-in 
   function map
   

-- 

--- 
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.




Re: [web2py] Re: web2canvas looks nice

2013-06-17 Thread Martin Barnard
That would explain my confusion when changing the language didn't change 
the menu :)


On Monday, June 10, 2013 5:06:25 AM UTC+3, Gustavo Souza wrote:

 Hello guys, I'm the one responsible for this project, I intend to make it 
 multi language, is currently only in Portuguese.


 2013/6/8 samuel bonilla pytho...@gmail.com javascript:

 Alan solo me gusta la aplicación, me parece interesante.
 El 09/06/2013 08:32, Alan Etkin spam...@gmail.com javascript: 
 escribió:

  wowww. nice LOL


 Do you like it or it makes you laugh? (or both?) Both is fine, although 
 rare.

  -- 
  
 --- 
 You received this message because you are subscribed to a topic in the 
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/rfyhvXxtGcY/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@googlegroups.com javascript:.

 For more options, visit https://groups.google.com/groups/opt_out.
  
  

  -- 
  
 --- 
 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+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




 -- 
 **
 *
 *
 *Gustavo de Souza Lima*
 gus...@agenciax4.com.br javascript:
 DESENVOLVEDOR

 *(21) 2423-4351* (escritório)
 *(21) 8163-0309* (celular)

 Twitter: @dodilei https://twitter.com/dodilei
 Google+: gplus.to/dodilei

 tech4noobs.agenciax4.com.br/
  

-- 

--- 
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.




Re: [web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Martin Barnard
Tried. Didn't work.


On 8 April 2013 19:57, Derek sp1d...@gmail.com wrote:

 try putting it in [brackets] or quotes.


 On Sunday, April 7, 2013 7:32:03 PM UTC-7, Martin Barnard wrote:

 Continuing on my Oracle adventures, I have found a table which I need to
 access, which has an integer field called '*drop*'.  For *obvious*reasons, 
 it is disallowed. Is there any way to force this field name
 through the DAL (my account is read-only, so I know that I *probably*can't 
 actually drop the table).

 I think that the reserved_sql_keywords is a good thing, but it would be
 nice if we could occasionally 'force' a table or field name for legacy
 database access.

 *Can anybody think of ways of bypassing reserved words checking for
 legacy dbs tablenames?*


 Martin Barnard

  --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/gHOkeBz3_yA/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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.




Re: [web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Martin Barnard
I had already done that. The error generated is in the Field class and is
matching against REGEX_PYTHON_KEYWORDS, here:

  File /home/www-data/web2py/gluon/dal.py, line 9139, in __init__
raise SyntaxError('Field: invalid field name: %s' % fieldname)
SyntaxError: Field: invalid field name: drop


code at line 9139 in dal.py is:
  if not isinstance(fieldname, str) or hasattr(Table,fieldname) or \
fieldname[0] =='_' or REGEX_PYTHON_KEYWORDS.match(fieldname):
raise SyntaxError('Field: invalid field name: %s' % fieldname)


Would there be a simple way of forcing it to not check, at the field level
maybe? It would be beneficial for the field definition to have a
check_reserved flag or even a *force_name=False* by default flag for us
poor souls wrestling with legacy applications. I could bypass this, but
then I'd need to keep doing it every time I update web2py.



Martin


On 8 April 2013 22:48, Massimo Di Pierro massimo.dipie...@gmail.com wrote:

 You can simply set DAL(..., check_reserved=None)

 the problem is, will Oracle accept the SQL generated by DAL? You need to
 try. I do not know.


 On Sunday, 7 April 2013 21:32:03 UTC-5, Martin Barnard wrote:

 Continuing on my Oracle adventures, I have found a table which I need to
 access, which has an integer field called '*drop*'.  For *obvious*reasons, 
 it is disallowed. Is there any way to force this field name
 through the DAL (my account is read-only, so I know that I *probably*can't 
 actually drop the table).

 I think that the reserved_sql_keywords is a good thing, but it would be
 nice if we could occasionally 'force' a table or field name for legacy
 database access.

 *Can anybody think of ways of bypassing reserved words checking for
 legacy dbs tablenames?*


 Martin Barnard

  --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/gHOkeBz3_yA/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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.




Re: [web2py] Re: legacy database with reserved word field name

2013-04-08 Thread Martin Barnard
After tinkering with dal.py  separating out the check, the issue is with *
hasattr*(Table,fieldname). I'm assuming that self.drop exists as part of
the object creation. A possible solution would be to have a legacy flag on
a field so that internally it could map to the right field, but externally
it would have a safe name. Something like this would be good:

Field('drop' ,'integer', alias_name=True, alias='d_value')

Then it could be accessed via *db.table_name.d_value*

Martin

(and yes, I've found at least 5 tables with a drop field so far, sigh.)



On 8 April 2013 23:25, Martin Barnard barnard.mar...@gmail.com wrote:

 I had already done that. The error generated is in the Field class and is
 matching against REGEX_PYTHON_KEYWORDS, here:

   File /home/www-data/web2py/gluon/dal.py, line 9139, in __init__
 raise SyntaxError('Field: invalid field name: %s' % fieldname)
 SyntaxError: Field: invalid field name: drop


 code at line 9139 in dal.py is:
   if not isinstance(fieldname, str) or hasattr(Table,fieldname) or \
 fieldname[0] =='_' or REGEX_PYTHON_KEYWORDS.match(fieldname):
 raise SyntaxError('Field: invalid field name: %s' % fieldname)


 Would there be a simple way of forcing it to not check, at the field level
 maybe? It would be beneficial for the field definition to have a
 check_reserved flag or even a *force_name=False* by default flag for us
 poor souls wrestling with legacy applications. I could bypass this, but
 then I'd need to keep doing it every time I update web2py.



 Martin


 On 8 April 2013 22:48, Massimo Di Pierro massimo.dipie...@gmail.comwrote:

 You can simply set DAL(..., check_reserved=None)

 the problem is, will Oracle accept the SQL generated by DAL? You need to
 try. I do not know.


 On Sunday, 7 April 2013 21:32:03 UTC-5, Martin Barnard wrote:

 Continuing on my Oracle adventures, I have found a table which I need to
 access, which has an integer field called '*drop*'.  For *obvious*reasons, 
 it is disallowed. Is there any way to force this field name
 through the DAL (my account is read-only, so I know that I *probably*can't 
 actually drop the table).

 I think that the reserved_sql_keywords is a good thing, but it would be
 nice if we could occasionally 'force' a table or field name for legacy
 database access.

 *Can anybody think of ways of bypassing reserved words checking for
 legacy dbs tablenames?*


 Martin Barnard

  --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/gHOkeBz3_yA/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 

--- 
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.




[web2py] legacy database with reserved word field name

2013-04-07 Thread Martin Barnard
Continuing on my Oracle adventures, I have found a table which I need to 
access, which has an integer field called '*drop*'.  For *obvious* reasons, 
it is disallowed. Is there any way to force this field name through the DAL 
(my account is read-only, so I know that I *probably* can't actually drop 
the table).

I think that the reserved_sql_keywords is a good thing, but it would be 
nice if we could occasionally 'force' a table or field name for legacy 
database access.

*Can anybody think of ways of bypassing reserved words checking for legacy 
dbs tablenames?* 


Martin Barnard

-- 

--- 
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.




Re: [web2py] Re: another oracle question :(

2013-04-06 Thread Martin Barnard
Good point!
:)

Martin


On 6 April 2013 14:53, Niphlod niph...@gmail.com wrote:

 I'd go for
 *rows=db(
(db.my_table.created_on  date_one) 
(**db.mytable..my_field==my_criteria)
).select(db.mytable.membership)*
 *.

 *if your my criteria is not a function, but a fixed value 

 On Saturday, April 6, 2013 4:27:10 AM UTC+2, Martin Barnard wrote:

 Thanks again for the help - it's invaluable to the oracle noob! :D

 I'm actually building an analysis system so that my boss can view some
 statistical subset of the information based on a few months or weeks. One
 part of the data is stored in *our* MySQL database (which our department
 control), whilst the rest of it is stored in the IT's oracle system. I have
 to pull a bunch of data from the MySQL database (usually with a date-based
 search parameter), then search the oracle system for the rest of the data
 for each return in the MySQL rows (by membership).

 My current solution (for those on similar paths):

 *rows=db(db.my_table.created_on  date_one).select()
 *
 *ml=[]
 *
 *for row in rows:
 *
 *  if row.my_field==my_criteria:
 *
 *ml.append(row.membership)

 *
 *rows=odb(odb.other_table.membership.belongs(ml)).select()*

 Of course, I have to worry about the length of the list that I'm passing,
 as I read that it cannot exceed 1000 items, but this shouldn't be an issue
 in normal use, and I'll wrap it in a test first.
 More efficient methods welcome!!!

 Martin





 On 6 April 2013 01:11, Niphlod nip...@gmail.com wrote:



 On Friday, April 5, 2013 11:58:37 PM UTC+2, Martin Barnard wrote:

  Thanks for the info, Niphlod.

 I will look into the efficiency of the IN clause for my needs, as it
 appears to offer a solution which may mollify the IT  DBA, and his demands
 for bind vars (they are concerned that a looped select will bring the db to
 it's knees).


  a db(whatever.belongs(a_set)) issues ONE query only.

 If you want to force a looping query, you should do explicitely with

 mems = [1,2,3,4,5,6,...]
 for c in mems:
  one_result = db(db.table.field == c).select()
  ..
 of course, for zillions values into mems, it's not a smart move.

 the smartest move with a huge set (i.e. the technique with most of the
 balance) would be paginating through your mems .

 You'd loop a few times but if you have thousands of values into mems,
 a single IN () (or thousands ORs) will take some time 

 Try to draw a limit with your DBA and if he says that you're allowed
 to do an IN() with 500 values at a times, you have it covered ^_^

 On the other end, you have a requirement. fetch a zillions rows.
 either you do it in one shot or in zillions/500 each.

 --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit https://groups.google.com/d/**
 topic/web2py/E2pVWl_71t4/**unsubscribe?hl=enhttps://groups.google.com/d/topic/web2py/E2pVWl_71t4/unsubscribe?hl=en
 .
  To unsubscribe from this group and all its topics, send an email to
 web2py+un...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/E2pVWl_71t4/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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.




[web2py] Re: another oracle question :(

2013-04-05 Thread Martin Barnard
Sorry for the delay.

My DAL code would ideally be something like this:

mems=[135123123,135123154,150012323]
rows=odb(odb.player_master.link_id.belongs(mems)).select()


This works, but I know if I scale up to a large list, as I eventually must, 
it will bring complaints  lockout from our oracle dba. The *lastsql* of 
DAL is like this:

SELECT  player_master.link_id, player_master.last_name, 
player_master.first_name 
FROM logismos.player_master WHERE (player_master.link_id IN (135123123,
135123154))


Browsing oracles 
websitehttp://www.oracle.com/technetwork/articles/dsl/prez-python-queries-101587.html,
 
I came across some info on using cx_oracle with bind queries. They have 
some examples:

 named_params = {'dept_id':50, 'sal':1000}
  query1 = cursor.execute('SELECT * FROM employees WHERE 
 department_id=:dept_id AND salary:sal', named_params)
  query2 = cursor.execute('SELECT * FROM employees WHERE 
 department_id=:dept_id AND salary:sal', dept_id=50, sal=1000) When using 
 named bind variables you can check the currently assigned ones using the 
 bindnames() method of the cursor:


  print cursor.bindnames()
 ['DEPT_ID', 'SAL']
 Passing by position is similar but you need to be careful about naming. 
 Variable names are arbitrary so it's easy to mess up queries this way. In 
 the example below, all three queries r1, r2, and r3 are equivalent. The 
 parameters variable must be given as a sequence.


  r1 = cursor.execute('SELECT * FROM locations WHERE country_id=:1 AND 
 city=:2', ('US', 'Seattle'))
  r2 = cursor.execute('SELECT * FROM locations WHERE country_id=:9 AND 
 city=:4', ('US', 'Seattle'))
  r3 = cursor.execute('SELECT * FROM locations WHERE country_id=:m AND 
 city=:0', ('US', 'Seattle'))
 When binding, you can first prepare the statement and then execute None 
 with changed parameters. Oracle will handle it as in the above case, 
 governed by the rule that one prepare is enough when variables are bound. 
 Any number of executions can be involved for prepared statements.


  cursor.prepare('SELECT * FROM jobs WHERE min_salary:min')
  r = cursor.execute(None, {'min':1000})
  print len(cursor.fetchall())


Any suggestions would be much appreciated.

Martin Barnard.


On Wednesday, April 3, 2013 6:22:28 AM UTC+3, Massimo Di Pierro wrote:

 What does the SQL look like?

 On Tuesday, 2 April 2013 20:44:40 UTC-5, Martin Barnard wrote:

 I have a list of ids [1,2,3,...,n] and I want to run a query on an oracle 
 table (using cx_oracle), but I have to use bind variables. Anybody know the 
 correct format before I start experimentation?

 Will I be forced to use db.executesql?

 Thanks,

 Martin Barnard



-- 

--- 
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.




Re: [web2py] Re: another oracle question :(

2013-04-05 Thread Martin Barnard
Thanks for the info, Niphlod.

I will look into the efficiency of the IN clause for my needs, as it
appears to offer a solution which may mollify the IT  DBA, and his demands
for bind vars (they are concerned that a looped select will bring the db to
it's knees).



Martin Barnard.



On 6 April 2013 00:07, Niphlod niph...@gmail.com wrote:

 I really don't understand.
 The query shipped to your oracle instance will be exactly the same using
 DAL as the one using bind variables.

 The DAL just does binding for you (in the 90% of the cases, better)

 If you want to retrieve from a table all records in one query, and you
 have a large list of key values to filter it with, you can do it only
 with two syntaxes
 either
 select * from table where column in (1,2,3,4,5,6,)

 or
 select * from table
 where
 column = 1
 or
 column = 2
 or
 column = 3
 or
 column = 4



 Now, every database has its own query planning, but as far as I know
 Oracle responds better to the first one than the latter.
 For the sake of completeness,  MSSQL is more fun  MSSQL 2000 to 2005
 without any SP performed better on the first, while 2005 sp2 to 2008 R2
 performs best with the latter ... Postgresql instead has similar times but
 from 8.4 to 9.1 there has been a steep improvement on it, etc etc etc

 Binding with in won't get you where you want to go you have to
 prepare the in list as a pre-quoted string and pass that as a
 parameter, however, as I was saying, there will not be any difference on
 the query shipped to your db instance.

 Same thing goes for the or method .

 For the sake of completeness #2, in web2py should resemble similarly to
 mems = [1,2,3,4,5, ...]
 q = [] # list of conditions
 for c in mems:
 q.append[db.table1.field == c]
 all_queries_in_or = reduce(lambda a,b: (a | b ), q)
 result = db(all_queries_in_or).select()



  --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/E2pVWl_71t4/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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.




Re: [web2py] Re: another oracle question :(

2013-04-05 Thread Martin Barnard
Thanks again for the help - it's invaluable to the oracle noob! :D

I'm actually building an analysis system so that my boss can view some
statistical subset of the information based on a few months or weeks. One
part of the data is stored in *our* MySQL database (which our department
control), whilst the rest of it is stored in the IT's oracle system. I have
to pull a bunch of data from the MySQL database (usually with a date-based
search parameter), then search the oracle system for the rest of the data
for each return in the MySQL rows (by membership).

My current solution (for those on similar paths):

*rows=db(db.my_table.created_on  date_one).select()
*
*ml=[]
*
*for row in rows:
*
*  if row.my_field==my_criteria:
*
*ml.append(row.membership)

*
*rows=odb(odb.other_table.membership.belongs(ml)).select()*

Of course, I have to worry about the length of the list that I'm passing,
as I read that it cannot exceed 1000 items, but this shouldn't be an issue
in normal use, and I'll wrap it in a test first.
More efficient methods welcome!!!

Martin





On 6 April 2013 01:11, Niphlod niph...@gmail.com wrote:



 On Friday, April 5, 2013 11:58:37 PM UTC+2, Martin Barnard wrote:

 Thanks for the info, Niphlod.

 I will look into the efficiency of the IN clause for my needs, as it
 appears to offer a solution which may mollify the IT  DBA, and his demands
 for bind vars (they are concerned that a looped select will bring the db to
 it's knees).


  a db(whatever.belongs(a_set)) issues ONE query only.

 If you want to force a looping query, you should do explicitely with

 mems = [1,2,3,4,5,6,...]
 for c in mems:
  one_result = db(db.table.field == c).select()
  ..
 of course, for zillions values into mems, it's not a smart move.

 the smartest move with a huge set (i.e. the technique with most of the
 balance) would be paginating through your mems .

 You'd loop a few times but if you have thousands of values into mems, a
 single IN () (or thousands ORs) will take some time 

 Try to draw a limit with your DBA and if he says that you're allowed
 to do an IN() with 500 values at a times, you have it covered ^_^

 On the other end, you have a requirement. fetch a zillions rows.
 either you do it in one shot or in zillions/500 each.

 --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/E2pVWl_71t4/unsubscribe?hl=en.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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.




[web2py] Re: retrieving blobs from legacy (oracle) database

2013-04-02 Thread Martin Barnard
I forgot to mention I have to use the MyDAL version as I have to connect to 
different oracle schemas. Not fun! For anybody in a similar situation, this 
was my solution

In the Model

odb=MyDAL(my_connection_string, migrate=False, fake_migrate_all=True)
odb.define_table('player_photo',[
Field('link_id', 'integer'),
Field('photo', type=SQLCustomType(type='string', native='blob')),
primarykey=['link_id'],
table_class=MyTable, # from MyDAL
migrate=True, fake_migrate=True, 
 )


 
*As I only have read-only access to the data, and I am under strict 
instructions to not load the oracle server, my strategy is to check local 
storage first, to see if we have a local copy of the image, which isn't too 
old, which means that I only hit the oracle db when I have either an old 
(2 months) image, or no image at all.*

*Controller:*

def player_image():
 import os, 
 from datetime import datetime
 rows=None
 img_url=None
 mem=int(request.args(0))
 if mem:
loc=os.path.join(request.folder, 'static','player_images', '%d.jpg' % mem) # 
dump spot for images
img_url='/our_app/static/player_images/%d.jpg' % mem
if os.path.exists(loc):
ct=os.path.getctime(loc)
if datetime.fromtimestamp(ct)  request.now - timedelta(days=60):
rows=odb(odb.player_photo.link_id==mem).select(limitby=(0,1))
if rows:
img=rows[0].photo.read()
f=open(loc,'wb')
f.write(img)
f.close()
  return dict(img_url=img_url)


*The View*

{{=IMG(_src=img_url, _width='90px')}}




I also had to slightly tweak the MyDAL oracle adapter class by importing 
SQLCustomType: 
changed *from gluon.dal import DAL, MySQLAdapter, OracleAdapter, 
PostgreSQLAdapter, Expression, Table, Field, Query* to *from gluon.dal 
import DAL, MySQLAdapter, OracleAdapter, PostgreSQLAdapter, Expression, 
Table, Field, SQLCustomType*

Thanks for the help, guys!

Martin

On Monday, April 1, 2013 2:26:23 AM UTC+3, Massimo Di Pierro wrote:

 This should do it:

 Field('photo',type=SQLCustomType(type ='string', native ='blob'))




 On Friday, 29 March 2013 21:26:32 UTC-5, Martin Barnard wrote:

 Hi, I have read-only access to a legacy oracle database which is storing 
 image files as blobs.

 I cannot modify the model to include a 'filename' field, or alter the 
 table in any way. How can I display returned images as a stream?

 I.e. model looks like this:
 odb.define_table('player_photo',
 Field('link_id','integer'),
 Field('photo','blob')
 )


 So, without a filename field, I cannot figure out how to stream the photo 
 to the server.

 Any suggestions would be greatly appreciated.

 Thanking you in advance.

 Martin



-- 

--- 
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.




[web2py] another oracle question :(

2013-04-02 Thread Martin Barnard
I have a list of ids [1,2,3,...,n] and I want to run a query on an oracle 
table (using cx_oracle), but I have to use bind variables. Anybody know the 
correct format before I start experimentation?

Will I be forced to use db.executesql?

Thanks,

Martin Barnard

-- 

--- 
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.




[web2py] retrieving blobs from legacy (oracle) database

2013-03-29 Thread Martin Barnard
Hi, I have read-only access to a legacy oracle database which is storing 
image files as blobs.

I cannot modify the model to include a 'filename' field, or alter the table 
in any way. How can I display returned images as a stream?

I.e. model looks like this:
odb.define_table('player_photo',
Field('link_id','integer'),
Field('photo','blob')
)


So, without a filename field, I cannot figure out how to stream the photo 
to the server.

Any suggestions would be greatly appreciated.

Thanking you in advance.

Martin

-- 

--- 
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.




[web2py] Re: SQLFORM list with indirect labels

2012-06-03 Thread Martin Barnard
You know, this should be in the book. 
Herehttp://web2py.com/books/default/chapter/29/6#Record-representationon the 
section regarding record representation would be a good point. 

Martin


On Saturday, 2 June 2012 21:14:56 UTC+3, Anthony wrote:

 db.define_table('customers_job',
 Field('city', db.cities),
 Field('description', 'text'),
 Field('customer', db.customer),
 format=%(customer)s - %(city)s
 )


 The format argument to define_table() is not recursive -- the customer 
 value in the format argument above will simply be the value of the 
 customer field, which is an integer id referring to the db.customer 
 table. The db.customer table has its own format argument, but that format 
 is not used in constructing the formats of any referring tables. Instead of 
 providing a string format, as above, you can use a callable (e.g., lambda) 
 format to achieve what you want:

 db.define_table('customers_job',
 Field('city', db.cities),
 Field('description', 'text'),
 Field('customer', db.customer),
 format=lambda r: '%s - %s' % (db.customer[r.customer].customer,
   db.cities[r.city].city)
 )

 That will take the id values of the record from the city and customer 
 fields and use them to query the db.customer and db.cities tables, 
 respectively, to obtain the customer and city names.

 Anthony



[web2py] SQLFORM list with indirect labels

2012-06-02 Thread Martin Barnard
I have some linked tables like so:

db.define_table('cities',
Field('city', 'string'),
format=%(city)s
)
db.define_table('customers',
Field('customer', 'string'),
Field('contact_name', 'string'),
format=%(customer)s
)
db.define_table('customers_job',
Field('city', db.cities),
Field('description', 'text'),
Field('customer', db.customer),
format=%(customer)s - %(city)s
)
db.define_table('emp_hours',
Field('employee', db.employee),
Field('job', db.customers_jobs),
Field('work_date', 'date', default=request.now.date(), ),
Field('number_of_hours', 'integer', default=10),
)

My question is, when designing a CRUD/SQLFORM/whatever for the emp_hours 
table, I would like the *db.emp_hours.job *field widget to display the 
following in a drop-down:
   
   - db.customers.customer 
   - db.cities.city, 
   - and the first 20 chars of db.customers_jobs.description
   - (e.g. format=%(customer)s - %(city)s (%(description[:20])s))
   

Is there any way that I can do this? I have tried constructing widgets  
validators, etc. But because the emp_hours.job is linking to the 
customers_jobs and not the customers, it only displays the customers_jobs.id
.

Thanks in advance!


Re: [web2py] Re: SQLFORM list with indirect labels

2012-06-02 Thread Martin Barnard
Much thanks. I've been struggling with various sub-par implementations of
this for a while. I wondered how you could get a recursive represent.

M.

On 2 June 2012 21:14, Anthony abasta...@gmail.com wrote:

 db.define_table('customers_**job',
 Field('city', db.cities),
 Field('description', 'text'),
 Field('customer', db.customer),
 format=%(customer)s - %(city)s
 )


 The format argument to define_table() is not recursive -- the customer
 value in the format argument above will simply be the value of the
 customer field, which is an integer id referring to the db.customer
 table. The db.customer table has its own format argument, but that format
 is not used in constructing the formats of any referring tables. Instead of
 providing a string format, as above, you can use a callable (e.g., lambda)
 format to achieve what you want:

 db.define_table('customers_job',
 Field('city', db.cities),
 Field('description', 'text'),
 Field('customer', db.customer),

 format=lambda r: '%s - %s' % (db.customer[r.customer].customer,
   db.cities[r.city].city)
 )

 That will take the id values of the record from the city and customer
 fields and use them to query the db.customer and db.cities tables,
 respectively, to obtain the customer and city names.

 Anthony



[web2py] threaded comments system

2012-04-14 Thread Martin Barnard
I'm trying to create a threaded comments system for part of a work log. I 
would like it to have dynamically generated forms, which, once posted, 
update the contents of the containing DIV() with the comment and removes 
the form. This way I don't have 100's of form objects cluttering up a 
system, especially for a threaded comments system.

*Attempt at an explanation*

   1. Threaded comments view displays all comments  indents them 
   accordingly.
   2. Each comment has a 'reply' button, which calls the *ac_f* action and 
   points it to a target DIV. 
   3. ac_f builds a form with a submit action, ac(), which submits the data 
   and returns a DIV object containing the nicely-formatted content.
   4. DIV() object is displayed in the original DIV which the FORM object 
   was in.
   
*link to controller functions:*
http://pastie.textmate.org/3784855

comment is called in the view thusly: *
*
*{{=A('comment', callback=URL('supervisors', 'ac_f', 
vars={'event_id':row.id}), target=comment_form_div_%d % row.id, 
_class=button_class)}}*

My issue with step 4, in that the FORM submission calls a separate action 
which returns a DIV object which *should * display the nicely formatted, 
comment, along with any new reply urls, etc. inside the DIV object. 
However, upon form submission, it reloads the entire page. Is there any way 
to actually keep it inside the DIV object?


Re: [web2py] Madeira Cloud

2012-04-08 Thread Martin Barnard
And a very nice island it is too. Nice levadas, if a little steep :)

On Sunday, 8 April 2012 11:58:52 UTC+3, Ramos wrote:

 Madeira is the name of an Island in Portugal
 :)

 2012/4/8 Massimo Di Pierro massimo.dipie...@gmail.com

 http://www.madeiracloud.com/




[web2py] multiselect widget not working in component.

2011-07-17 Thread Martin Barnard


I'm having problems displaying the multiselect widget inside components. I have 
two actions which do the same thing, basically give us a list of tags, with 
which to select our multiple tags:

### Model

staff_tags=['this', 'is', 'a', 'tag']

db.define_table('test_tagging',
Field('tags', 'list:string', requires=IS_IN_SET(staff_tags, multiple=True)),
Field('time_reference', 'time'),
)

### Controller

def index():

form=crud.create(db.test_tagging) 

return dict( form=form) 

def test():

form=crud.create(db.test_tagging)

return dict(form=form)

### View

{{extend 'layout.html'}}
h1Did You Know?/h1
pthat when you load a component (like below), you lose the jquery.multiselect 
formattingbr /
Check the 'tags' field for an illustration of what I mean.../p
{{=LOAD('incident_reports/test.load', ajax=True)}}
hr width=70%
h2This, however, is a form NOT in a LOAD() function/h2
pAs you can see, we get a nice multiselect option here/p
{{if form:}}
{{=form}}
{{pass}}

However, when you display the form, it looks like this: 

https://lh5.googleusercontent.com/-JMTTedPrNcI/TiOYuZ8MBqI/BJk/0N2i81A07RM/screenie.jpg

As you can see, the lower multi-select is working as expected, however the 
LOAD-ed component version is stripped of all niceness.

Any suggestions?



Re: [web2py] Re: Query construction question

2011-07-06 Thread Martin Barnard
No. There is a good chance that the person who uploaded the memo
(db.memo_store.created_by) is not the same as the person viewing the memo
(db.viewed_memos.created_by).
My solution, for people who are interested in something similar:

def unread_memos():

Will return a list of all unread memos

# We want to count the # of memos which we haven't looked at
read_memos=db(db.viewed_memos.created_by==auth.user_id).select(
db.viewed_memos.memo, groupby=db.viewed_memos.memo)
mul=[] # Our read memos list
if len(read_memos)  0:
for row in read_memos:
mul.append(row.memo)
unread=db(~db.memo_store.id.belongs(mul)).select(db.memo_store.ALL,

orderby=~db.memo_store.created_on)
else:
unread=db(db.memo_store).select(db.memo_store.ALL,
orderby=~db.memo_store.created_on)

return dict(unread_rows=unread)


On 6 July 2011 08:14, pbreit pbreitenb...@gmail.com wrote:

 I don't totally understand but would this do it?

 db(db.memo_store.created_by==auth.user.id)(db.viewed_memos.memo==
 db.memo_store.id).select()



[web2py] Query construction question

2011-07-05 Thread Martin Barnard
I have the following models. I am storing memos in table *memo_store*, and 
user_views in *viewed_memos*. Each user can have multiple views for each 
memo. Every time they look at a memo, I store a new entry in* viewed_memos*.

My question is: *How can I construct a query which will display all unread 
memos from a particular user?*
I was hoping to do it in a single-step query, however, I am struggling.

*Table Definitions:*
db.define_table ('memo_store',
Field ('created_by', db.auth_user, default = auth.user_id, readable = 
False, writable = False),
Field ('created_on', 'datetime', default = request.now, writable = 
False, readable = False),
Field ('memo', 'upload', uploadfolder = os.path.join (request.folder, 
'memo_uploads'),
  ondelete = 'NO ACTION', uploadseparate = True,),
Field ('file_name', 'string', readable = False, writable = False),
Field ('author', 'string'),
Field ('department', 'string', requires = IS_IN_SET (department_list)),
Field ('memo_title', 'string'),
Field ('memo_note', 'text'),
Field ('tags', 'list: string'),
)
db.define_table ('viewed_memos',
Field ('created_by', db.auth_user, default = auth.user_id, readable = 
False, writable = False),
Field ('created_on', 'datetime', default = request.now, writable = 
False, readable = False),
Field ('memo', db.memo_store),
Field ('my_tags', 'list: string'),
)





Re: [web2py] Re: Need help in standardizing my coding and naming schemes before I start my main project

2011-02-01 Thread Martin Barnard
General request for comments  corrections from the more experienced (than
me) programmers in this group please. I really don't want to be giving bad
advice. Anyway, on to the advice...

Rupesh,

In the end, it doesn't matter what scheme you use, as long as you find it
easy  your practices are consistent. If you are working on shared code
(i.e. working with somebody else), then you should both agree on a set of
coding practices.
If you are working on multiple applications within the same database, then
it makes sense to prefix application-specific tables with something which
easily describes it (in case you have to examine the back-end database, or
have to make cross-application queries).

That being said, I suggest that at the very least, you take a look at Python
PEP http://www.python.org/dev/peps/pep-0008/ guidelines, in order to
standardise your coding practice.

As far as database naming goes, if you are building applications from
scratch, try to ensure that you have memorable names (or ones which are
logical  easy to recreate). If there is the possibility of more than one
app being stored in your database backend, and the possibility exists for
table name collisions (tables called 'name' or 'address' are very common).
It is, in my opinion, good practice to prefix your application-specific
tables with something to separate them from the other applications tables.
Let's call your app *Contacts List.* We now have a nice, 2-prefix addition
to our table names: CL

# Storing our address types in a list as opposed to
# devoting a full table to them:
address_types=['permanent', 'temporary', 'postal', 'additional']
db.define_table('cl_contact',
  Field('name'),
)
db.define_table('cl_address',
  Field('contact', db.cl_contact),
  Field('address_type', 'string', requires=IS_IN_LIST(address_types))
  Field('
)

For small values of the list (i.e. less than a dozen items, which are
unlikely to change), you may as well store them in a list (as above) and let
web2py deal with the lookup. If you need a lookup table, then prefix it with
whatever is easy enough to remember. The important part (*and trust me on
this* :) is consistency.

At the end of the day, as long as your methodology is consistent, logical
and easy to follow, then just go with whatever's easiest for you.

Martin.


On 31 January 2011 21:58, Rupesh Pradhan rupeshkrprad...@gmail.com wrote:

 I am trying to standardize my naming schemes for my database, table and
 fields. I am trying to follow the one given below. Please share with me your
 scheme.

 Standard Database Table Naming Scheme
 =
 Table name:
 ---
 small caps with underscore
 look-up table prefixed with 'lu_'
 link table prefixed with 'lk_' (should i do this?)




 eg.
 contact
 lu_address_type


 Field names:
 
 small caps with under score
 primary key suffixed with '_id'

 eg.
 name
 address_text
 contact_id

 Table Field access notation:
 ---
 table name DOT field name

 eg.
 contact.name
 contact.contact_id
 lu_address_type.name
 lu_address_type.address_type




Re: [web2py] Re: Need help in standardizing my coding and naming schemes before I start my main project

2011-02-01 Thread Martin Barnard
I'd be cautious about some of those field names. I'm not about to look them
up, but they look suspiciously like they may collide with reserved words.
I'm looking particularly hard at 'type' and 'text'. You may want to check
that.

Martin.

I don't mind typing the extra characters now that work bought me one of
these http://www.kinesis-ergo.com/advantage_pro.htm :)



On 1 February 2011 23:08, howesc how...@umich.edu wrote:

 i try to use pythonic naming conventions in my database.

 i prefer:
 db.define_table('address_type',
 Field('name'))

 db.define_table('contact',
 Field('name'))

 db.define_table('address',
 Field('contact', db.contact),
 Field('type', db.address_type),
 Field('text'))

 but perhaps mainly because i don't like to type all those extra characters.
 :)



[web2py] Fix for kpaxcms

2011-01-27 Thread Martin Barnard
Hi. 
I've been lurking here whilst trying out web2py (thanks for the software, 
Massimo!). I'm looking at building something similar to kpax, with a few 
modified tweaks. However, when I tried to change group permissions, I'd get 
this error. It's in access.py controller, change function:

Error Traceback (pastie.org) http://pastie.org/1503100

A little bit of poking, found an apparent solution from somebody, which was to 
call the first object in the list, as opposed to the variable directly. 
This didn't work for me (for some reason), so I have provided another fix, 
which appears to work.
I don't know where or how I can submit this as a patch, so I thought the group 
could have it.
The most interesting lines are the last few. I basically take the first segment 
of the *request.vars.forward* variable, split it  remove leading space (which 
for some reason is there), then call redirect with the URL decorator.

I hope it's of some use to somebody...
Martin

if not session.token: redirect(LOGIN)

def change():
if len(request.args)2: redirect(MAIN)
table_name=request.args[0]
record_id=request.args[1]
if not is_owner(user_id,table_name,record_id):
session.flash=not authorized
redirect(MAIN)
access_types=db[table_name].access_types
rows=db(db.access.table_name==table_name)\
   (db.access.record_id==record_id)\
   (db.access.users_group==db.users_group.id)\
   .select(orderby=db.access.id)
group_keys=dict([(r.users_group.id,r.access.access_type) for r in rows])
keys=dict([(r.access.id,r.access.access_type) for r in rows])
accesses=[]
for g in session.groups:
if table_name=='users_group' and g.id==int(record_id): continue
item=Storage()
item.group_id=g.id
item.group_name=g.name
item.membership_type=g.membership_type
if group_keys.has_key(g.id): item.access_type=group_keys[g.id] 
else: item.access_type='none'
accesses.append(item)
ch=False
for key,value in request.vars.items():
if key=='forward': continue
ch=True
g=int(key[1:])
if g==g_tuple[1]: continue
if g==g_tuple[0] and user_id!=1: continue
if group_keys.has_key(g):
s=db(db.access.users_group==g)\
(db.access.record_id==record_id)\
(db.access.table_name==table_name)
if value=='none': 
s.delete()
elif value in access_types: 
s.update(access_type=value)
elif value!='none' and value in access_types:
db.access.insert(users_group=g,
 table_name=table_name,
 record_id=record_id,
 access_type=value)
if ch:
uuu=request.vars.forward[0].split('/')[1:]
if len(uuu) ==3:
redirect(URL(uuu[0],uuu[1],uuu[2]))
elif len(uuu) ==2:
redirect(URL(uuu[0],uuu[1]))

else:
st=request.vars.forward
raise HTTP(500, cannot redirect!br%sbr%d%(uuu, len(uuu)))
return dict(accesses=accesses,access_types=access_types)