[web2py] Re: Need to save a multipage PDF

2012-11-21 Thread LightDot
This group is a wealth of information for other users, so when you can, 
please do post what is it that you've figured out. :)

It's highly likely someone will have the same or similar problem and search 
for answers.

Regards,
Ales

On Wednesday, November 21, 2012 6:36:04 AM UTC+1, Paul Rykiel wrote:

 Nevermind ... figured it out
 On Tuesday, November 20, 2012 3:06:22 PM UTC-6, Paul Rykiel wrote:

 Greetings everyone,
  
 this is my code and I am having difficulity creating a Multipage PDF to 
 save to a directory.
 any assistance will be welcomed.
  
 Regards,
  
 def taggen_print():
 rows = db(db.bike_no.id  0).select()
 for row in rows:
tag_no = row.bike_typ+str(row.id)
pfile = tag_no+'_p.pdf'
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 14)
pdf.cell(40,10,tag_no)
pdf.output(name=request.folder + '/static/temp.pdf')
 response.headers['Content-Disposition']='attachment.filename =' + 
 pfile
 response.headers['Content-Type']='application/pdf'
 return response.stream(open(request.folder+'/static/temp.pdf', 
 'rb'),chunk_size=4096)
 #  pdf.output(pfile, 'F')
 redirect(URL(index))   
  
 right now it only saves the PDF for the last record... I need it to 
 create a page for each record and save it in PDF format in the directory



-- 





[web2py] Re: I need a bit of Help with a function ! .. please ...

2012-11-21 Thread lyn2py
Use 
auth.user_id
instead.

def index():
   if auth.is_logged_in():
   redirect(URL('profile', 'member',args=auth.user_id))



On Wednesday, November 21, 2012 12:24:17 PM UTC+8, Don_X wrote:

 In an app where users have their own profile page !
 Once a user gets logged in with their credentials .. they get redirected 
 to their own profile page with all of their edit functions and preferences 
 etc ...  ... OK ! all was good so far ... BUT

 when the user is browsing through the app, I want that same user to be 
 able to view other users' profile pages... if he wants to . !
  so I am tweaking my previous function to do that without having to 
 replicate the same profile page so the logged in user can view  other 
 users'profile page !

 so I have a setup similar to this now :

 the user gets logged in and that user gets redirected to 
 ('profile','index')  i.e. ( controller, function )
 in the profile.py controller,   I  have set up a new function index is as 
 follows :
 def index():
redirect(URL('profile', 'member',args=' '))

 Where the args, which is empty by default at first, would be the user's id 
 !

 ( that way : all links to other user's profile would be written like : 
 {{=URL('profile','member',args=auth_user.id http://auth_user.id)}} on 
 any given page for any given user listed with their respective ids  on the 
 site )

 now, I am having some trouble with the member function
 basically, I want this member function to do the following :

 if the logged in user id  is the same as args  then return the logged in 
 user  row ( member )
 if not then return the row of the user id equal to args (member)  from the 
 database

 and obviously, in the profile page itself, I will do validation such as if 
 member == to loggged in user then they can edit, do stuff they can do on 
 their own profile etc ...  and if not ... then they cannot edit that other 
 user's profile's etc ...

  you get the idea ! so : ... I am not sure if my logic is fine through 
 these lines of python code for that member function :

 def member():
 response.view = 'profile/index.html'
 member = session.get(auth,{})
 if member.id == auth_user[args] :
 return dict(member=member)
 else : 
 for row in db(db.auth_user.id == args).select():
 member = row  
 return dict(member=member)


 I would think it would work .. but does not ! ... Can any one can 
 enlighten me with this !!

 thank you

 Don



-- 





[web2py] Re: type 'exceptions.SyntaxError' Set: no tables selected

2012-11-21 Thread Amit
I have done slight changes in the code and its working for select() 
statement but still facing problem in case of delete():

code:

def test():

query = request.vars['keywords']

if query:
print query
row =str(db(query).select(db.status.ALL))
if row:
print row
redirect(URL('status'))

In this case query string is : *status.id = 12*
So I am getting result properly, but problem is:
 if I remove *db.status.ALL* from select() statement , it again gives the 
same error : 
*type 'exceptions.SyntaxError' Set: no tables selected*


Same applies for delete() statement, even for delete we can't specify the 
database table name as a parameter like select().



On Wednesday, 21 November 2012 12:01:08 UTC+5:30, Amit wrote:

 I have added button Delete beside Clear button on SQLFORM.grid and when 
 user selects query and click on it , I am passing the query to my 
 controller function and using regular expression I just prepending db. 
 and changing = to == and passing the query to the db() function but it 
 throws SyntaxError : Set: no tables selected.

 Please check below the code:

 def status():
 
 grid = SQLFORM.grid(db.status)
 
 grid[0][1][1].components.append(TAG.a('Delete',_id=px-delete,\
   _class 
 =btn,_onclick=window.location 
 = ' \
   + URL('default','test')+?+ '+ 
 $('#web2py_keywords').serialize();\
))
 
 return locals()


 def test():
 
 query = request.vars['keywords']
 
 if query:
 modfied_query = re.sub(r'(status)', r'db.\1', query)
 final_query = re.sub(r'(=)', r'=\1', modfied_query)   
  
 row =db(final_query).select().first()
 if row:
 print row
 redirect(URL('status'))

 here, status is the grid view where I added the Delete button and after 
 query selection If I click button , I am able to get the query like 
 status.id = 12, I changed it using regex to db.status.id == 12 and 
 passing the final string to db() function , please check test() function.

 I am getting error on the below statement:

 *row **=db(final_query).select().first()*

 where final_query value will be db.status.id == 12.

 But if I use the same query like this:

 *row =db(db.status.id == 12).select().first()*

 it works fine.

 So not sure what I am doing wrong on the passing string as query.



-- 





[web2py] Re: perhaps a silly question about index

2012-11-21 Thread lyn2py
You can remap this using routes.py

Details on how to use it is available here:
http://web2py.com/books/default/chapter/29/04#URL-rewrite

On Tuesday, November 20, 2012 9:44:37 PM UTC+8, Brian Blais wrote:

 Hello, 

 I was just started using web2py, and came across this organizational 
 question.  It seems as if the default application points to 

 http://127.0.0.1:8000/appname/default/index 

 why doesn't it point to: 

 http://127.0.0.1:8000/appname/index 

 Is there a reason to have the controllers all in default.py, or is there 
 some reason to have certain controllers in default.py and others not?  When 
 you want to point to your actual app, I will want to give a url that is 
 http:///appname/ 

 not with the /default/ in it.  Is that remapped later? 

 thanks, and I hope this isn't too silly a question! 


 Brian Blais 


 -- 
 Brian Blais 
 bbl...@gmail.com javascript: 
 http://web.bryant.edu/~bblais 
 http://brianblais.wordpress.com/ 





-- 





[web2py] Re: REF: SQLFROM.grid

2012-11-21 Thread lyn2py
To have the buttons, EITHER use user_signature=False (which means data can 
be edited without login) OR log into an account that has permissions to 
access the page (which means user_signature defaults to True). Use the 
latter where possible.

On Wednesday, November 21, 2012 3:33:53 PM UTC+8, software.ted wrote:

 ...Okey can someone explain what the user_signature=False switch...adding 
 it to the grid changes everything and all buttons appear..changing it like 
 so..

 form = SQLFORM.grid(db.department,
searchable=True,
deletable=True,
details=True,
selectable=False,
csv=False, user_signature=False)


 On Wed, Nov 21, 2012 at 7:51 AM, Teddy Nyambe 
 softwa...@gmail.comjavascript:
  wrote:

 Hey all,

 Having trouble using SQLFORM.smartgrid/grid...this is how my controller 
 looks like:
 def myfiles():
 response.title= Files in the system 
 grid = SQLFORM.grid(db.myfile,deletable=True, editable=True, 
 details=False,create=True, csv=False)
 return dict(grid=grid)

 My view:

 {{extend 'layout.html'}}
 h1Files/h1
 {{=grid}}

 The problem is the buttons for add, delete, edit are not appearing. What 
 attribute am I missing?

 Teddy L.
 -- 

 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is 
 all - Thomas Carlyle 1795-1881

 /~
  



 -- 

 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is 
 all - Thomas Carlyle 1795-1881

 /~
  

-- 





Re: [web2py] Re: Need to save a multipage PDF

2012-11-21 Thread Javier Pepe
Try this:

def taggen_print():
*pdf = FPDF()*
rows = db(db.bike_no.id  0).select()
for row in rows:
   tag_no = row.bike_typ+str(row.id)
   pfile = tag_no+'_p.pdf'
   pdf.add_page()
   pdf.set_font('Arial', 'B', 14)
   pdf.cell(40,10,tag_no)
*   pdf.AddPage()*
*pdf.output(name=request.folder + '/static/temp.pdf')*
response.headers['Content-Disposition']='attachment.filename =' + pfile
response.headers['Content-Type']='application/pdf'
return response.stream(open(request.folder+'/static/temp.pdf',
'rb'),chunk_size=4096)
#  pdf.output(pfile, 'F')
redirect(URL(index))


On Wed, Nov 21, 2012 at 5:18 AM, LightDot light...@gmail.com wrote:

 This group is a wealth of information for other users, so when you can,
 please do post what is it that you've figured out. :)

 It's highly likely someone will have the same or similar problem and
 search for answers.

 Regards,
 Ales


 On Wednesday, November 21, 2012 6:36:04 AM UTC+1, Paul Rykiel wrote:

 Nevermind ... figured it out
 On Tuesday, November 20, 2012 3:06:22 PM UTC-6, Paul Rykiel wrote:

 Greetings everyone,

 this is my code and I am having difficulity creating a Multipage PDF
 to save to a directory.
 any assistance will be welcomed.

 Regards,

 def taggen_print():
 rows = db(db.bike_no.id  0).select()
 for row in rows:
tag_no = row.bike_typ+str(row.id)
pfile = tag_no+'_p.pdf'
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 14)
pdf.cell(40,10,tag_no)
pdf.output(name=request.folder + '/static/temp.pdf')
 response.headers['Content-**Disposition']='attachment.**filename ='
 + pfile
 response.headers['Content-**Type']='application/pdf'
 return response.stream(open(request.**folder+'/static/temp.pdf',
 'rb'),chunk_size=4096)
 #  pdf.output(pfile, 'F')
 redirect(URL(index))

 right now it only saves the PDF for the last record... I need it to
 create a page for each record and save it in PDF format in the directory

  --





-- 





Re: [web2py] Unsigned int in DAL

2012-11-21 Thread Joseph Piron
Finally I will go with something hand made but would be great to think on this 
:)
Just a thing, in mysql unsigned exists, that's one of the column properties.

On 17 Nov 2012, at 15:57, Niphlod wrote:

 ps: checked a little and probably found out because web2py doesn't have a 
 default type for unsigned ints.
 
 SQLite -- unsigned integer doesn't exist. Only integer
 Postgresql -- same as above
 MSSQL -- same as above
 Oracle -- can be used in t-sql only, so, for table columns no support
 Mysql -- supported
 Firebird -- supported
 
 
 
 -- 
  
  
  

-- 





Re: [web2py] Re: we should support this in DAL

2012-11-21 Thread Niphlod
that is exactly the explanation of the term experimental.
The problem as always is that if noone starts to test it, it will be in 
this way forever.

On Tuesday, November 20, 2012 11:25:59 PM UTC+1, Simon Ashley wrote:

 The bottom line seems to be that we/ others need to start to use nosql 
 engines to sort the issues. 
 My guess is that, currently, critical mass is not present to rely on it 
 for production sites.



-- 





[web2py] Re: Existing MySQL database

2012-11-21 Thread Niphlod
you can use 
https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py 
to extract models from your existing tables or just define your tables with 
migrate=False to be able to access to those.
Also, check this section 
http://web2py.com/books/default/chapter/29/06#Legacy-databases-and-keyed-tables

On Tuesday, November 20, 2012 10:02:30 PM UTC+1, Dennis Mackin wrote:

 I have an existing MySQL data with some existing tables. I'd like to use 
 gluon.dal to insert data into these tables.  How do I do it? It seem dal 
 only parses tables that it creates. I'm looking for a method names 
 something like load_schema.

 I can use the _mysql module instead, but I plan to use the database with 
 web2py so I'd rather use a single database connection module. 

 Thank you.


-- 





Re: [web2py] Unsigned int in DAL

2012-11-21 Thread Niphlod


 Finally I will go with something hand made but would be great to think on 
 this :) 
 Just a thing, in mysql unsigned exists, that's one of the column 
 properties. 

 
