[web2py] Re: How to use web2py auth using JavaScript+ajax?
I found an old thread: https://groups.google.com/forum/?fromgroups#!searchin/web2py/auth.login()$20from$20inside$20a$20component/web2py/Qg4AAePIlJw/tOTdGwtAj6EJ The discussion stopped at some point. On Friday, March 30, 2012 7:08:10 AM UTC-7, Anthony wrote: On Friday, March 30, 2012 2:22:42 AM UTC-4, thstart wrote: Thank you, could you please post an example? Perhaps someone else has a full working example. You just need a form on the page that gets posted via Ajax (see http://web2py.com/books/default/chapter/29/11#The-ajax-function), and then check the submitted credentials with auth.login_bare (see http://web2py.com/books/default/chapter/29/9#Manual-Authentication). Anthony
[web2py] Re: How to use web2py auth using JavaScript+ajax?
Thank you, could you please post an example? On Thursday, March 29, 2012 7:24:02 PM UTC-7, Anthony wrote: Now I need to make possible login/logout with just Javascript and Ajax snd calling web2py auth remotely. How to implement it so that I get the same functionality with sessions, etc? If you need to login with an Ajax request, try using auth.login_bare(). That will require you to handle the form creation and submission logic yourself. For Ajax logout, you can write your own function -- it just needs to add the logout event to the db via auth.log_event(auth.messages.logout_log, auth.user) and then set session.auth = None (the event logging is optional). Sessions should work as usual. Anthony
[web2py] How to use web2py auth using JavaScript+ajax?
I need to do a major rework in order to move client-side functionality to the browser and using Javascript to get more responsive client side experience with no refresh etc. That means web2py will give a rich server side functionality and all client work to be performed via JavaScript and Ajax. I made several tests and see this integration working just perfect. I successfully implemented auth with web2py. Now I need to make possible login/logout with just Javascript and Ajax snd calling web2py auth remotely. How to implement it so that I get the same functionality with sessions, etc? Assuming this is working, then how to retain the users' session state? Thanks in advance,
[web2py] Re: Python Negative Popularity
Guido is working for Google. GAE is having Python as a primary language - e.g. all libraries are implemented on Python first, Java and Go next. So we get a priority for Python. So from GAE point of view you better use Python to have an advantage. If not using GAE what alternatives we have? PHP is not secure and is outdated. Google refuses to use it on GAE for security reasons. Javascript is the only possibility for the client side, node.js makes it possible for server side. Java is bloated, inefficient, etc. So basically it boils down to two options: Javascript and Python. On Thursday, March 29, 2012 6:42:08 AM UTC-7, Ovidio Marinho wrote: The fall of the python's fault Django and Python 3.0? http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Ovidio Marinho Falcao Neto Web Developer ovidio...@gmail.com ovidiomari...@itjp.net.br ITJP - itjp.net.br 83 8826 9088 - Oi 83 9334 0266 - Claro Brasil
[web2py] How to get unencrypted auth password?
I need to unencrypt auth password having the key. How to do that?
[web2py] Re: How to get unencrypted auth password?
I needed to transfer accounts to a new server. It turns out it is not needed.
[web2py] Re: How to get unencrypted auth password?
it was not needed to decrypt I wanted to say.
[web2py] Re: How to get unencrypted auth password?
Hi Massimo, Could you please comment on related question? https://groups.google.com/forum/#!topic/web2py/DXQ9hBAuVDA Tanks in advance, --Constantine
[web2py] Re: Ho to implement a SignIn with multiple verified email addresses.
the simplest way to implement without changing auth table is: 1) user logs in with email/password 2) my app checks if login passed through 3) if not my app checks if the email entered in login matches a list in a different table. 4) if it matches, it checks the password if matches in auth table and if it matches, the login is OK. To make this working I need info on 2) and 4)
[web2py] How to modify the look and text of: Remember me (for 30 days)?
I need to modify the look and text of: Remember me (for 30 days) How to do that?
[web2py] Re: How to modify the look and text of: Remember me (for 30 days)?
Actually I need just to change Remember me (for 30 days) to Remember mebr(for 30 days)
[web2py] Re: How to modify the look and text of: Remember me (for 30 days)?
Thank you Anthony, will try it!
[web2py] Re: How to modify the look and text of: Remember me (for 30 days)?
It worked. Now I want to change *formstyle* and default labels: 1) E-mail to Email 2) The message in red below Email: Invalid email to Please enter a valid email address. 3) The message in red below password: too short to Please enter a valid password. too short is actually misleading because I am hitting Sign Up with all fields empty. auth.settings.login_onvalidation = login_email_lower current.app.auth = auth form=current.app.auth.login(next=login_next) form.custom.submit['_data-theme'] = 'e' form.custom.submit_button = 'Sign In' like in: form_add_email_address = SQLFORM.factory( Field('email_address', requires=[IS_NOT_EMPTY(), IS_EMAIL(error_message='invalid email!')]), submit_button = 'Add', *formstyle *= 'table2cols' )
[web2py] Re: How to modify the look and text of: Remember me (for 30 days)?
This is working: auth.settings.formstyle ='divs' This is not working (it remains E-mail): auth.messages.label_email = 'Email' Remember me (for 30 days works) - but there is a space above it up to password - how to remove it?
[web2py] Re: How to modify the look and text of: Remember me (for 30 days)?
Also on Sign Up form I got a message 'too short' below the Password field - in the book link there is not correspondent function to change it. Additionally, tried to change auth.messages.invalid_email = 'Please enter a valid email address' But it still shows 'Invalid email'
[web2py] Ho to implement a SignIn with multiple verified email addresses.
I need to implement the following. Basically a SignIn with multiple verified email addresses. 1. A first time email/password SignUp. 2. Registered emails - send verification to the email account and verified from the user after click. (this is done). 3. Each of the registered emails plus the initial SignUp email to be a valid email address for email/password SignIn. The password - the same as the initial Sign Up. e.g. the user SignUp with ema...@...com/password, then he registers/verifies two more emails: ema...@...com, email3...com. when he logs in next time he can login with: ema...@...com/password ema...@...com/password ema...@...com/password Security is OK because he is the owner of ema...@...com, ema...@...com and proves it by SignIn to these email accounts. ema...@...com is pending until he does the same as for other email addresses. How to accomplish this?
[web2py] Re: How is the best way to export/import auth_user database?
yes, how to have same ID's?
[web2py] Re: How is the best way to export/import auth_user database?
It is a complex case. I am using GAE and already having users. Needed to change the database structure, so I need to move to new GAE app. The simplest option is to re-invite the users but they are 100s. They will need to re-register again using email/password. Probably not big deal for them but I try to eliminate this step - if it is possible to migrate their accounts, then re-direct the domain to the new GAE app and when they access the new site, which will look the same they just have to login. But the ID's are used in the database for their membership. If their ID's are different it will not work. I am using the native GAE models for speed. web2py - only the auth functionality plus the generated ID's.
[web2py] Re: How is the best way to export/import auth_user database?
you are correct - if I have a way to use GAE to populate auth table - this is the best way, but how to do that?
[web2py] How is the best way to export/import auth_user database?
I need to migrate to new server. How is the best way to export auth_user data from the old and import to the new database and all username/passwords to be used with no change?
[web2py] How to do that: Verifying email account ownership
Verifying email account ownership - I am brainstorming for the best way to know email address is owned by an user. Something like that - a user enters email address, my app generates a code and sends an email message with a link with this code, the user clicks and comes to my app which thus verifies he is the owner of the email account. Similar to reset password. How is the easiest wat to do that with web2py?
Re: [web2py] How to do that: Verifying email account ownership
I mean a separate functionality from auth. Like the user is posting a list of email addresses in a text box and my app gets them and sends verification email messages to these accounts. Once the user clicks the links to go to my app and my app to mark this email verified and store it in a users' separate database
[web2py] email/password Login cannot enter longer emails like 30 letters.
I defined email/password only Login. cannot enter longer emails like 30 letters. I see in auth_user Field('email', length=512, type='string', default='', label=current.T('Email')), What is wrong?
[web2py] Re: email/password Login cannot enter longer emails like 30 letters.
problem solved - it was in the widget - thank you!
[web2py] How to implement http_user_agents statistics?
I am recording http_user_agents info like this: *value:* [u'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)', u'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7', u'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; BRI/2)'] In order to optimize the app according most used devices. How is the best way to analyze this info and make a statistics?
[web2py] Re: How to make a function to download a file?
*As I see I need this:* * stream = cStringIO.StringIO() * * return stream.getvalue() * * * *I have a ready to go content as a string in a variable:* *content = * '.'* * So how to put this string in a stream? *My code is:* * * *def download(): response.headers['Content-Type'] = 'text/csv' attachment = 'attachment;filename=' + file+ '.csv' response.headers['Content-Disposition'] = attachment content = ',,' raise HTTP(200,str(content), **{'Content-Type':'text/csv', 'Content-Disposition':attachment + ';'})* * *
[web2py] Re: How to make a function to download a file?
file is composed dynamically - I get it from request - it is send like ?file=name and I get it from there. can you post the code you just tried?
[web2py] Re: How to make a function to download a file?
You mean my original code is working? With IE it is not. What browser you are using? In IE nothing comes for download.
[web2py] Re: How to make a function to download a file?
I don't use a database to create the CSV content but generate is as a comma delimited text. Also I want to set the file name to be downloaded. I don't see how to do it from the book. This line has to be changed in order to work: raise HTTP(200,str(content), **{'Content-Type':'text/csv', 'Content-Disposition':attachment + ';'})
[web2py] How to add link for downloading CSV file with specifying filename
I generate CSV content ready to use as a .csv file; don't use a database and have a function to do that. I want this .csv file to be available for download after click and the filename to be set from the application. How to do that in web2py?
[web2py] GAE+email+a list of CC
I want to send an email to multiple users so each of them to reply to all recipients in the message. I am using GAE and set a CC=[ema...@gmail.com,ema...@gmail.com...] but only the 'to' email is received and in CC I see CC=None. What is wrong?
[web2py] Re: GAE+email+a list of CC
Here is the code: cc = [] for to_name, to_email_addr in to_email_addrs: cc.append(to_email_addr) result = *send_email_message_web2py*( reply_to=reply_to, reply_to_email_addr=reply_to_email_addr, sender_organization=sender_organization, sender_name=sender_name, sender_email_addr=sender_email_addr, sender_phone_work=sender_phone_work, to_name=to_name, to_email_addr=to_email_addr, template=template, subject=subject, message_body=message_body, attachments=attachments, cc=cc, bcc=bcc, ) def *send_email_message_web2py* ( reply_to, reply_to_email_addr, sender_organization, sender_name, sender_email_addr, sender_phone_work, to_name, to_email_addr, template, subject, message_body, attachments=None, cc=None, bcc=None, ): from gluon import current request = current.request response = current.response mail=current.app.mail if not isinstance(cc, (list, tuple)):\ to_email_addr=to_email_addr.replace(' ','') reply_to_email_addr=reply_to_email_addr.replace(' ','') result = False sender = ('%s %s' % (sender_name, sender_email_addr)) reply_to_email_addr1 = ('%s %s' % (reply_to, reply_to_email_addr)) to_email_addr = ('%s %s' % (to_name, to_email_addr)) ## #render the email template ## filename_email_template_txt = template + '.txt' filename_email_template_txt=os.path.join(request.folder,filename_email_template_txt) if os.access(filename_email_template_txt,os.R_OK): body=open(filename_email_template_txt,'r').read() else: body=('Internal error:%s' % (message_body)) filename_email_template_html = template + '.html' filename_email_template_html=os.path.join(request.folder,filename_email_template_html) if os.access(filename_email_template_html,os.R_OK): body=open(filename_email_template_html,'r').read() else: body=('htmlbodyh1Internal error/h1%s/html' % (message_body)) ## #import name in body context=dict( sender_organization = sender_organization, sender_name = sender_name, sender_email_addr = sender_email_addr, sender_phone_work = sender_phone_work, to_name_in_body = to_name_in_body, to_name = to_name, message_body=message_body ) try: message_txt = response.render(filename_email_template_txt,context) except Exception, e: pass context=dict( sender_organization = sender_organization, sender_name = sender_name, sender_email_addr = sender_email_addr, sender_phone_work = sender_phone_work, to_name_in_body = to_name_in_body, to_name = to_name, message_body=message_body ) #message_body=message_body.replace('br','\n') #logging.info('%s: context_html:%s' % (sub, str(context))) try: message_html = response.render(filename_email_template_html,context) except Exception, e: pass ## message_html = message_html.replace('lt;brgt;', 'br') message_body = (message_txt, message_html) to = to_email_addr reply_to = reply_to_email_addr msg = ('%s, to:%s, subject=%s, message_html:%s' % (sub, to, subject, str(message_html))) logging.info('%s:%s' % (sub, msg)) ''' cc: list or tuple of carbon copy receiver addresses; will also accept single object bcc: list or tuple of blind carbon copy receiver addresses; will also accept single object reply_to: address to which reply should be composed def send( self, to, subject='None', message='None', attachments=None, cc=None, bcc=None, reply_to=None, encoding='utf-8', headers={} ): ''' result = *mail.send*(to=to,
[web2py] How to optionally check IS_EMAIL if not blank?
I have this form: form = SQLFORM.factory( Field('first_name', requires=IS_NOT_EMPTY() ), Field('last_name', requires=IS_NOT_EMPTY() ), Field('email_work', requires=[IS_EMAIL(error_message='invalid email!')]), Field('email_home', requires = IS_EMAIL(error_message='invalid email!')), submit_button = submit_button_text ) Right now if email_work AND email_home are not blank I get an error message 'invalid email' which is OK. What I want as a better solution is web2py not to check if email is valid if email_work OR email_home are blank. Only if not blank is submitted then to check if it is a valid email address. How to accomplish this?
[web2py] How to make a function to download a file?
I want the visitors to be able to download a CSV file. here is my code: def download(): response.headers['Content-Type'] = 'text/csv' attachment = 'attachment;filename=' + file+ '.csv' response.headers['Content-Disposition'] = attachment content = ',,' raise HTTP(200,str(content), **{'Content-Type':'text/csv', 'Content-Disposition':attachment + ';'}) When I click on the link download, I get 'Undefined' in the browser and nothing is downloaded. What is wrong?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
OK I added this code after database definition: db.auth_user.email.requires.insert(0, IS_LOWER()) So it is always present with register and login. Now register is working as expected - e.g. if I create first an account with lower case email and then try to create an account with same email but mixed case, the system does not creates a new account. So this important part is working now. But now when I try to login I always have to enter lower case, with mixed case the message is 'Invalid login'. here is the code: #auth.settings.login_onvalidation = *login_email_lower*#current.app.auth = authform=current.app.auth.login(next=login_next) As you see I commented out login_email_lower and I suppose I should return it back. def *login_email_lower*(form): form.vars.email = form.vars.email.lower() return(form)
Re: [web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
How to perform a function to strip out white spaces before registration?
Re: [web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
the issue is I see with the debugger in the case of register - the validator executes after register telling 'Invalid Email' when I copy/paste an email with space after the email itself. I want to prevent this to happen.
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
I used your suggestion for 'reset_email_lower' from this thread but it doesn't works with register. It works for login/reset_password but not with register. https://groups.google.com/forum/#!topic/web2py/1QjBUy62jP8 I added this code (reset_email_lower) to registration too. But I checked the database and see the following: 1) I create a new user account with email all lower case. 2) the app logs in as default. 3) Log out. 4) I try to create a new user account with same email but first letter a capital. I see in the database that a new account is created and the email is stored a lower cap but now I have two id's with the same email in auth_user table 5) after creating the new account the app logs automatically and in auth_event I see User # Registered and in user_id column the user_id of the other account which already was created with lower caps. Bottom line - when registering - how to convert the email to lower cap so web2py to be able to check if the same email is already registered, and if so to prevent creating of a new account and notify the user that the account already exist.
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
could you please post a code how to that for register especially?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
Thank you, I will test it.
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
great, I set this globally where the auth_user table is defined. On register got the message *'value already in database or empty'* how to change it?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
Also, when logged in - how to make possible for the user to change his email?
[web2py] Re: email/password login only: How to change email to lower case at the register page and store as a lower case to the database.
I am using email/password as a login. After login I want to have an option for the user to be able to change his email used as a login. say the user logs in with myem...@gmail.com/ after log in he clicks on a button (change your email), a form is present where he enters his new email as newem...@gmail.com. He logs out, and now he can login with newem...@gmail.com/ e.g. auth_user.email used to be myem...@gmail.com, after the change to be newem...@gmail.com