[web2py] Re: Query with postgres

2012-10-17 Thread Paolo
Hi Cliff,
I got the reasons of postgres, but I don't know how to fix it. The query is 
actually very simple, I have several post, I want to group them by s, and 
get the number of post for each s. Where s is:
s=db.club.created_on.year() | db.club.created_on.month() | 
db.club.created_on.day() 
In the select I may created_on and use s instead, something like that:
dates = db(query).select(s,count,orderby=~s, limitby=limitby, groupby=s)

but doing that I got this error:
2012-10-17 08:27:59,210 - web2py - ERROR - Traceback (most recent call 
last):
  File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 209, in 
restricted
exec ccode in environment
  File 
/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
line 140, in module
  File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 184, in 
lambda
self._caller = lambda f: f()
  File 
/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
line 3, in index
d= dict(clubs = get_clubs())
  File 
/home/paolo/Dropbox/git/web2py/applications/bikend/models/clubDB.py, line 
25, in get_clubs
dates = db(query).select(s,count,orderby=~s, limitby=limitby, groupby=s)
  File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8787, in select
return adapter.select(self.query,fields,attributes)
  File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 2127, in select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1615, in select
return self._select_aux(sql,fields,attributes)
  File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1596, in 
_select_aux
return processor(rows,fields,self._colnames,cacheable=cacheable)
  File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1974, in parse
fields[j].type,blob_decode)
IndexError: list index out of range

Paolo