who said the opposite ? the thing is, it's just mysql and firebird that the 
support can be added, it's a small list compared to all engines dal 
supports.
 

 On 17 Nov 2012, at 15:57, Niphlod wrote: 

  ps: checked a little and probably found out because web2py doesn't have 
 a default type for unsigned ints. 
  
  SQLite -- unsigned integer doesn't exist. Only integer 
  Postgresql -- same as above 
  MSSQL -- same as above 
  Oracle -- can be used in t-sql only, so, for table columns no support 
 * Mysql -- supported *
  Firebird -- supported 



-- 





[web2py] Re: Login error messages

2012-11-21 Thread Niphlod
auth.settings.hideerror ?

On Wednesday, November 21, 2012 1:22:46 AM UTC+1, Daniele wrote:

 For some reason, I am not getting the right error messages to display on 
 my login form.
 Right now, I'm getting the same errors that one should get upon 
 registration, such as:

 Minimum length is 8
 Must include at least 1 upper case
 Must include at least 1 number

 However, this is giving away too many clues for a mere login. I just want 
 the message to say password or email incorrect or something along those 
 lines. How can I do this?


-- 





[web2py] Re: type 'exceptions.SyntaxError' Set: no tables selected

2012-11-21 Thread Amit
Fixed :).

using smart_query:

db.smart_query([db.status],query).delete()

where query is in string format.

On Wednesday, 21 November 2012 15:23:44 UTC+5:30, Amit wrote:

 I have done slight changes in the code and its working for select() 
 statement but still facing problem in case of delete():

 code:

 def test():
 
 query = request.vars['keywords']
 
 if query:
 print query
 row =str(db(query).select(db.status.ALL))
 if row:
 print row
 redirect(URL('status'))

 In this case query string is : *status.id = 12*
 So I am getting result properly, but problem is:
  if I remove *db.status.ALL* from select() statement , it again gives the 
 same error : 
 *type 'exceptions.SyntaxError' Set: no tables selected*


 Same applies for delete() statement, even for delete we can't specify the 
 database table name as a parameter like select().



 On Wednesday, 21 November 2012 12:01:08 UTC+5:30, Amit wrote:

 I have added button Delete beside Clear button on SQLFORM.grid and when 
 user selects query and click on it , I am passing the query to my 
 controller function and using regular expression I just prepending db. 
 and changing = to == and passing the query to the db() function but it 
 throws SyntaxError : Set: no tables selected.

 Please check below the code:

 def status():
 
 grid = SQLFORM.grid(db.status)
 
 grid[0][1][1].components.append(TAG.a('Delete',_id=px-delete,\
   _class 
 =btn,_onclick=window.location 
 = ' \
   + URL('default','test')+?+ '+ 
 $('#web2py_keywords').serialize();\
))
 
 return locals()


 def test():
 
 query = request.vars['keywords']
 
 if query:
 modfied_query = re.sub(r'(status)', r'db.\1', query)
 final_query = re.sub(r'(=)', r'=\1', modfied_query) 

 row =db(final_query).select().first()
 if row:
 print row
 redirect(URL('status'))

 here, status is the grid view where I added the Delete button and after 
 query selection If I click button , I am able to get the query like 
 status.id = 12, I changed it using regex to db.status.id == 12 and 
 passing the final string to db() function , please check test() function.

 I am getting error on the below statement:

 *row **=db(final_query).select().first()*

 where final_query value will be db.status.id == 12.

 But if I use the same query like this:

 *row =db(db.status.id == 12).select().first()*

 it works fine.

 So not sure what I am doing wrong on the passing string as query.



-- 





[web2py] Re: posts being deleted again?

2012-11-21 Thread dhmorgan
seems last week someone commented it happened to him; not for me since 
Sep.29

On Tuesday, November 20, 2012 9:07:02 PM UTC-6, Dave wrote:

 I posted three replies to this thread:

 https://groups.google.com/forum/?fromgroups=#!topic/web2py/Z7ZoN6Bn6pU

 And all three have shown up as deleted.  I know Anthony and Massimo have 
 said in the past they don't delete posts.  Have other people seen this 
 phantom post stealing ghost in Google Groups come back recently?


-- 





[web2py] Referring to a table to populate a drop down in a FORM

2012-11-21 Thread Tim Richardson
I have a simple FORM to collect some parameters from the user. 
I want one of the fields to be populated by values in a table (like the 
normal dropdown on an SQLFORM). 
I bet there is an easy way to do this, but I haven't found it.


-- 





[web2py] Re: Referring to a table to populate a drop down in a FORM

