Re: [web2py] Re: Helper for many-to-many result sets?
Taking this exact example Foreach movie in movies print movie.title foreach stars in movie.stars print star.name I guess `movie.stars` is a list:string field? if so.. there's one-liner solution table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in movie.stars]))) for movie in movies]) if db.stars has a list:reference to movies table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in db(movie.id.belongs(db.stars.movies)).select(db.stars.name)]))) for movie in movies]) or with a subquery (for each loop iteration) table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(item.stars.name) \ for item in *db((db.movies.id == db.stars.id) \* * ( db.movies.id == movie.id)).select(db.stars.name)*]))) \ for movie in movies]) On Mon, Aug 13, 2012 at 9:51 PM, Cliff Kachinske cjk...@gmail.com wrote: There may be a more elegant way to do this, but it does work. Be sure to select the movie id in your query. Then you can do something like this: rows = db(query).select(.) #whatever you're doing trows = [] stars = [] for i, r in enumerate rows: stars.extend([r.stars.name, BR()]) if r.movie.id != rows[i+1].movie.id or i+1==len(rows): trows.append(TR( TD(r.movie.name), TD(stars), # Other stuff from the row follows ) ) stars=[] # Reset the stars list return(TABLE(*trows)) On Monday, August 13, 2012 6:04:44 PM UTC-4, Mike Girard wrote: I have a movie table that has a many-to-many relationship with a person table expressed through a star table. A simplified version of my model: db.define_table('movie', Field('title','string'), db.define_table('person', Field('name', 'string', unique=True), db.define_table('star', Field('movie_id', db.movie), Field('person_id', db.person), I am able to create a select that joins the three tables and produces a result with all the data I need. It's easy to iterate through the result and produce something akin to this: Movie Title Star 1 Movie Title Star 2 Movie Title Star 3 What I want is: Movie Title 1 Star 1, Star 2, Star 3 Movie Title 2 Star 1, Star 2, Star 3 Programmatically, I'd like something like: for each movie in rows h2move.title/h2 ul for each star in movie.stars listar.name/li Before I write a function to pre-process the result, can someone tell me if there is a helper for producing a result of this kind? This thread addresses the same issue - https://groups.google.com/**forum/?fromgroups#!topic/**web2py/GQsMt4qvqSshttps://groups.google.com/forum/?fromgroups#!topic/web2py/GQsMt4qvqSs - but I was unable to discern the solution the question asker had produced for himself, the key to which was this: web2py automatically add the many-to-many sets to an instance with the same name of the relation table I do not know what that means. -- --
Re: [web2py] Re: Helper for many-to-many result sets?
I guess you can also do: table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in * movie.stars.select()*])) for movie in movies]) when a table is referenced by another, he gets a DAL Set object with the referer name. movie.*stars *will be a DAL Set. which has *select, update, delete* methods But it will only happens depending on your model and relations definition. Can you share your model for those 2 tables? On Tue, Aug 14, 2012 at 3:10 AM, Bruno Rocha rochacbr...@gmail.com wrote: Foreach movie in movies print movie.title foreach stars in movie.stars print star.name --
[web2py] redirect results in invalid request.
As part of a router function I have the following code: id=request.args(0) account=db(db.NodeAccount.nodeID==id).select(db.NodeAccount.ALL).first() if account: if account.statusID!=1: # in that case the account is blocked or under maintenance redirect(URL('card',args=id)) elif account.accountID==ADVANCEDACCOUNTID: if not session[id]: session[id]=Storage(id=id) session[id].accountid=ADVANCEDACCOUNTID redirect(URL('site','index',args=id)) elif account.accountID==ADVANCEDCONNECTORACCOUNTID: if not session[id]: session[id]=Storage(id=id) session[id].accountid=ADVANCEDCONNECTORACCOUNTID redirect(URL('connector','index',args=id)) In a controller I start the index function with the following code: if not len(request.args): redirect(URL('addressbook','router')) elif not session[request.args(0)]: redirect(URL('addressbook','router',request.args(0))) elif not session[request.args(0)].accountid==ADVANCEDACCOUNTID: redirect(URL('addressbook','router',request.args(0))) else: When I have an object session[283] and visit the url: http://127.0.0.1:8000/bootstrap/site/index/283 and then change 283 to 2053: http://127.0.0.1:8000/bootstrap/site/index/2053 (and session[2053] doesn't exist) instead of a redirection to http://127.0.0.1:8000/bootstrap/addressbook/router/2053 I get an invalid request: http://127.0.0.1:8000/addressbook/router/2053 When I add the application to the url: redirect(URL('bootstrap','addressbook','router',request.args(0))), I get: Traceback (most recent call last): File /Library/Python/2.5/site-packages/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 192, in module File /Library/Python/2.5/site-packages/web2py/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 19, in index redirect(URL('bootstrap','addressbook','router',request.args(0))) File /Library/Python/2.5/site-packages/web2py/gluon/html.py, line 246, in URL application = r.application AttributeError: 'str' object has no attribute 'application' Why doesn't this work? Kind regards, Annet. --
Re: [web2py] redirect results in invalid request.
On Tue, Aug 14, 2012 at 10:14 AM, Annet anneve...@googlemail.com wrote: In a controller I start the index function with the following code: if not len(request.args): redirect(URL('addressbook','router')) elif not session[request.args(0)]: redirect(URL('addressbook','router',request.args(0))) elif not session[request.args(0)].accountid==ADVANCEDACCOUNTID: redirect(URL('addressbook','router',request.args(0))) else: Try this instead: URL('adresbook', 'router', args=request.args(0) Marin --
[web2py] Re: Sending emails with background queue problem
The problem sums up to: I expect when committing that something like saving a file happens...everybody, and I mean everybody trying to access that file later would read the same thing. SQlite, MSSQL, Postgresql, Oracle adapters work this way, and I assume also mongo and couchdb. I tried to read the PEP for the DBAPI and saw no explicit references to what committing should do in reference to a multiprocess environment (i.e. if commit should save the changes and make them available for other processes). However, I'm not a python guru to rule that out, I'm just saying that from a DAL point of view having to commit before reading to see records changed/inserted by other processes is required ONLY from mysql. On Tuesday, August 14, 2012 6:15:14 AM UTC+2, Massimo Di Pierro wrote: Should we change the settings in the Adapter? On Monday, 13 August 2012 17:21:09 UTC-5, Niphlod wrote: The most probable cause is the transaction isolation problem with mysql as explained in https://groups.google.com/d/msg/web2py/qLHP3iYz8Lo/Ly2wqK4qZZgJ I'm starting to think that it's the only adapter behaving differently. On Monday, August 13, 2012 11:46:11 PM UTC+2, Florian Letsch wrote: Yes, I am using mysql. I've accidentally posted this twice [0] on the group (sorry for that). Anthony asked: How are emails added to the database -- does that happen within the application, or also in a script? Emails are added to the database from within the application (a controller function adds a confirmation email to the queue) [0] https://groups.google.com/forum/?fromgroups#!topic/web2py/YT2jDMea6lU On Sunday, 12 August 2012 07:17:39 UTC+12, Massimo Di Pierro wrote: Are you using mysql? On Friday, 10 August 2012 23:11:03 UTC-5, Florian Letsch wrote: I want to send emails using a background queue as described in the web2py book: http://web2py.com/books/default/chapter/29/8#Sending-messages-using-a-background-task However, the queue only sends emails that have been in the database when I start the script. Database entries added lateron don't get picked up by the script. The only way I can achieve that is to add another db.commit() before the select(). I am sure this is not supposed to be necessary. Does anyone know why this is happening? import time while True: db.commit() # Only works if I add this line rows = db(db.queue.status=='pending').select() for row in rows: if mail.send(to=row.email, subject=row.subject, message=row.message): row.update_record(status='sent') else: row.update_record(status='failed') db.commit() time.sleep(60) # check every minute --
Re: [web2py] redirect results in invalid request.
edit: URL('addressbook', 'router', args=request.args(0)) On Tue, Aug 14, 2012 at 10:34 AM, Marin Pranjić marin.pran...@gmail.comwrote: On Tue, Aug 14, 2012 at 10:14 AM, Annet anneve...@googlemail.com wrote: In a controller I start the index function with the following code: if not len(request.args): redirect(URL('addressbook','router')) elif not session[request.args(0)]: redirect(URL('addressbook','router',request.args(0))) elif not session[request.args(0)].accountid==ADVANCEDACCOUNTID: redirect(URL('addressbook','router',request.args(0))) else: Try this instead: URL('adresbook', 'router', args=request.args(0) Marin --
Re: [web2py] redirect results in invalid request.
Hi Marin. Thanks for your reply, problem solved. Annet. --
[web2py] comparing responding arg with request.args(0)
My application largely depends on request.args(0), which holds the id of a node. When visitors don't change the id in the url this works well, however, when a visitor changes the url, the applications' behaviour becomes unpredictable. I think I can solve this problem by comparing the responding arg with request.args(0), when it differs I only have to redirect to a router function to make the application's behaviour predictable. What is the best way to implement this, are there better ways to solve this problem? Kind regards, Annet --
[web2py] web2py for embedded hardware control
Hi all, I'm fairly new to web2py and python, but I'm trying to build a 'proof of concept' system to demonstrate how one of our products might work. The system consists of an embedded Linux board and an RS232 serial digital compass. The system will read the orientation from the compass and light a few LEDs as well as an audible tone to point a user in the right direction. The device will also host a small web server running web2py so that people can log on and view the real compass outputs - possibly an animated graphical display if i get that far... So really i just need some advice about the best architecture to get me started. Should I build everything into web2py - will it handle worker threads for reading serial port etc, will it handle the LEDs/tone if no http users are connected? Should I build a stand-alone python 'service' that handles the hardware interface - web2py can then read the results for the web elements? Would this use JSON, SOAP etc? Any help would be gratefully appreciated. Sam --
[web2py] Re: redirect results in invalid request.
Note, the signature of the URL() function is URL(a, c, f, r, args, vars, ...). So, in your first example, it interprets addressbook as the application and request.args(0) as the function, and in your second example, it interprets request.args(0) as the request object (which is why you get the error about a str object not having an application attribute). So, in general, it is best to specify args and vars as keyword arguments -- if you want to specify them as positional arguments, you have to fill in all four preceding positional arguments as well. Also, note that regarding the first three arguments, URL() is smart -- if you only specify two positional arguments, it assumes they are c and f rather than a and c, and if you only specify one positional argument, it assumes it is f rather than either a or c (if a and or c are missing, they get filled in with the current application and controller). Anthony On Tuesday, August 14, 2012 4:14:20 AM UTC-4, Annet wrote: As part of a router function I have the following code: id=request.args(0) account=db(db.NodeAccount.nodeID==id).select(db.NodeAccount.ALL).first() if account: if account.statusID!=1: # in that case the account is blocked or under maintenance redirect(URL('card',args=id)) elif account.accountID==ADVANCEDACCOUNTID: if not session[id]: session[id]=Storage(id=id) session[id].accountid=ADVANCEDACCOUNTID redirect(URL('site','index',args=id)) elif account.accountID==ADVANCEDCONNECTORACCOUNTID: if not session[id]: session[id]=Storage(id=id) session[id].accountid=ADVANCEDCONNECTORACCOUNTID redirect(URL('connector','index',args=id)) In a controller I start the index function with the following code: if not len(request.args): redirect(URL('addressbook','router')) elif not session[request.args(0)]: redirect(URL('addressbook','router',request.args(0))) elif not session[request.args(0)].accountid==ADVANCEDACCOUNTID: redirect(URL('addressbook','router',request.args(0))) else: When I have an object session[283] and visit the url: http://127.0.0.1:8000/bootstrap/site/index/283 and then change 283 to 2053: http://127.0.0.1:8000/bootstrap/site/index/2053 (and session[2053] doesn't exist) instead of a redirection to http://127.0.0.1:8000/bootstrap/addressbook/router/2053 I get an invalid request: http://127.0.0.1:8000/addressbook/router/2053 When I add the application to the url: redirect(URL('bootstrap','addressbook','router',request.args(0))), I get: Traceback (most recent call last): File /Library/Python/2.5/site-packages/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 192, in module File /Library/Python/2.5/site-packages/web2py/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 19, in index redirect(URL('bootstrap','addressbook','router',request.args(0))) File /Library/Python/2.5/site-packages/web2py/gluon/html.py, line 246, in URL application = r.application AttributeError: 'str' object has no attribute 'application' Why doesn't this work? Kind regards, Annet. --
[web2py] Re: comparing responding arg with request.args(0)
What do you mean by responding arg? On Tuesday, August 14, 2012 5:57:29 AM UTC-4, Annet wrote: My application largely depends on request.args(0), which holds the id of a node. When visitors don't change the id in the url this works well, however, when a visitor changes the url, the applications' behaviour becomes unpredictable. I think I can solve this problem by comparing the responding arg with request.args(0), when it differs I only have to redirect to a router function to make the application's behaviour predictable. What is the best way to implement this, are there better ways to solve this problem? Kind regards, Annet --
Re: [web2py] web2py for embedded hardware control
I think you're not going to have good results with web2py for this kind of project. I'd encourage you to take a look at projects as http://mblogic.sourceforge.net/ , which using python (and a bit of javascript) allows you to control, and report or easily showing animated bars and graphics. mblogic has a modular design and allows you use things as modbus, but you don't need to use modbus to build a scada-like web application. You only will need to add authentication, as mblogic (in its hmiserver module) doesn't have it implemented. Hope this helps. Regards. 2012/8/14 Sam samjenkin...@googlemail.com: Hi all, I'm fairly new to web2py and python, but I'm trying to build a 'proof of concept' system to demonstrate how one of our products might work. The system consists of an embedded Linux board and an RS232 serial digital compass. The system will read the orientation from the compass and light a few LEDs as well as an audible tone to point a user in the right direction. The device will also host a small web server running web2py so that people can log on and view the real compass outputs - possibly an animated graphical display if i get that far... So really i just need some advice about the best architecture to get me started. Should I build everything into web2py - will it handle worker threads for reading serial port etc, will it handle the LEDs/tone if no http users are connected? Should I build a stand-alone python 'service' that handles the hardware interface - web2py can then read the results for the web elements? Would this use JSON, SOAP etc? Any help would be gratefully appreciated. Sam -- --
[web2py] Change the default format.
I have a problem I want to change the values stored into the database data_id value of id. db.define_table('product', Field('data_id','integer'), Field('name','string') format='%(name)s') please .. any help, cues or snippets of codes to accomplish this ... will be greatly appreciated Picheth. --
[web2py] Using Decorators for RESTful URLs
Hi all, Could anybody help me give a heads up on how to use RESTful service with URL decorators in web2py? Deepak --
[web2py] Re: Change the default format.
It's not quite clear what you want to do -- could you be more specific and maybe provide an example? On Tuesday, August 14, 2012 1:55:00 AM UTC-4, Picheth wrote: I have a problem I want to change the values stored into the database data_id value of id. db.define_table('product', Field('data_id','integer'), Field('name','string') format='%(name)s') please .. any help, cues or snippets of codes to accomplish this ... will be greatly appreciated Picheth. --
[web2py] Re: Using Decorators for RESTful URLs
Are you asking how to use the @request.restful decorator, or how to use additional decorators along with that one? If the former, check out http://web2py.com/books/default/chapter/29/10#Restful-Web-Services; if the latter, here's an example with an auth decorator: http://web2py.com/books/default/chapter/29/10#Access-Control. Anthony On Tuesday, August 14, 2012 1:22:28 AM UTC-4, deepak wrote: Hi all, Could anybody help me give a heads up on how to use RESTful service with URL decorators in web2py? Deepak --
[web2py] Re: autoincremente field with a specific first value
I would like to have it on insert. Like for example a mouvement number that start with 100 not 1 as is the case for id. I have foud another alternative in fiorm.accepts(): def index(): example action using the internationalization operator T and flash rendered by views/default/index.html or views/generic.html form = SQLFORM(db.bs) if form.accepts(request.vars,session): db(db.bs.id==form.vars.id).update(Numero=db.bs.id + 100); return dict(form=form) But I still cannot declare Number as not null and unique. On Monday, August 13, 2012 4:06:57 AM UTC, Massimo Di Pierro wrote: Do you mean something like this? db(query).update(field = db.table.field+value) On Friday, 10 August 2012 10:46:54 UTC-5, tigmmi wrote: Is there a way to add an autoincremente field with a specific first value. Compute won't work with id + number. --
[web2py] Re: autoincremente field with a specific first value
I would like to have it on DAL mysql specific. I found the _befor_insert and other events very intresent and can hel in many part of my code. Thansk to Massimo. On Monday, August 13, 2012 6:33:59 PM UTC, Cliff Kachinske wrote: In MySQL there is ALTER TABLE mytable AUTO_INCREMENT = 500 Is that what you want to do? On Friday, August 10, 2012 11:46:54 AM UTC-4, tigmmi wrote: Is there a way to add an autoincremente field with a specific first value. Compute won't work with id + number. --
Re: [web2py] web2py for embedded hardware control
Thanks for you suggestion, i'll take a look. On Tuesday, 14 August 2012 11:52:47 UTC+1, José Luis Redrejo Rodríguez wrote: I think you're not going to have good results with web2py for this kind of project. I'd encourage you to take a look at projects as http://mblogic.sourceforge.net/ , which using python (and a bit of javascript) allows you to control, and report or easily showing animated bars and graphics. mblogic has a modular design and allows you use things as modbus, but you don't need to use modbus to build a scada-like web application. You only will need to add authentication, as mblogic (in its hmiserver module) doesn't have it implemented. Hope this helps. Regards. 2012/8/14 Sam samjen...@googlemail.com javascript:: Hi all, I'm fairly new to web2py and python, but I'm trying to build a 'proof of concept' system to demonstrate how one of our products might work. The system consists of an embedded Linux board and an RS232 serial digital compass. The system will read the orientation from the compass and light a few LEDs as well as an audible tone to point a user in the right direction. The device will also host a small web server running web2py so that people can log on and view the real compass outputs - possibly an animated graphical display if i get that far... So really i just need some advice about the best architecture to get me started. Should I build everything into web2py - will it handle worker threads for reading serial port etc, will it handle the LEDs/tone if no http users are connected? Should I build a stand-alone python 'service' that handles the hardware interface - web2py can then read the results for the web elements? Would this use JSON, SOAP etc? Any help would be gratefully appreciated. Sam -- --
[web2py] Re: KeyError: 'name' when inserting/updating via appadmin
On Saturday, August 11, 2012 4:28:24 AM UTC+5:30, Derek wrote: That definitely looks like a problem. Still though, I think you are taking 3NF a bit too far, no? What I have given below is an example. So it would look i'm taking 3NF too far. But in my real app, have about 10-15 tables, some of them have just name, some have both name and description, some have neither. hence the way I have defined inheritance. I hope that makes sense. -Mandar On Wednesday, August 8, 2012 10:08:53 AM UTC-7, Mandar Vaze wrote: I'm using web2py version : Version 2.0.0 (2012-07-26 06:06:10) dev I have tables defined as follows : name = db.Table(db, 'name', Field('name', 'string', length=128, notnull=True, unique=True)) name_desc = db.Table(db, 'base', name, Field('description', 'text', default='')) db.define_table('mother', name_desc, format='%(name)s') db.define_table('father', name_desc, format='%(name)s') db.define_table('child', name_desc, Field('mother', db.mother), Field('father', db.father), format='%(name)s') I am able to insert data in mother table via script (like db.mother.insert(name=Alice)) But when I use appadmin to insert new record into mother table, I get the following error : Traceback (most recent call last): File /home/mandar/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /home/mandar/web2py/applications/test1/controllers/appadmin.py, line 432, in module File /home/mandar/web2py/gluon/globals.py, line 182, in lambda self._caller = lambda f: f() File /home/mandar/web2py/applications/test1/controllers/appadmin.py, line 127, in insert if form.accepts(request.vars, session): File /home/mandar/web2py/gluon/sqlhtml.py, line 1146, in accepts hideerror=hideerror, File /home/mandar/web2py/gluon/html.py, line 1870, in accepts status = self._traverse(status,hideerror) File /home/mandar/web2py/gluon/html.py, line 793, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File /home/mandar/web2py/gluon/html.py, line 793, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File /home/mandar/web2py/gluon/html.py, line 793, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File /home/mandar/web2py/gluon/html.py, line 793, in _traverse newstatus = c._traverse(status,hideerror) and newstatus File /home/mandar/web2py/gluon/html.py, line 800, in _traverse newstatus = self._validate() File /home/mandar/web2py/gluon/html.py, line 1625, in _validate (value, errors) = validator(value) File /home/mandar/web2py/gluon/validators.py, line 554, in __call__ table = self.dbset.db[tablename] File /home/mandar/web2py/gluon/dal.py, line 6877, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: 'name' Similarly, after populating mother/father and child tables via script when I try to update child record - In the dropdown I see mother's names instead of ID (as expected) but when I select different mother and submit I get same error (traceback may be slightly different - but same KeyError:'name' ) What is wrong with the table definitions ? Thanks, -Mandar --
Re: [web2py] Re: Book clarification regarding verify_email reset_password
Thinking again I am guessing a better option for this... (note: the problem here is not to get the 'key', the problem is to be able to build the string and interpolate multiple keys on to it on different running times) I think this could be better. auth,messages.verify_email = 'Click on the link http://%(host)s/%(url)s/%(key)s to verify your email' *So Auth would do:* auth.settings.get_verify_email = lambda key, httphost, url: auth.messages.verify_email \ % dict(host=host, url=url, key=key) auth.settings.verify_email_url = URL(..) auth.settings.verify_email_host = request.env.http_host self.settings.mailer.send(to=form.vars.email, subject=self.messages.verify_email_subject, message=self.settings.get_verify_email(key, self.settings.verify_email_url, auth.settings.verify_email_host) ) *Why this? just to let users to personalize the message string more easily.* Example: auth,messages.verify_email = ('Here I put my very long html code' 'I can write texts ' 'I can put a tutorial ' 'I can put an user agreement' 'ans so the final link' ' Click on the link' ' http://%(host)s/%(url)s/%(key)s ' to verify your email') *or even...* auth,messages.verify_email = template.render(my_verify_email_template.html, {mycontext: myvalues}) Customizing this message sin the current way is very difficult and lead on errors because of string interpolation being done on the time of definition. On Tue, Aug 14, 2012 at 12:14 AM, Anthony abasta...@gmail.com wrote: I think maybe the book is just suggesting the http://; + request.env.http_host part of the URL might not be the correct host name if you're behind a proxy, so you should ensure you have the correct full URL. The remainder of the URL should be correct as is. Note, the example shown in the book is actually the default value for auth.settings.verify_email, so you don't really have to set it unless you need to change it. Anthony On Monday, August 13, 2012 9:31:25 PM UTC-4, Anthony wrote: Actually, the book is a bit confusing there -- the example code appears to be complete as is. Anthony On Monday, August 13, 2012 9:09:46 PM UTC-4, JoeCodeswell wrote: Dear web2py folks, In the book it says in /chapter/29/9#Authentication: In Auth, by default, email verification is disabled. To enable email, append the following lines in the model where auth is defined: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. auth.settings.registration_**requires_verification = False auth.settings.registration_**requires_approval = False auth.settings.reset_password_**requires_verification = True auth.messages.verify_email = 'Click on the link http://' + \ request.env.http_host + \ URL(r=request,c='default',f='**user',args=['verify_email']) + \ '/%(key)s to verify your email' auth.messages.reset_password = 'Click on the link http://' + \ request.env.http_host + \ URL(r=request,c='default',f='**user',args=['reset_password']) + \ '/%(key)s to reset your password' You need to replace the string 1. 'Click on the link ...' in auth.messages.verify_email with the proper complete URL of the action verify_email. For both verify_email and reset_password: Should I replace 'Click on the link http://' With: 'Click on the link http://myserver.com/myapp/' Or with: 'Click on the link http://myserver.com/myapp/defa**ult/user/verify_email' My guess is the first, but because the book says proper complete URL, I am not sure. Thanks in advance for the help. Love and peace, Joe -- --
[web2py] Auth and Model less
Hello again, I'm having some trouble with my model less aproch with auth module. I've put him on a separeted file on modules folder, and, when needed, I import it as follows: modules/web2py/auth.py: auth = Auth(db, hmac_key=Auth.get_or_create_key()) controllers/tracking.py: from applications.main.modules.web2py.auth import auth But some times (its not every time) when I try to loggin, the form just don't validate and don't pass through the login/password for checking (I'm also using the default login form from docs). Maybe this have some relation with imports being done only once on appengine? And, if is it, what can I do about (since not every page on my app needs auth) Thanks --
Re: [web2py] Re: Book clarification regarding verify_email reset_password
auth,messages.verify_email = ('Here I put my very long html code' 'I can write texts ' 'I can put a tutorial ' 'I can put an user agreement' 'ans so the final link' ' Click on the link' ' http://%(host)s/%(url)s/%(key)s ' to verify your email') *or even...* auth,messages.verify_email = template.render(my_verify_email_template.html, {mycontext: myvalues}) But can't you already do either of the above? As long as the resulting string includes %(key)s somewhere, the current setup should work fine, no? In the first case, for example, you could do: auth.messages.verify_email = '''here I put my very long html code I can write text I can put a tutorial and so...the final link Click on the link http://%(host)s/%(url)s/%%(key)s to verify your email''' % dict(host='mysite.com', url= 'default/user/verify_email') Which will yield: 'here I put my very long html code\nI can write text\nI can put a tutorial\nand so...the final link\nClick on the link\nhttp://mysite.com/default/user/verify_email/%(key)s\nto verify your email' which includes %(key)s, which will be filled in by the register function. Anthony --
[web2py] compute fields do not show up in SQLFORM view form
I have a few fields that have compute attribute defined. I've only inserted the records via script - compute fields are updated correctly. I have a SQLFORM.grid which shows a join query. When I explicitly select the computed field in the fields param - it is shown correctly. But when I click the View or Edit button for that record, the computed field does NOT show up. (Same when I try to update the record via appadmin) I expect the computed field to definitely show up in the View form, and as read-only field in the Edit form. Why do the computed fields NOT show up in SQLFORM ? --
Re: [web2py] compute fields do not show up in SQLFORM view form
in your controller.. if request.args(0) == view: db.table.field.readable = True grid = SQLFORM.grid(.) http://zerp.ly/rochacbruno Em 14/08/2012 09:37, Mandar Vaze mandarv...@gmail.com escreveu: I have a few fields that have compute attribute defined. I've only inserted the records via script - compute fields are updated correctly. I have a SQLFORM.grid which shows a join query. When I explicitly select the computed field in the fields param - it is shown correctly. But when I click the View or Edit button for that record, the computed field does NOT show up. (Same when I try to update the record via appadmin) I expect the computed field to definitely show up in the View form, and as read-only field in the Edit form. Why do the computed fields NOT show up in SQLFORM ? -- --
[web2py] Re: Auth and Model less
modules/web2py/auth.py: auth = Auth(db, hmac_key=Auth.get_or_create_key()) Where does that db object come from? Note, global objects are defined only once when the module is first imported, so any such objects are associated with the first request and are not re-created with each request. Instead, you should put the Auth code inside a function or class and pass in the db object from the controller: module: def initialize_auth(db): auth = Auth(db, ...) auth.define_tables return auth controller: import initialize_auth auth = initialize_auth(db) Anthony --
Re: [web2py] Re: Auth and Model less
But the DB object can be static through requests as well or I should instantiate it on every request too? On Tue, Aug 14, 2012 at 10:02 AM, Anthony abasta...@gmail.com wrote: modules/web2py/auth.py: auth = Auth(db, hmac_key=Auth.get_or_create_**key()) Where does that db object come from? Note, global objects are defined only once when the module is first imported, so any such objects are associated with the first request and are not re-created with each request. Instead, you should put the Auth code inside a function or class and pass in the db object from the controller: module: def initialize_auth(db): auth = Auth(db, ...) auth.define_tables return auth controller: import initialize_auth auth = initialize_auth(db) Anthony -- -- Att, Felipe Meirelles. --
Re: [web2py] Re: Book clarification regarding verify_email reset_password
On 14 Aug 2012, at 5:35 AM, Anthony abasta...@gmail.com wrote: auth,messages.verify_email = ('Here I put my very long html code' 'I can write texts ' 'I can put a tutorial ' 'I can put an user agreement' 'ans so the final link' ' Click on the link' ' http://%(host)s/%(url)s/%(key)s ' to verify your email') or even... auth,messages.verify_email = template.render(my_verify_email_template.html, {mycontext: myvalues}) But can't you already do either of the above? As long as the resulting string includes %(key)s somewhere, the current setup should work fine, no? In the first case, for example, you could do: auth.messages.verify_email = '''here I put my very long html code I can write text I can put a tutorial and so...the final link Click on the link http://%(host)s/%(url)s/%%(key)s to verify your email''' % dict(host='mysite.com', url='default/user/verify_email') Which will yield: 'here I put my very long html code\nI can write text\nI can put a tutorial\nand so...the final link\nClick on the link\nhttp://mysite.com/default/user/verify_email/%(key)s\nto verify your email' which includes %(key)s, which will be filled in by the register function. With Python 2.6+, you can also use str.format() to provide a second level of interpolation that's independent of %-interpolation. http://docs.python.org/library/stdtypes.html#str.format --
Re: [web2py] Re: Auth and Model less
On Tuesday, August 14, 2012 9:14:21 AM UTC-4, Felipe Meirelles wrote: But the DB object can be static through requests as well or I should instantiate it on every request too? You should instantiate on every request (that needs the db). Anthony --
[web2py] HTTPS and the Rocket server?
I am testing some authentication mechanisms with janrain locally using a modified /etc/hosts name. Unfortunately it keeps redirecting to `https://` rather than to `http://`. Is there a way I can get Rocket to server as https? (I can generate unverified certs :P) Or is there a better way I can sandbox Janrain testing? Thanks for all suggestions, Alec Taylor --
Re: [web2py] Depoying on GAE. Frustration. Followed directions but still getting error.
If you are using the app launcher, what are its logs saying? Sent from my iPad On 14.08.2012, at 11:52, SeamusSeamus morrisjamespatr...@gmail.com wrote: HI. I followed the directions on the deployment recipe seen here http://web2py.com/books/default/chapter/29/13 I still get: Internal error Ticket issued: unknown I am not sure which code to post as all I have changed is the app.yaml file: application: seamusapp version: 1 api_version: 1 I run dev_appserver.py ../web2py no errors show up until I open 127.0.0.1:8080 I cant find any logs on 127.0.0.1/_ah/admin either... Any ideas? The recipe worked fine until I got to the try it out locally part... -- --
Re: [web2py] web2py 2.0 almost done
Patch is in attachment. Marin On Mon, Aug 13, 2012 at 4:52 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: ouch! sorry about that. On Monday, 13 August 2012 09:46:51 UTC-5, Marin Pranjić wrote: Sure. There is no upload logic for URLs. It was removed with this revision: http://code.google.com/p/**web2py/source/diff?spec=** svn33970ff5ac8470c8003290671a1**352c29ec00e25r=** 33970ff5ac8470c8003290671a1352**c29ec00e25format=sidepath=/** applications/admin/**controllers/default.pyhttp://code.google.com/p/web2py/source/diff?spec=svn33970ff5ac8470c8003290671a1352c29ec00e25r=33970ff5ac8470c8003290671a1352c29ec00e25format=sidepath=/applications/admin/controllers/default.py Application is retreived with urllib.urlopen but is not installed (if-elif-else logic is wrong). Marin On Mon, Aug 13, 2012 at 4:31 PM, Massimo Di Pierro massimo@gmail.com wrote: Can you help looking into it? On Monday, 13 August 2012 05:32:20 UTC-5, Marin Pranjić wrote: Installing new app in admin via URL is not working for me (trunk) On Tue, Aug 7, 2012 at 6:33 AM, Massimo Di Pierro massimo@gmail.com wrote: Web2py 2.0 is almost done. Please try the nightly build. Let us know if it breaks anything. massimo -- -- -- -- admininstall.diff Description: Binary data
Re: [web2py] compute fields do not show up in SQLFORM view form
I have not set readable flag during db definition. Is it set to False by default, for compute fields ? On Tuesday, August 14, 2012 6:16:20 PM UTC+5:30, rochacbruno wrote: in your controller.. if request.args(0) == view: db.table.field.readable = True grid = SQLFORM.grid(.) Does NOT seem to work. computed field is still not visible. My current workaround : remove compute attribute, I can see it (I've then marked it as writable=False so that it is NOT editable in Edit form) But I'm not happy with it. BTW, I'm using Version 2.0.0 (2012-07-26 06:06:10) dev -Mandar --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
Hey Jon: *Q: * BTW, are you deliberately *forbidding* upper-case letters? *A: *. *Yes*, just like Google does, usernames are lowercase, although if your gmail username is *johnsmith* you can log in with *JohnSmith*, or *JOHNSMITH*, or *Johnsmith* etc. but there is ONLY ONE user. At least for my app, Just case lowercase names are best... user's have enough trouble remembering names without burden of case-sensitivity. --- So, with the of this forum, I think I have nearly completed my Google-like Registration policy in web2py. I'll continue to test. Here is code, entire file (based on simple app, is attached db.py) *Concern:* I *hope* I'm restricting the length of password correctly? I just followed discussion on this forum. Note: Curiously, in version 1.99, the .insert works, where id didn't with username. -- thanks all, ~ Rob --- db.py from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db, hmac_key=Auth.get_or_create_key()) crud, service, plugins = Crud(db), Service(), PluginManager() ## - START CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## # | Summary: # | Modify web2py to allow user registrations similar to # | Google registrations. # | i.e. # | - lower case only [a-z] # | - numbers [0-9] and period are OK # | - can't end in a period # | - can't start with a period # | - can't have consecutive periods # | - min 8 letter password # | - username can't be changed once registered # | # | Note: Messages are nearly same as Google displays ## create all tables needed by auth if not custom tables # use usernames rather than email addresses to register auth.define_tables(username=True) # allow username only on registration, but can only # be viewed (readable) in Profile # user can't change username once registered. if auth.is_logged_in(): db.auth_user.username.writable = False db.auth_user.username.readable = True #custom message for password length - like Google # ref: https://groups.google.com/forum/?fromgroups#!searchin/web2py/$20default$20length$20for$20password/web2py/k5os3bMz228/vG-UOLbhcBUJ[1-25] db.auth_user.password.requires.insert(0,IS_LENGTH(minsize=8)) db.auth_user.password.requires = CRYPT(key=auth.settings.hmac_key,min_length =8) #add a comments to exlain policy db.auth_user.password.comment='minimum 8 letters' db.auth_user.username.comment='min. 6 letters (a-z), you may use numbers, and periods.' # apply nearly identical username policy and message that Google Accounts use. # this OVERWRITES web2py's default username validation # reference and thanks to web2py community for help: # https://groups.google.com/forum/?fromgroups#!starred/web2py/HBODB00HMfU[1-25] auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] ## - END CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## -- # -*- coding: utf-8 -*- # ## This scaffolding model makes your app work on Google App Engine too ## File is released under public domain and you can use without limitations # ## if SSL/HTTPS is properly configured and you want all HTTP requests to ## be redirected to HTTPS, uncomment the line below: # request.requires_https() if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite') else: ## connect to Google BigTable (optional 'google:datastore://namespace') db = DAL('google:datastore') ## store sessions and tickets there session.connect(request, response, db = db) ## or store session in Memcache, Redis, etc. ## from gluon.contrib.memdb import MEMDB ## from google.appengine.api.memcache import Client ## session.connect(request, response, db = MEMDB(Client())) ## by default give a view/generic.extension to all actions from localhost ## none otherwise. a pattern can be 'controller/function.extension' response.generic_patterns = ['*'] if request.is_local else [] ## (optional) optimize handling of static files # response.optimize_css =
Re: [web2py] Re: Appengine CPU cycles
This is what I am talking about, this functionality/dependency on requests needs to be moved to controllers, leaving models as a run once file. as some model code does in fact depend on the request and must be run each request). Anthony -- --
[web2py] Re: comparing responding arg with request.args(0)
Hi Anthony, In a request I use request.args(0) to determine the response, for instance http://127.0.0.1:8000/bootstrap/calendar/eventlist/6 In this case 6 is the argument of the response, when the visitor changes this argument manually and requests http://127.0.0.1:8000/bootstrap/calendar/eventlist/28 I need a way to determine that the visitor did change the argument, for node 6 has access to eventlist but user 28 probably not. In that case I'd like to route to a router function which determines what to do. I thought something like storing session.response=request.args(0), in this case session.response=6 and comparing session.response!=request.args(0) in this case 6!=28 and the redirect(URL('addressbook','router',args=request.args(0) in every function would solve my problem. I'd like to know if this is the way to go or whether there is a better way to solve this problem? Kind regards, Annet --
[web2py] Re: redirect results in invalid request.
Hi Anthony, Thanks for your explanation. After reading it I haven't got a clue why I thought this: redirect(URL('bootstrap',' addressbook','router',request.args(0))) would work, especially after writing so many correct urls. Best regards, Annet --
[web2py] Re: Book clarification regarding verify_email reset_password
Thanks for the info, everyone. I thought the example might look OK as is, but i really don't understand everything the way you folks do. I have a bit of a follow up question. The ENTIRE example *seems* to imply that the following lines are *NEEDED* to enable email verification: auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True Is that true? I want, at least i think i want: registration_requires_verification = True BTW there's a sample code bug i found in the same section. Replace the double quote () in the following with a single quote (') and it compiles. auth.settings.register_onaccept.append(lambda form:\ mail.send(to='y...@example.com',subject='new user', message=new user email is %s'%form.vars.email)) Thanks for the help. And thanks for the great documentation and for caring about it. Love and peace, Joe On Monday, August 13, 2012 6:09:46 PM UTC-7, JoeCodeswell wrote: Dear web2py folks, In the book it says in /chapter/29/9#Authentication: In Auth, by default, email verification is disabled. To enable email, append the following lines in the model where auth is defined: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + \ request.env.http_host + \ URL(r=request,c='default',f='user',args=['verify_email']) + \ '/%(key)s to verify your email' auth.messages.reset_password = 'Click on the link http://' + \ request.env.http_host + \ URL(r=request,c='default',f='user',args=['reset_password']) + \ '/%(key)s to reset your password' You need to replace the string 1. 'Click on the link ...' in auth.messages.verify_email with the proper complete URL of the action verify_email. For both verify_email and reset_password: Should I replace 'Click on the link http://' With: 'Click on the link http://myserver.com/myapp/' Or with: 'Click on the link http://myserver.com/myapp/default/user/verify_email' My guess is the first, but because the book says proper complete URL, I am not sure. Thanks in advance for the help. Love and peace, Joe --
Re: [web2py] Re: Appengine CPU cycles
On Tuesday, August 14, 2012 11:17:57 AM UTC-4, Khalil KHAMLICHI wrote: This is what I am talking about, this functionality/dependency on requests needs to be moved to controllers, leaving models as a run once file. Moving part of the model definitions to the controller is counter to the M/C separation and may involve redundancy for controllers that need the same models. In any case, there's a thread safety issue: https://groups.google.com/d/msg/web2py-developers/AWchDa8owxw/Mcpa-5v531AJ. Anthony --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
Note, you shouldn't need: db.auth_user.password.requires.insert(0,IS_LENGTH(minsize=8)) given that you specify min_length in the CRYPT validator. You might consider the IS_STRONG validator as well. Anthony On Tuesday, August 14, 2012 11:11:42 AM UTC-4, Rob_McC wrote: Hey Jon: *Q: * BTW, are you deliberately *forbidding* upper-case letters? *A: *. *Yes*, just like Google does, usernames are lowercase, although if your gmail username is *johnsmith* you can log in with *JohnSmith*, or *JOHNSMITH*, or *Johnsmith* etc. but there is ONLY ONE user. At least for my app, Just case lowercase names are best... user's have enough trouble remembering names without burden of case-sensitivity. --- So, with the of this forum, I think I have nearly completed my Google-like Registration policy in web2py. I'll continue to test. Here is code, entire file (based on simple app, is attached db.py) *Concern:* I *hope* I'm restricting the length of password correctly? I just followed discussion on this forum. Note: Curiously, in version 1.99, the .insert works, where id didn't with username. -- thanks all, ~ Rob --- db.py from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db, hmac_key=Auth.get_or_create_key()) crud, service, plugins = Crud(db), Service(), PluginManager() ## - START CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## # | Summary: # | Modify web2py to allow user registrations similar to # | Google registrations. # | i.e. # | - lower case only [a-z] # | - numbers [0-9] and period are OK # | - can't end in a period # | - can't start with a period # | - can't have consecutive periods # | - min 8 letter password # | - username can't be changed once registered # | # | Note: Messages are nearly same as Google displays ## create all tables needed by auth if not custom tables # use usernames rather than email addresses to register auth.define_tables(username=True) # allow username only on registration, but can only # be viewed (readable) in Profile # user can't change username once registered. if auth.is_logged_in(): db.auth_user.username.writable = False db.auth_user.username.readable = True #custom message for password length - like Google # ref: https://groups.google.com/forum/?fromgroups#!searchin/web2py/$20default$20length$20for$20password/web2py/k5os3bMz228/vG-UOLbhcBUJ[1-25] db.auth_user.password.requires.insert(0,IS_LENGTH(minsize=8)) db.auth_user.password.requires = CRYPT(key=auth.settings.hmac_key,min_length =8) #add a comments to exlain policy db.auth_user.password.comment='minimum 8 letters' db.auth_user.username.comment='min. 6 letters (a-z), you may use numbers, and periods.' # apply nearly identical username policy and message that Google Accounts use. # this OVERWRITES web2py's default username validation # reference and thanks to web2py community for help: # https://groups.google.com/forum/?fromgroups#!starred/web2py/HBODB00HMfU[1-25] auth.settings.table_user.username.requires = [IS_LENGTH(30,6,'Please use between 6 and 30 characters.'), IS_MATCH('^[a-z0-9.]*$', error_message='Please use only letters (a-z) and numbers (0-9), and periods.'), IS_NOT_EMPTY(error_message='You can\'t leave this empty. '), IS_EXPR(value[0]'.', error_message='The FIRST character of your username should be a letter (a-z) or number.'), IS_EXPR(value[-1]'.', error_message='The LAST character of your username should be a letter (a-z) or number.'), IS_EXPR(str(value).find('..')==-1,error_message='A fan of punctuation! Alas, usernames can\'t have consecutive periods.'), IS_NOT_IN_DB(db, auth.settings.table_user.username, 'Someone already has that username. ') ] ## - END CUSTOMIZATION - - - - - - - - - - - - - - - - - - - - - - ## --
Re: [web2py] Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
On 14 Aug 2012, at 8:11 AM, Rob_McC mrmccorm...@gmail.com wrote: Hey Jon: Q: BTW, are you deliberately forbidding upper-case letters? A: . Yes, just like Google does, usernames are lowercase, although if your gmail username is johnsmith you can log in with JohnSmith, or JOHNSMITH, or Johnsmith etc. but there is ONLY ONE user. At least for my app, Just case lowercase names are best... user's have enough trouble remembering names without burden of case-sensitivity. An alternative is to let the user enter any case, but append the IS_LOWER validator, which isn't a validator, but forces the field to lower case. --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
On 14 Aug 2012, at 8:47 AM, Anthony abasta...@gmail.com wrote: Note, you shouldn't need: db.auth_user.password.requires.insert(0,IS_LENGTH(minsize=8)) given that you specify min_length in the CRYPT validator. You might consider the IS_STRONG validator as well. It's maybe worth pointing out that these validators should be imposed only when registering or changing a password, not during login. The problem with having password validators on login is that they leak password constraints to an attacker. (Of course, the registration form can be used to extract this information as well, but still...) --
Re: [web2py] Re: Auth and Model less
Now I'm getting this error when I call the initialization method: SyntaxError: invalid table name: auth_user On Tue, Aug 14, 2012 at 10:38 AM, Anthony abasta...@gmail.com wrote: On Tuesday, August 14, 2012 9:14:21 AM UTC-4, Felipe Meirelles wrote: But the DB object can be static through requests as well or I should instantiate it on every request too? You should instantiate on every request (that needs the db). Anthony -- -- Att, Felipe Meirelles. --
[web2py] Re: Book clarification regarding verify_email reset_password
Yes, you want to set that to True. Just fixed those two errors, and tried to clarify the language regarding the URLs. Anthony On Tuesday, August 14, 2012 11:31:09 AM UTC-4, JoeCodeswell wrote: Thanks for the info, everyone. I thought the example might look OK as is, but i really don't understand everything the way you folks do. I have a bit of a follow up question. The ENTIRE example *seems* to imply that the following lines are *NEEDED* to enable email verification: auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True Is that true? I want, at least i think i want: registration_requires_verification = True BTW there's a sample code bug i found in the same section. Replace the double quote () in the following with a single quote (') and it compiles. auth.settings.register_onaccept.append(lambda form:\ mail.send(to='y...@example.com javascript:',subject='new user', message=new user email is %s'%form.vars.email)) Thanks for the help. And thanks for the great documentation and for caring about it. Love and peace, Joe On Monday, August 13, 2012 6:09:46 PM UTC-7, JoeCodeswell wrote: Dear web2py folks, In the book it says in /chapter/29/9#Authentication: In Auth, by default, email verification is disabled. To enable email, append the following lines in the model where auth is defined: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True auth.messages.verify_email = 'Click on the link http://' + \ request.env.http_host + \ URL(r=request,c='default',f='user',args=['verify_email']) + \ '/%(key)s to verify your email' auth.messages.reset_password = 'Click on the link http://' + \ request.env.http_host + \ URL(r=request,c='default',f='user',args=['reset_password']) + \ '/%(key)s to reset your password' You need to replace the string 1. 'Click on the link ...' in auth.messages.verify_email with the proper complete URL of the action verify_email. For both verify_email and reset_password: Should I replace 'Click on the link http://' With: 'Click on the link http://myserver.com/myapp/' Or with: 'Click on the link http://myserver.com/myapp/default/user/verify_email' My guess is the first, but because the book says proper complete URL, I am not sure. Thanks in advance for the help. Love and peace, Joe --
Re: [web2py] Re: Auth and Model less
Can you show the exact code you're using in the module and controller? On Tuesday, August 14, 2012 12:07:15 PM UTC-4, Felipe Meirelles wrote: Now I'm getting this error when I call the initialization method: SyntaxError: invalid table name: auth_user On Tue, Aug 14, 2012 at 10:38 AM, Anthony abas...@gmail.com javascript: wrote: On Tuesday, August 14, 2012 9:14:21 AM UTC-4, Felipe Meirelles wrote: But the DB object can be static through requests as well or I should instantiate it on every request too? You should instantiate on every request (that needs the db). Anthony -- -- Att, Felipe Meirelles. --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
Thanks. -1- *you might consider the IS_STRONG validator as well. *. What a quick and easy way to increase security of passwords, thanks for tip. This is what I love about web2py. http://web2py.com/books/default/chapter/29/7 Example: requires = IS_STRONG(min=10, special=2, upper=2) where min is minimum length of the value special is the minimum number of required special characters special characters are any of the following !@#$%^*(){}[]-+ upper is the minimum number of upper case characters -2- * Note, you shouldn't need : * db.auth_user.password.requires.insert(0,IS_LENGTH(minsize=8)) - I* removed it and tested*, work well without it, the post wasn't clear to me if I need both, or just this one, -3- *validators on login is that they leak password constraints to an attacker. (Of course, the registration form can be used to extract this information as well, but still...) * - I think I understand, when you say *leak*-- is it just a matter than anyone would *see* the message on the screen, ie. min 8 letters? or is there more of a technical security leak you are referring to. Thanks once again... Rob --
[web2py] Re: comparing responding arg with request.args(0)
OK, I guess it's a nomenclature issue -- args are part of the URL requested and therefore only part of the request, not the response. Rather, you need to validate whether the request arg is valid for the particular user. Of course, you can store the user's node id in the session, but if you are then going to check it against request.args(0) on every request, you might as well get rid of the node id from request.args altogether and simply store the node in the session instead. So, wherever you are no using request.args(0), you would instead reference something like session.nodeID. If session.nodeID doesn't exist, you then redirect to your router so it can be set. Anthony On Tuesday, August 14, 2012 11:22:48 AM UTC-4, Annet wrote: Hi Anthony, In a request I use request.args(0) to determine the response, for instance http://127.0.0.1:8000/bootstrap/calendar/eventlist/6 In this case 6 is the argument of the response, when the visitor changes this argument manually and requests http://127.0.0.1:8000/bootstrap/calendar/eventlist/28 I need a way to determine that the visitor did change the argument, for node 6 has access to eventlist but user 28 probably not. In that case I'd like to route to a router function which determines what to do. I thought something like storing session.response=request.args(0), in this case session.response=6 and comparing session.response!=request.args(0) in this case 6!=28 and the redirect(URL('addressbook','router',args=request.args(0) in every function would solve my problem. I'd like to know if this is the way to go or whether there is a better way to solve this problem? Kind regards, Annet --
[web2py] What purpose? Search - Edit App Screen - web2py application, v 1.99 and 2.00
*Quick Question: What does the search box do at the top, when editiing a web2py app? *(see screenshot)* * I assumed it would search all my app files for occurrence of a word, then present me with a list of which files contained that word. (Like Coda, BBEdit, - most text edtitors let you search files on a disk, or files open in editor) When I click on it, nothing happens in 1.99 or 2.00 Thanks, hope I'm not asking too many basic questions. Rob -- attachment: Screen Shot 2012-08-14 at 12.23.36 PM.png
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
It's maybe worth pointing out that these validators should be imposed only when registering or changing a password, not during login. The problem with having password validators on login is that they leak password constraints to an attacker. (Of course, the registration form can be used to extract this information as well, but still...) Looks like the code does remove the min_length constraint of CRYPT for login: http://code.google.com/p/web2py/source/browse/gluon/tools.py#1829, but doesn't do anything about IS_STRONG. Do you think we should change that? Anthony --
[web2py] session[id].r['Nav']['function']=True TypeError: 'NoneType' object is unsubscriptable
I have the following lines of code: aboutnav=db((db.NodeNav.nodeID==id)(db.NodeNav.navID==db.Nav.id)(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position).as_list() if aboutnav: session[id].aboutnav=True for r in aboutnav: if r['Nav']['id']==ABOUTNAVID and r['NodeNav']['frontend']: session[id].site_menu.append([T(r['Nav']['name']),False,'#']) elif r['NodeNav']['frontend']: session[id].about_dropdown.append([T(r['Nav']['name']),False, URL(r['Nav']['frontendcontroller'],r['Nav']['function'],args=id)]) session[id].r['Nav']['function']=True The last line results in the following error: Traceback (most recent call last): File /Library/Python/2.5/site-packages/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 194, in module File /Library/Python/2.5/site-packages/web2py/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 83, in index session[id].r['Nav']['function']=True TypeError: 'NoneType' object is unsubscriptable Why can I do session[id].plural=True and can't I do session[id].r['Nav']['function']=True Annet --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
On 14 Aug 2012, at 9:19 AM, Rob_McC mrmccorm...@gmail.com wrote: validators on login is that they leak password constraints to an attacker. (Of course, the registration form can be used to extract this information as well, but still...) - I think I understand, when you say leak-- is it just a matter than anyone would see the message on the screen, ie. min 8 letters? or is there more of a technical security leak you are referring to. Just that they would see it, telling them that they needn't try guessing passwords less than 8 characters. There's a cosmetic reason to suppress the validator as well, in that there's no particular point in telling the user anything more than that they got their login wrong. It's trivial to implement: just make adding the validator(s) conditional on the current request. Something like: if request.args(0) != 'login': add validators will suffice. --
[web2py] Re: What purpose? Search - Edit App Screen - web2py application, v 1.99 and 2.00
It's part of a psychological experiment -- we're counting how many times you click on it. ;-) Actually, it looks like the button isn't working, but if you hit return, it should run the search you expect. Anthony On Tuesday, August 14, 2012 12:33:13 PM UTC-4, Rob_McC wrote: *Quick Question: What does the search box do at the top, when editiing a web2py app? *(see screenshot)* * I assumed it would search all my app files for occurrence of a word, then present me with a list of which files contained that word. (Like Coda, BBEdit, - most text edtitors let you search files on a disk, or files open in editor) When I click on it, nothing happens in 1.99 or 2.00 Thanks, hope I'm not asking too many basic questions. Rob --
Re: [web2py] Re: Auth and Model less
Sorry, the DB was still static. Just created a init_db() and worked as spected. On Tue, Aug 14, 2012 at 1:18 PM, Anthony abasta...@gmail.com wrote: Can you show the exact code you're using in the module and controller? On Tuesday, August 14, 2012 12:07:15 PM UTC-4, Felipe Meirelles wrote: Now I'm getting this error when I call the initialization method: SyntaxError: invalid table name: auth_user On Tue, Aug 14, 2012 at 10:38 AM, Anthony abas...@gmail.com wrote: On Tuesday, August 14, 2012 9:14:21 AM UTC-4, Felipe Meirelles wrote: But the DB object can be static through requests as well or I should instantiate it on every request too? You should instantiate on every request (that needs the db). Anthony -- -- Att, Felipe Meirelles. -- -- Att, Felipe Meirelles. --
[web2py] Re: session[id].r['Nav']['function']=True TypeError: 'NoneType' object is unsubscriptable
Is session[id] a Storage object? If so, if you do session[id].r and r does not exist, the Storage object will return None. If you try to do session[id].r['Nav'], it will attempt to subscript None with 'Nav', which won't work. Anthony On Tuesday, August 14, 2012 12:36:22 PM UTC-4, Annet wrote: I have the following lines of code: aboutnav=db((db.NodeNav.nodeID==id)(db.NodeNav.navID==db.Nav.id )(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position).as_list() if aboutnav: session[id].aboutnav=True for r in aboutnav: if r['Nav']['id']==ABOUTNAVID and r['NodeNav']['frontend']: session[id].site_menu.append([T(r['Nav']['name']),False,'#']) elif r['NodeNav']['frontend']: session[id].about_dropdown.append([T(r['Nav']['name']),False, URL(r['Nav']['frontendcontroller'],r['Nav']['function'],args=id)]) session[id].r['Nav']['function']=True The last line results in the following error: Traceback (most recent call last): File /Library/Python/2.5/site-packages/web2py/gluon/restricted.py, line 205, in restricted exec ccode in environment File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 194, in module File /Library/Python/2.5/site-packages/web2py/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py, line 83, in index session[id].r['Nav']['function']=True TypeError: 'NoneType' object is unsubscriptable Why can I do session[id].plural=True and can't I do session[id].r['Nav']['function']=True Annet --
Re: [web2py] Re: Enforcing - like gmail: first character of your username should be a letter (a-z) or number.
On 14 Aug 2012, at 9:33 AM, Anthony abasta...@gmail.com wrote: It's maybe worth pointing out that these validators should be imposed only when registering or changing a password, not during login. The problem with having password validators on login is that they leak password constraints to an attacker. (Of course, the registration form can be used to extract this information as well, but still...) Looks like the code does remove the min_length constraint of CRYPT for login: http://code.google.com/p/web2py/source/browse/gluon/tools.py#1829, but doesn't do anything about IS_STRONG. Do you think we should change that? I think so, if we can do it safely there. --
Re: [web2py] Re: Auth and Model less
Well, but even initializing db and auth for evey request I still get the not validating bug... ill attach my code to you to take a look. On Tue, Aug 14, 2012 at 1:44 PM, Felipe Meirelles poz...@gmail.com wrote: Sorry, the DB was still static. Just created a init_db() and worked as spected. On Tue, Aug 14, 2012 at 1:18 PM, Anthony abasta...@gmail.com wrote: Can you show the exact code you're using in the module and controller? On Tuesday, August 14, 2012 12:07:15 PM UTC-4, Felipe Meirelles wrote: Now I'm getting this error when I call the initialization method: SyntaxError: invalid table name: auth_user On Tue, Aug 14, 2012 at 10:38 AM, Anthony abas...@gmail.com wrote: On Tuesday, August 14, 2012 9:14:21 AM UTC-4, Felipe Meirelles wrote: But the DB object can be static through requests as well or I should instantiate it on every request too? You should instantiate on every request (that needs the db). Anthony -- -- Att, Felipe Meirelles. -- -- Att, Felipe Meirelles. -- Att, Felipe Meirelles. -- {{=form}} {{if request.args(0)=='login':}} {{if 0:}} {{if not 'register' in auth.settings.actions_disabled:}} {{=T("register")}} {{pass}} {{if not 'request_reset_password' in auth.settings.actions_disabled:}} {{=T("lost password")}} {{pass}} {{pass}} {{pass}} auth.py Description: Binary data db.py Description: Binary data default.py Description: Binary data
Re: [web2py] Re: Auth and Model less
I'm also using memcache to store the session as follows: from gluon.contrib.gae_memcache import MemcacheClient from gluon.contrib.memdb import MEMDB cache.memcache = MemcacheClient(request) cache.ram = cache.disk = cache.memcache session.connect(request,response,MEMDB(cache.memcache)) On Tue, Aug 14, 2012 at 1:52 PM, Felipe Meirelles poz...@gmail.com wrote: Well, but even initializing db and auth for evey request I still get the not validating bug... ill attach my code to you to take a look. On Tue, Aug 14, 2012 at 1:44 PM, Felipe Meirelles poz...@gmail.comwrote: Sorry, the DB was still static. Just created a init_db() and worked as spected. On Tue, Aug 14, 2012 at 1:18 PM, Anthony abasta...@gmail.com wrote: Can you show the exact code you're using in the module and controller? On Tuesday, August 14, 2012 12:07:15 PM UTC-4, Felipe Meirelles wrote: Now I'm getting this error when I call the initialization method: SyntaxError: invalid table name: auth_user On Tue, Aug 14, 2012 at 10:38 AM, Anthony abas...@gmail.com wrote: On Tuesday, August 14, 2012 9:14:21 AM UTC-4, Felipe Meirelles wrote: But the DB object can be static through requests as well or I should instantiate it on every request too? You should instantiate on every request (that needs the db). Anthony -- -- Att, Felipe Meirelles. -- -- Att, Felipe Meirelles. -- Att, Felipe Meirelles. -- Att, Felipe Meirelles. --
[web2py] Re: session[id].r['Nav']['function']=True TypeError: 'NoneType' object is unsubscriptable
Is session[id] a Storage object? Yes. If so, if you do session[id].r and r does not exist, the Storage object will return None. r does exist, otherwise this condition would fail: elif r['NodeNav']['frontend']: If you try to do session[id].r['Nav'], it will attempt to subscript None with 'Nav', which won't work. This works: f=r['Nav']['function'] if f: session[id].f=True Kind regards, Annet --
[web2py] Re: Using Decorators for RESTful URLs
I want to use RESTful URL patters likewise in Flask, ' http://publish.luisrei.com/articles/flaskrest.html' All I could end up finding was to make use of routes.py [routes_in routes_out]. Deepak --
[web2py] Re: comparing responding arg with request.args(0)
So, wherever you are now using request.args(0), you would instead reference something like session.nodeID. If session.nodeID doesn't exist, you then redirect to your router so it can be set. That's what I've been experimenting with the last couple of days, it works fine for the single page views, however, nodes can have sites with multiple views, and different nodes can be visited in more than one browser window. In case of sites with multiple views, the router function always routes to an index function, in which I build the menu for the current node and store it in session[id], this is part of the code: aboutnav=db((db.NodeNav.nodeID==id)(db.NodeNav.navID==db.Nav.id)(db.Nav.navbarID==ABOUTNAVBARID)).select(db.Nav.ALL,db.NodeNav.ALL,orderby=db.Nav.position).as_list() if aboutnav: session[id].aboutnav=True for r in aboutnav: if r['Nav']['id']==ABOUTNAVID and r['NodeNav']['frontend']: session[id].site_menu.append([T(r['Nav']['name']),False,'#']) elif r['NodeNav']['frontend']: session[id].about_dropdown.append([T(r['Nav']['name']),False,URL(r['Nav']['frontendcontroller'],r['Nav']['function'],args=id)]) f=r['Nav']['function'] if f: session[id].f=True The last three lines, are what I am experimenting with right now. Every function that is referenced by a menu item starts with: def eventList(): f=request.function if not len(request.args): redirect(URL('addressbook','router')) elif not session[request.args(0)]: redirect(URL('addressbook','router',args=request.args(0))) elif not session[request.args(0)].f: redirect(URL('addressbook','router',args=request.args(0))) else: So far, this seems to solve the problem. Is it possible to put these conditions in a separate function, and call that function from every function that needs it? Something like: def access(): f=request.function if not len(request.args): redirect(URL('addressbook','router')) elif not session[request.args(0)]: redirect(URL('addressbook','router',args=request.args(0))) elif not session[request.args(0)].f: redirect(URL('addressbook','router',args=request.args(0))) else: return True def eventList(): if access() Kind regards, Annet --
Re: [web2py] Re: Using Decorators for RESTful URLs
Maybe this example will help: https://groups.google.com/forum/#!topic/web2py/efrSxAT9AnU On Wed, Aug 15, 2012 at 3:10 AM, deepak deepakshankar...@gmail.com wrote: I want to use RESTful URL patters likewise in Flask, 'http://publish.luisrei.com/articles/flaskrest.html' All I could end up finding was to make use of routes.py [routes_in routes_out]. Deepak -- --
Re: [web2py] Re: Alternative to Janrain: in pure Python
Can we get an update? I think this would be a good selling point for web2py, if ported. On Thursday, July 19, 2012 8:12:43 AM UTC+10, Daniel Gonzalez wrote: Hi, I have tried the example in this sanction library and it looks that the authentication using oauth2 is really easy to implement. Unfortunately the example uses BaseHTTPRequestHandler and not web2py (which is the point of this discussion, of course) I think that a first step would be, as the example in sanction demonstrates, to have an authentication token which can be used to access account info, which can be used to setup an internal web2py user linked to the oauth2 account. The data which can be accessed via oauth2 will differ from provider to provider, but probably some basic identification data can be obtained. It is not clear to me which data can be obtained, how the link account in web2py can be setup, what is the role of the authentication token, whether the authentication token can be saved for later use, how long is the authentication token valid, and lots of other open questions. In my research to have a OAuth2 system working I have also tried to use the oauth2 framework used in the application described in this threadhttps://groups.google.com/d/topic/web2py/ftWKSXcOwVc/discussion (Movuca https://github.com/rochacbruno/Movuca), but it turns out that the whole OAuth2 interaction is integrated with the data structures used by the application, and I have failed to split the pure OAuth2 parts from the rest. My goal is to have a basic demo of how to integrate a OAuth2 library with web2py, preferably this sanction library, since it seems that lots of providers are supported out of the box, and that more can be easily added. My main problem is that I am not familiar with the Auth system and I do not know to configure the login system in web2py to use the OAuth2 library. Maybe somebody could provide some assistance. I would be willing to contribute back of course. Regards, Daniel --
Re: [web2py] Re: web2py 2.0 almost done
this is one of the main changes I was looking forward for 2.0, I would rather wait until the integration is complete On Thursday, August 9, 2012 9:43:28 AM UTC-7, AngeloC wrote: Hi Massimo, I think I cannot complete the bootstrap/web2py css merging in time for 2.0, it's really a lot of work and I'm a bit busy these days. Btw, i'm fixing the bug I introduced with issue 896 and I want to share a thought with you. Actually, there is no way to maintain a mobile first approach and make it working on IE other than add something like this to the scaffolding: !-- Makes bootswatch working on IE 7/8 -- !--[if (lt IE 9)] link rel=stylesheet href=/responsivekit/static/css/bootswatch_ie.css ![endif]-- This will make speedier the whole css on not IE browsers because we remove IE specific rules (smaller css), but has the downside to require an extra http get on IE. What do you think? 2012/8/9 Alec Taylor alec.t...@gmail.com javascript: It would be good to have OAuth working for web2py 2 Facebook and LinkedIn still have some issues LinkedIn: https://groups.google.com/forum/#!topic/web2py/SbnQEnXEcOg Facebook: (will add bug report once I've gotten LinkedIn login to work) On Thu, Aug 9, 2012 at 11:25 PM, Massimo Di Pierro massimo@gmail.com javascript: wrote: Can you help us fix the CSS? On Thursday, 9 August 2012 00:29:58 UTC-5, Andrew wrote: Just a note on IE7 navbar behaviour: The Menu has taken a turn for the worse: Initially the Welcome App Sub Menus dissapeared in : welcome css pathc, issue 896, thanks Angelo They then returned in fixed issue qith clicking on toplevel menus except all of the submenus are displayed when the menu first appears and they are all on top of each other. The login options are still blue, and the space between the navbar and Welcome isn't there. See screen shot. On Thursday, August 9, 2012 9:17:17 AM UTC+12, Massimo Di Pierro wrote: more issues have been addressed. In order to fix an issue I had to introduce a slight change of behavior and I am not sure what is the best way to handle it. If you login using a third party service (for example janrain using facebook) and the service sends info about you, if web2py has corresponding fields in auth_user, it stores them. If you edit your profile, logout, change your facebook profile, login again using janrain, should web2py keep the current local profile or update it? The bug report suggested that web2oy should always give preference to the local profile. I changed web2py accordingly. In practice this change will probably not affect anybody because none of the services sends any information stored by auth_user. Yet, please check it. Massimo On Monday, 6 August 2012 23:33:48 UTC-5, Massimo Di Pierro wrote: Web2py 2.0 is almost done. Please try the nightly build. Let us know if it breaks anything. massimo -- -- -- Profile: http://it.linkedin.com/in/compagnucciangelo --
[web2py] Re: Using Decorators for RESTful URLs
It looks like you could do all of that with web2py. Can you be more specific regarding how you want your URLs to look and what they should retrieve. In addition to RESTful services and routing, have you looked at the basics: http://web2py.com/books/default/chapter/29/4#Dispatching? Anthony On Tuesday, August 14, 2012 1:10:58 PM UTC-4, deepak wrote: I want to use RESTful URL patters likewise in Flask, ' http://publish.luisrei.com/articles/flaskrest.html' All I could end up finding was to make use of routes.py [routes_in routes_out]. Deepak --
[web2py] Re: comparing responding arg with request.args(0)
So, wherever you are now using request.args(0), you would instead reference something like session.nodeID. If session.nodeID doesn't exist, you then redirect to your router so it can be set. That's what I've been experimenting with the last couple of days, it works fine for the single page views, however, nodes can have sites with multiple views, and different nodes can be visited in more than one browser window. Different browser windows should share the same session (though not different browsers). Is it possible to put these conditions in a separate function, and call that function from every function that needs it? Something like: Yes, I was going to suggest that. Anthony --
[web2py] Re: session[id].r['Nav']['function']=True TypeError: 'NoneType' object is unsubscriptable
If so, if you do session[id].r and r does not exist, the Storage object will return None. r does exist, otherwise this condition would fail: elif r['NodeNav']['frontend']: I meant if r does not exist within session -- although r exists at the top level, there is no session.r defined, is there? Anthony --
[web2py] Re: Functions in Views
I am having issues calling the prettydate function in my views as its not working, I pull the datetime variable stored in my database and when I call the prettydate function, it fails quietly without throwing any errors. On Tuesday, August 14, 2012 1:50:52 AM UTC+1, Anthony wrote: The view does not see objects created in the controller unless they are returned in the dict from the controller function that was called. So, you can do: def view_func(arg1, arg2): [do something] return something def index(): return dict(message='Hello World', func=view_func) And in the view, you could call: {{=func(arg1='this', arg2='that')}} Note, functions defined in controllers are by default exposed for access via HTTP requests unless they take arguments or start with a double underscore, so be careful not to expose a function intended only for internal purposes. Another option is to define the function in a model file, in which case it will be available in all views without needing to be passed from the controller. You could also define the function in a module and import it in the view. Anthony On Monday, August 13, 2012 8:34:41 PM UTC-4, dundee wrote: Hi All, Can I call custom functions in views? Functions that I have created in my controller/default.py. Thanks. --
[web2py] Re: Functions in Views
I am having issues calling the prettydate function in my views as its not working, I pull the datetime variable stored in my database and when I call the prettydate function, it fails quietly without throwing any errors. Are you saying it only fails in the view? I know it worked in the shell for you, but how about in a controller or model. Anthony --
[web2py] Re: howto subset a select element
ok, what if i have a nested type select field like: db.define_table('class_assignments', Field('class_id', db.classes, requires=IS_IN_DB(db, db.classes.id, '%(class_title)s (%(id)s)'), writable=False, readable=False), Field('lecture_id', db.lectures, requires=IS_IN_DB(db(db.lectures.user_id == auth.user_id), db.lectures.id, '%(title)s (%(id)s)')), Field('lecture_item_id', db.lecture_items, requires=IS_IN_DB(db, db.lecture_items.id, '%(title)s (%(id)s)')), ... where in this case i want the user to select the lecture_id first, and then the lecture_item_id would be a subset or a detail list of the master lecture_id. i tried: Field('lecture_item_id', db.lecture_items, requires=IS_IN_DB(db(db.lecture_items.lecture_id == lecture_id), db.lecture_items.id, '%(title)s (%(id)s)')), and: Field('lecture_item_id', db.lecture_items, requires=IS_IN_DB(db(db.lecture_items.lecture_id == db.class_assignments.lecture_id), db.lecture_items.id, '%(title)s (%(id)s)')), but both attempts failed. so how do i do a subselect kind of model? thanx in advance, lucas --
[web2py] Re: howto subset a select element
You can't do that all at once when you respond to the initial request because it depends on user input, so you have to populate the second select via Ajax on the client side once the first selection is made. See herehttp://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910for some ideas. Anthony On Tuesday, August 14, 2012 2:49:28 PM UTC-4, lucas wrote: ok, what if i have a nested type select field like: db.define_table('class_assignments', Field('class_id', db.classes, requires=IS_IN_DB(db, db.classes.id, '%(class_title)s (%(id)s)'), writable=False, readable=False), Field('lecture_id', db.lectures, requires=IS_IN_DB(db(db.lectures.user_id == auth.user_id), db.lectures.id, '%(title)s (%(id)s)')), Field('lecture_item_id', db.lecture_items, requires=IS_IN_DB(db, db.lecture_items.id, '%(title)s (%(id)s)')), ... where in this case i want the user to select the lecture_id first, and then the lecture_item_id would be a subset or a detail list of the master lecture_id. i tried: Field('lecture_item_id', db.lecture_items, requires=IS_IN_DB(db(db.lecture_items.lecture_id == lecture_id), db.lecture_items.id, '%(title)s (%(id)s)')), and: Field('lecture_item_id', db.lecture_items, requires=IS_IN_DB(db(db.lecture_items.lecture_id == db.class_assignments.lecture_id), db.lecture_items.id, '%(title)s (%(id)s)')), but both attempts failed. so how do i do a subselect kind of model? thanx in advance, lucas --
[web2py] Re: Functions in Views
it works in the controller and shell but if I try calling it in the view, it fails silently. On Tuesday, August 14, 2012 7:47:09 PM UTC+1, Anthony wrote: I am having issues calling the prettydate function in my views as its not working, I pull the datetime variable stored in my database and when I call the prettydate function, it fails quietly without throwing any errors. Are you saying it only fails in the view? I know it worked in the shell for you, but how about in a controller or model. Anthony --
[web2py] Re: Functions in Views
In my controller, I do this: def index(): rows = db().select(db.post.ALL, orderby=~db.post.timestamp) return locals() In my view I do this: for item in rows: {{=prettydate(item.timestamp)}} it fails quietly without any errors. What am I doing wrong? On Tuesday, August 14, 2012 8:11:49 PM UTC+1, Pystar wrote: it works in the controller and shell but if I try calling it in the view, it fails silently. On Tuesday, August 14, 2012 7:47:09 PM UTC+1, Anthony wrote: I am having issues calling the prettydate function in my views as its not working, I pull the datetime variable stored in my database and when I call the prettydate function, it fails quietly without throwing any errors. Are you saying it only fails in the view? I know it worked in the shell for you, but how about in a controller or model. Anthony --
Re: [web2py] Re: Functions in Views
maybe {{=prettydate(item.timestamp, *T*)}} --
[web2py] Re: Functions in Views
I don't know, but see suggestion herehttps://groups.google.com/d/msg/web2py/Rguuny9E3X8/-a976Tjx4EIJto help diagnose. I don't think it's related to being in the view (as opposed to in the controller). Anthony On Tuesday, August 14, 2012 3:15:19 PM UTC-4, Pystar wrote: In my controller, I do this: def index(): rows = db().select(db.post.ALL, orderby=~db.post.timestamp) return locals() In my view I do this: for item in rows: {{=prettydate(item.timestamp)}} it fails quietly without any errors. What am I doing wrong? On Tuesday, August 14, 2012 8:11:49 PM UTC+1, Pystar wrote: it works in the controller and shell but if I try calling it in the view, it fails silently. On Tuesday, August 14, 2012 7:47:09 PM UTC+1, Anthony wrote: I am having issues calling the prettydate function in my views as its not working, I pull the datetime variable stored in my database and when I call the prettydate function, it fails quietly without throwing any errors. Are you saying it only fails in the view? I know it worked in the shell for you, but how about in a controller or model. Anthony --
Re: [web2py] Re: Functions in Views
tried prettydate(item.timestamp, T) still didnt work On Tuesday, August 14, 2012 8:16:39 PM UTC+1, rochacbruno wrote: maybe {{=prettydate(item.timestamp, *T*)}} --
Re: [web2py] Depoying on GAE. Frustration. Followed directions but still getting error.
On GAE at least one language file needs to be present. Could be that one :) Op Tue, 14 Aug 2012 06:52:29 +0200 schreef SeamusSeamus morrisjamespatr...@gmail.com: HI. I followed the directions on the deployment recipe seen here http://web2py.com/books/default/chapter/29/13 I still get: Internal error Ticket issued: unknown I am not sure which code to post as all I have changed is the app.yaml file: application: seamusapp version: 1 api_version: 1 I run dev_appserver.py ../web2pyno errors show up until I open 127.0.0.1:8080 I cant find any logs on 127.0.0.1/_ah/admin either... Any ideas? The recipe worked fine until I got to the try it out locally part... -- -- Gemaakt met Opera's revolutionaire e-mailprogramma: http://www.opera.com/mail/ --
[web2py] Re: Triggering LOAD
That's perfect. Thanks for your help guys. On Monday, 13 August 2012 02:38:17 UTC+1, Anthony wrote: Note, {{=LOAD('default','myaction', ajax=True)}} is just a helper that produces the following HTML: script type=text/javascript!-- web2py_component('/test/default/myaction','c784764977599'); //--/scriptdiv id=c784764977599loading.../div So, you can trigger a component loading in a div by manually calling the web2py_component() function in the browser and specifying a target div. Note, if you want the component to load initially via LOAD() and then make subsequent calls to web2py_component() to load other content into the div, you can specify your own id for the div instead of having LOAD() generate a random id as above: {{=LOAD('default','myaction', ajax=True, target='mydiv')}} yields: script type=text/javascript!-- web2py_component('/test/default/myaction','mydiv'); //--/scriptdiv id=mydivloading.../div Bruno mentioned the use of web2py_ajax_page() -- that function is ultimately called by web2py_component(), so either will work, but web2py_component() is probably easier. Anthony On Friday, August 10, 2012 5:08:49 AM UTC-4, Rob Goldsmith wrote: Hi Is it possible to trigger the LOAD component when a user clicks on something, or can it only be used when a page is first loaded? I have been using the ajax function to do this but would prefer the extra flexibility of LOAD if it is possible. thanks Rob. --
[web2py] Re: Scheduler: help us test it while learning
Am Montag, 13. August 2012 22:32:19 UTC+2 schrieb Niphlod: Ok, done (the save output for TIMEOUTted tasks). That's great! If you want I can test it. Small issue, but quite manageable: when a task timeouts the output now is saved, and you have the traceback to see where it stopped. e.g. queue function1 with a timeout of 5 seconds def function1(): time.sleep(3) print first print time.sleep(5) print second print The scheduler_run records will report: 1. status = TIMEOUT 2. output = first print 3. traceback = /web2py/gluon/scheduler.py, line 203, in executor result = dumps(_function(*args,**vars)) File applications/w2p_scheduler_tests/models/scheduler.py, line 21, in function1 time.sleep(5) File /home/niphlod/Scrivania/web2py_source/web2py/gluon/scheduler.py, line 446, in lambda signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(1)) SystemExit: 1 Is that ok ? The small issue here is that the traceback is full, starting from where the process is stopped after 5 seconds (the executor function), to the where it really stopped (line 21, function1, in models/scheduler.py) that is the useful information. I wouldn't consider this an issue, actually it's a feature, isn't it? Should the scheduler report only the output and not the traceback for TIMEOUTted tasks? On Wednesday, August 8, 2012 3:25:13 PM UTC+2, Daniel Haag wrote: Hi Niphlod, thanks for the great work with the scheduler, I'm using it in a project where it handles lots of big data imports into a database and the migration to your version was without any problems. On thing catched my eye in the old version and it still seems to be a problem/missing feature in the new one. When a long running process gets executed and produces output (print etc.) this output is written to the database only after the task was run (and finished). It would be really great if the output gets written into the task table while the task runs as this would be a possible feedback mechanism (and we would not need another table etc. just for that) just thinking of a progress meter for example. What I really miss though is the output of the task when it produces a timeout - nothing in the task table about the output... Daniel --
[web2py] Earn more money online just by spending two hours online.
Earn more money online just by spending two hours online. http://www.sfi4.com/10288668/FREE Buy Products for cheap online http://www.tripleclicks.com/10288668/wave http://www.tripleclicks.com/10288668 Advanced Liquid Nutrition Gateway: http://www.tripleclicks.com/detail.php?item=5169/10288668 IAHBE: http://www.tripleclicks.com/detail.php?item=5540/10288668 The Natural™ Cleaners: http://www.tripleclicks.com/search/department_search/9/sfiid/10288668 My Magazines: http://www.tripleclicks.com/search/department_search/10/sfiid/10288668 ECA (E-Commerce Associates) Gateway: http://www.tripleclicks.com/10288668/ECA --
[web2py] webgrid Id key error
For a majority of my tables I do not use the default 'id' column. Instead, I explicitly define one with the 'id' keyword. However, I seem to be running into a problem when trying to use webgrid. Whenever I use webgrid with a table that does not have a column named 'Id,' I get the KeyError exception. However, things appear to work if I use a table that has an 'Id' column defined. Is there a work around so I can actually use the webgrid plugin for tables that do not have a column named 'Id'? Thanks, Andre --
[web2py] Re: Electronic voting anybody?
Very cool app. I noticed following: 1- Had to add security exception in Firefox browser, https:// when I clicked on https://tests.web2py.com/evote/default/index 2- Is Voted on column suppose to record the date? my is blank 3- When I voted, it said it would send me an email, but I didn't get that email, only the first one telling me to vote. 4- On my 3rd test, voting results 0. I'll do some more testing. I'll test some more, I like the popup calendar. A good app to learn from. Thanks Rob On Friday, August 10, 2012 5:24:10 PM UTC-4, Massimo Di Pierro wrote: Demo service: https://tests.web2py.com/evote/default/index Source: https://github.com/mdipierro/evote I could use some help checking it. Specifically usability and security. Massimo -- attachment: Screen Shot 2012-08-14 at 4.02.21 PM.png
Re: [web2py] Re: Appengine CPU cycles
Would it not be possible to do something like this: if 'db' not in dir(): db = DAL(...) On Monday, August 13, 2012 6:43:34 PM UTC-7, rochacbruno wrote: Thinking again... It could be better if define_my_tables run once on the very first request and table keeps defined forever from there --
Re: [web2py] Re: Helper for many-to-many result sets?
Salient bits of model at the top of the thread. On Tuesday, August 14, 2012 2:16:56 AM UTC-4, rochacbruno wrote: I guess you can also do: table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in * movie.stars.select()*])) for movie in movies]) when a table is referenced by another, he gets a DAL Set object with the referer name. movie.*stars *will be a DAL Set. which has *select, update, delete*methods But it will only happens depending on your model and relations definition. Can you share your model for those 2 tables? On Tue, Aug 14, 2012 at 3:10 AM, Bruno Rocha rocha...@gmail.comjavascript: wrote: Foreach movie in movies print movie.title foreach stars in movie.stars print star.name --
Re: [web2py] Re: Helper for many-to-many result sets?
This all looks promising. Meanwhile, here's my model with irrelevant Fields omitted and below that my query for the Select. Thanks for the help! A simplified version of my model: db.define_table('movie', Field('title','string'), db.define_table('person', Field('name', 'string', unique=True), db.define_table('star', Field('movie_id', db.movie), Field('person_id', db.person), movies_and_stars = db((db.movie.id == db.star.movie_id) (db.star.person_id == db.person.id)) On Tuesday, August 14, 2012 2:16:56 AM UTC-4, rochacbruno wrote: I guess you can also do: table = TABLE(*[TR(TD(movie.title), TD(UL(*[LI(star.name) for star in * movie.stars.select()*])) for movie in movies]) when a table is referenced by another, he gets a DAL Set object with the referer name. movie.*stars *will be a DAL Set. which has *select, update, delete*methods But it will only happens depending on your model and relations definition. Can you share your model for those 2 tables? On Tue, Aug 14, 2012 at 3:10 AM, Bruno Rocha rocha...@gmail.comjavascript: wrote: Foreach movie in movies print movie.title foreach stars in movie.stars print star.name --
[web2py] Re: Scheduler: help us test it while learning
That's great! If you want I can test it. No problem, that is easy to test and it's working well. I wouldn't consider this an issue, actually it's a feature, isn't it? I'm ok with that if users won't start asking why there is the full traceback instead of the restricted version of it ^_^ Now I'm going to take a look at your patch and see if I can understand all the bits of it . TY again. --
Re: [web2py] Re: Functions in Views
I just noticed that doing {{=prettydate(request.now, T)}} in my views works, but doing {{=prettydate(item.now, T)}} doesnt work in my views, even when my default value in the database definition is request.now for the timestamp. What exactly am I doing wrong? On Tuesday, August 14, 2012 8:32:18 PM UTC+1, Pystar wrote: tried prettydate(item.timestamp, T) still didnt work On Tuesday, August 14, 2012 8:16:39 PM UTC+1, rochacbruno wrote: maybe {{=prettydate(item.timestamp, *T*)}} --
Re: [web2py] Re: Functions in Views
What error is being raised? What is the type of item.now? On Tuesday, August 14, 2012 6:00:31 PM UTC-4, Pystar wrote: I just noticed that doing {{=prettydate(request.now, T)}} in my views works, but doing {{=prettydate(item.now, T)}} doesnt work in my views, even when my default value in the database definition is request.now for the timestamp. What exactly am I doing wrong? On Tuesday, August 14, 2012 8:32:18 PM UTC+1, Pystar wrote: tried prettydate(item.timestamp, T) still didnt work On Tuesday, August 14, 2012 8:16:39 PM UTC+1, rochacbruno wrote: maybe {{=prettydate(item.timestamp, *T*)}} --
Re: [web2py] Re: Appengine CPU cycles
Where would you put that? If in a model or controller, won't the condition be true on every request? Anthony On Tuesday, August 14, 2012 4:44:24 PM UTC-4, Derek wrote: Would it not be possible to do something like this: if 'db' not in dir(): db = DAL(...) On Monday, August 13, 2012 6:43:34 PM UTC-7, rochacbruno wrote: Thinking again... It could be better if define_my_tables run once on the very first request and table keeps defined forever from there --
Re: [web2py] Re: Functions in Views
item.now is a field in my database whose default value is request.now. So I am confused why {{=prettydate(request.now, T)}} works and {{=prettydate(item.now, T)}} doesnt? Although I am looping through all the returned values from a db select and applying the prettydate function On Tuesday, August 14, 2012 11:05:15 PM UTC+1, Anthony wrote: What error is being raised? What is the type of item.now? On Tuesday, August 14, 2012 6:00:31 PM UTC-4, Pystar wrote: I just noticed that doing {{=prettydate(request.now, T)}} in my views works, but doing {{=prettydate(item.now, T)}} doesnt work in my views, even when my default value in the database definition is request.now for the timestamp. What exactly am I doing wrong? On Tuesday, August 14, 2012 8:32:18 PM UTC+1, Pystar wrote: tried prettydate(item.timestamp, T) still didnt work On Tuesday, August 14, 2012 8:16:39 PM UTC+1, rochacbruno wrote: maybe {{=prettydate(item.timestamp, *T*)}} --
[web2py] Re: DAL belongs() fails on App Engine
i added a patch against trunk to the ticket. spiffytech - can you see if that works for you? cfh On Monday, August 13, 2012 12:20:02 AM UTC-7, howesc wrote: we do special query handling on the key field, so i suspect the multiple filters on key is wonky. i'll try and look at this in the next couple of days thanks for reporting, and thanks for your patience guiding us through it. :) christian On Sunday, August 12, 2012 8:01:29 PM UTC-7, spiffytech wrote: Yes, I've verified that this can be done. The below query works in the App Engine Datastore Viewer (note that it only worked once I manually created the index in index.yaml and deployed it; web2py did not automatically create the appropriate index: SELECT * FROM posts WHERE __key__ IN (KEY('posts', 3), KEY('posts', 4), KEY('posts', 1003)) and post_date = DATETIME('2012-08-12 00:00:00') ORDER BY post_date DESC On Sunday, August 12, 2012 9:56:20 PM UTC-4, Anthony wrote: How would you do the query in GQL? Have you confirmed that it can be done? Anthony On Sunday, August 12, 2012 9:23:39 PM UTC-4, spiffytech wrote: I tested with your suggested orderby, but the outcome was the same. I tested with the query as you wrote it below, with no common_filter, and the query still failed. Since that's a pretty straightforward query that should work, this seems like a bug to me, so I filed a web2py bug report: http://code.google.com/p/web2py/issues/detail?id=930 On Thursday, August 9, 2012 5:39:14 PM UTC-4, howesc wrote: i had to look up common_filters.based on your experience i would assume that this is being implemented as a query filter rather than getting results from the DB and then filtering them. so what is must be causing in your case is: posts = db((db.posts.id.belongs(post_ids)) (db.posts.post_date=request.now)).select(db.posts.ALL,orderby=db.posts.post_date, cache =(cache.ram, 60)) it *might* work if you put an orderby on that is db.posts.id|db.posts.post_date i'm not sure. you might have to remove the common filter for this query and then filter the results. (i don't have experience with common filters and how they are implemented) GAE has a restriction on IN queries (web2py belongs queries) that they have no more than 30 items in the list. because i said so says google. On Thursday, August 9, 2012 1:57:13 PM UTC-7, spiffytech wrote: I've narrowed the problem down further- the exception is caused by a common_filter attached to my posts table: common_filter = lambda query: db.posts.post_date = request.now I'm not sure why that would trigger the orderby error, though. Also, is there some significance to limiting the belongs lists to 30 items? On Thursday, August 9, 2012 4:24:13 PM UTC-4, howesc wrote: the query and the error message do not match. your query has no orderby, yet the error message suggests there is an orderby property set. this confuses me. i do: db(db.table.id.belongs([list of items not more than 30 long])).select() all the time on GAE and it works for me (latest stable web2py, and the last time i checked trunk though that was a few weeks ago) note that cache does nothing on selects on GAE due to the inability to serialize Rows objects to memcache (at least i think that is the limitation) cfh On Thursday, August 9, 2012 10:40:33 AM UTC-7, spiffytech wrote: I'm trying to use the DAL belongs clause on App Engine and am getting an error. posts = db(db.posts.id.belongs(post_ids)).select(db.posts.ALL,cache =(cache.ram, 60)) Produces: BadArgumentError: First ordering property must be the same as inequality filter property, if specified for this query; received __key__, expected post_date Some Googling suggests this can be due to not providing a sort key. I tried orderby=db.posts.post_date with no success. What could be going wrong? I'm using the latest trunk web2py, but tested all the way back to 1.99.3. --
Re: [web2py] Re: Functions in Views
item.now is a field in my database whose default value is request.now. Yes, I understand, but can you report the error raised as well as checking the type of item.now? Anthony --
[web2py] Grahs
Dear All. I am looking how i can doing some humedity graph from my database like: http://www.google.cl/imgres?imgurl=http://bfinet.es/objects/300_19_1511558087/grafico-humedad.jpgimgrefurl=http://bfinet.es/Sonda%2BTemperatura%2By%2BHumedad-300.htm?sid%3D86888e016e7af58b05e6bd8071640e45h=395w=650sz=39tbnid=cyGO1-CPIR49ZM:tbnh=74tbnw=121prev=/search%3Fq%3Dgrafico%2Bhumedad%26tbm%3Disch%26tbo%3Duzoom=1q=grafico+humedadusg=__5kwEzOircYj92GYI4L0ROPQb_gs=docid=DFD_8y7rDNLQmMhl=es-419sa=Xei=Fc0qULSCFKfy0gHIx4DADAved=0CE0Q9QEwAAdur=221 X=Time (0 - 24 Hrs) Y= % humedity I hope you could give me some idea or how i can do. Regards --
Re: [web2py] Re: Functions in Views
It fails silently, it outputs nothing. On Tuesday, August 14, 2012 11:34:54 PM UTC+1, Anthony wrote: item.now is a field in my database whose default value is request.now. Yes, I understand, but can you report the error raised as well as checking the type of item.now? Anthony --
Re: [web2py] Grahs
If it is a webapp you can start looking here: https://google-developers.appspot.com/chart/interactive/docs/index --
[web2py] Re: Scheduler: help us test it while learning
Niphlod- has there been any discussion about a param for clearing out old records on the runs and tasks tables? Maybe a retain_results or retain_completed value that specifies a period for which records will be kept? On Thursday, July 12, 2012 4:36:38 PM UTC-4, Niphlod wrote: Hello everybody, in the last month several changes were commited to the scheduler, in order to improve it. Table schemas were changed, to add some features that were missed by some users. On the verge of releasing web2py v.2.0.0, and seeing that the scheduler potential is often missed by regular web2py users, I created a test app with two main objectives: documenting the new scheduler and test the features. App is available on github (https://github.com/niphlod/w2p_scheduler_tests). All you need is download the trunk version of web2py, download the app and play with it. Current features: - one-time-only tasks - recurring tasks - possibility to schedule functions at a given time - possibility to schedule recurring tasks with a stop_time - can operate distributed among machines, given a database reachable for all workers - group_names to divide tasks among different workers - group_names can also influence the percentage of assigned tasks to similar workers - simple integration using modules for embedded tasks (i.e. you can use functions defined in modules directly in your app or have them processed in background) - configurable heartbeat to reduce latency: with sane defaults and not t many tasks queued normally a queued task doesn't exceed 5 seconds execution times - option to start it, process all available tasks and then die automatically - integrated tracebacks - monitorable as state is saved on the db - integrated app environment if started as web2py.py -K - stop processes immediately (set them to KILL) - stop processes gracefully (set them to TERMINATE) - disable processes (set them to DISABLED) - functions that doesn't return results do not generate a scheduler_run entry - added a discard_results parameter that doesn't store results no matter what - added a uuid record to tasks to simplify checkings of unique tasks - task_name is not required anymore - you can skip passing the function to the scheduler istantiation: functions can be dinamically retrieved in the app's environment So, your mission is: - test the scheduler with the app and familiarize with it Secondary mission is: - report any bug you find here or on github ( https://github.com/niphlod/w2p_scheduler_tests/issues) - propose new examples to be embedded in the app, or correct the current docs (English is not my mother tongue) Once approved, docs will be probably embedded in the book ( http://web2py.com/book) Feel free to propose features you'd like to see in the scheduler, I have some time to spend implementing it. --
Re: [web2py] Re: Install in hostgator
Hi Brian, I tried a similar setup but I wasn't able to run it... Were you able to run web2py in hostgator? When I try to run it from ssh I get: lance...@lancesegols.com [~/public_html/lancesegols.com]# python web2py.py web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2011 Version 1.99.7 (2012-03-04 22:12:08) stable Database drivers available: SQLite3, pymysql, pg8000, IMAP Starting hardcron... choose a password: no password, no admin interface please visit: http://127.0.0.1:8000 use kill -SIGTERM 31355 to shutdown the web2py server Fatal Python error: Couldn't create autoTLSkey mapping Aborted (core dumped) Not sure what is wrong... I have put web2py source inside public_html is it the right path? My dispatch.fcgi #!/home/lanceseg/local/bin/python import sys from flup.server.fcgi_fork import WSGIServer import gluon.main application=gluon.main.wsgibase ## or # application=gluon.main.wsgibase_with_logging WSGIServer(application).run() My .htaccess: AddHandler fcgid-script .fcgi Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteBase / RewriteRule ^dispatch\.fcgi/ - [L] RewriteRule ^(.*)$ dispatch.fcgi/$1 [L] Not usre what is wrong but there is not a good tutorial for hostgator. Regards, Tito On Wed, May 18, 2011 at 9:48 PM, Brian M bmere...@gmail.com wrote: Yep it'll work similar on hostgator - tried it out a few months back just to see if I could get it working, haven't actually deployed anything useful but it appears to run ok. I recall that an appropriate version of Python flup were already installed on my hostgator shared box. I did my install of web2py into a subfolder rather than the site root which probably made things harder. Here's that I can quickly grab from my setup, sorry didn't take detailed notes :( .htaccess -- AddHandler fcgid-script .fcgi Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteBase /web2py/ RewriteRule ^dispatch\.fcgi/ - [L] RewriteRule ^(.*)$ dispatch.fcgi/$1 [L] dispatch.fcgi --- #!/usr/bin/python2.7 import sys from flup.server.fcgi_fork import WSGIServer import gluon.main application=gluon.main.wsgibase ## or # application=gluon.main.wsgibase_with_logging WSGIServer(application).run() routes.py (sorry honestly don't remember if I changed this or not, think I had to add the /web2py/ because I put web2py in a subfolder of the site) #routes_in = ((r'.*:/favicon.ico', r'/examples/static/favicon.ico'), # (r'.*:/robots.txt', r'/examples/static/robots.txt'), # ((r'.*http://otherdomain.com.* (?Pany.*)', r'/app/ctr\gany'))) routes_in = (('/web2py/(?Pa.*)','/\ga'),) # routes_out, like routes_in translates URL paths created with the web2py URL() # function in the same manner that route_in translates inbound URL paths. # #routes_out = ((r'.*http://otherdomain.com.* /app/ctr(?Pany.*)', r'\gany'), # (r'/app(?Pany.*)', r'\gany')) routes_out=(('/(?Pa.*)','/web2py/\ga'),) -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ --
Re: [web2py] Re: Scheduler: help us test it while learning
Nope, that goes wyyy over the scheduler responsibility. Prune all records, prune only completed, prune only failed, requeue timeoutted, prune every day, every hour, etc, etc, etc these are implementation details that belongs to the application. We though that since it is all recorded and timestamped it's a matter of: timelimit = datetime.datetime.utcnow() - datetime.timedelta(days=15) db((db.scheduler_task.status == 'COMPLETED') (db.scheduler_task.last_run_time timelimit)).delete() that is actually not so hard (scheduler_run records should be pruned away automatically because they are referenced) (I like to have a function maintenance fired off every now and then with these things on it.) 2012/8/15 Yarin ykess...@gmail.com Niphlod- has there been any discussion about a param for clearing out old records on the runs and tasks tables? Maybe a retain_results or retain_completed value that specifies a period for which records will be kept? On Thursday, July 12, 2012 4:36:38 PM UTC-4, Niphlod wrote: Hello everybody, in the last month several changes were commited to the scheduler, in order to improve it. Table schemas were changed, to add some features that were missed by some users. On the verge of releasing web2py v.2.0.0, and seeing that the scheduler potential is often missed by regular web2py users, I created a test app with two main objectives: documenting the new scheduler and test the features. App is available on github (https://github.com/niphlod/** w2p_scheduler_tests https://github.com/niphlod/w2p_scheduler_tests). All you need is download the trunk version of web2py, download the app and play with it. Current features: - one-time-only tasks - recurring tasks - possibility to schedule functions at a given time - possibility to schedule recurring tasks with a stop_time - can operate distributed among machines, given a database reachable for all workers - group_names to divide tasks among different workers - group_names can also influence the percentage of assigned tasks to similar workers - simple integration using modules for embedded tasks (i.e. you can use functions defined in modules directly in your app or have them processed in background) - configurable heartbeat to reduce latency: with sane defaults and not t many tasks queued normally a queued task doesn't exceed 5 seconds execution times - option to start it, process all available tasks and then die automatically - integrated tracebacks - monitorable as state is saved on the db - integrated app environment if started as web2py.py -K - stop processes immediately (set them to KILL) - stop processes gracefully (set them to TERMINATE) - disable processes (set them to DISABLED) - functions that doesn't return results do not generate a scheduler_run entry - added a discard_results parameter that doesn't store results no matter what - added a uuid record to tasks to simplify checkings of unique tasks - task_name is not required anymore - you can skip passing the function to the scheduler istantiation: functions can be dinamically retrieved in the app's environment So, your mission is: - test the scheduler with the app and familiarize with it Secondary mission is: - report any bug you find here or on github (https://github.com/niphlod/* *w2p_scheduler_tests/issueshttps://github.com/niphlod/w2p_scheduler_tests/issues ) - propose new examples to be embedded in the app, or correct the current docs (English is not my mother tongue) Once approved, docs will be probably embedded in the book ( http://web2py.com/book) Feel free to propose features you'd like to see in the scheduler, I have some time to spend implementing it. -- --
Re: [web2py] Re: Scheduler: help us test it while learning
10 4 - thanks On Tue, Aug 14, 2012 at 7:48 PM, niphlod niph...@gmail.com wrote: Nope, that goes wyyy over the scheduler responsibility. Prune all records, prune only completed, prune only failed, requeue timeoutted, prune every day, every hour, etc, etc, etc these are implementation details that belongs to the application. We though that since it is all recorded and timestamped it's a matter of: timelimit = datetime.datetime.utcnow() - datetime.timedelta(days=15) db((db.scheduler_task.status == 'COMPLETED') (db.scheduler_task.last_run_time timelimit)).delete() that is actually not so hard (scheduler_run records should be pruned away automatically because they are referenced) (I like to have a function maintenance fired off every now and then with these things on it.) 2012/8/15 Yarin ykess...@gmail.com Niphlod- has there been any discussion about a param for clearing out old records on the runs and tasks tables? Maybe a retain_results or retain_completed value that specifies a period for which records will be kept? On Thursday, July 12, 2012 4:36:38 PM UTC-4, Niphlod wrote: Hello everybody, in the last month several changes were commited to the scheduler, in order to improve it. Table schemas were changed, to add some features that were missed by some users. On the verge of releasing web2py v.2.0.0, and seeing that the scheduler potential is often missed by regular web2py users, I created a test app with two main objectives: documenting the new scheduler and test the features. App is available on github (https://github.com/niphlod/** w2p_scheduler_tests https://github.com/niphlod/w2p_scheduler_tests). All you need is download the trunk version of web2py, download the app and play with it. Current features: - one-time-only tasks - recurring tasks - possibility to schedule functions at a given time - possibility to schedule recurring tasks with a stop_time - can operate distributed among machines, given a database reachable for all workers - group_names to divide tasks among different workers - group_names can also influence the percentage of assigned tasks to similar workers - simple integration using modules for embedded tasks (i.e. you can use functions defined in modules directly in your app or have them processed in background) - configurable heartbeat to reduce latency: with sane defaults and not t many tasks queued normally a queued task doesn't exceed 5 seconds execution times - option to start it, process all available tasks and then die automatically - integrated tracebacks - monitorable as state is saved on the db - integrated app environment if started as web2py.py -K - stop processes immediately (set them to KILL) - stop processes gracefully (set them to TERMINATE) - disable processes (set them to DISABLED) - functions that doesn't return results do not generate a scheduler_run entry - added a discard_results parameter that doesn't store results no matter what - added a uuid record to tasks to simplify checkings of unique tasks - task_name is not required anymore - you can skip passing the function to the scheduler istantiation: functions can be dinamically retrieved in the app's environment So, your mission is: - test the scheduler with the app and familiarize with it Secondary mission is: - report any bug you find here or on github (https://github.com/niphlod/ **w2p_scheduler_tests/issueshttps://github.com/niphlod/w2p_scheduler_tests/issues ) - propose new examples to be embedded in the app, or correct the current docs (English is not my mother tongue) Once approved, docs will be probably embedded in the book ( http://web2py.com/book) Feel free to propose features you'd like to see in the scheduler, I have some time to spend implementing it. -- -- --
[web2py] Re: HTTPS and the Rocket server?
yes. Try web2py.py -h for options. you can use -c and -k if you just want https. Of you can use --interfaces if you want both http and https on different ports On Tuesday, 14 August 2012 09:09:38 UTC-5, Alec Taylor wrote: I am testing some authentication mechanisms with janrain locally using a modified /etc/hosts name. Unfortunately it keeps redirecting to `https://` rather than to `http://`. Is there a way I can get Rocket to server as https? (I can generate unverified certs :P) Or is there a better way I can sandbox Janrain testing? Thanks for all suggestions, Alec Taylor --
[web2py] Re: What purpose? Search - Edit App Screen - web2py application, v 1.99 and 2.00
Please submit a ticket. I can fix this tonight. On Tuesday, 14 August 2012 11:48:36 UTC-5, Rob_McC wrote: Hey! we're counting how many times you click on it. ;-) . I'm up to 1,222 clicks... * BUT... * When I press ENTER, it WORKS! It is when I press the *magnifying glass,* it doesn't function, This is very handy. Note: Not sure why it reports that all my language files contain the search term... see attached, 2.00 web2py. Thanks for fast response. Rob Thanks Rob --