On Wednesday, October 17, 2012 4:45:35 AM UTC+2, Cliff Kachinske wrote:

 I don't know how it possibly worked in sqlite, but this is an aggregate 
 query combined with a non-aggregate query.

 In other words, the count is a property of an aggregation of rows in the 
 database, whereas created_on is a property of individual rows.

 This confuses Postgres.  It doesn't know if you want the aggregate result 
 (count) or the result for individual rows (created_on).  It cannot deliver 
 both from the same query.

 What are you trying to find out in your query?



 On Tuesday, October 16, 2012 4:59:36 PM UTC-4, Paolo wrote:

 Dear all, 
 I've just switched from sqlite to postgres, and now I have problems with 
 few queries.
 One query that works correctly on sqlite and fails on postgres is the 
 following:
 s=db.club.created_on.year() | db.club.created_on.month() | 
 db.club.created_on.day() 
 count = db.club.id.count()
 dates = 
 db(query).select(db.club.created_on,count,orderby=~db.club.created_on, 
 limitby=limitby, groupby=s)

 Now on postgres, it raises the following error:
 ProgrammingError: column club.created_on must appear in the GROUP BY 
 clause or be used in an aggregate function
 LINE 1: SELECT  club.created_on, COUNT(club.id) FROM club WHERE (((c...

 I read online that the fields in the select must be on the groupby as 
 well. The problem is that by grouping even by club.created_on (by adding 
 groupby=s | club.created_on)  the result is totally different. What can I 
 do to tackle this problem?

 Best,
 Paolo



-- 





[web2py] Re: lock table possible?

2012-10-17 Thread vince
well, i think i did some test before and update from other connect was 
allowed in between the query and update. i will test it again with a 
time.sleep in between.

On Wednesday, October 17, 2012 3:19:42 AM UTC+8, Niphlod wrote:

 Disclaimer: I may be wrong
 Reading your example code, you are updating a single record. 
 If done in a single request, web2py wraps all commands in a transaction. 
 In your code, that means that when you want to remove from photolist an 
 item of your publication row, that operation is atomic. Why are you 
 requesting that no other publication can be updated on that single request ?

 On Tuesday, October 16, 2012 9:06:08 PM UTC+2, vince wrote:

 forget it. it's weird that read lock for mysql is read only, i have to 
 obtain write lock. it seems not possible to block write access only.

  

 On Wednesday, October 17, 2012 2:55:49 AM UTC+8, vince wrote:

 i tried to lock table but with error
 class 'gluon.contrib.pymysql.err.InternalError' (1099, uTable 
 'publication' was locked with a READ lock and can't be updated)

db.executesql('LOCK TABLE publication READ;')
result = db(db.publication.id==pubid).select()[0]
newlist = result.photo_list
newlist.remove(int(pid))
db(db.publication.id==pubid).update(photo_list=newlist)
db.executesql('UNLOCK TABLES;')

 is it possible to use the same connection?

 On Thursday, October 11, 2012 9:32:14 PM UTC+8, Massimo Di Pierro wrote:

 You can try:

 db.executesql('LOCK TABLE tablename READ;') 


 http://aarklondatabasetrivia.blogspot.com/2009/04/how-to-lock-and-unlock-tables-in-mysql.html


 On Thursday, 11 October 2012 01:44:14 UTC-5, vince wrote:

 can i lock a table as readonly during the transaction? the case is i 
 need to insert a record to table B which is base on the query result of 
 table A, i would like to lock table A as readonly until i finish the 
 insert.

 i am using mysql at the moment. i know web2py may not have this 
 feature, what is the best way to use mysql's 'lock table' on web2py?

 thanks in advance,
 vince



-- 





[web2py] Re: Odd behavior with domain routes. Can't undo them.

2012-10-17 Thread Anthony
Yes, if you change routes.py, you must either reload routes (which you can 
do from the admin interface) or restart the webserver.

Anthony

On Wednesday, October 17, 2012 12:09:51 AM UTC-4, HittingSmoke wrote:

 I set up my Webfaction hosting with a single web2py install that I intend 
 to use for a couple of subdomains pointing to separate apps using routes.py.

 I pointed domain.com and blog.domain.com to my web2py app and through 
 routes.py told web2py to point blog.domain.com to my blog app that I plan 
 on writing. Right now it's just a default scaffolding app. Here is the code 
 in my routes.py file:

 routers = dict(
 BASE = dict(
 domains = {
 'blog.domain.com' : 'blog',
 }
 )
 )

 So... this worked great, until I tried to undo it for some troubleshooting 
 purposes. I commented out all the code in routes.py. blog.domain.comstill 
 points to my blog app instead of my default web2py app (currently 
 Welcome). I renamed routes.py, blog.domain.com still points to the blog 
 app.

 I thought maybe this was some new default behavior where if a subdomain is 
 used with the same name as an app it will point to the app. I made a new 
 app and a subdomain of the same name and pointed it to my web2py app. This 
 one points to the default Welcome app as expected.

 So what is the deal here? Is there some cache of routes.py that I need to 
 clear to return a domain route back to default?


-- 





[web2py] Re: IS_STRONG and CRYPT

2012-10-17 Thread piero crisci
Sorry but i never opened a ticket before. Do you mean open a ticket in 
google groups or there is a Ticket Request System dedicated for the 
request?.
Thank again Richard and Massimo for the support.


Il giorno mercoledì 17 ottobre 2012 00:20:54 UTC+2, Massimo Di Pierro ha 
scritto:

 Can you please open a ticket about this?

 On Friday, 12 October 2012 10:04:35 UTC-5, piero crisci wrote:

 I tryed to find others with the same iusse problem without understand how 
 to solve the problems :(

 I set in the db.py the follow table

 
 db.define_table('auth_user',
 Field('username', type='string',
   label=T('Username')),
 Field('first_name', type='string',
   label=T('First Name')),
 Field('last_name', type='string',
   label=T('Last Name')),
 Field('email', type='string',
   label=T('Email')),
 Field('password', type='password',length=512,
   readable=False,
   label=T('Password')),
 Field('created_on','datetime',default=request.now,
   label=T('Created On'),writable=False,readable=False),
 Field('modified_on','datetime',default=request.now,
   label=T('Modified On'),writable=False,readable=False,
   update=request.now),
 Field('registration_key',default='',
   writable=False,readable=False),
 Field('reset_password_key',default='',
   writable=False,readable=False),
 Field('registration_id',default='',
   writable=False,readable=False),
 format='%(username)s',
 migrate=settings.migrate)


 db.auth_user.first_name.requires = 
 IS_NOT_EMPTY(error_message=auth.messages.is_empty)
 db.auth_user.last_name.requires = 
 IS_NOT_EMPTY(error_message=auth.messages.is_empty)
 #db.auth_user.password.requires = [ IS_STRONG(min=8, 
 number=1,special=1,error_message = La password deve contenere almeno 8 
 Caratteri, un Numero, un Carattere Speciale, un carattere Maiuscolo), 
 CRYPT(key=auth.settings.hmac_key)]
 db.auth_user.password.requires= [*IS_STRONG(min=8), 
 CRYPT(auth.settings.hmac_key)*]

 db.auth_user.username.requires = IS_NOT_IN_DB(db, db.auth_user.username, 
 error_message = 'Username già censita')
 db.auth_user.email.requires = 
 (IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, 
 db.auth_user.email,error_message = 'Email già censita'))
 auth.define_tables(migrate = settings.migrate)

 I set in the default.py this def for manage the user changes .

 @auth.requires_login()
 @auth.requires_membership('risorse_umane' or 'admin')
 def anagrafica_utenti_db_manage():
 form = SQLFORM.smartgrid(db.auth_user,onupdate=auth.archive)
 return locals()

 When i try to modify the name or the surname the framework rise the 
 IS_STRONG control even if i don't touch the password string.
 I am new with web2py and i want just to know if i need to create a form 
 to make the user changes or i can fix this problem using the smartgrid.
 I also set the Requires approval for the new registration. How can i 
 delete the Pending in the registration key ? (I can t do it right now 
 because of the IS_STRONG control.
 Thanks for help
 And sorry for bother you



-- 





[web2py] Web2py 2.1.1 csv import bug or ?

2012-10-17 Thread martzi
Hello all,

I have being trying to import a csv data to a DAL database and this is what 
i get:

Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Traceback (most recent call last):
  File /home/xxx/Documents/web2py211/gluon/restricted.py, line 209, in 
restricted
exec ccode in environment
  File /home/xxxDocuments/web2py211/applications/appx/controllers/appadmin.py 
http://127.0.0.1:8000/admin/default/edit/Ggrouplayout/controllers/appadmin.py,
 line 447, in module
  File /home/xxx/Documents/web2py211/gluon/globals.py, line 187, in lambda
self._caller = lambda f: f()
  File 
/home/xxx/Documents/web2py211/applications/appx/controllers/appadmin.py 
http://127.0.0.1:8000/admin/default/edit/Ggrouplayout/controllers/appadmin.py,
 line 255, in select
tb = tb,
UnboundLocalError: local variable 'tb' referenced before assignment

...
 Has anyone come across similar problem ?

-- 





[web2py] link to sqlform.factory

2012-10-17 Thread andrej burja
hi

i have one page with links (in view1)

{{=A(tag.f_name,_href=URL('games_with_tags_show',vars=dict(tags=tag.f_name
)))}}

and i have search form (in function2/view2):

form = SQLFORM.factory(
Field('tags_ava','list:string',label=T('Tags'), 
requires = IS_EMPTY_OR(IS_IN_SET(tags_ava_set)),
widget=SQLFORM.widgets.options.widget),
formstyle='divs',
submit_button ='Search' 
   
)
reset = INPUT(_type='button',_id=reset_all,_value=T('Reset'))
form.append(reset)

if form.process().accepted:

i would with click on the link in view 2:
- open view2
- fill the field 'tags_ava' with URL arguments
- click the button in view2
and i would like also to use the function2/view2 alone (without comming 
there from view1)

is this possible?

andrej


-- 





[web2py] Re: URL requests always aiming to default controller...

2012-10-17 Thread apinho
I'm using 
Version 1.99.7 (2012-03-04 22:12:08) stable
If I try, from the example app :
https://myserver/examples/session-examples/counter



I get :
Invalid request

This is weird.

Meanwhile, as you told me that declaring a default_application on models.py 
was ineffective, I removed  default_application='myapp'  from my 
models.py, and i changed this in routes.py :
routers = dict( BASE = dict( default_application = 'myapp', ), )

But, things didn't change a bit.

I believe something went wrong on my web2py install, so I'm resorting the 
reinstall it back. Won't take long anyway.


On Tuesday, October 16, 2012 10:27:14 AM UTC+1, apinho wrote:

 Hi,

 Using web2py, straight out of the box, no routes.py or such :

 When i request :  
 https://myserver/myapp/mycontroller/myfunction

 having /models/models.py :
 ...
 default_application   = 'myapp'
 ...



 and /controllers/mycontroller.py :
 def myfunction():
 # no pasa nada
 return dict()

 Web2py answers :
 invalid function (default/mycontroller)

 So, he is looking for function *mycontroller*, inside controller *
 default.py*, instead of looking for function *myfunction*, inside 
 controller *mycontroller.py*.

 Why ? What I am missing ?


-- 





[web2py] tags and speed

2012-10-17 Thread andrej burja
hi

i have table games and they have tags
i followed the example in the book and put tags in separate table

now i want to show all games with all tags in the view: game.title, 
games.instruction, game.tags
in fuction i have
for game in games:
equipment =[tag.name for tag in 
db(db.tag.game_id==game.id).select()]
game.f_equipment =', '.join(equipment)

having more than 1000 games (games is row object with more than 1000 
entries), this is very slow. how can i make that faster?

andrej

-- 





[web2py] Re: about constraints on fields of table

2012-10-17 Thread dantuluri jaganadha raju
when writing
Field('two','time',requires=IS_TIME(format='%H:%M'))
I am getting error type 'exceptions.TypeError' __init__() got an 
unexpected keyword argument 'format'  
So, please reply as soon as possible.

On Friday, October 12, 2012 10:44:23 AM UTC+5:30, dantuluri jaganadha raju 
wrote:

 Hi,
  I want to accept only 9 digit number as input to one field and 
 other's are invalid. and in another field I want to accept time format of 
 form (hours:minutes to hours:minutes).
  
Thank you in advance...


-- 





Re: [web2py] Re: help me test sessions in cookies

2012-10-17 Thread Michele Comitini
+1

Massimo, is it compressing data also?

mic

2012/10/17 Massimo Di Pierro massimo.dipie...@gmail.com



 On Tuesday, 16 October 2012 17:39:36 UTC-5, Niphlod wrote:

 BTW, encrypting and decrypting (on the worst case scenario, 4KB of data)
 takes 4,7 seconds for 1 million iterations. I'd definitely use encryption
 no matter what if designing a large scale deployment,


 +1 sessions in cookies without encryption are not an option.

 --





-- 





Re: [web2py] access a configuration file into web2py

2012-10-17 Thread Bruno Rocha
you need to use a dynamic path

import os
path = os.path.join(request.folder, 'private', 'conf.ini')

then place the file in private folder and use the 'path' to read it.

Bruno Rocha
http://rochacbruno.com.br
mobile
 Em 16/10/2012 19:19, deepak shanky...@gmail.com escreveu:

 Hi,
 I have a configuration file. I wanted to use ConfigObj library to access
 the configuration file.
 I have placed the file inside the controller and tried accessing it like:

 cfg=ConfigObj(conf.ini)

 It didnt read the file. But when i gave it like this:

 cfg=ConfObj(/home/deepak/web2py/applications/depyweb/controller/conf.ini)

 it worked!..

 What is the issue with this?

 --





-- 





[web2py] Re: proposal: change SQLFORM delete checkbox handling

2012-10-17 Thread Mandar Vaze


On Tuesday, March 23, 2010 10:32:19 AM UTC+5:30, Jonathan Lundell wrote:

 no loss of functionality), but more important it allows us to have an 
 option to SQLFORM.__init__() to override the text associated with the 
 confirmation. 'Sure you want to delete this object?' is somewhat 
 idiosyncratic English to begin with, but the main problem is that usually 
 we'd like to be more specific than this object. Depending on the record, 
 we might say this item or this item in your cart or this user or any 
 number of things.

I have achieved this by overriding variable w2p_ajax_confirm_message as 
follows :

 {{extend 'layout.html'}}
+script
+var w2p_ajax_confirm_message = {{=T('Are you sure you want to remove 
this item from cart?')}};
+/script


It seems to be work for me.  (on web2py 2.0.9 - if it matters)
Do you see any problem with this approach ?

-Mandar



-- 





[web2py] Re: web2py/gluon/compileapp.py throwing ticket

2012-10-17 Thread Massimo Di Pierro
Do you have a file called html.py in myapp/modules/?

On Tuesday, 16 October 2012 23:54:55 UTC-5, weheh wrote:

 I'm getting the following ticket after upgrading from web2py 1.99.x to 
 2.1.1 source:

 Traceback (most recent call last):
   File N:\web2py\gluon\restricted.py, line 209, in restricted
 exec ccode in environment
   File N:\web2py\applications\myapp\views\mycontroller/index.html, line 
 444, in module
 jQuery('#image-form').ajaxForm({
   File N:\web2py\gluon\compileapp.py, line 136, in LOAD
 from html import TAG, DIV, URL, SCRIPT, XML
 ImportError: cannot import name TAG




-- 





[web2py] Re: Query with postgres

2012-10-17 Thread Massimo Di Pierro
s=db.club.created_on.year(),db.club.created_on.month(),db.club.created_on.day() 
def join(s): return reduce(lambda a,b:a|b,s)
dates = db(query).select(*s,count,orderby=~join(s), limitby=limitby, 
groupby=join(s))

On Wednesday, 17 October 2012 01:31:55 UTC-5, Paolo wrote:

 Hi Cliff,
 I got the reasons of postgres, but I don't know how to fix it. The query 
 is actually very simple, I have several post, I want to group them by s, 
 and get the number of post for each s. Where s is:
 s=db.club.created_on.year() | db.club.created_on.month() | 
 db.club.created_on.day() 
 In the select I may created_on and use s instead, something like that:
 dates = db(query).select(s,count,orderby=~s, limitby=limitby, groupby=s)

 but doing that I got this error:
 2012-10-17 08:27:59,210 - web2py - ERROR - Traceback (most recent call 
 last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 209, in 
 restricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
 line 140, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 184, in 
 lambda
 self._caller = lambda f: f()
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
 line 3, in index
 d= dict(clubs = get_clubs())
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/models/clubDB.py, line 
 25, in get_clubs
 dates = db(query).select(s,count,orderby=~s, limitby=limitby, 
 groupby=s)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8787, in select
 return adapter.select(self.query,fields,attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 2127, in select
 return super(SQLiteAdapter, self).select(query, fields, attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1615, in select
 return self._select_aux(sql,fields,attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1596, in 
 _select_aux
 return processor(rows,fields,self._colnames,cacheable=cacheable)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1974, in parse
 fields[j].type,blob_decode)
 IndexError: list index out of range

 Paolo

 On Wednesday, October 17, 2012 4:45:35 AM UTC+2, Cliff Kachinske wrote:

 I don't know how it possibly worked in sqlite, but this is an aggregate 
 query combined with a non-aggregate query.

 In other words, the count is a property of an aggregation of rows in the 
 database, whereas created_on is a property of individual rows.

 This confuses Postgres.  It doesn't know if you want the aggregate result 
 (count) or the result for individual rows (created_on).  It cannot deliver 
 both from the same query.

 What are you trying to find out in your query?



 On Tuesday, October 16, 2012 4:59:36 PM UTC-4, Paolo wrote:

 Dear all, 
 I've just switched from sqlite to postgres, and now I have problems with 
 few queries.
 One query that works correctly on sqlite and fails on postgres is the 
 following:
 s=db.club.created_on.year() | db.club.created_on.month() | 
 db.club.created_on.day() 
 count = db.club.id.count()
 dates = 
 db(query).select(db.club.created_on,count,orderby=~db.club.created_on, 
 limitby=limitby, groupby=s)

 Now on postgres, it raises the following error:
 ProgrammingError: column club.created_on must appear in the GROUP BY 
 clause or be used in an aggregate function
 LINE 1: SELECT  club.created_on, COUNT(club.id) FROM club WHERE (((c...

 I read online that the fields in the select must be on the groupby as 
 well. The problem is that by grouping even by club.created_on (by adding 
 groupby=s | club.created_on)  the result is totally different. What can I 
 do to tackle this problem?

 Best,
 Paolo



-- 





Re: [web2py] Re: help me test sessions in cookies

2012-10-17 Thread Niphlod
patch along the way for that, and some other optimization too.

On Wednesday, October 17, 2012 11:24:26 AM UTC+2, Michele Comitini wrote:

 +1

 Massimo, is it compressing data also? 

 mic

 2012/10/17 Massimo Di Pierro massimo@gmail.com javascript:



 On Tuesday, 16 October 2012 17:39:36 UTC-5, Niphlod wrote:

 BTW, encrypting and decrypting (on the worst case scenario, 4KB of data) 
 takes 4,7 seconds for 1 million iterations. I'd definitely use encryption 
 no matter what if designing a large scale deployment,


 +1 sessions in cookies without encryption are not an option. 

 -- 
  
  
  




-- 





[web2py] Re: IS_STRONG and CRYPT

2012-10-17 Thread Massimo Di Pierro
http://code.google.com/p/web2py/issues/list

On Wednesday, 17 October 2012 02:12:31 UTC-5, piero crisci wrote:

 Sorry but i never opened a ticket before. Do you mean open a ticket in 
 google groups or there is a Ticket Request System dedicated for the 
 request?.
 Thank again Richard and Massimo for the support.


 Il giorno mercoledì 17 ottobre 2012 00:20:54 UTC+2, Massimo Di Pierro ha 
 scritto:

 Can you please open a ticket about this?

 On Friday, 12 October 2012 10:04:35 UTC-5, piero crisci wrote:

 I tryed to find others with the same iusse problem without understand 
 how to solve the problems :(

 I set in the db.py the follow table

 
 db.define_table('auth_user',
 Field('username', type='string',
   label=T('Username')),
 Field('first_name', type='string',
   label=T('First Name')),
 Field('last_name', type='string',
   label=T('Last Name')),
 Field('email', type='string',
   label=T('Email')),
 Field('password', type='password',length=512,
   readable=False,
   label=T('Password')),
 Field('created_on','datetime',default=request.now,
   label=T('Created On'),writable=False,readable=False),
 Field('modified_on','datetime',default=request.now,
   label=T('Modified On'),writable=False,readable=False,
   update=request.now),
 Field('registration_key',default='',
   writable=False,readable=False),
 Field('reset_password_key',default='',
   writable=False,readable=False),
 Field('registration_id',default='',
   writable=False,readable=False),
 format='%(username)s',
 migrate=settings.migrate)


 db.auth_user.first_name.requires = 
 IS_NOT_EMPTY(error_message=auth.messages.is_empty)
 db.auth_user.last_name.requires = 
 IS_NOT_EMPTY(error_message=auth.messages.is_empty)
 #db.auth_user.password.requires = [ IS_STRONG(min=8, 
 number=1,special=1,error_message = La password deve contenere almeno 8 
 Caratteri, un Numero, un Carattere Speciale, un carattere Maiuscolo), 
 CRYPT(key=auth.settings.hmac_key)]
 db.auth_user.password.requires= [*IS_STRONG(min=8), 
 CRYPT(auth.settings.hmac_key)*]

 db.auth_user.username.requires = IS_NOT_IN_DB(db, db.auth_user.username, 
 error_message = 'Username già censita')
 db.auth_user.email.requires = 
 (IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, 
 db.auth_user.email,error_message = 'Email già censita'))
 auth.define_tables(migrate = settings.migrate)

 I set in the default.py this def for manage the user changes .

 @auth.requires_login()
 @auth.requires_membership('risorse_umane' or 'admin')
 def anagrafica_utenti_db_manage():
 form = SQLFORM.smartgrid(db.auth_user,onupdate=auth.archive)
 return locals()

 When i try to modify the name or the surname the framework rise the 
 IS_STRONG control even if i don't touch the password string.
 I am new with web2py and i want just to know if i need to create a form 
 to make the user changes or i can fix this problem using the smartgrid.
 I also set the Requires approval for the new registration. How can i 
 delete the Pending in the registration key ? (I can t do it right now 
 because of the IS_STRONG control.
 Thanks for help
 And sorry for bother you



-- 





[web2py] Re: about constraints on fields of table

2012-10-17 Thread Massimo Di Pierro
I was wrong. My example works for IS_DATE but not IS_TIME. Let me look more 
into this..

On Wednesday, 17 October 2012 04:17:54 UTC-5, dantuluri jaganadha raju 
wrote:

 when writing
 Field('two','time',requires=IS_TIME(format='%H:%M'))
 I am getting error type 'exceptions.TypeError' __init__() got an 
 unexpected keyword argument 'format'  
 So, please reply as soon as possible.

 On Friday, October 12, 2012 10:44:23 AM UTC+5:30, dantuluri jaganadha raju 
 wrote:

 Hi,
  I want to accept only 9 digit number as input to one field and 
 other's are invalid. and in another field I want to accept time format of 
 form (hours:minutes to hours:minutes).
  
Thank you in advance...



-- 





[web2py] Re: web2py/gluon/compileapp.py throwing ticket

2012-10-17 Thread weheh
Uh, yes.

-- 





Re: [web2py] Re: URL requests always aiming to default controller...

2012-10-17 Thread Jonathan Lundell
On 17 Oct 2012, at 2:07 AM, apinho jaapi...@sapo.pt wrote:
 I'm using 
 Version 1.99.7 (2012-03-04 22:12:08) stable
 
 
 If I try, from the example app :
 https://myserver/examples/session-examples/counter
 
 
 
 I get :
 Invalid request
 
 This is weird.
 
 Meanwhile, as you told me that declaring a default_application on models.py 
 was ineffective, I removed  default_application='myapp'  from my models.py, 
 and i changed this in routes.py :
 routers = dict( BASE = dict( default_application = 'myapp', ), )
 
 But, things didn't change a bit.
 
 I believe something went wrong on my web2py install, so I'm resorting the 
 reinstall it back. Won't take long anyway.

I think that's best.

-- 





Re: [web2py] Re: IS_STRONG and CRYPT

2012-10-17 Thread Richard Vézina
I open the issue!

http://code.google.com/p/web2py/issues/detail?id=1098

Richard

On Wed, Oct 17, 2012 at 8:36 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 http://code.google.com/p/web2py/issues/list


 On Wednesday, 17 October 2012 02:12:31 UTC-5, piero crisci wrote:

 Sorry but i never opened a ticket before. Do you mean open a ticket in
 google groups or there is a Ticket Request System dedicated for the
 request?.
 Thank again Richard and Massimo for the support.


 Il giorno mercoledì 17 ottobre 2012 00:20:54 UTC+2, Massimo Di Pierro ha
 scritto:

 Can you please open a ticket about this?

 On Friday, 12 October 2012 10:04:35 UTC-5, piero crisci wrote:

 I tryed to find others with the same iusse problem without understand
 how to solve the problems :(

 I set in the db.py the follow table

 ##**##
 db.define_table('auth_user',
 Field('username', type='string',
   label=T('Username')),
 Field('first_name', type='string',
   label=T('First Name')),
 Field('last_name', type='string',
   label=T('Last Name')),
 Field('email', type='string',
   label=T('Email')),
 Field('password', type='password',length=512,
   readable=False,
   label=T('Password')),
 Field('created_on','datetime',**default=request.now,
   label=T('Created On'),writable=False,readable=**False),
 Field('modified_on','datetime'**,default=request.now,
   label=T('Modified On'),writable=False,readable=**False,
   update=request.now),
 Field('registration_key',**default='',
   writable=False,readable=False)**,
 Field('reset_password_key',**default='',
   writable=False,readable=False)**,
 Field('registration_id',**default='',
   writable=False,readable=False)**,
 format='%(username)s',
 migrate=settings.migrate)


 db.auth_user.first_name.**requires = IS_NOT_EMPTY(error_message=**
 auth.messages.is_empty)
 db.auth_user.last_name.**requires = IS_NOT_EMPTY(error_message=**
 auth.messages.is_empty)
 #db.auth_user.password.**requires = [ IS_STRONG(min=8,
 number=1,special=1,error_**message = La password deve contenere
 almeno 8 Caratteri, un Numero, un Carattere Speciale, un carattere
 Maiuscolo), CRYPT(key=auth.settings.hmac_**key)]
 db.auth_user.password.**requires= [*IS_STRONG(min=8),
 CRYPT(auth.settings.hmac_key)*]

 db.auth_user.username.requires = IS_NOT_IN_DB(db,
 db.auth_user.username, error_message = 'Username già censita')
 db.auth_user.email.requires = (IS_EMAIL(error_message=auth.**
 messages.invalid_email),
IS_NOT_IN_DB(db,
 db.auth_user.email,error_**message = 'Email già censita'))
 auth.define_tables(migrate = settings.migrate)

 I set in the default.py this def for manage the user changes .

 @auth.requires_login()
 @auth.requires_membership('**risorse_umane' or 'admin')
 def anagrafica_utenti_db_manage():
 form = SQLFORM.smartgrid(db.auth_**user,onupdate=auth.archive)
 return locals()

 When i try to modify the name or the surname the framework rise the
 IS_STRONG control even if i don't touch the password string.
 I am new with web2py and i want just to know if i need to create a form
 to make the user changes or i can fix this problem using the smartgrid.
 I also set the Requires approval for the new registration. How can i
 delete the Pending in the registration key ? (I can t do it right now
 because of the IS_STRONG control.
 Thanks for help
 And sorry for bother you

  --





-- 





[web2py] Re: Auth Wiki functionality?

2012-10-17 Thread Bill Thayer
Cool! Thanks. I did not understand what ,load was for.

This morning I'm thinking that I'll have to add a See Also field of type 
'list:reference wiki_page' to the wiki_page table to handle my many to many 
relationships. Plus also add a wiki_page_id filed to my parts tables.

Thanks for the advice!

-Bill

On Tuesday, October 16, 2012 9:17:25 PM UTC-5, Massimo Di Pierro wrote:

 Try:

 @{component:default/part_manage.load}

 Or customize the part_manage.html to not {{extend 'layout.html'}}

 On Tuesday, 16 October 2012 19:20:35 UTC-5, Bill Thayer wrote:

 Hello everyone,

 Thanks to Allen, Villas, of course Massimo among a few others I have 
 web2py auth.wiki with Oracle storing the media blobs and all the pages.  I 
 believe I can use the wiki features in a structure way to improv 
 productivity and cross department functionality in my workplace.

 Now what in the heck to do with it?

 The app wizard created a bunch of controllers like
 @auth.requires_login()
 def part_manage():
 form = SQLFORM.smartgrid(db.part)
 return locals()



 but if I add
 @{component:default/part_manage}
 to my markmin I get a page with my SQLFORM.smartgrid inside a page so I 
 get two footers and two headers. Not to mention the add and edit pages 
 should really be a wiki page with my table attributes added.

 Looks like auth-wiki is for creating web pages but what caught my 
 attention was the media and tagging capability built in so I don't have to 
 write my own app to do what's already there. However, I have a bunch of 
 tables (parts, sub parts, orders, samples, testing, analyses for tested 
 samples, etc...) defined for my application and  basically 75% of the items 
 have attachments, images, files, user references and tags too. 

 Unless someone says different I guess I should be adding a wiki_page 
 column to all of my tables? Then create separate edit/show/create 
 controllers that generate the proper...slug...and return a wiki page? 
 That shouldn't break my relationships I don't think.

 Just kind of wondering if there's already a know technique for my 
 application that you know of?

 Regards,
 Bill



-- 





Re: [web2py] Re: cannot upgrade to 2.1.1 from GUI on Pythonanywhere

2012-10-17 Thread Hansel Dunlop
Hi Nico, 

Glad you got it working! I'm one of the PythonAnywhere developers. Would 
you mind sharing the changes you made to the gui upgrade check? We should 
have the latest version by default next time we deploy. It's currently 
running through our integration tests now. 

Cheers 

Hansel 

On Tuesday, 16 October 2012 13:59:05 UTC+1, Nico Zanferrari wrote:

 Now it's working fine! I suppose they cached the old version in their web 
 proxy ...

 Thank you,
 Nico




-- 





[web2py] Re: Query with postgres

2012-10-17 Thread Paolo
Hi Massimo, thanks for the suggested query but unfortunately I got this 
error:

Traceback (most recent call last):
  File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 208, in 
restricted
ccode = compile2(code,layer)
  File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 193, in 
compile2
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec')
  File /home/paolo/Dropbox/git/web2py/applications/bikend/models/clubDB.py 
http://127.0.0.1:8000/admin/default/edit/bikend/models/clubDB.py, line 29
dates = db(query).select(*s,count,orderby=~join(s), limitby=limitby, 
groupby=join(s))
SyntaxError: only named arguments may follow *expression

If that can help, I've tried without the wildcard but it failed, web2py was 
blocked and python took 100% of the cpu.

Paolo

On Wednesday, October 17, 2012 2:35:23 PM UTC+2, Massimo Di Pierro wrote:


 s=db.club.created_on.year(),db.club.created_on.month(),db.club.created_on.day()
  
 def join(s): return reduce(lambda a,b:a|b,s)
 dates = db(query).select(*s,count,orderby=~join(s), limitby=limitby, 
 groupby=join(s))

 On Wednesday, 17 October 2012 01:31:55 UTC-5, Paolo wrote:

 Hi Cliff,
 I got the reasons of postgres, but I don't know how to fix it. The query 
 is actually very simple, I have several post, I want to group them by s, 
 and get the number of post for each s. Where s is:
 s=db.club.created_on.year() | db.club.created_on.month() | 
 db.club.created_on.day() 
 In the select I may created_on and use s instead, something like that:
 dates = db(query).select(s,count,orderby=~s, limitby=limitby, groupby=s)

 but doing that I got this error:
 2012-10-17 08:27:59,210 - web2py - ERROR - Traceback (most recent call 
 last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 209, in 
 restricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
 line 140, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 184, in 
 lambda
 self._caller = lambda f: f()
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
 line 3, in index
 d= dict(clubs = get_clubs())
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/models/clubDB.py, line 
 25, in get_clubs
 dates = db(query).select(s,count,orderby=~s, limitby=limitby, 
 groupby=s)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8787, in select
 return adapter.select(self.query,fields,attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 2127, in select
 return super(SQLiteAdapter, self).select(query, fields, attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1615, in select
 return self._select_aux(sql,fields,attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1596, in 
 _select_aux
 return processor(rows,fields,self._colnames,cacheable=cacheable)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1974, in parse
 fields[j].type,blob_decode)
 IndexError: list index out of range

 Paolo

 On Wednesday, October 17, 2012 4:45:35 AM UTC+2, Cliff Kachinske wrote:

 I don't know how it possibly worked in sqlite, but this is an aggregate 
 query combined with a non-aggregate query.

 In other words, the count is a property of an aggregation of rows in the 
 database, whereas created_on is a property of individual rows.

 This confuses Postgres.  It doesn't know if you want the aggregate 
 result (count) or the result for individual rows (created_on).  It cannot 
 deliver both from the same query.

 What are you trying to find out in your query?



 On Tuesday, October 16, 2012 4:59:36 PM UTC-4, Paolo wrote:

 Dear all, 
 I've just switched from sqlite to postgres, and now I have problems 
 with few queries.
 One query that works correctly on sqlite and fails on postgres is the 
 following:
 s=db.club.created_on.year() | db.club.created_on.month() | 
 db.club.created_on.day() 
 count = db.club.id.count()
 dates = 
 db(query).select(db.club.created_on,count,orderby=~db.club.created_on, 
 limitby=limitby, groupby=s)

 Now on postgres, it raises the following error:
 ProgrammingError: column club.created_on must appear in the GROUP BY 
 clause or be used in an aggregate function
 LINE 1: SELECT  club.created_on, COUNT(club.id) FROM club WHERE (((c...

 I read online that the fields in the select must be on the groupby as 
 well. The problem is that by grouping even by club.created_on (by adding 
 groupby=s | club.created_on)  the result is totally different. What can I 
 do to tackle this problem?

 Best,
 Paolo



-- 





[web2py] Re: conditionally process form

2012-10-17 Thread Annet
I tried:

form=SQLFORM.factory(...)
if form.process(onvalidation=validate_create_node,keepvalues=True).accepted:
processForm(form)
elif form.errors:
response.flash=responseFlash('formerror',session)
elif not response.flash:
response.flash=responseFlash('form',session)
return dict(form=form)


def validate_create_node(form):
if session.allow_duplicate:
session.allow_duplicate=False
elif form.vars.cocNumber:
organization=db(...).select(db.organization.ALL)
if organization:
session.allow_duplicate=True
form.errors.cocNumber=str(form.vars.cocNumber) + 
str(form.vars.subdossierNumber) + ' already in database'
elif form.vars.lastName and form.vars.birthday:
person=db(...).select(db.person.ALL)
if person:
session.allow_duplicate=True
form.errors.lastName=str(form.vars.lastName) + 
str(form.vars.birthday) + '  already in database'

... but this:

if session.allow_duplicate:
session.allow_duplicate=False

Doesn't work. How do I implement this correctly?


Kind regards,

Annet

-- 





[web2py] Changing subject line of email verification email

2012-10-17 Thread Yarin
I'd like to change the subject line of the email verification sent on 
registration- is that possible?

-- 





[web2py] Re: conditionally process form

2012-10-17 Thread Anthony
First, you can't set session.allow_duplicate to False until you've first 
checked its value. Second, you have to actually check its value somewhere. 
Maybe something like this:

allow_duplicate = session.allow_duplicate
del session.allow_duplicate
if not allow_duplicate:
if form.vars.cocNumber and db(...).select(db.organization.ALL):
session.allow_duplicate=True
form.errors.cocNumber=str(form.vars.cocNumber) + str(form.vars.
subdossierNumber) + ' already in database'
elif form.vars.lastName and form.vars.birthday and person=db(...).
select(db.person.ALL):
session.allow_duplicate=True
form.errors.lastName=str(form.vars.lastName) + str(form.vars.
birthday) + '  already in database'

Anthony

On Wednesday, October 17, 2012 12:54:33 PM UTC-4, Annet wrote:

 I tried:

 form=SQLFORM.factory(...)
 if 
 form.process(onvalidation=validate_create_node,keepvalues=True).accepted:
 processForm(form)
 elif form.errors:
 response.flash=responseFlash('formerror',session)
 elif not response.flash:
 response.flash=responseFlash('form',session)
 return dict(form=form)


 def validate_create_node(form):
 if session.allow_duplicate:
 session.allow_duplicate=False
 elif form.vars.cocNumber:
 organization=db(...).select(db.organization.ALL)
 if organization:
 session.allow_duplicate=True
 form.errors.cocNumber=str(form.vars.cocNumber) + 
 str(form.vars.subdossierNumber) + ' already in database'
 elif form.vars.lastName and form.vars.birthday:
 person=db(...).select(db.person.ALL)
 if person:
 session.allow_duplicate=True
 form.errors.lastName=str(form.vars.lastName) + 
 str(form.vars.birthday) + '  already in database'

 ... but this:

 if session.allow_duplicate:
 session.allow_duplicate=False

 Doesn't work. How do I implement this correctly?


 Kind regards,

 Annet



-- 





[web2py] Re: web2py/gluon/compileapp.py throwing ticket [CLOSED]

2012-10-17 Thread Massimo Di Pierro
LOL. The only thing that changed that could have made this work is actually 
making custom_import work as intended.

On Wednesday, 17 October 2012 08:36:15 UTC-5, weheh wrote:

 Uh, yes. How did you guess? 

 I feel like the kid caught with his hand in the cookie jar by a 
 mind-reading parent.

 Anyway, I renamed html.py in modules and issue goes away. (Hand removed 
 from cookie jar -- intact, for now.) 

 Thanks, Massimo.


-- 





Re: [web2py] Re: proposal: change SQLFORM delete checkbox handling

2012-10-17 Thread Richard Vézina
Adding a attributes to SQLFORM would be better...

The way you do it, mean that you will need to include your little script in
every view.

Richard

On Wed, Oct 17, 2012 at 8:18 AM, Mandar Vaze mandarv...@gmail.com wrote:



 On Tuesday, March 23, 2010 10:32:19 AM UTC+5:30, Jonathan Lundell wrote:

 no loss of functionality), but more important it allows us to have an
 option to SQLFORM.__init__() to override the text associated with the
 confirmation. 'Sure you want to delete this object?' is somewhat
 idiosyncratic English to begin with, but the main problem is that usually
 we'd like to be more specific than this object. Depending on the record,
 we might say this item or this item in your cart or this user or any
 number of things.

 I have achieved this by overriding variable w2p_ajax_confirm_message as
 follows :

  {{extend 'layout.html'}}
 +script
 +var w2p_ajax_confirm_message = {{=T('Are you sure you want to
 remove this item from cart?')}};
 +/script


 It seems to be work for me.  (on web2py 2.0.9 - if it matters)
 Do you see any problem with this approach ?

 -Mandar

  --





-- 





Re: [web2py] Re: cannot upgrade to 2.1.1 from GUI on Pythonanywhere

2012-10-17 Thread Massimo Di Pierro
I am releasing 2.2.1 tomorrow. It will have support for encrypted sessions 
in cookie. :-)

On Wednesday, 17 October 2012 11:22:09 UTC-5, Hansel Dunlop wrote:

 Hi Nico, 

 Glad you got it working! I'm one of the PythonAnywhere developers. Would 
 you mind sharing the changes you made to the gui upgrade check? We should 
 have the latest version by default next time we deploy. It's currently 
 running through our integration tests now. 

 Cheers 

 Hansel 

 On Tuesday, 16 October 2012 13:59:05 UTC+1, Nico Zanferrari wrote:

 Now it's working fine! I suppose they cached the old version in their web 
 proxy ...

 Thank you,
 Nico




-- 





[web2py] Re: Query with postgres

2012-10-17 Thread Massimo Di Pierro
It should work with python 2.7 but not previous version. You can also do:

s=db.club.created_on.year() | db.club.created_on.month() | 
db.club.created_on.day() 
dates = 
db(query).select(db.club.created_on.year(),db.club.created_on.month(),db.club.created_on.day()
 ,
  count,orderby=~s, limitby=limitby, groupby=s)


On Wednesday, 17 October 2012 11:54:29 UTC-5, Paolo wrote:

 Hi Massimo, thanks for the suggested query but unfortunately I got this 
 error:

 Traceback (most recent call last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 208, in 
 restricted
 ccode = compile2(code,layer)
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 193, in 
 compile2
 return compile(code.rstrip().replace('\r\n','\n')+'\n', layer, 'exec')
   File /home/paolo/Dropbox/git/web2py/applications/bikend/models/clubDB.py 
 http://127.0.0.1:8000/admin/default/edit/bikend/models/clubDB.py, line 29
 dates = db(query).select(*s,count,orderby=~join(s), limitby=limitby, 
 groupby=join(s))
 SyntaxError: only named arguments may follow *expression

 If that can help, I've tried without the wildcard but it failed, web2py 
 was blocked and python took 100% of the cpu.

 Paolo

 On Wednesday, October 17, 2012 2:35:23 PM UTC+2, Massimo Di Pierro wrote:


 s=db.club.created_on.year(),db.club.created_on.month(),db.club.created_on.day()
  
 def join(s): return reduce(lambda a,b:a|b,s)
 dates = db(query).select(*s,count,orderby=~join(s), limitby=limitby, 
 groupby=join(s))

 On Wednesday, 17 October 2012 01:31:55 UTC-5, Paolo wrote:

 Hi Cliff,
 I got the reasons of postgres, but I don't know how to fix it. The query 
 is actually very simple, I have several post, I want to group them by s, 
 and get the number of post for each s. Where s is:
 s=db.club.created_on.year() | db.club.created_on.month() | 
 db.club.created_on.day() 
 In the select I may created_on and use s instead, something like that:
 dates = db(query).select(s,count,orderby=~s, limitby=limitby, groupby=s)

 but doing that I got this error:
 2012-10-17 08:27:59,210 - web2py - ERROR - Traceback (most recent call 
 last):
   File /home/paolo/Dropbox/git/web2py/gluon/restricted.py, line 209, 
 in restricted
 exec ccode in environment
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
 line 140, in module
   File /home/paolo/Dropbox/git/web2py/gluon/globals.py, line 184, in 
 lambda
 self._caller = lambda f: f()
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
 line 3, in index
 d= dict(clubs = get_clubs())
   File 
 /home/paolo/Dropbox/git/web2py/applications/bikend/models/clubDB.py, line 
 25, in get_clubs
 dates = db(query).select(s,count,orderby=~s, limitby=limitby, 
 groupby=s)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 8787, in 
 select
 return adapter.select(self.query,fields,attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 2127, in 
 select
 return super(SQLiteAdapter, self).select(query, fields, attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1615, in 
 select
 return self._select_aux(sql,fields,attributes)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1596, in 
 _select_aux
 return processor(rows,fields,self._colnames,cacheable=cacheable)
   File /home/paolo/Dropbox/git/web2py/gluon/dal.py, line 1974, in parse
 fields[j].type,blob_decode)
 IndexError: list index out of range

 Paolo

 On Wednesday, October 17, 2012 4:45:35 AM UTC+2, Cliff Kachinske wrote:

 I don't know how it possibly worked in sqlite, but this is an aggregate 
 query combined with a non-aggregate query.

 In other words, the count is a property of an aggregation of rows in 
 the database, whereas created_on is a property of individual rows.

 This confuses Postgres.  It doesn't know if you want the aggregate 
 result (count) or the result for individual rows (created_on).  It cannot 
 deliver both from the same query.

 What are you trying to find out in your query?



 On Tuesday, October 16, 2012 4:59:36 PM UTC-4, Paolo wrote:

 Dear all, 
 I've just switched from sqlite to postgres, and now I have problems 
 with few queries.
 One query that works correctly on sqlite and fails on postgres is the 
 following:
 s=db.club.created_on.year() | db.club.created_on.month() | 
 db.club.created_on.day() 
 count = db.club.id.count()
 dates = 
 db(query).select(db.club.created_on,count,orderby=~db.club.created_on, 
 limitby=limitby, groupby=s)

 Now on postgres, it raises the following error:
 ProgrammingError: column club.created_on must appear in the GROUP BY 
 clause or be used in an aggregate function
 LINE 1: SELECT  club.created_on, COUNT(club.id) FROM club WHERE 
 (((c...

 I read online that the fields in the select must be on the groupby as 
 well. The problem is that by grouping even by club.created_on (by adding 
 groupby=s | club.created_on)  the result is 

[web2py] Re: Changing subject line of email verification email

2012-10-17 Thread Massimo Di Pierro
Yes. You can see all the settings below:

auth.settings = Storage(dict(
login_button = 'Login',
register_button = 'Register',
password_reset_button = 'Request reset password',
password_change_button = 'Change password',
profile_save_button = 'Save profile',
submit_button = 'Submit',
verify_password = 'Verify Password',
delete_label = 'Check to delete',
function_disabled = 'Function disabled',
access_denied = 'Insufficient privileges',
registration_verifying = 'Registration needs verification',
registration_pending = 'Registration is pending approval',
login_disabled = 'Login disabled by administrator',
logged_in = 'Logged in',
email_sent = 'Email sent',
unable_to_send_email = 'Unable to send email',
email_verified = 'Email verified',
logged_out = 'Logged out',
registration_successful = 'Registration successful',
invalid_email = 'Invalid email',
unable_send_email = 'Unable to send email',
invalid_login = 'Invalid login',
invalid_user = 'Invalid user',
invalid_password = 'Invalid password',
is_empty = Cannot be empty,
mismatched_password = Password fields don't match,
verify_email = 'Click on the link %(link)s to verify your email',
verify_email_subject = 'Email verification',
username_sent = 'Your username was emailed to you',
new_password_sent = 'A new password was emailed to you',
password_changed = 'Password changed',
retrieve_username = 'Your username is: %(username)s',
retrieve_username_subject = 'Username retrieve',
retrieve_password = 'Your password is: %(password)s',
retrieve_password_subject = 'Password retrieve',
reset_password = \
'Click on the link %(link)s to reset your password',
reset_password_subject = 'Password reset',
invalid_reset_password = 'Invalid reset password',
profile_updated = 'Profile updated',
new_password = 'New password',
old_password = 'Old password',
group_description = 'Group uniquely assigned to user %(id)s',
register_log = 'User %(id)s Registered',
login_log = 'User %(id)s Logged-in',
login_failed_log = None,
logout_log = 'User %(id)s Logged-out',
profile_log = 'User %(id)s Profile updated',
verify_email_log = 'User %(id)s Verification email sent',
retrieve_username_log = 'User %(id)s Username retrieved',
retrieve_password_log = 'User %(id)s Password retrieved',
reset_password_log = 'User %(id)s Password reset',
change_password_log = 'User %(id)s Password changed',
add_group_log = 'Group %(group_id)s created',
del_group_log = 'Group %(group_id)s deleted',
add_membership_log = None,
del_membership_log = None,
has_membership_log = None,
add_permission_log = None,
del_permission_log = None,
has_permission_log = None,
impersonate_log = 'User %(id)s is impersonating %(other_id)s',
label_first_name = 'First name',
label_last_name = 'Last name',
label_username = 'Username',
label_email = 'E-mail',
label_password = 'Password',
label_registration_key = 'Registration key',
label_reset_password_key = 'Reset Password key',
label_registration_id = 'Registration identifier',
label_role = 'Role',
label_description = 'Description',
label_user_id = 'User ID',
label_group_id = 'Group ID',
label_name = 'Name',
label_table_name = 'Object or table name',
label_record_id = 'Record ID',
label_time_stamp = 'Timestamp',
label_client_ip = 'Client IP',
label_origin = 'Origin',
label_remember_me = Remember me (for 30 days),
verify_password_comment = 'please input your password again',
))

On Wednesday, 17 October 2012 12:14:44 UTC-5, Yarin wrote:

 I'd like to change the subject line of the email verification sent on 
 registration- is that possible?

-- 





[web2py] Re: help test codemirrorw

2012-10-17 Thread Ivan Brkanac
On osx chrome ctrl+f11 full screen is to big there is no end off editor on 
screen.
Also on default view only about 40% is usable for editing rest is 
mostly waist, key bindings hase same size as usable editor, can this be 
changed somewhere ?

Ivan

On Sunday, September 9, 2012 6:26:40 AM UTC+2, Massimo Di Pierro wrote:

 we are considering replacing the admin editor with codemirror since it 
 should work with IE.

 Can you please help us try it?

 get web2py form github and edit admin/models/0.py and set the editor to 
 'codemirror'.

 let us know what browser you try and your findings.

 Massimo


-- 





[web2py] unable to submit auth forms

2012-10-17 Thread Rohan Malhotra
Version 2.1.1 (2012-10-15 12:44:40) stable

Hi,

I am not able to submit an auth form. I am using default auth code. On 
submitting the form, password is shown as invalid and 'enter from 0 to 512 
characters' error is thrown. Input

td class=w2p_fw
input class=password invalidinput id=auth_user_password 
name=password type=password 
value=passwod_value_entered_before_submitting_form
div class=error_wrapper
div class=error id=password__error style=display: block;enter from 
0 to 512 characters/div
/div
/td


Please advice.

Thanks

-- 





[web2py] Re: Problem with adding Grids in book

2012-10-17 Thread mikech
Im not seeing the auth user table only db.image and db.comment

On Tuesday, October 16, 2012 5:28:24 PM UTC-7, Bill Thayer wrote:

 Hello Mike,

 I'm not an expert but i think you need to go to 
 http://127.0.0.1:8000/myapp/appadmin/index then click on the auth user 
 table and add a user, 
 then go to the groups table table and create a manager
 then go to the membership table and make your new user a manager
 then go to the permissions table and make 3 entries: permission = Create  
 group=manager; permission = read  group=manager; permission = update  
 group=manager,

 This is a quick answer on my way out the door 

 hope it helped.

 -Bill


 On Tuesday, October 16, 2012 6:33:19 PM UTC-5, mikech wrote:

 The section Adding Grids refers to using appadmin to create a group 
 manager, but I can't find anything in appadmin that allows that.
 Could someone give me a clue.  It seems that something is missing here.



-- 





Re: [web2py] easy way to validate a list of emails?

2012-10-17 Thread Adi
Thank you Bruno for this! Exactly what I was looking for. 

Maybe it would be a good idea to add it as a multiple parameter to 
standard IS_EMAIL(multiple=True, ...)

In any case, thanks :)

On Wednesday, July 6, 2011 4:39:39 AM UTC-4, rochacbruno wrote:

 forget the latest, I wrote directly here in email and there were errors. 

 This is the tested code:

 ### put in models ###

 class IS_EMAIL_LIST(object):
 def __init__(self, error_message=Email %s is invalid, sep=,):
 self.error_message = error_message
 self.sep = sep
 
 def __call__(self, value):
 emails = 
 value.strip().replace('\n','').replace('\t','').split(self.sep)
 for email in emails:
 email = email.strip()
 if IS_EMAIL()(email)[1] != None:
 return (email, self.error_message % email)
 return (emails, None) 

 db.define_table('emails',
 Field('list','text', requires=IS_EMAIL_LIST())
 )

 ###


-- 





[web2py] Re: about constraints on fields of table

2012-10-17 Thread dantuluri jaganadha raju
I kept field('aaa', requires=IS_DATE(format='%H:%M')) . and when I try 
to open database administration and that particular table I am getting 
error 
str' object has no attribute 'year'.

   Thank in advance.

On Friday, October 12, 2012 10:44:23 AM UTC+5:30, dantuluri jaganadha raju 
wrote:

 Hi,
  I want to accept only 9 digit number as input to one field and 
 other's are invalid. and in another field I want to accept time format of 
 form (hours:minutes to hours:minutes).
  
Thank you in advance...


-- 





[web2py] Re: conditionally process form

2012-10-17 Thread Annet
Hi Anthony,

Thanks for your reply, problem solved.

I have been struggling with an other problem for days, and I have no idea 
why the function doesn't do what I expect it do do.

I have a database containing nodes being organizations and people. These 
organizations and people can register for plan 1, 2, 3 or 4. When they 
register for plan 2 or 4, I have to enter a node being a hub before 
registering them as users. This is the function:

def register():
# get the registration form
row=db(db.register.id==request.args(0)).select(db.register.ALL).first()
# see whether an organization or persons wants to register
if row.cocNumber and row.subdossierNumber:

id=organization.nodeID
elif row.lastName and row.birthday:
...
id=person.nodeID
# the database doesn't contain the organization or person
else:
session.flash=''
redirect(URL('register'))
# the organization or person wants to register for a hub
if row.hub:
if id:
ownerID=id
hub=db(db.hub.name==row.hub).select(db.hub.ALL).first()
if hub:
session.flash='The database already contains a hub named ' 
+ str(row.hub)
redirect(URL('register'))
else:
id=db.node.insert()

db.hub.insert(nodeID=id,ownerID=ownerID,name=row.hub,label='Onbekend')
...
form=SQLFORM.factory(db.auth_user,ignore_rw=True,separator='')
# here I prepopulate the form based on row.field
if form.process(keepvalues=False).accepted:
...
elif form.errors:
response.flash=response_flash('formerror',session)
elif not response.flash:
response.flash='...' 
return dict(form=form)

This form is being processed correctly when an organization or person 
registers, however, when an organization or person registers for a hub, 
these lines are executed first:

else:
id=db.node.insert()
db.hub.insert(nodeID=id,ownerID=ownerID,name=row.hub,label='Onbekend')

then the form displays containing the correct value for nodeID (the id 
returned by the insert), but when I submit the form instead of making all 
the database inserts (as when an organization or person registers) the 
flash is being set to: 'The database already contains a hub named ' + 
str(row.hub) an no records are inserted.

I don't see what's wrong with my logic, I hope you do, the issue is keeping 
me awake at night :-(


Best regards,

Annet

-- 





[web2py] how to count() when joining

2012-10-17 Thread Richard
Hello,

The book is not clear about counting in context of join : 

Grouping and counting

When doing joins, sometimes you want to group rows according to certain 
criteria and count them. For example, count the number of things owned by 
every person. web2py allows this as well. First, you need a count operator. 
Second, you want to join the person table with the thing table by owner. 
Third, you want to select all rows (person + thing), group them by person, 
and count them while grouping:
grouping

 count = db.person.id.count()
 for row in db(db.person.id==db.thing.owner).select(
db.person.name, count, groupby=db.person.name):
print row.person.name, row[count]
Alex 2
Bob 1

Notice the count operator (which is built-in) is used as a field. The only 
issue here is in how to retrieve the information. Each row clearly contains 
a person and the count, but the count is not a field of a person nor is it 
a table. So where does it go? It goes into the storage object representing 
the record with a key equal to the query expression itself. The count 
method of the Field object has an optional distinct argument. When set to 
Trueit specifies that only distinct values of the field in question are to 
be counted.



I try this, but it not seems to work properly, at least it not giving me 
the count I suppose to have :

count = db.table.id.count()
db((db.table.date='2012-01-01')  
(db.table.date='2012-12-31')).select(count, 
join=[db.table.on(db.table.othertable_id==db.othertable.id), ...])

I know, that I could just add a where clause like this one 
(db.table.othertable_id==db.othertable.id), but I have many joins...

Thanks

Richard

-- 





[web2py] Error on OpenShift deploy

2012-10-17 Thread Relsi Hur
Hello, 

I try to deploy a app int the OpenShift using this option in the admin, but 
I have a error. Someone has the inside track for this operation?

The error is:

Traceback (most recent call last):
  File /home/locatto/Downloads/site-locatto/gluon/restricted.py, line 209, in 
restricted
exec ccode in environment
  File 
/home/locatto/Downloads/site-locatto/applications/admin/controllers/openshift.py
 http://localhost:8000/admin/default/edit/admin/controllers/openshift.py, 
line 58, in module
  File /home/locatto/Downloads/site-locatto/gluon/globals.py, line 187, in 
lambda
self._caller = lambda f: f()
  File 
/home/locatto/Downloads/site-locatto/applications/admin/controllers/openshift.py
 http://localhost:8000/admin/default/edit/admin/controllers/openshift.py, 
line 33, in deploy
index = repo.index
AttributeError: 'Repo' object has no attribute 'index'


-- 





Re: [web2py] easy way to validate a list of emails?

2012-10-17 Thread villas
For more unstructured addresses,  I also find this useful:   
http://docs.python.org/library/email.util.html
I use parseaddr.

-- 





[web2py] executesql - referring to fields in result?

2012-10-17 Thread Simon Carr
When I run a query using executesql, what is the object that is returned? 
is it a dictionary?

The reason I ask is that I am starting to think that the order of fields 
being returned to me is not the order that I put them in the SQL statement. 
As an example, I am running this code.

def clean_qty():
import re
rows = cmdb.executesql(select name, description_short, description, 
id_product from product_lang where name like '%X%' or description_short 
like '%X%' or description like '%X%')
for row in rows:
match = re.search('(.+)X|\d*',row[0])
prod_name = match.group(1)
match = re.search('(.+)X|\d*',row[1])
prod_short_description = match.group(1)
cmdb(cmdb.product_lang.id_product==row[3]).update(name=prod_name,
description_short=prod_short_description)


When I use row[1], I am starting to think that I am not getting back 
description_short. 

Is there a way that I can refer to the fields in the result by name rather 
than numeric position?

Thanks
Simon

-- 





[web2py] Re: executesql - referring to fields in result?

2012-10-17 Thread Massimo Di Pierro
You get a list of tuples unless you pass the fields or columns argument. In 
that case you get a Rows object.

On Wednesday, 17 October 2012 16:13:20 UTC-5, Simon Carr wrote:

 When I run a query using executesql, what is the object that is returned? 
 is it a dictionary?

 The reason I ask is that I am starting to think that the order of fields 
 being returned to me is not the order that I put them in the SQL statement. 
 As an example, I am running this code.

 def clean_qty():
 import re
 rows = cmdb.executesql(select name, description_short, description, 
 id_product from product_lang where name like '%X%' or description_short 
 like '%X%' or description like '%X%')
 for row in rows:
 match = re.search('(.+)X|\d*',row[0])
 prod_name = match.group(1)
 match = re.search('(.+)X|\d*',row[1])
 prod_short_description = match.group(1)
 cmdb(cmdb.product_lang.id_product==row[3]).update(name=prod_name,
 description_short=prod_short_description)


 When I use row[1], I am starting to think that I am not getting back 
 description_short. 

 Is there a way that I can refer to the fields in the result by name rather 
 than numeric position?

 Thanks
 Simon


-- 





[web2py] Re: unable to submit auth forms

2012-10-17 Thread Massimo Di Pierro
What is the code? Is this something that worked before? using a custom form?

On Wednesday, 17 October 2012 09:17:57 UTC-5, Rohan Malhotra wrote:

 Version 2.1.1 (2012-10-15 12:44:40) stable

 Hi,

 I am not able to submit an auth form. I am using default auth code. On 
 submitting the form, password is shown as invalid and 'enter from 0 to 
 512 characters' error is thrown. Input

 td class=w2p_fw
 input class=password invalidinput id=auth_user_password 
 name=password type=password 
 value=passwod_value_entered_before_submitting_form
 div class=error_wrapper
 div class=error id=password__error style=display: block;enter from 
 0 to 512 characters/div
 /div
 /td


 Please advice.

 Thanks


-- 





[web2py] Putting modified files into a separate directory?

2012-10-17 Thread Csillag
Hi,

I am learning web2py.
I have a simple web2py application, which consists of ~90 files.
I have modified only about 5-10 of them, the rest comes from the 'welcome' 
app.

When managing the project, if possible, I would like to avoid putting all 
the unmodified files under version control.
Is there a way to store the modified files separately, in a distinct 
directory, and use the rest from a standard location?

I could imagine a mechanism where at first, the customized directory is 
searched for required files, and if it's not found,
than the standard one... this way, I would only need to store the few files 
that I have modified, which would make it much easier to grasp the project.

(I think for example node.js has a somewhat similar feature, called 
node_modules, which makes it possible to search for files in several 
directories, see here: http://nodejs.org/docs/latest/api/modules.html )

Thank you for your help:

   Csillag

-- 





[web2py] File download permission

2012-10-17 Thread Hanyo
Hi,

i want to build a kind of web shop for file download. What I need is 
individual permission for each uploaded file vs. each user.

So far I see two ways of doing that:

The first way is to create auth_group for each user and add a permission 
tot hat group for each file whixh was bought by user.

The secon way is to greacte a group and a permisson  for each file and add 
users to the file group.

Which way is better? Is there eve better way than these two?

Best,
Hanyo

-- 





[web2py] Re: powerTable AttributeError: 'DAL' object has no attribute 'virtual'

2012-10-17 Thread Jacinto Parga Fernández
Thanks so much!!

El lunes, 8 de octubre de 2012 22:15:58 UTC+2, Massimo Di Pierro escribió:

 :-)

 On Monday, 8 October 2012 12:53:27 UTC-5, Don_X wrote:

 BINGO ! - IT WORKS LIKE A CHARM MASSIMO !!! ...  

 Thank you ... now  I can study this properly so I can adapt it to my app !

 On Monday, October 8, 2012 1:49:09 PM UTC-4, Massimo Di Pierro wrote:

 Now the error is at a different line. The previous error has been fixed. 
 Now it is at line 215:


 try:
 _id = record[keycolumntbl][keycolumnfld]
 except KeyError:


 as before it should be

 try:
 _id = record[keycolumntbl][keycolumnfld]
 except (KeyError, AttributeError):



 On Monday, 8 October 2012 12:39:09 UTC-5, Don_X wrote:

 For a more detailed report .. I have openned up the last line 
 pertaining to the plugin_powertable.py below :



- 
Function argument list   

()

Code listing



20.
21.
22.
23.
24.
25.

26.
27.
28.
29.

table.showkeycolumn = False
table.extra = dict(
   
 details={'detailscallback':URL('myfunction.load')}
   )

table = table.create()


return locals()

   Variables
 
tableStorage {'keycolumn': 'product.id', 'extra': {
'...te': function plugin_powertable at 0xa762e144}table.create
function plugin_powertable   
-   

*File /home/www-data/web2py/applications/powertable/
models/plugin_powertable.py in plugin_powertable at line 811*
code
arguments
variables   
Function argument list


()
  Code listing 

806.
807.
808.
809.
810.
811.

812.
813.
814.
815.

ifunctions=str(ifunctions),

 searchcolumnjs=str(searchcolumnjs)
)
  ),
CSS,
PowerTable(),

)


plugins.powerTable.create = plugin_powertable

Variables
global PowerTableclass '__restricted__.PowerTable'
- 
 

*File /home/www-data/web2py/applications/powertable/
models/plugin_powertable.py in __init__ at line 215*
code
arguments
variables   

Function argument list


(self=__restricted__.PowerTable object)
  Code listing



210.
211.
212.
213.
214.
215.

216.
217.
218.
219.

else:
_title = T('Record %s' % str(rc+1))

#setting the id and key for every tr based on required 
 keycolumn
try:
_id = record[keycolumntbl][keycolumnfld]

except KeyError:
if virtualfields:
_id = record[sqlrows.colnames[0].split('.')[0]].id
else:


   Variables
 
 recordRow {'description': 'LCD TV', 'quantity': 34, '...ter 
object at 0xa757f98c, 'name': 'Television'}_idundefined
keycolumntbl'product'keycolumnfld'id'
- 

*File /home/www-data/web2py/gluon/dal.py in __getitem__ 
at line 6376*
code
arguments
variables  
Function argument list


(self=Row {'description': 'LCD TV', 'quantity': 34, 
'...ter object at 0xa757f98c, 'name': 'Television'}, 
key='product')
Code listing  

6371.
6372.
6373.
6374.
6375.
6376.

6377.
6378.
6379.
6380.

elif m:
try:
return ogetattr(self, m.group(1))[m.group(2)]
except (KeyError,AttributeError,TypeError):
key = m.group(2)
return ogetattr(self, key)


def __setitem__(self, key, value):
setattr(self, str(key), value)

 Variables
   selfRow {'description': 'LCD TV', 'quantity': 34, 
 '...ter 
object at 0xa757f98c, 'name': 'Television'}global ogetattrslot 
wrapper '__getattribute__' of 'object' objectskey'product'





-- 





Re: [web2py] Re: cannot upgrade to 2.1.1 from GUI on Pythonanywhere

2012-10-17 Thread Nico Zanferrari
Hi Hansel.
I've just changed a single line of code in the default PA installation,
following rochacbruno suggestion on
https://groups.google.com/forum/#!msg/web2py/glJjRw-TLKU/AkmktM7XExYJ .
This allows everyone to simply upgrade by themselves to the latest version
from the web2py administrative console, if they wish so.

My suggestion is to implement ASAP this simple fix on all existing web2py
installations on PythonAnywhere, And from tomorrow you should use  version
2.1.1 as the new base install version of web2py, as Massimo pointed out.

Thank you,
Nico

-- 





[web2py] Re: File download permission

2012-10-17 Thread Massimo Di Pierro
For example only uploader can download:

db.define_table('stuff',Field('file','upload'),auth.signature)
db.stuff.file.authorize = lambda row: row.created_by==auth.user_id

You should be able to extend this to other policies. The policy will be 
enforced automatically by the download action.




On Wednesday, 17 October 2012 14:39:02 UTC-5, Hanyo wrote:

 Hi,

 i want to build a kind of web shop for file download. What I need is 
 individual permission for each uploaded file vs. each user.

 So far I see two ways of doing that:

 The first way is to create auth_group for each user and add a permission 
 tot hat group for each file whixh was bought by user.

 The secon way is to greacte a group and a permisson  for each file and add 
 users to the file group.

 Which way is better? Is there eve better way than these two?

 Best,
 Hanyo


-- 





[web2py] Re: web2py 2.1.1 is OUT!

2012-10-17 Thread Massimo Di Pierro
The line is:

from distutils import dir_util

I think you need to install distutils separately.


On Tuesday, 16 October 2012 09:14:47 UTC-5, apps in tables wrote:

 when i click on deploy to openshift , I get the error :

   cannot import name dir_util

 On Tuesday, October 16, 2012 2:17:43 PM UTC+3, Massimo Di Pierro wrote:

 As far as I know it works but I will say experimental until more people 
 have tried it.

 On Tuesday, 16 October 2012 04:07:37 UTC-5, apps in tables wrote:

 Thanks...

 is deploy to openshift experimental?

 On Tuesday, October 16, 2012 4:04:36 AM UTC+3, Massimo Di Pierro wrote:

 The book is now kind of in between versions it is correct but some 
 of the new features are not described and some example use old API while 
 there is a better way. I plan to finish update it and release the 5th 
 editions within one month. Hopefully sooner.

 On Monday, 15 October 2012 20:01:33 UTC-5, apps in tables wrote:


 Fantastic.as usual.

 tiny hint: 
 can the book title be more descriptive of the related version of 
 web2py ?


 On Monday, October 15, 2012 8:30:42 PM UTC+3, martzi wrote:

 Many thanks Massimo web2py is here to stay !

 On Monday, October 15, 2012 1:55:39 PM UTC+2, Massimo Di Pierro wrote:

 Changelog:

 - overall faster web2py
 - when apps are deleted, a w2p copy left in deposit folder
 - change in cron (it is now disabled by default). removed -N option 
 and introdu\
 ced -Y.
 - faster web2py_uuid() and request initialization logic, thanks 
 Michele
 - static asset management, thanks Niphlod
 - improved mobile admin
 - request.requires_https and Auth(secure=True), thanks Yarin and 
 Niphlod
 - better custom_import (works per app and is faster), thanks Michele
 - redis_sesssion.py, thanks Niphlod
 - allow entropy computation in IS_STRONG and web2py.js, thanks 
 Jonathan and Nip\
 hlod
 - fixed many aith.wiki problems
 - support for auth.wiki(render='html')
 - better welcome layout, thanks Paolo
 - db.define_table(...,redefine=True)
 - DAL, Row, and Rows object can now be pickled/unpickled, thanks to 
 zombie DAL.
 - admin uses codemirror
 - allow syntax auth = Auth(db).define_tables()
 - better auth.wiki with preview, thanks Alan
 - better auth.impersonate, thanks Alan
 - upgraded jQuery 1.8
 - upgraded Bootstrap 2.1
 - fixed problems with dropbox_account.py
 - many fixes to cache.ram, cache.disk, memcache and gae_memcache
 - cache.with_prefix(cache.ram,'prefix')
 - db.table.field.epoch() counts seconds from epoch
 - DAL support for SQL CASE, example: 
 db().select(...query.case('true','false))
 - DAL(...,do_connect=False) allows faking connections
 - DAL(...,auto_import=True) now retieves some fiel attributes
 - mail can specify a sender: mail.send(...,sender='Mr X 
 %(sender)s')
 - renamed gluon/contrib/comet_messaging.py - 
 gluon/contrib/websocket_messaging.py

 Please check it and report any problem.
 As usual, thanks to the many people who have contributed, in 
 particular Michele and Niphlod.

 Massimo



-- 





[web2py] pythondiary

2012-10-17 Thread Massimo Di Pierro
http://www.pythondiary.com/reviews/web2pyV2.0.html

-- 





Re: [web2py] Re: Reloading modules stops working after some time ...

2012-10-17 Thread Richard Vézina
I do notice the same problem here and it drive me crazy... I suspect that,
but since it seems to be intermittent, I wasn't sure...

I did what you ask and I get True all the time, but the change I had made
to module never been applied when page render.

Richard


On Mon, Oct 15, 2012 at 4:58 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Can you do

 from gluon.custom_import import *
 track_changes(True)
 print is_tracking_changes()

 does it print True all time? It should.




 On Monday, 15 October 2012 15:43:49 UTC-5, David Marko wrote:

 Using the latest trunk ... Updated today

  --





-- 





[web2py] delete on GAE

2012-10-17 Thread howesc
Hi all,

I'm trying to clean up old expired sessions.but i waited a long time to 
get to this and now my GAE delete is just timing out.  Reading the GAE 
docs, there appears to be some improvements that we can make to the query 
delete method on GAE that will make it faster and cheaper.  what we lose 
then is the count of the number of rows deleted.

my question is, does having a db(db.table.something==True).delete() that 
does not return a count break the web2py API contract, or break anyone's 
applications?

thanks,

christian

-- 





[web2py] Re: executesql - referring to fields in result?

2012-10-17 Thread Simon Carr
many thanks Massimo,

I had not upgraded (still on 1.x) so the fields option was not available. I 
just did the upgrade and everything now works fine.

On Wednesday, 17 October 2012 22:16:51 UTC+1, Massimo Di Pierro wrote:

 You get a list of tuples unless you pass the fields or columns argument. 
 In that case you get a Rows object.

 On Wednesday, 17 October 2012 16:13:20 UTC-5, Simon Carr wrote:

 When I run a query using executesql, what is the object that is returned? 
 is it a dictionary?

 The reason I ask is that I am starting to think that the order of fields 
 being returned to me is not the order that I put them in the SQL statement. 
 As an example, I am running this code.

 def clean_qty():
 import re
 rows = cmdb.executesql(select name, description_short, description, 
 id_product from product_lang where name like '%X%' or description_short 
 like '%X%' or description like '%X%')
 for row in rows:
 match = re.search('(.+)X|\d*',row[0])
 prod_name = match.group(1)
 match = re.search('(.+)X|\d*',row[1])
 prod_short_description = match.group(1)
 cmdb(cmdb.product_lang.id_product==row[3]).update(name=prod_name,
 description_short=prod_short_description)


 When I use row[1], I am starting to think that I am not getting back 
 description_short. 

 Is there a way that I can refer to the fields in the result by name 
 rather than numeric position?

 Thanks
 Simon



-- 





[web2py] Re: proposal: change SQLFORM delete checkbox handling

2012-10-17 Thread howesc
i don't mind the functionality change, though i'll admit that i often 
forget to update web2py_ajax.html and web2py.js on upgrade.  if you add a 
note to the release that contains this to help remind me that would be 
helpful. :)

On Tuesday, March 23, 2010 6:30:10 AM UTC-7, mdipierro wrote:

 The only problem I see but needs testing is what happens to an
 existing app that uses the new SQLFORM with the existing
 web2py_ajax.html code? Send me a patch and I will try it.

 On Mar 23, 12:02 am, Jonathan Lundell jlund...@pobox.com wrote:
  At the moment, there's a delete-confirmation checkbox that's turned on 
 when an SQLFORM is 'deletable'. It's a simple checkbox with class='delete', 
 along with this bit of code in web2py_ajax.html:
 

 jQuery(input[type='checkbox'].delete).each(function(){jQuery(this).click(function()
  
 { if(this.checked) if(!confirm({{=T('Sure you want to delete this 
 object?')}})) this.checked=false; });});
 
  It presents the user with a dialog, and if the use doesn't OK the 
 dialog, the box isn't checked and no delete occurs on submit.
 
  This logic serves at least two purposes. One, it's a workaround for the 
 problem that having multiple submit buttons is problematical with IE. Two, 
 it forces the user to take three actions to delete a record: check the box, 
 confirm the deletion, and click submit.
 
  I have to alternative suggestions.
 
  One is to move the above jQuery logic into a simple 'onclick' attached 
 to the checkbox by SQLFORM. This gets rid of the jQuery requirement (with 
 no loss of functionality), but more important it allows us to have an 
 option to SQLFORM.__init__() to override the text associated with the 
 confirmation. 'Sure you want to delete this object?' is somewhat 
 idiosyncratic English to begin with, but the main problem is that usually 
 we'd like to be more specific than this object. Depending on the record, 
 we might say this item or this item in your cart or this user or any 
 number of things.
 
  I see no downside to this. It's compatible, and the default action is 
 identical to the current mechanism.
 
  Alternative: change the delete checkbox to a 'button' element labeled 
 'Delete'. Use onclick to attach a confirmation dialog to the button. If the 
 user confirms, do a submit of the form, but set a hidden variable in the 
 form to communicate the delete action to accepts. This avoids the IE 
 problem (there's only one submit button).
 
  Downsides: the UI changes a checkbox to a Delete button, and JavaScript 
 is required to do a delete at all.


-- 





[web2py] Re: pythondiary

2012-10-17 Thread Luther Goh Lu Feng
Great and balanced review imho. Submitted to 
HN http://news.ycombinator.com/item?id=4666756

On Thursday, October 18, 2012 5:58:24 AM UTC+8, Massimo Di Pierro wrote:

 http://www.pythondiary.com/reviews/web2pyV2.0.html


-- 





[web2py] Re: tags and speed

2012-10-17 Thread howesc
what database are you using?  you might need to add a custom index to your 
database.

try using db._lastsql to see the SQL that web2py executed, and then use the 
explain query plan feature of your database to look for possible index(es) 
to add.

cfh

On Wednesday, October 17, 2012 2:09:17 AM UTC-7, andrej burja wrote:

 hi

 i have table games and they have tags
 i followed the example in the book and put tags in separate table

 now i want to show all games with all tags in the view: game.title, 
 games.instruction, game.tags
 in fuction i have
 for game in games:
 equipment =[tag.name for tag in db(db.tag.game_id==game.id
 ).select()]
 game.f_equipment =', '.join(equipment)

 having more than 1000 games (games is row object with more than 1000 
 entries), this is very slow. how can i make that faster?

 andrej



-- 





[web2py] Passing pyodbc timeout argument for a specific request.

2012-10-17 Thread chris_g
I'm using SQL Server with pyodbc on Linux. ( Web2py 1.99.7 )
I have been trying to force a database timeout in certain methods in my 
controller.

I added the following conditional to models/db.py  

db_connection_string='mssql://dbuser:pwd@dbserver/DB?DRIVER=FreeTDS'
if request.function == 'test_wait':
db = DAL(db_connection_string, migrate=migrate, 
driver_args=dict(timeout=3))
else:
db = DAL(db_connection_string, migrate=migrate, pool_size=100)

and this method to my controller:

def test_wait():
db.executesql(WAITFOR DELAY '00:00:30')
return 'OK'

I had presumed that the timeout argument would be passed to pyodbc.connect 
and I get a timeout error raised. Instead I am seeing 'OK' returned.

Is there a better way to enforce a query timeout?

Chris Guest


-- 





[web2py] Re: Odd behavior with domain routes. Can't undo them.

2012-10-17 Thread HittingSmoke
Thanks! For whatever reason Reload Routes won't work, but restarting the 
server did.

On Tuesday, October 16, 2012 11:49:14 PM UTC-7, Anthony wrote:

 Yes, if you change routes.py, you must either reload routes (which you can 
 do from the admin interface) or restart the webserver.

 Anthony

 On Wednesday, October 17, 2012 12:09:51 AM UTC-4, HittingSmoke wrote:

 I set up my Webfaction hosting with a single web2py install that I intend 
 to use for a couple of subdomains pointing to separate apps using routes.py.

 I pointed domain.com and blog.domain.com to my web2py app and through 
 routes.py told web2py to point blog.domain.com to my blog app that I 
 plan on writing. Right now it's just a default scaffolding app. Here is the 
 code in my routes.py file:

 routers = dict(
 BASE = dict(
 domains = {
 'blog.domain.com' : 'blog',
 }
 )
 )

 So... this worked great, until I tried to undo it for some 
 troubleshooting purposes. I commented out all the code in routes.py. 
 blog.domain.com still points to my blog app instead of my default web2py 
 app (currently Welcome). I renamed routes.py, blog.domain.com still 
 points to the blog app.

 I thought maybe this was some new default behavior where if a subdomain 
 is used with the same name as an app it will point to the app. I made a new 
 app and a subdomain of the same name and pointed it to my web2py app. This 
 one points to the default Welcome app as expected.

 So what is the deal here? Is there some cache of routes.py that I need to 
 clear to return a domain route back to default?



-- 





[web2py] How to access the auth tables in appadmin?

2012-10-17 Thread mikech
I'm working thru the book again, and when I get to the image tutorial it 
mentions adding a manager group to the auth tables in appadmin: 

Using appadmin create a group manager and make some users members of the 
group. They will not be able to access  

I cannot find where this is, when I bring up the appadmin it just shows the 
two tables of the application - image and comment.

-- 





[web2py] Looking for a tutor

2012-10-17 Thread mikech
I would be interested in hooking up with someone for some tutoring online 
for pay of course.  Anyone interested?  I'm in California so a similiar 
time zone would be best.

Mike

-- 





[web2py] response.flash during login - backward compatibility issue

2012-10-17 Thread weheh
I use a non-standard login where I user auth.settings.login_onaccept to 
complete the login process.

Prior to upgrading to web2py 2.1.1, my login response.flash would display

Welcome so and so.

now, it displays

Welcome%20so%20and%20so

I think something downstream in web2py changed because I didn't change my 
code. How to modify to get rid of the %20s?

My app's response.flash = DIV(T(...), _class='...'), so there's nothing 
special there. Looks like maybe there's a strict XML downstream ... just 
guessing.

-- 





Re: [web2py] easy way to validate a list of emails?

2012-10-17 Thread Adnan Smajlovic
thank you villas. that one is good too!

On Wed, Oct 17, 2012 at 3:13 PM, villas villa...@gmail.com wrote:

 For more unstructured addresses,  I also find this useful:
 http://docs.python.org/library/email.util.html
 I use parseaddr.

  --



-- 





[web2py] Re: response.flash during login - backward compatibility issue

2012-10-17 Thread weheh
I'm now seeing this in other cases, so it's not isolated to login.

-- 





[web2py] Re: tags and speed

2012-10-17 Thread Massimo Di Pierro
You do 1000 selects in that code. I would use a join. What is the purpose 
of that code? I am sure there is a better way.

On Wednesday, 17 October 2012 04:09:17 UTC-5, andrej burja wrote:

 hi

 i have table games and they have tags
 i followed the example in the book and put tags in separate table

 now i want to show all games with all tags in the view: game.title, 
 games.instruction, game.tags
 in fuction i have
 for game in games:
 equipment =[tag.name for tag in db(db.tag.game_id==game.id
 ).select()]
 game.f_equipment =', '.join(equipment)

 having more than 1000 games (games is row object with more than 1000 
 entries), this is very slow. how can i make that faster?

 andrej



-- 





Re: [web2py] Re: tags and speed

2012-10-17 Thread Bruno Rocha
I am using list:string for tags and it is working very well for my needs.

-- 





[web2py] Re: How to access the auth tables in appadmin?

2012-10-17 Thread Bill Thayer
Try this:
In db.py:
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()

auth.define_tables(username=True) # arg makes it so you can use a username 
instead of email to login



On Wednesday, October 17, 2012 6:20:48 PM UTC-5, mikech wrote:

 I'm working thru the book again, and when I get to the image tutorial it 
 mentions adding a manager group to the auth tables in appadmin: 

 Using appadmin create a group manager and make some users members of 
 the group. They will not be able to access  

 I cannot find where this is, when I bring up the appadmin it just shows 
 the two tables of the application - image and comment.


-- 





Re: [web2py] Re: Reloading modules stops working after some time ...

2012-10-17 Thread weheh
I experienced this issue with the 1.99 series web2py. Not enough experience 
with 2.1.1 to say for sure if it's still there. However, with 2.1.1, when I 
insert print is_tracking_changes() I always see True. Will report any 
inconsistencies if I see them in the future.

On Thursday, October 18, 2012 6:02:23 AM UTC+8, Richard wrote:

 I do notice the same problem here and it drive me crazy... I suspect that, 
 but since it seems to be intermittent, I wasn't sure...

 I did what you ask and I get True all the time, but the change I had made 
 to module never been applied when page render.

 Richard


 On Mon, Oct 15, 2012 at 4:58 PM, Massimo Di Pierro 
 massimo@gmail.comjavascript:
  wrote:

 Can you do

 from gluon.custom_import import *
 track_changes(True)
 print is_tracking_changes()

 does it print True all time? It should.




 On Monday, 15 October 2012 15:43:49 UTC-5, David Marko wrote:

 Using the latest trunk ... Updated today

  -- 
  
  
  




-- 





[web2py] Re: Reloading modules stops working after some time ...

2012-10-17 Thread Donatas Burba
I have noticed another issue. With version 2.1.1 I can't use appy.pod 
anymore. It means I can generate only one pdf file, every other try gives 
me error (that I'm using python which can't access uno). I think that 
problem is in custom_import.py, so I was forced to return back to 2.0.9, 
where appy.pod works perfectly.

-- 





Re: [web2py] Re: powerTable AttributeError: 'DAL' object has no attribute 'virtual'

2012-10-17 Thread tomt
After a little digging around on the web  I found out why I was powertable 
was generating errors with the latest web2py.

jquery version 1.8 requires jquery-ui-1.8.22

I went to http://jqueryui.com/ and downloaded legacy v1.8.24 which provided 
jquery-ui-1.8.24.custom.zip. This zip file included 
jquery-ui-1.8.24.custom.min.js which I then copied to 
static/plugin_powertable/ui/js
I modified models/powertable.py to load it:
response.files.append(URL(r=request,c='static',f='plugin_powertable/ui/css/%s/jquery-ui-1.8.24.custom.css'
 
% theme))

After taking these steps, the error messages are gone and now powertable 
works with no problems.



On Sunday, October 14, 2012 9:10:17 PM UTC-6, tomt wrote:

 I noticed another problem with powertable and web2py 2.0.9

 When I created a new app under web2py 2.0.9 and tried to implement a 
 powertable it exhibited some unusual behaviour. On initial callup, the 
 powertable showed all records instead of the number specified by 
 iDisplayLength and the columns don't show the column sorting icon. Also the 
 column id is displayed even though table.showkeycolumn = False

 Firebug showed an error in plugin_powertable/jquery.dataTables.min.js: 
 detailed error: TypeError: a.charCodeAt is not a function

 I discovered that if I replaced /static/js/jquery.js with version v1.7.1 
 from an earlier version of web2py, all the powertable problems disappeared.

 Web2py 2.0.9 uses jQuery v@1.8.0 which apparently triggers the problem 
 with powertable.  Earlier versions of web2py used jQuery v1.7.1 which seems 
 to work ok with powertable.

 I'm wondering if I can make powertable work if I use a more recent version 
 of datatables?  Which files from the datatables would I have to 
 incorporate? Any suggestions?

 - Tom




 On Monday, October 8, 2012 5:42:46 PM UTC-6, rochacbruno wrote:

 Thanks, I will update the repo. 



-- 





[web2py] problem with logic in a function

2012-10-17 Thread Annet
I have a database containing nodes being either an organization or a 
person. These organizations and people can register for plan 1, 2, 3 or 4. 
When they register for plan 2 or 4, I have to enter a node being a hub 
before registering them as users. This is the function:

def register():
# get the registration form
row=db(db.register.id==request.args(0)).select(db.register.ALL).first()
# find out who wants to register, an organization or a person
if row.cocNumber and row.subdossierNumber:

id=organization.nodeID
elif row.lastName and row.birthday:
...
id=person.nodeID
# in case  the database doesn't contain the organization or person
else:
session.flash=''
redirect(URL('register'))
# find out if the organization or person wants to register for a hub
if row.hub:
ownerID=id
hub=db(db.hub.name==row.hub).select(db.hub.ALL).first()
if hub:
session.flash='The database already contains a hub named ' + 
str(row.hub)
redirect(URL('register'))
else:
id=db.node.insert()

db.hub.insert(nodeID=id,ownerID=ownerID,name=row.hub,label='Onbekend')
...
form=SQLFORM.factory(db.auth_user,ignore_rw=True,separator='')
# here I prepopulate the form based on row.field
if form.process(keepvalues=False).accepted:
...
elif form.errors:
response.flash=response_flash('formerror',session)
elif not response.flash:
response.flash='...' 
return dict(form=form)

This form is being processed correctly when an organization or person 
registers, however, when an organization or person registers for a hub, 
these lines are executed first:

else:
id=db.node.insert()
db.hub.insert(nodeID=id,ownerID=ownerID,name=row.hub,label='Onbekend')

then the form displays containing the correct value for nodeID (the id 
returned by the insert), but when I submit the form instead of making all 
the database inserts (as when an organization or person registers) the 
flash is being set to: 'The database already contains a hub named ' + 
str(row.hub) an no records are inserted.

I don't see what's wrong with my logic, I hope you do, the issue is keeping 
me awake at night :-(


Best regards,

Annet

--