2012-11-21 Thread Niphlod
SQLFORM.factory(Field('mydropdown', requires=IS_IN_SET(('a','b','c'

On Wednesday, November 21, 2012 12:47:59 PM UTC+1, Tim Richardson wrote:

 I have a simple FORM to collect some parameters from the user. 
 I want one of the fields to be populated by values in a table (like the 
 normal dropdown on an SQLFORM). 
 I bet there is an easy way to do this, but I haven't found it.




-- 





[web2py] Re: Referring to a table to populate a drop down in a FORM

2012-11-21 Thread Tim Richardson


On Wednesday, 21 November 2012 22:56:43 UTC+11, Niphlod wrote:

 SQLFORM.factory(Field('mydropdown', requires=IS_IN_SET(('a','b','c'


Thanks. 
for my future reference, this code below does exactly what I want. 
 
  
Field('Commission_set',requires=IS_IN_DB(db1,db1.com_general_settings.id,'%(cmsn_set)s
 
%(cmsn_set_desc)s')) 

I haven't used SQLFORM.factory before. Looks like I lose the functionality 
of keepvalues=True

-- 





[web2py] Re: Referring to a table to populate a drop down in a FORM

2012-11-21 Thread Tim Richardson



 I haven't used SQLFORM.factory before. Looks like I lose the functionality 
 of keepvalues=True

No, I was wrong.

  if form.process(keepvalues=True).accepted:
 

-- 





[web2py] Re: Login error messages

2012-11-21 Thread Daniele
Hiding the error is not my point. I want an error message when the user 
inputs an invalid email/password combination. However, the error message 
should just say something like Email or password invalid. It shouldn't be 
running the same check as it does when a user registers a password...

On Wednesday, November 21, 2012 12:22:46 AM UTC, Daniele wrote:

 For some reason, I am not getting the right error messages to display on 
 my login form.
 Right now, I'm getting the same errors that one should get upon 
 registration, such as:

 Minimum length is 8
 Must include at least 1 upper case
 Must include at least 1 number

 However, this is giving away too many clues for a mere login. I just want 
 the message to say password or email incorrect or something along those 
 lines. How can I do this?


-- 





[web2py] good read on security

2012-11-21 Thread Massimo Di Pierro
http://erratasec.blogspot.de/2012/11/you-are-committing-crime-right-now.html

-- 





[web2py] Re: User Recaptcha With a Crud form

2012-11-21 Thread Massimo Di Pierro
No but crud will be deprecated. Do

form = SQLFORM(.)
form.element('table).append(TR('',Recaptcha(),'')
form.process()
if form.accepted: 

it does not matter how the form is made.

On Tuesday, 20 November 2012 02:32:57 UTC-6, Hassan Alnatour wrote:

 Dear ALL ,

 How Can i Use Recaptcha with a crud form ??

 Regards,


-- 





[web2py] Re: admin interface + GAE

2012-11-21 Thread Massimo Di Pierro
This is not a bug!

1) First of all, for new apps, do not use get_or_create_key any more. The 
new web2py had better security using salted password. You do not need a key.

2) If you must use a key (because you have a legacy app or because you want 
to use hmac) the key must be saved on a file. You should save it on the 
host (by running the app locally once) and then deploy on GAE. 

Massimo


On Tuesday, 20 November 2012 03:28:23 UTC-6, Sebastian Cambeo wrote:

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


-- 





Re: [web2py] Re: Bug? Invalid url puts python into a tight loop - 100% CPU

2012-11-21 Thread Massimo Di Pierro
I will take a patch to fix this. 

On Tuesday, 20 November 2012 07:00:37 UTC-6, jc wrote:

 You are correct of course, but to quote the book:

 web2py includes two distinct URL rewrite systems: an easy-to-use 
 parameter-based system for most use cases, and a flexible pattern-based 
 system for more complex cases.

 You have to use the pattern based system to avoid the vulnerability, and I 
 bet most people don't.

 Anyway, thanks for your work-around. Prompted by Jonathan I will look into 
 using the pattern based system and remove the temporary fix.


-- 





[web2py] Re: SQLFORM.grid in LOAD

2012-11-21 Thread Massimo Di Pierro
This is controlled by the action you are LOADing. What does it do when you 
delete? Does it redirect? if so make it redirect to a page without layout.

On Tuesday, 20 November 2012 07:02:52 UTC-6, vivek wrote:


 https://lh4.googleusercontent.com/-Wk4LfMakiVg/UKt_Z_gNxFI/ABc/UxjmHhF-t1A/s1600/nestedloads.jpg
 Hi ,

  I have a grid as a LOAD component , everything works  fine  , except 
 for delete. If i was to click on delete , and then cancel it (delete button 
 in grid) , the URL is reloaded again , what happens is  a whole new page 
 gets loaded into the Div of the component  basically it gets nested. 

 Any ideas what to be done?




-- 





[web2py] Re: posts being deleted again?

2012-11-21 Thread Massimo Di Pierro
I have seen a number of messages deleted recently. I did not delete them. 
The other managers are also well trusted. It is not our policy to delete 
messages unless: 1) there are repeated posts; 2) there is spam; 3) the 
author asks to delete (usually with a good reason, like the post contains 
confidential info).

This may be accidental or may be a bug.
If it happens again, please continue to report it.

massimo

On Wednesday, 21 November 2012 05:45:20 UTC-6, dhmorgan wrote:

 seems last week someone commented it happened to him; not for me since 
 Sep.29

 On Tuesday, November 20, 2012 9:07:02 PM UTC-6, Dave wrote:

 I posted three replies to this thread:

 https://groups.google.com/forum/?fromgroups=#!topic/web2py/Z7ZoN6Bn6pU

 And all three have shown up as deleted.  I know Anthony and Massimo 
 have said in the past they don't delete posts.  Have other people seen this 
 phantom post stealing ghost in Google Groups come back recently?



-- 





[web2py] Re: Encrypting password verify

2012-11-21 Thread Dave
I posted a reply with sample code, but it has been deleted.  PM me and I 
can help.  Not sure who deleted the message or why.

On Sunday, November 18, 2012 4:58:51 PM UTC-5, Daniele wrote:

 I have a field in my register form for verifying the password, as such:

 Field http://127.0.0.1:8000/examples/global/vars/Field('password', 
 'password', length=512, readable=False),
 Field 
 http://127.0.0.1:8000/examples/global/vars/Field('password_verify', 
 'password', length=512, readable=False, requires=CRYPT 
 http://127.0.0.1:8000/examples/global/vars/CRYPT(digest_alg='sha512'))

 Even though I added requires CRYPT, this field gets stored as the user's 
 actual password
 (without any encryption). I take it this is not a good thing.

 How can I encrypt even the verify password field on my registration form?

 Thanks


-- 





[web2py] Re: Encrypting password verify

2012-11-21 Thread Dave
It is quite annoying that someone keeps deleting my posts.  Whomever you 
are contact me and kindly let me know why you are doing it.

On Sunday, November 18, 2012 4:58:51 PM UTC-5, Daniele wrote:

 I have a field in my register form for verifying the password, as such:

 Field http://127.0.0.1:8000/examples/global/vars/Field('password', 
 'password', length=512, readable=False),
 Field 
 http://127.0.0.1:8000/examples/global/vars/Field('password_verify', 
 'password', length=512, readable=False, requires=CRYPT 
 http://127.0.0.1:8000/examples/global/vars/CRYPT(digest_alg='sha512'))

 Even though I added requires CRYPT, this field gets stored as the user's 
 actual password
 (without any encryption). I take it this is not a good thing.

 How can I encrypt even the verify password field on my registration form?

 Thanks


-- 





[web2py] Re: Encrypting password verify

2012-11-21 Thread Dave
Since the CRYPT validator generates a unique salt for each password hash, 
they will never be equal.  If you are going to create your own custom 
register form, you will need to implement your own register controller 
logic to validate the password  confirm password match in clear text, then 
hash the value and add it to the database.  Here is some sample code from 
one of my apps where I have extra fields and needed my own register:

I have bolded the important part.

Note that your form should NOT have a requires = CRYPT.  you have to do 
that after validating the form and making sure the values are equal in 
clear-text.

def validate_form(form):
if form.vars.password != form.vars.password_two:
form.errors.password = 'Passwords must match'
form.errors.password_two = 'Passwords must match'
else:
*form.vars.password = 
str(CRYPT(digest_alg='sha512',salt=True)(form.vars.password)[0])*

form = SQLFORM.factory(
db.auth_user.first_name,
db.auth_user.last_name,
db.auth_user.email,
db.auth_user.year_of_birth,
db.auth_user.zip_code,
db.auth_user.news_and_updates,
db.auth_user.sale_launch_alert,
db.auth_user.ninety_pt_wine_alerts,
db.auth_user.near_sellout_warning,
db.auth_user.soldout_alert,
db.auth_user.charity_updates,
*Field('password', 'password'),*
Field('password_two', 'password'),
Field('tos', 'boolean', requires=IS_EXPR('bool(value)', 
error_message='You must agree')))

if session.invite:
form.vars.first_name = session.invite.first_name
form.vars.last_name = session.invite.last_name
form.vars.email = str(session.invite.email).lower()

#form[0].insert(-1, TR('',  auth.settings.register_captcha))

if form.process(onvalidation=validate_form).accepted:  
if session.invite:
# update the invite table to 'accepted'
invite = 
db((db.invites.registration_key==session.invite.registration_key)).select().first()
invite.status = 'accepted'
invite.update_record()

userid = 
db.auth_user.insert(**db.auth_user._filter_fields(form.vars))
member_group_id = db(db.auth_group.role == 
'member').select().first().id
auth.add_membership(member_group_id, userid)

user_record = db.auth_user[userid]

from utils import web2py_uuid
user = Storage(db.auth_user._filter_fields(user_record, id=True))
auth.user = user

## subscribe user to mailchimp mailing lists
from mailchimp import MailChimp
mailchimp = MailChimp()

mailchimp.create(user_record)

session.auth = Storage(user=user, last_visit=request.now,
   expiration=auth.settings.expiration,
   hmac_key = web2py_uuid())

session.flash = 'Thank you for registering'
redirect(URL('sales','current'))


On Sunday, November 18, 2012 4:58:51 PM UTC-5, Daniele wrote:

 I have a field in my register form for verifying the password, as such:

 Field http://127.0.0.1:8000/examples/global/vars/Field('password', 
 'password', length=512, readable=False),
 Field 
 http://127.0.0.1:8000/examples/global/vars/Field('password_verify', 
 'password', length=512, readable=False, requires=CRYPT 
 http://127.0.0.1:8000/examples/global/vars/CRYPT(digest_alg='sha512'))

 Even though I added requires CRYPT, this field gets stored as the user's 
 actual password
 (without any encryption). I take it this is not a good thing.

 How can I encrypt even the verify password field on my registration form?

 Thanks


-- 





Re: [web2py] Re: Extracting row id from url using request.args

2012-11-21 Thread Mike Pixael
Wow Cliff thank you for this superb bit of info. Like all the best problems
it seems glaringly obvious to me now.

Thank you everyone for your help.

Mike

On Wed, Nov 21, 2012 at 2:40 AM, Cliff Kachinske cjk...@gmail.com wrote:

 It's been a while since I've played with smartgrid, but I seem to recall
 that the ID of the record being edited was always the final arg.

 And you can treat request.args as a list, so the ID of the record being
 edited is request.args[-1], or so it seems to me.

 On Tuesday, November 20, 2012 7:44:09 AM UTC-5, Michael Hall wrote:

 In the end I have used a different slightly more messy approach. I am
 getting the record id from the args by using a conditional to test if it is
 in one of 2 possible positions.

 @auth.requires_login()
 def contact_manage():
 form = SQLFORM.smartgrid(db.t_**contact,linked_tables=['t_**
 courses','t_membership','t_**paypal'], onupdate=auth.archive,
 formname=Contact Manager)
 if request.args(2) == 't_contact':
 memberId = request.args(3)
 else:
 memberId = request.args(2)

 return locals()

 I looked into fetching it using similar code to your link function but it
 seems you can only request the id of the current record using
 db.t_contact.id from within the parameters of your SQLFORM.smartgrid
 request.

 Its a dirty hack but it seems to work.

 Mike

 On Tuesday, 20 November 2012 07:15:22 UTC, Johann Spies wrote:

 On 19 November 2012 14:58, Michael Hall pix...@gmail.com wrote:

 Hi Villas

 I like the idea of using a var instead of args but I am still uncertain
 of how I get the ID of the current record I am viewing/editing in 
 smartgrid.


 Here is an example of code I am using where 'auid' represents the id of
 the author record:

   links = [lambda row: (A(B(T('Edit')), _target = _blank,
 _href = URL(r = request,
   **  c = 'authors',
   **  f = 'edit_author',
   **  vars = dict(auid = str(row[
 db.akb_authors.id]**)]
 query = ...
 fields = [list of fields]

 I then call the grid with SQLFORM.grid(query, fields=fields, links=links)


 Regards
 Johann
 --
 Because experiencing your loyal love is better than life itself,
 my lips will praise you.  (Psalm 63:3)

  --





-- 





Re: [web2py] global name 'T' / 'auth' / 'request' is not defined, but i'm in a model file...

2012-11-21 Thread Cédric Mayer
Thank you for your answer. I don't know why my initial post was deleted, I 
would have answered it sooner...

The origin of the problem was that I imported functions from a model file 
in a controller file.
I usually do that prefixing it by 
if 0:
   from model file import function or class
in order to make import errors disappear in Eclipse, so that I see the real 
errors ; but in this case I had forgotten this if 0:

And as imported modules do not have access to global variables, so was it 
for this imported model.

So, imports are dangerous :-)

Le mardi 20 novembre 2012 08:09:08 UTC+1, Johann Spies a écrit :

 On 19 November 2012 15:53, Cédric Mayer argl...@gmail.com 
 javascript:wrote:


   File 
 C:/Users/cedric/projets/LACT/eclipse/Lactw221/web2py/applications/lact/models/a34_lact_running_modes.py
  
 http://127.0.0.1:8000/admin/default/edit/lact/models/a34_lact_running_modes.py,
  line 43, in on_end

 session.flash = T('Serie finished! Thank you!')
 NameError: global name 'T' is not defined

 de.on_end()

 As you see, a34_running_modes.py is in the 'models' folder. But a 
 function from it called from the controller doesn't know of 'T' which is 
 global !
 Previously I had the same error in some other functions with 'auth' 
 (defined in a12_db.py, so still before) and 'request', which I solved by 
 passing 'auth' or 'request' as function arguments (even if I find it not 
 very nice...), as they are available in the controller function.

 But if even T is not known, I cannot pass all usual global variables as 
 arguments to every function present in 'models' folder.

 Do I miss something ? Like a what-to-check-if-you want-to-upgrade 
 web2py documentation ? (even if I thought web2py was fully backward 
 compatible, this is why I choose it)


 The problem might be the name of your model.  If I remember correctly the 
 models are imported in alphabetical order.  In the default db.py (like in 
 the welcome app) some important stuff gets imported that should happen 
 before other models are loaded.

 As an experiment try a changed name for your model which starts with a 
 character  'd'.

 Otherwise do import the necessary stuff from gluon in your model.

 e.g.

 from gluon import T

 Regards
 Johann

 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)



-- 





Re: [web2py] Re: Gigya - Janrain alternative

2012-11-21 Thread Taryn Cooksey
Yeah, Gigya's pricing is insane. Anyways, I came across LoginRadius 
http://goo.gl/LvCUn and they offer pretty much same thing. You can check 
out their pricing (that starts at $9/mo) and features here - 
https://www.loginradius.com/pricing/packages

-- 





Re: [web2py] Re: Gigya - Janrain alternative

2012-11-21 Thread Bruno Rocha
That looks really cool!

I will try to play with its API.




On Wed, Nov 21, 2012 at 5:53 AM, Taryn Cooksey taryncook...@gmail.comwrote:

 Yeah, Gigya's pricing is insane. Anyways, I came across LoginRadius
 http://goo.gl/LvCUn and they offer pretty much same thing. You can check
 out their pricing (that starts at $9/mo) and features here -
 https://www.loginradius.com/pricing/packages

 --





-- 





[web2py] Re: using Stripe

2012-11-21 Thread Massimo Di Pierro
Hello Margaret,

first of all sorry for the late response. Here is a simple application that 
implements a shopping cart sing Authorize.net:

https://github.com/mdipierro/web2py-appliances/blob/master/PosOnlineStore

In file

https://github.com/mdipierro/web2py-appliances/blob/master/PosOnlineStore/controllers/default.py

look at the lines:

from gluon.contrib.AuthorizeNet import process
 ...
 if process(form.vars.creditcard,form.vars.expiration, 
total,form.vars.cvv,0.0,invoice,testmode=True): ...


In the case of sprite.com they are replaced by

  from gluon.contrib.stripe import Stripe
...
d = stripe.charge(amount=total, currency='usd', card_number=form.vars.
creditcard, card_exp_month=form.vars.expiration[:2],
card_exp_year=form.vars.expiration[2:],
card_cvc_check=form.vars.cvv,
description='invoice %s' % invoice)
if d.get('paid',False): ...

Hope this helps.


On Monday, 19 November 2012 18:43:25 UTC-6, greaneym wrote:

 Hello,

 I've looked into stripe.com and it does look like it is easier than 
 google wallet to implement. 

 When I put the example from the web2py manual into a controller, then the 
 charge of whatever amount does communicate with Stripe's server and I can 
 see that a charge went through as a test.


 How do I see display this example from the manual, section14.10.3, in a 
 view?

 thank you,
 Margaret



-- 





Re: [web2py] Re: Need to save a multipage PDF

2012-11-21 Thread Paul Rykiel
thats what I did ... I couldn't believe how I missed that

On Wednesday, November 21, 2012 4:06:52 AM UTC-6, Javier Pepe wrote:

 Try this:

 def taggen_print():
 *pdf = FPDF()*
 rows = db(db.bike_no.id  0).select()
 for row in rows:
tag_no = row.bike_typ+str(row.id)
pfile = tag_no+'_p.pdf'
pdf.add_page()
pdf.set_font('Arial', 'B', 14)
pdf.cell(40,10,tag_no)
 *   pdf.AddPage()*
 *pdf.output(name=request.folder + '/static/temp.pdf')*
 response.headers['Content-Disposition']='attachment.filename =' + pfile
 response.headers['Content-Type']='application/pdf'
 return response.stream(open(request.folder+'/static/temp.pdf', 
 'rb'),chunk_size=4096)
 #  pdf.output(pfile, 'F')
 redirect(URL(index)) 


 On Wed, Nov 21, 2012 at 5:18 AM, LightDot ligh...@gmail.com javascript:
  wrote:

 This group is a wealth of information for other users, so when you can, 
 please do post what is it that you've figured out. :)

 It's highly likely someone will have the same or similar problem and 
 search for answers.

 Regards,
 Ales


 On Wednesday, November 21, 2012 6:36:04 AM UTC+1, Paul Rykiel wrote:

 Nevermind ... figured it out
 On Tuesday, November 20, 2012 3:06:22 PM UTC-6, Paul Rykiel wrote:

 Greetings everyone,
  
 this is my code and I am having difficulity creating a Multipage PDF 
 to save to a directory.
 any assistance will be welcomed.
  
 Regards,
  
 def taggen_print():
 rows = db(db.bike_no.id  0).select()
 for row in rows:
tag_no = row.bike_typ+str(row.id)
pfile = tag_no+'_p.pdf'
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 14)
pdf.cell(40,10,tag_no)
pdf.output(name=request.folder + '/static/temp.pdf')
 response.headers['Content-**Disposition']='attachment.**filename 
 =' + pfile
 response.headers['Content-**Type']='application/pdf'
 return response.stream(open(request.**folder+'/static/temp.pdf', 
 'rb'),chunk_size=4096)
 #  pdf.output(pfile, 'F')
 redirect(URL(index))   
  
 right now it only saves the PDF for the last record... I need it to 
 create a page for each record and save it in PDF format in the directory

  -- 
  
  
  




-- 





[web2py] Re: Need to save a multipage PDF

2012-11-21 Thread Paul Rykiel
Oh I am sorry, the answer was simple 
 
I just had to move the following line outside of the for loop
 
 pdf = FPDF() 
 for row in rows ...
 
instead of
 
 for row in Rows()
   pdf = FPDF()

On Wednesday, November 21, 2012 2:18:50 AM UTC-6, LightDot wrote:

 This group is a wealth of information for other users, so when you can, 
 please do post what is it that you've figured out. :)

 It's highly likely someone will have the same or similar problem and 
 search for answers.

 Regards,
 Ales

 On Wednesday, November 21, 2012 6:36:04 AM UTC+1, Paul Rykiel wrote:

 Nevermind ... figured it out
 On Tuesday, November 20, 2012 3:06:22 PM UTC-6, Paul Rykiel wrote:

 Greetings everyone,
  
 this is my code and I am having difficulity creating a Multipage PDF 
 to save to a directory.
 any assistance will be welcomed.
  
 Regards,
  
 def taggen_print():
 rows = db(db.bike_no.id  0).select()
 for row in rows:
tag_no = row.bike_typ+str(row.id)
pfile = tag_no+'_p.pdf'
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 14)
pdf.cell(40,10,tag_no)
pdf.output(name=request.folder + '/static/temp.pdf')
 response.headers['Content-Disposition']='attachment.filename =' + 
 pfile
 response.headers['Content-Type']='application/pdf'
 return response.stream(open(request.folder+'/static/temp.pdf', 
 'rb'),chunk_size=4096)
 #  pdf.output(pfile, 'F')
 redirect(URL(index))   
  
 right now it only saves the PDF for the last record... I need it to 
 create a page for each record and save it in PDF format in the directory



-- 





Re: [web2py] Re: Bug? Invalid url puts python into a tight loop - 100% CPU

2012-11-21 Thread Jonathan Lundell
On 21 Nov 2012, at 5:59 AM, Massimo Di Pierro massimo.dipie...@gmail.com 
wrote:
 I will take a patch to fix this. 
 
 On Tuesday, 20 November 2012 07:00:37 UTC-6, jc wrote:
 You are correct of course, but to quote the book:
 
 web2py includes two distinct URL rewrite systems: an easy-to-use 
 parameter-based system for most use cases, and a flexible pattern-based 
 system for more complex cases.
 
 You have to use the pattern based system to avoid the vulnerability, and I 
 bet most people don't.
 
 Anyway, thanks for your work-around. Prompted by Jonathan I will look into 
 using the pattern based system and remove the temporary fix.
 
 

I may have a solution.

Try replacing this: r'([\w@ -]+[=.]?)*$'

with this: r'([\w@ -]|(?=[\w@ -])[.=])*$'

You can do this by using the args_match override in routes.py. (I notice that 
the documented default for args_match in router.example.py is wrong; that will 
need to be corrected as well.)

file_match probably needs a similar fix.

-- 





[web2py] Re: using Stripe

2012-11-21 Thread greaneym
Thank you, Massimo. I will take a look.

Margaret




-- 





[web2py] Re: admin interface + GAE

2012-11-21 Thread Sebastian Cambeo
I don't know if we understand us correctly. I don't use get_or_create_key 
anywhere and I am not referring to dlypka posts (I think our problems are 
not related).

However my problem remains existing: If you deploy web2py trunk/stable with 
no other changes than altering the app.yaml in order to use the admin 
interface it fails due to forbidden calls in check_credentials.

Sebastian

-- 





[web2py] email logging

2012-11-21 Thread Brian Blais
Hello everyone,

I can't seem to find this in the docs anywhere: how can I make it so that a log 
of every event done on an app (adding a user, uploading a file, etc...) is sent 
via email to a specified place?  


thanks,

Brian Blais

-- 
Brian Blais
bbl...@gmail.com
http://web.bryant.edu/~bblais
http://brianblais.wordpress.com/



-- 





default vs not-default (was Re: [web2py] perhaps a silly question about index)

2012-11-21 Thread Brian Blais
On Nov 21, 2012, at 4:55 AM, lyn2py wrote:

 You can remap this using routes.py
 
 On Tuesday, November 20, 2012 9:44:37 PM UTC+8, Brian Blais wrote:
 Hello, 
 
 Is there a reason to have the controllers all in default.py, or is there some 
 reason to have certain controllers in default.py and others not?  When you 
 want to point to your actual app, I will want to give a url that is 
 http:///appname/ 
 
 not with the /default/ in it.  Is that remapped later? 
 

Okay, so I can reroute it afterword, but is there any reason why I would want 
to do this:

all controllers in models/default.py
remap to http:///appname/ with routes.py

versus this:

all controllers in models/ in their own files
no need to remap with routes.py


It seems odd to have all the controllers in one big file, rather than breaking 
them up, but perhaps there is a design reason for this. 

thanks,

Brian Blais




-- 
Brian Blais
bbl...@gmail.com
http://web.bryant.edu/~bblais
http://brianblais.wordpress.com/



-- 





[web2py] Re: admin interface + GAE

2012-11-21 Thread Massimo Di Pierro
You are right. This is a different problem. Please open a ticket about it, 
if not done already and I will check later today or tomorrow.

On Wednesday, 21 November 2012 11:08:55 UTC-6, Sebastian Cambeo wrote:

 I don't know if we understand us correctly. I don't use get_or_create_key 
 anywhere and I am not referring to dlypka posts (I think our problems are 
 not related).

 However my problem remains existing: If you deploy web2py trunk/stable 
 with no other changes than altering the app.yaml in order to use the admin 
 interface it fails due to forbidden calls in check_credentials.

 Sebastian


-- 





[web2py] Unable to send email in web2py

2012-11-21 Thread Daniele
I'm trying to send emails upon user registration. This is what I have in my 
models file:

mail = auth.settings.mailer
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = 'em...@gmail.com' #There's a proper email here
mail.settings.login = 'username:password' #There's a proper 
username/password combination here
auth.settings.registration_requires_verification = True
auth.messages.verify_email = 'Click on the link http://' + 
request.env.http_host + URL(r=request,f='user',args=['verify_email']) + 
'/%(key)s to verify your email'

mail.settings.server = settings.email_server
mail.settings.sender = settings.email_sender
mail.settings.login = settings.email_login

But every time I register a user with a valid email address, I'm getting no 
email. How can I debug this?

-- 





[web2py] 'reference tablename' field displays id value only when writable set to False

2012-11-21 Thread Jim S
I have a table defined as follows:

employee = db.define_table('employee',
 Field('employeeId', 'id', writable=False, label='Employee #'),
 Field('firstName', length=25, required=True, label='First Name',
 writable=False),
 Field('lastName', length=25, required=True, label='Last Name',
 writable=False),
...
 Field('departmentId', db.department, label='Department', writable=False),
 Field('supervisorId', 'reference employee', label='Supervisor', writable=
False),
 format='%(lastName)s, %(firstName)s')

db.employee.dob.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
db.employee.seniorityDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
db.employee.hireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
db.employee.originalHireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
db.employee.terminationDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))





My supervisorId field displays correctly with the dropdown if it is 
writable, but when I set writable=False it just displays the value of the 
supervisorId field, not the assosiated employee first/last name as the 
format would dictate.  departmentId is setup to behave the same way, just 
referencing a different table and it displays the proper 'name' of the 
department when writable=False instead of the id field like supervisorId 
does.  Is this a bug?

-Jim

-- 





[web2py] Re: email logging

2012-11-21 Thread Niphlod
You need to code a simple function that sends the email (better would be to 
queue them and send them asynchronously).
There's nothing embedded in web2py ready to use for that kind of 
functionality.

def app_log(message):
mail.send(to=['m...@example.com'],
  subject='event happened',
  message=message)


Then, you can do wherever you need in your code
app_log('something happened')



But that would slow response times because the mail is sent synchronously.
Better to use the scheduler for that. In addition to the app_log() 
function, just define in a model file


def queue_log(message):
 mysched.queue_task(app_log, [message])

from gluon.scheduler import Scheduler
mysched = Scheduler(db)

Now, in your app, use 
queue_log('something happened')

Mail sending will be queued. To activate the queue processing, just start
web2py.py -K yourappname


as another process. It will periodically check for queued tasks (your 
emails) and send them without slowing down your response times.



-- 





[web2py] Re: 'reference tablename' field displays id value only when writable set to False

2012-11-21 Thread Cliff Kachinske
In your controller do something like
def get_name(id):
   record = db(db.employees.id==id).select(db.employees.first_name, db.
employees.last_name).first()
   return ' %s %s' %(record.first_name, record.last_name)

db.employee.supervisor_id.represent = lambda row: get_name(row.supervisor_id
)

If it's an index list you will get one database hit per row.  Better to use 
this trick on the edit or view pages.


On Wednesday, November 21, 2012 2:32:54 PM UTC-5, Jim S wrote:

 I have a table defined as follows:

 employee = db.define_table('employee',
  Field('employeeId', 'id', writable=False, label='Employee #'),
  Field('firstName', length=25, required=True, label='First Name',
  writable=False),
  Field('lastName', length=25, required=True, label='Last Name',
  writable=False),
 ...
  Field('departmentId', db.department, label='Department', writable=False),
  Field('supervisorId', 'reference employee', label='Supervisor', writable=
 False),
  format='%(lastName)s, %(firstName)s')

 db.employee.dob.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.seniorityDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.hireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.originalHireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.terminationDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))





 My supervisorId field displays correctly with the dropdown if it is 
 writable, but when I set writable=False it just displays the value of the 
 supervisorId field, not the assosiated employee first/last name as the 
 format would dictate.  departmentId is setup to behave the same way, just 
 referencing a different table and it displays the proper 'name' of the 
 department when writable=False instead of the id field like supervisorId 
 does.  Is this a bug?

 -Jim


-- 





[web2py] Re: Login error messages

2012-11-21 Thread Paolo Caruccio
From the book http://web2py.com/books/default/chapter/29/09#Authenticationwe 
know that:

*The password field of the db.auth_user table defaults to a CRYPT validator*


From http://web2py.com/books/default/chapter/29/09#Customizing-Auth we know 
also that:

*You can add any field you wish, and you can change validators but you 
 cannot remove the fields marked as required*


(namely 'email', 'password', 'registration_key', 'reset_password_key', 
'registration_id' fields)

Finally we know that (
http://web2py.com/books/default/chapter/29/07#Validators):

*error_message* allows you to override the default error message for any 
 validator.


Consequently we can change the validators of auth.password field and 
customize error messages.

We could accomplish our target in the following way for example:

# in model db.py after auth.define_tables(username=False, signature=False)
default_password_validators = [def_val for def_val
 in db.auth_user.password.requires]
added_password_validators = [IS_NOT_EMPTY(error_message=T('Enter a value')),
 IS_LENGTH(minsize=8,
   error_message=T('Invalid password'))]
password_validators = added_password_validators +default_password_validators
db.auth_user.password.requires = password_validators


Il giorno mercoledì 21 novembre 2012 14:38:31 UTC+1, Daniele ha scritto:

 Hiding the error is not my point. I want an error message when the user 
 inputs an invalid email/password combination. However, the error message 
 should just say something like Email or password invalid. It shouldn't be 
 running the same check as it does when a user registers a password...

 On Wednesday, November 21, 2012 12:22:46 AM UTC, Daniele wrote:

 For some reason, I am not getting the right error messages to display on 
 my login form.
 Right now, I'm getting the same errors that one should get upon 
 registration, such as:

 Minimum length is 8
 Must include at least 1 upper case
 Must include at least 1 number

 However, this is giving away too many clues for a mere login. I just want 
 the message to say password or email incorrect or something along those 
 lines. How can I do this?



-- 





[web2py] Re: 'reference tablename' field displays id value only when writable set to False

2012-11-21 Thread Jim S
Yes, I know I can do that, but seems like this should be the default 
behavior for web2py.  I'm just looking for it to work the same way the 
other reference fields work (see the departmentId field in my example).

-Jim

On Wednesday, November 21, 2012 1:59:22 PM UTC-6, Cliff Kachinske wrote:

 In your controller do something like
 def get_name(id):
record = db(db.employees.id==id).select(db.employees.first_name, db.
 employees.last_name).first()
return ' %s %s' %(record.first_name, record.last_name)

 db.employee.supervisor_id.represent = lambda row: get_name(row.
 supervisor_id)

 If it's an index list you will get one database hit per row.  Better to 
 use this trick on the edit or view pages.


 On Wednesday, November 21, 2012 2:32:54 PM UTC-5, Jim S wrote:

 I have a table defined as follows:

 employee = db.define_table('employee',
  Field('employeeId', 'id', writable=False, label='Employee #'),
  Field('firstName', length=25, required=True, label='First Name',
  writable=False),
  Field('lastName', length=25, required=True, label='Last Name',
  writable=False),
 ...
  Field('departmentId', db.department, label='Department', writable=False
 ),
  Field('supervisorId', 'reference employee', label='Supervisor', writable
 =False),
  format='%(lastName)s, %(firstName)s')

 db.employee.dob.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.seniorityDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.hireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.originalHireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.terminationDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))





 My supervisorId field displays correctly with the dropdown if it is 
 writable, but when I set writable=False it just displays the value of the 
 supervisorId field, not the assosiated employee first/last name as the 
 format would dictate.  departmentId is setup to behave the same way, just 
 referencing a different table and it displays the proper 'name' of the 
 department when writable=False instead of the id field like supervisorId 
 does.  Is this a bug?

 -Jim



-- 





[web2py] Re: 'reference tablename' field displays id value only when writable set to False

2012-11-21 Thread Anthony
The problem is that unlike departmentId, supervisorId is a self reference. 
With a non-self-reference field, the DAL will automatically set the 
represent attribute to be the _format attribute of the referenced table, 
but that is not possible with a self reference because the referenced table 
does not yet exist at the time the field is created. I think you'll have to 
set the represent attribute separately in this case.

Anthony

On Wednesday, November 21, 2012 3:49:15 PM UTC-5, Jim S wrote:

 Yes, I know I can do that, but seems like this should be the default 
 behavior for web2py.  I'm just looking for it to work the same way the 
 other reference fields work (see the departmentId field in my example).

 -Jim

 On Wednesday, November 21, 2012 1:59:22 PM UTC-6, Cliff Kachinske wrote:

 In your controller do something like
 def get_name(id):
record = db(db.employees.id==id).select(db.employees.first_name, db.
 employees.last_name).first()
return ' %s %s' %(record.first_name, record.last_name)

 db.employee.supervisor_id.represent = lambda row: get_name(row.
 supervisor_id)

 If it's an index list you will get one database hit per row.  Better to 
 use this trick on the edit or view pages.


 On Wednesday, November 21, 2012 2:32:54 PM UTC-5, Jim S wrote:

 I have a table defined as follows:

 employee = db.define_table('employee',
  Field('employeeId', 'id', writable=False, label='Employee #'),
  Field('firstName', length=25, required=True, label='First Name',
  writable=False),
  Field('lastName', length=25, required=True, label='Last Name',
  writable=False),
 ...
  Field('departmentId', db.department, label='Department', writable=False
 ),
  Field('supervisorId', 'reference employee', label='Supervisor',writable
 =False),
  format='%(lastName)s, %(firstName)s')

 db.employee.dob.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.seniorityDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.hireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.originalHireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.terminationDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))





 My supervisorId field displays correctly with the dropdown if it is 
 writable, but when I set writable=False it just displays the value of the 
 supervisorId field, not the assosiated employee first/last name as the 
 format would dictate.  departmentId is setup to behave the same way, just 
 referencing a different table and it displays the proper 'name' of the 
 department when writable=False instead of the id field like supervisorId 
 does.  Is this a bug?

 -Jim



-- 





[web2py] Re: 'reference tablename' field displays id value only when writable set to False

2012-11-21 Thread Jim S
Thanks Anthony.  I will proceed with that route.

-Jim


On Wednesday, November 21, 2012 3:04:25 PM UTC-6, Anthony wrote:

 The problem is that unlike departmentId, supervisorId is a self reference. 
 With a non-self-reference field, the DAL will automatically set the 
 represent attribute to be the _format attribute of the referenced table, 
 but that is not possible with a self reference because the referenced table 
 does not yet exist at the time the field is created. I think you'll have to 
 set the represent attribute separately in this case.

 Anthony

 On Wednesday, November 21, 2012 3:49:15 PM UTC-5, Jim S wrote:

 Yes, I know I can do that, but seems like this should be the default 
 behavior for web2py.  I'm just looking for it to work the same way the 
 other reference fields work (see the departmentId field in my example).

 -Jim

 On Wednesday, November 21, 2012 1:59:22 PM UTC-6, Cliff Kachinske wrote:

 In your controller do something like
 def get_name(id):
record = db(db.employees.id==id).select(db.employees.first_name, db.
 employees.last_name).first()
return ' %s %s' %(record.first_name, record.last_name)

 db.employee.supervisor_id.represent = lambda row: get_name(row.
 supervisor_id)

 If it's an index list you will get one database hit per row.  Better to 
 use this trick on the edit or view pages.


 On Wednesday, November 21, 2012 2:32:54 PM UTC-5, Jim S wrote:

 I have a table defined as follows:

 employee = db.define_table('employee',
  Field('employeeId', 'id', writable=False, label='Employee #'),
  Field('firstName', length=25, required=True, label='First Name',
  writable=False),
  Field('lastName', length=25, required=True, label='Last Name',
  writable=False),
 ...
  Field('departmentId', db.department, label='Department', writable=
 False),
  Field('supervisorId', 'reference employee', label='Supervisor',writable
 =False),
  format='%(lastName)s, %(firstName)s')

 db.employee.dob.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.seniorityDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.hireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.originalHireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.terminationDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))





 My supervisorId field displays correctly with the dropdown if it is 
 writable, but when I set writable=False it just displays the value of the 
 supervisorId field, not the assosiated employee first/last name as the 
 format would dictate.  departmentId is setup to behave the same way, just 
 referencing a different table and it displays the proper 'name' of the 
 department when writable=False instead of the id field like supervisorId 
 does.  Is this a bug?

 -Jim



-- 





[web2py] Re: 'reference tablename' field displays id value only when writable set to False

2012-11-21 Thread Jim S
Thanks all, got it working.  One correction from the code offered:

db.employee.supervisor_id.represent = lambda row: 
get_name(row.supervisor_id)

should be:

db.employee.supervisor_id.represent = lambda val, row: 
get_name(row.supervisor_id)

Thanks again.

-Jim

On Wednesday, November 21, 2012 3:35:39 PM UTC-6, Jim S wrote:

 Thanks Anthony.  I will proceed with that route.

 -Jim


 On Wednesday, November 21, 2012 3:04:25 PM UTC-6, Anthony wrote:

 The problem is that unlike departmentId, supervisorId is a self 
 reference. With a non-self-reference field, the DAL will automatically set 
 the represent attribute to be the _format attribute of the referenced 
 table, but that is not possible with a self reference because the 
 referenced table does not yet exist at the time the field is created. I 
 think you'll have to set the represent attribute separately in this case.

 Anthony

 On Wednesday, November 21, 2012 3:49:15 PM UTC-5, Jim S wrote:

 Yes, I know I can do that, but seems like this should be the default 
 behavior for web2py.  I'm just looking for it to work the same way the 
 other reference fields work (see the departmentId field in my example).

 -Jim

 On Wednesday, November 21, 2012 1:59:22 PM UTC-6, Cliff Kachinske wrote:

 In your controller do something like
 def get_name(id):
record = db(db.employees.id==id).select(db.employees.first_name, db.
 employees.last_name).first()
return ' %s %s' %(record.first_name, record.last_name)

 db.employee.supervisor_id.represent = lambda row: get_name(row.
 supervisor_id)

 If it's an index list you will get one database hit per row.  Better to 
 use this trick on the edit or view pages.


 On Wednesday, November 21, 2012 2:32:54 PM UTC-5, Jim S wrote:

 I have a table defined as follows:

 employee = db.define_table('employee',
  Field('employeeId', 'id', writable=False, label='Employee #'),
  Field('firstName', length=25, required=True, label='First Name',
  writable=False),
  Field('lastName', length=25, required=True, label='Last Name',
  writable=False),
 ...
  Field('departmentId', db.department, label='Department', writable=
 False),
  Field('supervisorId', 'reference employee', label='Supervisor',writable
 =False),
  format='%(lastName)s, %(firstName)s')

 db.employee.dob.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.seniorityDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.hireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))
 db.employee.originalHireDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'
 ))
 db.employee.terminationDate.requires = IS_NULL_OR(IS_DATE('%m/%d/%Y'))





 My supervisorId field displays correctly with the dropdown if it is 
 writable, but when I set writable=False it just displays the value of the 
 supervisorId field, not the assosiated employee first/last name as the 
 format would dictate.  departmentId is setup to behave the same way, just 
 referencing a different table and it displays the proper 'name' of the 
 department when writable=False instead of the id field like supervisorId 
 does.  Is this a bug?

 -Jim



-- 





[web2py] Re: Dynamically generating forms from db data which will not be used to store the results in the db

2012-11-21 Thread villas
Show some checkboxes for each component:

e.g. something like this...

db.define_table('ingredient',
Field('name','string',length=100),
Field('kind',requires=IS_IN_SET(['alcohol','mixer','garnish']),
format='%(name)s',
)

Table Drink ...
Field('ingredient_garnish','list:reference ingredient',label='Garnish 
List',length=100,
widget=lambda f, v: SQLFORM.widgets.checkboxes.widget(f, v, 
style='divs')),


db.drink.ingredient_garnish.requires=IS_EMPTY_OR(IS_IN_DB(db(db.ingredient.kind=='garnish')
 
,db.ingredient.id,'%(name)s',multiple=True))

I don't have time to adapt to your models etc but I thought the above might 
be of interest for you to experiment.

Regards,
David

-- 





[web2py] Re: Running GAE locally - beginners question

2012-11-21 Thread howesc
can you open the logs in the GAE launcher and paste in the output from a 
launch and first URL access?  i suspect there is a config issue and 
hopefully the logs will help us debug!

cfh

On Tuesday, November 20, 2012 6:40:39 AM UTC-8, Andy W wrote:

 I am having trouble getting GAE to run a simple app on the desktop with 
 GAE Launcher. Any pointers to what I am doing wrong would be appreciated!

 So far I have:

1. Downloaded web2py source (v 2.2.1) and installed GAE Launcher (on 
mac)
2. Created app.yaml from app.example.yaml in the main web2py 
directory, changing first line to 'application: welcome'
3. Set default_application='welcome' in routes.py (in the main web2py 
directory)
4. Added application 'welcome' to GAE Launcher, using the path to the 
main web2py directory

 When I run GAE Launcher the browser shows Hello World, not the Welcome 
 app.

 Anyone able to suggest where I am going wrong??


-- 





Re: [web2py] Re: Gigya - Janrain alternative

2012-11-21 Thread villas
This is opensource:  https://velruse.readthedocs.org/en/latest/


On Wednesday, November 21, 2012 2:19:40 PM UTC, rochacbruno wrote:

 That looks really cool! 

 I will try to play with its API.




 On Wed, Nov 21, 2012 at 5:53 AM, Taryn Cooksey 
 tarync...@gmail.comjavascript:
  wrote:

 Yeah, Gigya's pricing is insane. Anyways, I came across LoginRadius 
 http://goo.gl/LvCUn and they offer pretty much same thing. You can check 
 out their pricing (that starts at $9/mo) and features here - 
 https://www.loginradius.com/pricing/packages

 -- 
  
  
  





-- 





[web2py] http://code.google.com/p/web2py/issues/detail?id=1105

2012-11-21 Thread Vasile Ermicioi
hi Massimo,

sorry to bother you, 
I commented a few days ago on this task , have you been able to reproduce 
it?

-- 





[web2py] Re: Unable to send email in web2py

2012-11-21 Thread howesc
login to gmail and check out that google is not requiring a verification (i 
find that for my unused email aliases that i send from that every few 
months google wants me to login for real to keep the account active).

also double check the google docs, i think there is a couple of smtp ports 
they use and sometimes switching to the other port makes a difference. 

On Wednesday, November 21, 2012 11:32:26 AM UTC-8, Daniele wrote:

 I'm trying to send emails upon user registration. This is what I have in 
 my models file:

 mail = auth.settings.mailer
 mail.settings.server = 'smtp.gmail.com:587'
 mail.settings.sender = 'em...@gmail.com javascript:' #There's a proper 
 email here
 mail.settings.login = 'username:password' #There's a proper 
 username/password combination here
 auth.settings.registration_requires_verification = True
 auth.messages.verify_email = 'Click on the link http://' + 
 request.env.http_host + URL(r=request,f='user',args=['verify_email']) + 
 '/%(key)s to verify your email'

 mail.settings.server = settings.email_server
 mail.settings.sender = settings.email_sender
 mail.settings.login = settings.email_login

 But every time I register a user with a valid email address, I'm getting 
 no email.
 So I'm trying to do it manually with:

 mail.send('em...@gmail.com javascript:', 'Message subject', 'Plain text 
 body of the message')


 But I'm getting an error message in the terminal that says:
 WARNING:web2py:Mail.send failure:[Errno 111] Connection refused

 How can I fix this???


-- 





Re: [web2py] Re: Unable to send email in web2py

2012-11-21 Thread Christian Foster Howes

i have used 587 successfully in the past.

i noticed that username if not a gmail account is the full email address 
like:


  b...@foo.com:password

perhaps try that even with the gmail account?

cfh

On 11/21/12 16:43 , Daniele Pestilli wrote:

I tried with port *465* and *587* any other port suggestions?


On Thu, Nov 22, 2012 at 12:35 AM, howesc how...@umich.edu wrote:


login to gmail and check out that google is not requiring a verification
(i find that for my unused email aliases that i send from that every few
months google wants me to login for real to keep the account active).

also double check the google docs, i think there is a couple of smtp ports
they use and sometimes switching to the other port makes a difference.

On Wednesday, November 21, 2012 11:32:26 AM UTC-8, Daniele wrote:


I'm trying to send emails upon user registration. This is what I have in
my models file:

mail = auth.settings.mailer
mail.settings.server = 'smtp.gmail.com:587'
mail.settings.sender = 'em...@gmail.com' #There's a proper email here
mail.settings.login = 'username:password' #There's a proper
username/password combination here
auth.settings.registration_**requires_verification = True
auth.messages.verify_email = 'Click on the link http://' +
request.env.http_host + URL(r=request,f='user',args=['**verify_email'])
+ '/%(key)s to verify your email'

mail.settings.server = settings.email_server
mail.settings.sender = settings.email_sender
mail.settings.login = settings.email_login

But every time I register a user with a valid email address, I'm getting
no email.
So I'm trying to do it manually with:

mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the 
message')


But I'm getting an error message in the terminal that says:
WARNING:web2py:Mail.send failure:[Errno 111] Connection refused

How can I fix this???


  --








--





[web2py] Re: Unable to send email in web2py

2012-11-21 Thread Daniele
I just tried port 25 as recommended on google's FAQ 
(http://support.google.com/mail/bin/answer.py?hl=enanswer=78775)
Still nothing. I'm wondering how can I debug this? Is there a log file of 
what's happening behind the scenes here?

On Wednesday, November 21, 2012 7:32:26 PM UTC, Daniele wrote:

 I'm trying to send emails upon user registration. This is what I have in 
 my models file:

 mail = auth.settings.mailer
 mail.settings.server = 'smtp.gmail.com:587'
 mail.settings.sender = 'em...@gmail.com' #There's a proper email here
 mail.settings.login = 'username:password' #There's a proper 
 username/password combination here
 auth.settings.registration_requires_verification = True
 auth.messages.verify_email = 'Click on the link http://' + 
 request.env.http_host + URL(r=request,f='user',args=['verify_email']) + 
 '/%(key)s to verify your email'

 mail.settings.server = settings.email_server
 mail.settings.sender = settings.email_sender
 mail.settings.login = settings.email_login

 But every time I register a user with a valid email address, I'm getting 
 no email.
 So I'm trying to do it manually with:

 mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the 
 message')


 But I'm getting an error message in the terminal that says:
 WARNING:web2py:Mail.send failure:[Errno 111] Connection refused

 How can I fix this???


-- 





[web2py] Re: Newbie: Cascading deletes with SQLFORM.grid and GAE

2012-11-21 Thread Julian Sanchez
Massimo,

I created a small test to try your function:

db.define_table('carrier',
Field('name', type='string'),
Field('description', type='string')
   )
   
db.carrier.name.requires = IS_NOT_IN_DB(db(db.carrier.id  0), 
'carrier.name')   
   
db.define_table('manufacturer',
Field('name', type='string'),
Field('country', type='string')
   )


db.manufacturer.name.requires = IS_NOT_IN_DB(db(db.manufacturer.id  0), 
'manufacturer.name')  
  
db.define_table('phone',
Field('model', type='string'),
Field('manufacturer', db.manufacturer),
Field('carrier', db.carrier)
   )
   
db.phone.manufacturer.requires = IS_IN_DB(db, 'manufacturer.id', '%(name)s')
db.phone.carrier.requires = IS_IN_DB(db, 'carrier.id', '%(name)s')




def delete_linked(query, table=db.carrier):
ids = [t.id in db(query).select(db.table.id)]
for field in table._referenced_by:
 db(field._table._id.belongs(ids)).delete()


db.carrier._before_delete.append(delete_linked)

I can create an Apple iPhone on Verizon and an Apple iPhone on Sprint.  If 
I run this under sqlite and I delete the carrier 'Sprint' I see one of the 
phones deleted as well (even without the '_before_delete' event which makes 
sense since that's the default behavior). 
However if I run this under GAE:

   - Without the '_before_delete' event the carrier 'Sprint' is deleted but 
   not the phone.  This is expected since cascading doesn't work.
   - With the '_before_delete' event (code just as above) *nothing* gets 
   deleted, not even the carrier.  I can see it disappear from the list but if 
   I refresh the page it comes right back.  I can also verify the record is 
   still there by looking at the GAE admin page (Datastore viewer).  Also, 
   none of the phones are deleted either.
   
Am I missing something?

Also, when you say that if I delete too many records the operation may fail 
midway... is that a GAE limitation?  Is the 1000 record limit I've read 
somewhere about?

Thanks,
Julian

On Saturday, November 17, 2012 1:06:01 PM UTC-6, Massimo Di Pierro wrote:

 You can try something like

 def delete_linked(query, table=table):
 ids = [t.id in db(query).select(db.table.id)]
 for field in table._referenced_by:
  db(field._table._id.belongs(ids)).delete()

 db.table._before_delete.append(delete_linked)

 but you will run into consistency problems. If there are too many records 
 this may fail midway.

 On Wednesday, 14 November 2012 19:07:02 UTC-6, Julian Sanchez wrote:

 Hi Everyone!!  Long time lurker  first time posting...

 I am working on a simple application that I intend to deploy in GAE.  I 
 have a few tables with fields that reference other tables which by default 
 enables the ondelete=CASCADE behavior.  This works fine when I run the app 
 locally using sqlite as the database.
 I believe GAE doesn't support cascading deletes natively. 
 I presume web2py doesn't support cascading deletes when running under GAE 
 because I don't see that happening.  When I delete a row (rendered through 
 SQLFORM.grid) only that row is deleted an all dependent tables remain 
 untouched.

 The problem I have is that I can't find a way for me to implement the 
 cascading behavior manually.  I added a 'ondelete=mydelete' event for the 
 SQLFORM.grid where I do the manual delete of the dependent tables and 
 commit in the database, but that doesn't seem to work either.  I searched 
 through this forum but didn't find any suggestions either.  Any suggestions 
 as to what could I do to solve this??  Do I have to stay away from 
 SQLFORM.grid to avoid this problem?

 Many Thanks!!
 Julian

 I am using web2py Version 2.2.1 (2012-10-21 16:57:04) stable on OS X 
 Mountain Lion and GoogleAppEngineLauncher version 1.7.3 (1.7.3.333)



-- 





[web2py] Orderby does not work field type 'double', sorts as if floats were strings

2012-11-21 Thread Mark Li
I currently have a table with 'scores' as one of the fields, with the field 
type 'double'. 

When I go to fetch a row (ordered by scores) and print the scores, they 
come back sorted as if they were strings.
I use the following:

rows = db(db.song_table).select(orderby = db.song_table.scores)
for x in rows:
print x.scores

this prints out the following:

-15.0
-16.0
-17.0
-2.0
-20.0
-34.0
0.0
0.0
15.0
2.0
20.0


The scores are ordered as if they were strings, not numbers. However, when 
you fetch a score, it is still a float, not a string. 

Is this intended behavior, or a bug with field type 'double'? 


I am aware that for field type 'integer', the scores are sorted properly, 
but I will have decimals in my scores.



-- 





[web2py] Re: I need a bit of Help with a function ! .. please ...

2012-11-21 Thread Don_X


 Thank you lyn2py ...


Unfortunately, your proposition does not work !

In this situation,  I wanted to practice the DRY principal ( DONT REAPEAT 
YOURSELF ) ... but it seems  ( based on my limited knowledge  ) 
the only way that I succeeded was in duplicating the exact same view page 
of index.html and named it member.html and offcourse by passing  the  
dictionnary membr as argument in order to view other 
members of the site

I did it like this :  ( it is very simplist ... but it is the only way I 
got it to work ! )
@auth.requires_login()
def index():
   return dict()
   
def member():
for row in db(db.auth_user.id == db.auth_user(request.args(0))).select
():
membr = row  
return dict(membr=membr)

that way, when the user gets logged in, that user goes to his profile page 
at profile/index.html and can edit and manage his own profile etc ...

and when any other user wishes to simply view someone's else profile page  
they get to go to  profile/member/#where the # is the user id of that 
member and not edit possible .. just comments on that user's wall can be 
made or to look around based on that user's personal preferences etc ...

I wanted to have one single view page  ... but .. hey ... I guess I will 
have to settle for this scenario for the time being ... until I come up 
with another way to have one view page for both actions !

Don

-- 





Re: [web2py] Re: Unable to send email in web2py

2012-11-21 Thread Jonathan Lundell
On 21 Nov 2012, at 4:49 PM, Daniele byakugan...@gmail.com wrote:
 I just tried port 25 as recommended on google's FAQ 
 (http://support.google.com/mail/bin/answer.py?hl=enanswer=78775)
 Still nothing. I'm wondering how can I debug this? Is there a log file of 
 what's happening behind the scenes here?

Double-check that you can log in to gmail with the credentials you're 
providing. If you're using two-factor authentication, you'll need to generate 
an app-specific password, I think.

I set this up successfully a while ago, but I abandoned it because I very 
quickly ran into Gmail's limit on the number of messages that can be sent in a 
day. It's surprisingly low.

 
 On Wednesday, November 21, 2012 7:32:26 PM UTC, Daniele wrote:
 I'm trying to send emails upon user registration. This is what I have in my 
 models file:
 
 mail = auth.settings.mailer
 mail.settings.server = 'smtp.gmail.com:587'
 mail.settings.sender = 'em...@gmail.com' #There's a proper email here
 mail.settings.login = 'username:password' #There's a proper username/password 
 combination here
 auth.settings.registration_requires_verification = True
 auth.messages.verify_email = 'Click on the link http://' + 
 request.env.http_host + URL(r=request,f='user',args=['verify_email']) + 
 '/%(key)s to verify your email'
 
 mail.settings.server = settings.email_server
 mail.settings.sender = settings.email_sender
 mail.settings.login = settings.email_login
 
 But every time I register a user with a valid email address, I'm getting no 
 email.
 So I'm trying to do it manually with:
 mail.send('em...@gmail.com', 'Message subject', 'Plain text body of the 
 message')
 
 But I'm getting an error message in the terminal that says:
 WARNING:web2py:Mail.send failure:[Errno 111] Connection refused
 
 How can I fix this???
 
 -- 
  
  
  


-- 





[web2py] How to use web2py confirmation form ?

2012-11-21 Thread Amit
Hi,
I have Delete button on SQLFORM.grid and upon clicking on it , it should 
popup confirmation dialog before deleting the records and once user click 
on OK , it should delete the records.
For that purpose I used web2py confirmation form but it is not working.

please check below the code :

def delete_records():
form = FORM.confirm('Are you sure, you want to delete the records?')

if form.accepted:
#delete records

else:
pass

redirect(URL('another_page'))

when I clicked on Delete button, delete_records() function is getting 
called but not popping up the confirmation form and control is always going 
to else part means form is not accepted.

can anyone please suggest me what am I doing wrong?

-- 





[web2py] SQLFORM.factory unexpectedly sets id datatype to str

2012-11-21 Thread Mark Kirkwood
Suppose I have an model like:

db.define_table(
'dog',
Field('name'),
Field('type'),
Field('vaccinated', 'boolean', default=False),
Field('picture', 'upload', default=''),
format = '%(name)s')

and a controller like:

@auth.requires_login()
def dogtest():

theId = None

form=SQLFORM.factory(
Field('dogid', label='Name',
  requires=IS_IN_DB(db(db.dog), 'dog.id', '%(name)s')),
)

if form.process().accepted:
theId = form.vars.dogid

if not isinstance(theId, int):
response.flash = 'datatype test fail'
form.errors.dogid = 'wrong datatype for id'

return dict(form=form)

I would expect that due to the validation rule for 'dogid' being 
constrained to be a db.dog.id that its datatype should match (i.e int). 
However the code above triggers the 'wrong datatype for id' error (it is in 
fact a str).

Is this expected? I was blithely thinking that it would be typed to match 
the corresponding validation field.

--