[web2py] login form registration problem with encoding
Hello I was scouting the internet(s) and could not found the solution for my problem So I am using web2py server on Linux. I also have a postgreSQL server on linux and when a user tries to login via login form and uses letters in name and surname such as š ž č ć the following error appears 'ascii' codec can't decode byte 0xc5 in position 0: ordinal not in range(128) Now the same web2py code is running on windows 7 (on my computer, including postgres database) and I do NOT receive that kind of error. I really need your help because I am getting some nervous calls from my clients :) thank you very much best regards -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] IS IN DB
Hi, i have three tables entry_attribute idint name varchar description longtext field_typevarchar field_sizeint report_attribute idint report_id int entry_attribute_idint sorting varchar and report_attribute_filter idint report_attribute_id int filter_type varchar On my report attribute_filter i have a select where user can select report attribute with name from entry attribute. I would like to do something like this. requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s', zero =T(-- Odaberite --)) Code above doesn't work. How can i do this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Scheduler - calling functions outside a model?
Thanks Simone, Turned out to be the following: path = os.path.join(request.folder, 'data\\') - os.chdir(path) - for files in os.listdir('*.*'): + for files in os.listdir(path): -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Contribute in book translation - translations sync with original file?
Hi All I would like to contribute in book translation. I found an existing translation in github *web2py-book / sources / 38-web2py-french-translation-in-progress *but I have 2 questions : 1. To contribute, I fork the source repo, do my translation, commit, and then send a pull request, that's all? 2. Are the translations sync with the original book? For example if I translate a chapter, and then massimo add new paragraphs in english book, what happens? Thank you -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] In openshift: Need help on why my web2py website is being constantly accessed by openshift itself
Hi folks, So in openshift in a python 2.6 cartridge + haproxy i'm having lots of accesses from openshift ip itself, like one every 3 seconds. I do not have any cron jobs. Is there a way to figure where these access are coming from : wsgi, web2py, openshift ? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Scheduler - calling functions outside a model?
never never never never run a chdir in web2py environment ... ^_^ Il giorno mercoledì 8 maggio 2013 10:26:49 UTC+2, Simon Ashley ha scritto: Thanks Simone, Turned out to be the following: path = os.path.join(request.folder, 'data\\') - os.chdir(path) - for files in os.listdir('*.*'): + for files in os.listdir(path): -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] In openshift: Need help on why my web2py website is being constantly accessed by openshift itself
On Wed, May 8, 2013 at 11:10 AM, smogzer smog...@gmail.com wrote: Hi folks, So in openshift in a python 2.6 cartridge + haproxy i'm having lots of accesses from openshift ip itself, like one every 3 seconds. I do not have any cron jobs. Is there a way to figure where these access are coming from : wsgi, web2py, openshift ? Those requests have an UserAgent? Can them be an openshift monitoring tools? Those requests have always the same uri? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] URL route when closed session
Hi, Let's say I'm in this route: /AppName/*normalController*/*index*, logged and then I close the session. Why when I close the session web2py redirects me to this URL? AppName/*default/user/login*?_next=/AppName/*default/index*, I was expecting something like: AppName/*default/user/login*?_next= /AppName/*normalController/index *?. Is there any way to do it? Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] login form registration problem with encoding
On Wed, May 8, 2013 at 7:24 AM, Yebach vid.og...@gmail.com wrote: Hello So I am using web2py server on Linux. I also have a postgreSQL server on linux and when a user tries to login via login form and uses letters in name and surname such as š ž č ć the following error appears 'ascii' codec can't decode byte 0xc5 in position 0: ordinal not in range(128) Now the same web2py code is running on windows 7 (on my computer, including postgres database) and I do NOT receive that kind of error. Can you make a minimal application that replicate the issue? Can you show us the traceback? When exactly the error happen? In the login POST request, or after it, in the redirect -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] IS IN DB
Why doen't it work? What it shows? What should be shown? What error does it report? -- Vinicius Assef On Wed, May 8, 2013 at 5:20 AM, Domagoj Kovač doctorko...@gmail.com wrote: Hi, i have three tables entry_attribute idint name varchar description longtext field_typevarchar field_sizeint report_attribute idint report_id int entry_attribute_idint sorting varchar and report_attribute_filter idint report_attribute_id int filter_type varchar On my report attribute_filter i have a select where user can select report attribute with name from entry attribute. I would like to do something like this. requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db.entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s', zero=T(-- Odaberite --)) Code above doesn't work. How can i do this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] IS IN DB
type 'exceptions.AttributeError' 'Table' object has no attribute 'entry_attribute.name' This is the error. On Wednesday, May 8, 2013 1:39:55 PM UTC+2, viniciusban wrote: Why doen't it work? What it shows? What should be shown? What error does it report? -- Vinicius Assef On Wed, May 8, 2013 at 5:20 AM, Domagoj Kovač docto...@gmail.comjavascript: wrote: Hi, i have three tables entry_attribute idint name varchar description longtext field_typevarchar field_sizeint report_attribute idint report_id int entry_attribute_idint sorting varchar and report_attribute_filter idint report_attribute_id int filter_type varchar On my report attribute_filter i have a select where user can select report attribute with name from entry attribute. I would like to do something like this. requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db.entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s', zero=T(-- Odaberite --)) Code above doesn't work. How can i do this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: IS IN DB
This also gives the same error. requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id).select(db.report_attribute.ALL, db.entry_attribute.ALL), report_attribute.id, '%(entry_attribute.name)s', zero=T(-- Odaberite -- )), -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Web Frameworks Performance
Hi, How we can improve web2py to match the fastest python web frameworks performance? http://www.techempower.com/benchmarks/#section=intro Surely, with many brains we can offer some method to improve that! Saludos, Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] IS IN DB
Show us your db.define_table() to these tables. On Wed, May 8, 2013 at 8:47 AM, Domagoj Kovač doctorko...@gmail.com wrote: type 'exceptions.AttributeError' 'Table' object has no attribute 'entry_attribute.name' This is the error. On Wednesday, May 8, 2013 1:39:55 PM UTC+2, viniciusban wrote: Why doen't it work? What it shows? What should be shown? What error does it report? -- Vinicius Assef On Wed, May 8, 2013 at 5:20 AM, Domagoj Kovač docto...@gmail.com wrote: Hi, i have three tables entry_attribute idint name varchar description longtext field_typevarchar field_sizeint report_attribute idint report_id int entry_attribute_idint sorting varchar and report_attribute_filter idint report_attribute_id int filter_type varchar On my report attribute_filter i have a select where user can select report attribute with name from entry attribute. I would like to do something like this. requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db.entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s', zero=T(-- Odaberite --)) Code above doesn't work. How can i do this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] IS IN DB
db.define_table(entry_attribute, Field('name', 'string', required=True, requires=[IS_NOT_EMPTY(), IS_ALPHANUMERIC()], label=LABEL(T(Naziv), _for=entry_attribute_type)), Field('description', 'text', required=True, requires=IS_NOT_EMPTY(), label=LABEL(T(Opis), _for=entry_attribute_type)), Field('field_type', 'string', required=True, requires=IS_IN_SET((STRING, LOV, TEXT, BOOLEAN, INTEGER, DECIMAL, DATE, TIME, DATETIME, UPLOAD, LOCATION, PARTNER, MANUFACTURER), zero=T(Odaberite tip polja)), label=LABEL(T(Tip polja), _for= entry_attribute_field_type)), Field('field_size', 'integer', label=LABEL(T(Veličina polja), _for= entry_attribute_field_size)), ) db.define_table('report', Field('name', 'string', required=True, requires=IS_NOT_EMPTY(), label=LABEL(T(Naziv), _for=report_name)), Field('description', 'string', required=False, label=LABEL(T(Opis), _for=report_description)), Field('entry_class_id', 'reference entry_class', required=True, requires=IS_IN_DB(db, entry_class.id, '%(name)s',zero =T(-- Odaberite --)), label=LABEL(T(Klasa), _for=report_entry_class_id )), ) db.define_table('report_attribute', Field('report_id', 'reference report', required=True, requires=IS_IN_DB(db, report.id, '%(name)s', zero=T(-- Odaberite --)), label=LABEL(T(Izvještaj), _for=report_report_id)), Field('entry_attribute_id', 'reference entry_attribute', requires=IS_IN_DB(db, entry_attribute.id, '%(name)s', zero=T(-- Odaberite --)), label=LABEL(T(Atribut), _for= report_entry_attribute_id)), Field('sorting', 'string', required=False, requires=IS_EMPTY_OR(IS_IN_SET((ASC, DESC), zero=T(Odaberite sortiranje))), label=LABEL(T(Sortiranje), _for= report_attribute_sorting)), ) db.define_table('report_attribute_filter', Field('report_attribute_id', 'reference report_attribute', required=True, requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db.entry_attribute.id), report_attribute.id, %(entry_attribute_id)s,zero =T(-- Odaberite --)), label=LABEL(T(Attribut), _for= report_attribute_filter_report_attribute_id)), Field('filter_type', 'string', requires=IS_IN_SET((LIKE, =, , , =, =), zero=T(Odaberite filter )), label=LABEL(T(TIP FILTERA), _for= report_attribute_filter_filter_type)), Field('filter_name', 'string', required=True, requires=IS_NOT_EMPTY(), label=LABEL(T(Naziv filtera), _for= report_attribute_filter_filter_name)), ) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: IS IN DB
requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s',zero =T(-- Odaberite --)) How about: requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, lambda row: row.entry_attribute.name, zero=T(-- Odaberite --)) Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: IS IN DB
This gives: type 'exceptions.AttributeError' 'Row' object has no attribute 'entry_attribute' On Wednesday, May 8, 2013 2:37:54 PM UTC+2, Anthony wrote: requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s',zero =T(-- Odaberite --)) How about: requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, lambda row: row.entry_attribute.name, zero=T(-- Odaberite --)) Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Web Frameworks Performance
Benchmarks! Time to get some popcorn and sit back... Btw, don't be so pessimistic, web2py isn't even included yet... :) Regards, Ales On Wednesday, May 8, 2013 2:31:19 PM UTC+2, Alfonso de la Guarda Reyes wrote: Hi, How we can improve web2py to match the fastest python web frameworks performance? http://www.techempower.com/benchmarks/#section=intro Surely, with many brains we can offer some method to improve that! Saludos, Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Web Frameworks Performance
Hi I am not pessimistic but rather seek to define a goal that can get that many heads can develop a procedure / mechanism or technology to carry web2py to another level. The benchmarks are inevitable when it comes to designing a strategy to scale a solution Saludos, Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 On Wed, May 8, 2013 at 8:02 AM, LightDot light...@gmail.com wrote: Benchmarks! Time to get some popcorn and sit back... Btw, don't be so pessimistic, web2py isn't even included yet... :) Regards, Ales On Wednesday, May 8, 2013 2:31:19 PM UTC+2, Alfonso de la Guarda Reyes wrote: Hi, How we can improve web2py to match the fastest python web frameworks performance? http://www.techempower.com/**benchmarks/#section=introhttp://www.techempower.com/benchmarks/#section=intro Surely, with many brains we can offer some method to improve that! Saludos, --**-- Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: wget and basic authentication
No one opened a ticket so I fixed it a few months ago On a recent you can use auth.basic auth.basic(basic_auth_realm=any string you like) BONUS: *the realm string can be changed runtime to allow the user to be logged out i.e. the browser will ask authentication credentials again* 2013/5/8 Ian MacKinnon imack...@gmail.com Was a ticket ever filed for this? I'm encountering the same issue and I couldn't find a ticket for this issue. Ian On Monday, 31 October 2011 20:09:49 UTC-7, Massimo Di Pierro wrote: Please open a ticket. this is easy and I can take of it tomorrow. On Oct 31, 7:58 pm, mdorval rockingdor...@gmail.com wrote: Ok, so this command example is in the documentation under basic authentication (http://web2py.com/book/**default/chapter/08#Access-http://web2py.com/book/default/chapter/08#Access- Control-and-Basic-**Authentication): wget --user=[username] --password=[password]http:// .../[app]/[controller]**/give_me_time but this command won't work with basic authentication in web2py, as web2py doesn't throw a 401 when the Authentication header is missing, but a 403 (at least with the current version of wget). In order for wget to work properly with basic authentication, one must do wget --user=[username] --password=[password] --auth-no-challengehttp://.../**[app]/[controller]/give_me_**time The documentation on wget's --auth-no-challenge flag is as follows: ‘--auth-no-challenge’ If this option is given, Wget will send Basic HTTP authentication information (plaintext username and password) for all requests, just like Wget 1.10.2 and prior did by default. Use of this option is not recommended, and is intended only to support some few obscure servers, which never send HTTP authentication challenges, but accept unsolicited auth info, say, in addition to form- based authentication. So my question is: Is there a way to get web2py to handle these requests properly (return a 401 status code to prompt the client to resend with credentials)? (on a related note, it seems requests using urllib2 run into a similar problem:http://stackoverflow.**com/questions/2407126/python-** urllib2-basic-auth-..http://stackoverflow.com/questions/2407126/python-urllib2-basic-auth-.. .) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: response.menu URLs
Dang... I'd looked at that section of the manual, and I'd compared my code with the example from the text I'm working out of and I would have sworn that it was identical and correct. Heck, it took me a few passes to pick up what was missing even in your example. Guess that happens when you keep staring at the same thing too long - you start seeing things that *aren't* there. Thanks, Monte On Tuesday, May 7, 2013 5:31:51 PM UTC-7, 黄祥 wrote: please check the book on : http://web2py.com/books/default/chapter/29/05?search=menu#Page-layout response.menu menu is a list of 3-tuples or 4-tuples. The three elements are: the link name, a boolean representing whether the link is active (is the current link), and the URL of the linked page. For example: response.menu = [('Google', False, 'http://www.google.com',[]), ('Index', True, URL('index'), [])] sub-menu The fourth tuple element is an optional sub-menu. response.menu = [ (T('Home'), False, URL('default', 'index'), []), (T('Add project'), URL('default', 'add'), []), (T('Add company'), URL('default', 'company'), []), (T('Employees'), URL('default', 'employee'), [])] should be response.menu = [ (T('Home'), False, URL('default', 'index'), []), (T('Add project'), False, URL('default', 'add'), []), (T('Add company'), False, URL('default', 'company'), []), (T('Employees'),False, URL('default', 'employee'), [])] best regards On Wednesday, May 8, 2013 7:04:15 AM UTC+7, Monte Milanuk wrote: So... I have a couple functions defined in default.py: @auth.requires_login() def index(): response.flash = T('Welcome!') grid = SQLFORM.grid(db.project, create=False, fields=[db.project.name, db.project.employee_name, db.project.company_name, db.project.start_date, db.project.due_date, db.project.completed], deletable=False, maxtextlength=50) return locals() @auth.requires_login() def company(): company_form = SQLFORM(db.company).process() return dict(company_form=company_form) @auth.requires_login() def add(): project_form = SQLFORM(db.project).process() return dict(project_form=project_form) ...and corresponding views that work when I go to them directly by typing the URL into the browser i.e. http://127.0.0.1:8000/task_manager/default/add or http://127.0.0.1:8000/task_manager/default/company. I've added some code to define menu options in menu.py. response.menu = [ (T('Home'), False, URL('default', 'index'), []), (T('Add project'), URL('default', 'add'), []), (T('Add company'), URL('default', 'company'), []), (T('Employees'), URL('default', 'employee'), [])] DEVELOPMENT_MENU = False The links appear in the nav bar region, but they don't work and the URLs aren't what was defined. If I'm on the main index page, all the URLs link to 'http://127.0.0.1:8000/task_manager/default/index/#'. If I'm on the 'Add Project' page, all the URLs other than 'Home' link to ' http://127.0.0.1:8000/task_manager/default/add/#', and so on for the 'Company' page, etc. What do I need to do to get my nav bar menu working correctly? TIA, Monte -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Simple Select Query Question
Thank you, worked like a charm! In my application, we are tracking the techs, but they do not have permission to use the app, so they are not in the the auth table. I will keep all of your input in mind as I continue to work in web2py, this is great info especially for a beginner like me!! On Tuesday, May 7, 2013 2:09:40 PM UTC-6, Anthony wrote: *tip: '{{db.executesql('SELECT first_name, last_name FROM tech WHERE id = 'row.tech';')}}',* There are several things wrong with the above. First, you're getting a syntax error because you've got 'row.tech' in single quotes inside a string that is also in single quotes. Second, the SQL string is just a string that gets passed to the database, so it cannot contain Python variables like row.tech. Finally, if you want to write something into a template inside the {{...}} delimiters, you need to use = (i.e., {{=db.executesql(...)}}). Anyway, there's no reason to use executesql() here -- this does the same thing as the DAL select. Also, why does the db.tech table include first_name and last_name columns -- aren't those redundant with the same columns in db.auth_user? Anyway, since row.tech is the id in the db.tech table, you can use it to select the record from that table and fill in a string with the fields you want: tip: '{{='%(first_name)s %(last_name)s' % db.tech(row.tech)}}' However, that will do an additional select for each tech, which is inefficient if you have a long list. Instead, you might consider making your initial query a join and include the name fields in the main rows object: def mycal(): rows=db((db.work_order.tech==auth.user.id) (db.work_order.tech==db. tech.id))\ .select(db.work_order.ALL, db.tech.first_name, db.tech.last_name) and in the view: tip: '{{='%(first_name)s %(last_name)s' % row.as_dict()['tech']}}' Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Please need some help with URL after session close
Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/*index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/* default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/* normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: IS IN DB
OK, looks like you can't do a join. Instead, you can just use recursive selects (though this will do a separate select for each item in the list): requires=IS_IN_DB(db, report_attribute.id, lambda row: row. entry_attribute_id.name, zero=T(-- Odaberite --)) row.entry_attribute_id.name does a select from the db.entry_attribute table for each item. The other alternative is to build the set yourself (using a join) and use IS_IN_SET() instead. Anthony On Wednesday, May 8, 2013 8:41:32 AM UTC-4, Domagoj Kovač wrote: This gives: type 'exceptions.AttributeError' 'Row' object has no attribute 'entry_attribute' On Wednesday, May 8, 2013 2:37:54 PM UTC+2, Anthony wrote: requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s',zero =T(-- Odaberite --)) How about: requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, lambda row: row.entry_attribute.name, zero=T(-- Odaberite --)) Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/*index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName /*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/* normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: IS IN DB
OK, i will try. Thanks! On Wednesday, May 8, 2013 4:02:47 PM UTC+2, Anthony wrote: OK, looks like you can't do a join. Instead, you can just use recursive selects (though this will do a separate select for each item in the list): requires=IS_IN_DB(db, report_attribute.id, lambda row: row. entry_attribute_id.name, zero=T(-- Odaberite --)) row.entry_attribute_id.name does a select from the db.entry_attribute table for each item. The other alternative is to build the set yourself (using a join) and use IS_IN_SET() instead. Anthony On Wednesday, May 8, 2013 8:41:32 AM UTC-4, Domagoj Kovač wrote: This gives: type 'exceptions.AttributeError' 'Row' object has no attribute 'entry_attribute' On Wednesday, May 8, 2013 2:37:54 PM UTC+2, Anthony wrote: requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, '%(entry_attribute.name)s',zero =T(-- Odaberite --)) How about: requires=IS_IN_DB(db(db.report_attribute.entry_attribute_id == db. entry_attribute.id), report_attribute.id, lambda row: row.entry_attribute.name, zero=T(-- Odaberite --)) Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Simple Select Query Question
In my application, we are tracking the techs, but they do not have permission to use the app, so they are not in the the auth table. If that's the case, then this line doesn't make any sense: rows=db(db.work_order.tech==auth.user.id).select() That selects the work orders whose tech is the current logged in user. Since db.work_order.tech is not actually referencing db.auth_user.id, the above will end up giving you records you did not really request (i.e., it will give you work orders of the tech who just happens to have the same record ID in the db.tech table as the current logged in user has in the db.auth_user table). For example, if you are logged in and have ID=5 in the db.auth_user table, the above will give you the work orders of the tech who happens to have ID=5 in the db.tech table (of course, there's no guarantee that such an ID even exists in that table, so this could return nothing). Anthony -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Markmin components
For anyone interested in my monologue... Function to my previous ideas, a function as follows could handle both internal and external URLs. I also included a simple check for allowed domains: def __component(text): if text and text.lower().strip().startswith('http'): from urlparse import urlparse allowed_domains = [ 'www.domain1.com', 'www.domain2.com', ] if allowed_domains and not any(i in urlparse(text)[1] for i inallowed_domains ): return H1('domain not allowed').xml() else: return LOAD(url=text, ajax=True).xml() else: items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() MARKMIN(mytext,url=True,extra=dict(component = lambda value: __component( value))) In our Markmin we can then include... ``http://www.domain1.com/app/mycont/myfunc/arg1``:component and/or ``mycont/myfunc/arg1``:component . Maybe someone has other better, or more flexibile, ideas? On Wednesday, May 8, 2013 2:09:28 AM UTC+1, villas wrote: I can do something like this... mytext = ``default/get_cms_article/4``:component def __component(text): items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() MARKMIN_ENV = dict( component = lambda value: __component(value) ) MARKMIN(mytext,url=True,extra=MARKMIN_ENV) This uses LOAD. What is recommended for loading components from other domains? I think I have used JSON for that in the past, but maybe there are other ways, I am not sure that I am using the currently recommended methods for Markmin. Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login*?_next=/AppName/* default/index* instead AppName/*default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/*index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/* normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: How can I run multiple applications with multiple domains on nginx?
Hi Peter! It helps a lot! I didn't know that we could have another routes.py inside the application folder, is it described anywhere in the book? Thanks! Tito On Sat, Mar 23, 2013 at 7:01 AM, peter peterchutchin...@gmail.com wrote: Sorry about replying late Tito. I struggled with your problem for quite a while, and here is a solution. In the web2py folder have a routes.py like this #!/usr/bin/python # -*- coding: utf-8 -*- routes_app=[ ('.*://www.site1.com:\w* /$anything','app1'), ('.*://site1.com:\w* /$anything','app1'), ('.*://www.site2.com:\w* /$anything','app2'), ('.*://site2.com:\w* /$anything','app2') ] Then in the application folder for app1 have something like #!/usr/bin/python # -*- coding: utf-8 -*- routes_in = ((r'.*://site1.com:\w* /static/$anything', r'/app1/static/$anything'), (r'.*://site1.com:\w* /$anything', r'/app1/default/$anything'), (r'.*://www.site1.com:\w* /static/$anything', r'/app1/static/$anything'), (r'.*://www.site1.com:\w* /$anything', r'/app1/default/$anything'),) routes_out = (('/app1/default/(?Pany.*)', '/\gany'),) and similarly for app2 I hope this helps Peter On Thursday, 21 March 2013 16:06:46 UTC, Massimo Di Pierro wrote: Yes you can. From the point of nginx treat all domains as one. the use web2py routes.py to map different domains to different apps. On Monday, 18 March 2013 15:21:25 UTC-5, Tito Garrido wrote: Hi Folks, I am reading the book section: http://web2py.com/books/** default/chapter/29/13#Nginxhttp://web2py.com/books/default/chapter/29/13#Nginx But I couldn't figure out how could I setup nginx to serve multiple domains pointing to a different application on the same web2py instance. Do you have any example? like: mydomain1 - /home/www-data/web2py/**applications/myapp1 mydomain2 - /home/www-data/web2py/**applications/myapp2 Thanks, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Contribute in book translation - translations sync with original file?
It is hard to keep them in sync but you can diff a specific revision/date and see what has changed in the official edition. On Wednesday, 8 May 2013 04:32:42 UTC-5, Loïc wrote: Hi All I would like to contribute in book translation. I found an existing translation in github *web2py-book / sources / 38-web2py-french-translation-in-progress *but I have 2 questions : 1. To contribute, I fork the source repo, do my translation, commit, and then send a pull request, that's all? 2. Are the translations sync with the original book? For example if I translate a chapter, and then massimo add new paragraphs in english book, what happens? Thank you -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Markmin components
There is an official syntax for this. @{component:controller/function/args} To enable this and enable OEMBED I do: def markmin(body): from gluon.contrib.autolinks import expand_one def component(text): items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() return MARKMIN(body, url=True, environment={'component':component}, autolinks=lambda link: expand_one(link, {})).xml() db.table.field.represent = lambda v,r: markmin(v or '') This is done automatically by auth.wiki() Massimo On Wednesday, 8 May 2013 09:16:21 UTC-5, villas wrote: For anyone interested in my monologue... Function to my previous ideas, a function as follows could handle both internal and external URLs. I also included a simple check for allowed domains: def __component(text): if text and text.lower().strip().startswith('http'): from urlparse import urlparse allowed_domains = [ 'www.domain1.com', 'www.domain2.com', ] if allowed_domains and not any(i in urlparse(text)[1] for i inallowed_domains ): return H1('domain not allowed').xml() else: return LOAD(url=text, ajax=True).xml() else: items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() MARKMIN(mytext,url=True,extra=dict(component = lambda value: __component( value))) In our Markmin we can then include... ``http://www.domain1.com/app/mycont/myfunc/arg1``:componenthttp://www.domain1.com/app/mycont/myfunc/arg1:component and/or ``mycont/myfunc/arg1``:component . Maybe someone has other better, or more flexibile, ideas? On Wednesday, May 8, 2013 2:09:28 AM UTC+1, villas wrote: I can do something like this... mytext = ``default/get_cms_article/4``:component def __component(text): items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() MARKMIN_ENV = dict( component = lambda value: __component(value) ) MARKMIN(mytext,url=True,extra=MARKMIN_ENV) This uses LOAD. What is recommended for loading components from other domains? I think I have used JSON for that in the past, but maybe there are other ways, I am not sure that I am using the currently recommended methods for Markmin. Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login*?_next=/AppName/* default/index* instead AppName/*default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/*index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/* normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Nasty redirect in Ajax call. 'web2py-redirect-location' header breaks website.
Thanks a lot, that seem to work. I had to do that in several places. It looks like you have client_side = auth.settings.client_side in trunk. Is there any knowledge of when the next release is? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Contribute in book translation - translations sync with original file?
and there is diffbook to help with that.http://niphlod.github.io/diffbook/ Il giorno mercoledì 8 maggio 2013 17:14:15 UTC+2, Massimo Di Pierro ha scritto: It is hard to keep them in sync but you can diff a specific revision/date and see what has changed in the official edition. On Wednesday, 8 May 2013 04:32:42 UTC-5, Loïc wrote: Hi All I would like to contribute in book translation. I found an existing translation in github *web2py-book / sources / 38-web2py-french-translation-in-progress *but I have 2 questions : 1. To contribute, I fork the source repo, do my translation, commit, and then send a pull request, that's all? 2. Are the translations sync with the original book? For example if I translate a chapter, and then massimo add new paragraphs in english book, what happens? Thank you -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Web Frameworks Performance
Benchmarks! Time to get some popcorn and sit back... +1. Don't expect web2py to be the fastest framework. It simply can't, and for a lot of (good) reasons. Nonetheless, it can be improved (as every program out there). -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/;bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login*?_next=/AppName/* default/index* instead AppName/*default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/*index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/ *normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. Title: {{=response.title or request.application}} {{=response.flash or ''}} web2py {{='auth' in globals() and auth.navbar(mode="dropdown") or ''}} {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} {{=response.title or request.application}} {{=response.subtitle or request.function}} {{if left_sidebar_enabled:}} {{block left_sidebar}} Left Sidebar {{end}} {{pass}} {{block center}} {{include}} {{end}} {{if right_sidebar_enabled:}} {{block right_sidebar}} Right Sidebar {{end}} {{pass}} {{block footer}} {{=T('Copyright')}} {{=request.now.year}} {{=T('UrRoom Extranet')}} {{end}}
[web2py] model not updated in scheduled task
So one of my model files is somewhat unique (and possibly a bad idea) and causing me problems...I'll try to describe things the best I can. My application creates tables dynamically based on user input. To stop web2py from defining all the tables on every request (which can be a lot in the whole app, but only 10ish per user), I check which tables the user has access to and define only those. This is done by looking at a table (projects) where each record specifies other tables that exist (the project support tables). The issue i'm having is the user fills out a form using smartgrid. In the oncreate callback I update the projects table which essentially specifies new tables. These new tables are not defined unless the model runs again. I know this will happen on a refresh, but is there any other way to force the models to update? If I then submit a job to the scheduler that references one of these new tables I get this error: 'DAL' object has no attribute 'test_project_proj' Where test_project_proj one of the support tables that should have been defined (in the model snippet below project.project_table = 'test_project_proj') . Example of key part of the model: user_allowed_ids = get_user_allowed_projects(False) for project in db(db. projects.id.belongs(user_allowed_ids)).select(): db.define_table(project.project_table,..) db.define_table(project.block_table,..) db.define_table(project.metadata_table,..) I thought that when a job runs on the scheduler it re-runs all the models, so i don't understand why the task isn't seeing the new tables. Thoughts? Thanks Dean -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login*?_next=/AppName/* default/index* instead AppName/*default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/*index *, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/*normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login*?_next=/AppName/* default/index* instead AppName/*default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/* index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/*normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
If you don't know where it is, then I suppose you probably haven't changed it from the default scaffolding code -- but it would be in db.py by default. Can you create a basic application that replicates this problem, pack it, and attach it here? Anthony On Wednesday, May 8, 2013 12:30:49 PM UTC-4, José Manuel López wrote: Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login*?_next=/AppName/ *default/index* instead AppName/*default/user/login*?_next= /AppName/ *normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/* index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/*normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
Now I think I know what you are asking me: auth = Auth(db) # all we need is login auth.settings.actions_disabled=['change_password','request_reset_password','retrieve_username','profile'] if request.controller != 'appadmin': auth.settings.actions_disabled +=['register'] ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = False auth.settings.login_after_registration = True Jose M. On Wednesday, May 8, 2013 6:35:30 PM UTC+2, Anthony wrote: If you don't know where it is, then I suppose you probably haven't changed it from the default scaffolding code -- but it would be in db.py by default. Can you create a basic application that replicates this problem, pack it, and attach it here? Anthony On Wednesday, May 8, 2013 12:30:49 PM UTC-4, José Manuel López wrote: Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login*?_next=/AppName /*default/index* instead AppName/*default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/* index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/*normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Why contenttype(.png) is not image/png ?
Hello. When loading static png, Chrome throws a lot of warnings like: Resource interpreted as Image but transferred with MIME type image/x-apple-ios-png: http://127.0.0.1:8000/nabla/static/js/dojo/dijit/themes/claro/form/images/buttonArrows.png;. I don't want to modify gluon.contenttype, so I tried to override that in my model: from gluon.contenttype import contenttype, CONTENT_TYPE print CONTENT_TYPE['.png'] #- 'image/x-apple-ios-png' (only the first time) CONTENT_TYPE['.png']='image/png' print contenttype('.png') #- 'image/png' But web2py still sends image/x-apple-ios-png. What reason is there for this? How can I override it? Regards. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Coping with new behavior of _referenced_by
This isn't exactly the solution you're looking for, in that it may not work for 1.99 (I no longer have that version running), but I have the same problem. As far as I can tell (broken apps), this code created buttons at the bottom of a form to access child records. example: original coding for (in my case) vehicle_read.html accessing table t_vehicle: {{=form}} {{for t,f in db.t_vehicle._referenced_by:}}{{if not t[-8:]=='_archive':}}[{{=A(t[2:],_href=URL('%s_select'%t[2:],args=(f,form.record.id)))}}]{{pass}}{{pass}} revised coding: {{=form}} {{for f in db.t_vehicle._referenced_by:}}{{t=f.tablename}}{{if not t[-8:]=='_archive':}}[{{=A(t[2:],_href=URL('%s_select'%t[2:],args=(f.name,form.record.id)))}}]{{pass}}{{pass}} substituions: *for t,f in* becomes *for f in* *_referenced_by:}}* becomes *_referenced_by:}}{{t=f.tablename}}* *args=(f,* becomes *args=(f.name,* * * *try:* {{for f in db.t_sys_config._referenced_by:}}{{t=f.tablename}}{{if not t[-8:]=='_archive':}}[{{=A(t[2:],_href=URL('%s_select'%t[2:],args=(f.name, form.record.id)))}}]{{pass}}{{pass}} Alternatively, if the buttons/link_urls are not required, the {{for t,f . pass}}{{pass}} stanza could just be removed. This would be more efficient in any event for leaf tables which have no children. ..Keith On Wednesday, May 1, 2013 6:37:29 PM UTC-3, Michael Ellis wrote: I've got an app from before 2.0 with wizard-generated code in multiple views that looks similar to this. {{=form}} {{for t,f in db.t_sys_config._referenced_by:}}{{if not t[-8:]=='_archive':}}[{{=A(t[2:],_href=URL('%s_select'%t[2:],args=(f, form.record.id)))}}]{{pass}}{{pass}} Under web2py 2.4.6, the for loop throws a ticket because *_referenced_by*is returning a list of Field objects instead of tuples. The app is running in almost 100 different servers on 1.99. How can I modify the app code (without doing something kludgey like detecting web2py versions) so it will run under any web2py version? Thanks, Mike -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
OK, my mistake -- the _next variable points to auth.settings.logout_next -- so just change that setting to whatever URL you want. Also, are you sure the Logout URL is pointing to /default/user/login and not /default/user/logout? Anthony On Wednesday, May 8, 2013 12:40:57 PM UTC-4, José Manuel López wrote: Now I think I know what you are asking me: auth = Auth(db) # all we need is login auth.settings.actions_disabled=['change_password','request_reset_password','retrieve_username','profile'] if request.controller != 'appadmin': auth.settings.actions_disabled +=['register'] ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = False auth.settings.login_after_registration = True Jose M. On Wednesday, May 8, 2013 6:35:30 PM UTC+2, Anthony wrote: If you don't know where it is, then I suppose you probably haven't changed it from the default scaffolding code -- but it would be in db.py by default. Can you create a basic application that replicates this problem, pack it, and attach it here? Anthony On Wednesday, May 8, 2013 12:30:49 PM UTC-4, José Manuel López wrote: Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login* ?_next=/AppName/*default/index* instead AppName/*default/user/login *?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/* index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/*normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Web Frameworks Performance
Well, if you look at the benchmarks, several things stand out. 1. All the WSGI servers are pre-loaded. That means the code is already pre-compiled and loaded in ram, ready to run. Web2py doesn't quite work that way, because each request loads the database, does migrations if necessary, and inserts a lot of objects into the scope. 2. They are all using gunicorn, which spawns about 4 workers on startup. We could certainly run Web2py in WSGI mode with gunicorn, but it wouldn't make much a difference. I believe if we are going to support sessions, they should be off by default and use a decorator @session_enabled or something like that. However, that may go against Web2py principles. 3. Those benchmarks are not development type setups. If we are going to compare benchmarks, we'll need to make sure that our configuration matches theirs. 4. Web2py was meant to be a teaching tool. However, as it is now, what it's teaching is years old. Now everything needs to be WSGI so you can run it on a PAAS such as Heroku, Iron.io, Azure, etc. It's good to know how we compare with performance, but at the same time, I think we need to be realistic. Web2py needs to be re-architectured if we're going to see wider adoption in the future. On Wednesday, May 8, 2013 5:31:19 AM UTC-7, Alfonso de la Guarda Reyes wrote: Hi, How we can improve web2py to match the fastest python web frameworks performance? http://www.techempower.com/benchmarks/#section=intro Surely, with many brains we can offer some method to improve that! Saludos, Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: The Great Web Framework Shootout
It would be nice if you could post your code to github, so we could make pull requests to fix the issues. On Sunday, April 21, 2013 1:05:44 PM UTC-7, OJ wrote: The application was copied from https://github.com/seedifferently/the-great-web-framework-shootout/issues/14 ... Please point me some performance problems and I'll fix and re-run the tests. .oj On Wednesday, April 17, 2013 1:05:35 AM UTC+3, Derek wrote: Seems a bit low, but no way to really critique until we see the application. If you were using the one in issue 14, I can point to several performance problems in that application already. Also, what version of web2py? One thing I noticed, you aren't using gevent or any other concurrency framework. If you are publishing your site on the internet, and performance is essential (hint: it almost always is), chances are you'd use one. On Tuesday, April 16, 2013 9:18:42 AM UTC-7, OJ wrote: Ok guys here are the results. I repeated and confirmed the results that the great web framework shootout did. Web2py was tested with the application Massimo provided (with couple of fixes that you guys helped me to do). Tests were done in Amazon EC2 M1 Large instance. Because other frameworks were tested using Apache + mod_wsgi combination, web2py were tested the same way. I also wanted to know how fast Rocket was so I tested with it also. All configurations to run web2py followed Massimos complete reference manual 5th edition. Tests were done with 'ab -n 1 -c 5' and they were run 10 times. Results are average results from these runs (there were no significant deviations). Here are the results for web2py: Hello world!-test: web2py apache + mod_wsgi: 459 requests /second, web2py rocket: 363 req/sec (Django: 2012 req/sec, Flask 1858 req/sec) Template test: web2py apache + mod_wsgi: 344 req/sec, web2py rocket: 292 req/sec, (Django: 925 req/sec, Flask: 1625 req/sec) Database + template: web2py apache + mod_wsgi 274 req/sec (sqlite) and 180 req/sec (DAL), web2py with rocket: 245 req/sec (sql), 171 req/sec (DAL)(Django: 450 req/sec, Flask 1076 req/sec) .oj On Monday, March 4, 2013 10:00:42 PM UTC+2, OJ wrote: I will, I'm currently figuring out how to arrange my EC2 instance. After that I'm looking for advice with web2py / Apache setup :) One problem at the time. On Sunday, March 3, 2013 3:37:32 PM UTC+2, wwwgong wrote: Please share the benchmark results when avail -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] rad2py
Man, I love pythoncard. Too bad it hasn't been updated since 2006. On Tuesday, May 7, 2013 1:02:03 AM UTC-7, Mariano Reingart wrote: rad2py is in stand-by, I plan to finish it as my master thesis (maybe the next semester). It should be usable (including the debugger), but not for begginers right now as it needs more testing and bug-fixing. I'm working in gui2py that was the only big missing part (pythoncard fork with web2py philosophy, including a visual point-and-click designer, property editor inspector, and some HTML and javascript-like features): https://code.google.com/p/gui2py/ If you want to discuss something related to them and web2py, the place is this list. I've created a new group for rad2py specific discussions and announces, fell free to join: https://groups.google.com/d/forum/rad2py And the group for gui2py discussions and announces is: https://groups.google.com/d/forum/gui2py Sadly I didn't have enough time to speed up their development, but I'm open to new ideas and contributions ;-) Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Mon, May 6, 2013 at 6:46 PM, Monte Milanuk memi...@gmail.comjavascript: wrote: Is this project still alive? Is there a better place to discuss it than here? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] rad2py
Also Boa constructor is forgotten in time 2013/5/8 Derek sp1d...@gmail.com Man, I love pythoncard. Too bad it hasn't been updated since 2006. On Tuesday, May 7, 2013 1:02:03 AM UTC-7, Mariano Reingart wrote: rad2py is in stand-by, I plan to finish it as my master thesis (maybe the next semester). It should be usable (including the debugger), but not for begginers right now as it needs more testing and bug-fixing. I'm working in gui2py that was the only big missing part (pythoncard fork with web2py philosophy, including a visual point-and-click designer, property editor inspector, and some HTML and javascript-like features): https://code.google.com/p/**gui2py/ https://code.google.com/p/gui2py/ If you want to discuss something related to them and web2py, the place is this list. I've created a new group for rad2py specific discussions and announces, fell free to join: https://groups.google.com/d/**forum/rad2pyhttps://groups.google.com/d/forum/rad2py And the group for gui2py discussions and announces is: https://groups.google.com/d/**forum/gui2pyhttps://groups.google.com/d/forum/gui2py Sadly I didn't have enough time to speed up their development, but I'm open to new ideas and contributions ;-) Best regards, Mariano Reingart http://www.sistemasagiles.com.**ar http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Mon, May 6, 2013 at 6:46 PM, Monte Milanuk memi...@gmail.com wrote: Is this project still alive? Is there a better place to discuss it than here? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@**googlegroups.com. For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
For a moment I can see the logout that you mention, but then I'm redirect to login?_next=/urroomserver/hoteluser/index, I'll change the next to my URL. Thank you for your time Anthony!, it's very appreciated. On Wednesday, May 8, 2013 6:53:51 PM UTC+2, Anthony wrote: OK, my mistake -- the _next variable points to auth.settings.logout_next -- so just change that setting to whatever URL you want. Also, are you sure the Logout URL is pointing to /default/user/login and not /default/user/logout? Anthony On Wednesday, May 8, 2013 12:40:57 PM UTC-4, José Manuel López wrote: Now I think I know what you are asking me: auth = Auth(db) # all we need is login auth.settings.actions_disabled=['change_password','request_reset_password','retrieve_username','profile'] if request.controller != 'appadmin': auth.settings.actions_disabled +=['register'] ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = False auth.settings.login_after_registration = True Jose M. On Wednesday, May 8, 2013 6:35:30 PM UTC+2, Anthony wrote: If you don't know where it is, then I suppose you probably haven't changed it from the default scaffolding code -- but it would be in db.py by default. Can you create a basic application that replicates this problem, pack it, and attach it here? Anthony On Wednesday, May 8, 2013 12:30:49 PM UTC-4, José Manuel López wrote: Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login* ?_next=/AppName/*default/index* instead AppName/* default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/* index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login*?_next= /AppName/*normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when the user close the session and try to log in again, the destiny is /AppName/*default/index , *and this is a problem because they don't have privileges to log in and the feeling is that the application is not working ok. Thank you for your help! -- --- You received
[web2py] Eclipse error but fine at runtime
In a module I have the following line: current.response.headers[Content-Type] = application/json Eclipse underlines headers and flags an error Undefined variable from import:headers Is there an alternative expression to access .headers so that I can be error free? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] what does please restart itx mean?
After upgrading web2py to 2.4.6, the admin tool stated that web2py was upgraded and to please restart itx. I restarted the webserver and everything seems to be working fine. Can someone please refer me to the magic decoder ring that can decipher this message? Jim -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Please need some help with URL after session close
Does the URL you are initially redirecting to after logout require login? If so, then when you attempt to go to that URL after having logged out, it will immediately redirect again to the login page. Anthony On Wednesday, May 8, 2013 1:42:19 PM UTC-4, José Manuel López wrote: For a moment I can see the logout that you mention, but then I'm redirect to login?_next=/AppName/*default/index*, I'll change the next to my URL. Thank you for your time Anthony!, it's very appreciated. On Wednesday, May 8, 2013 6:53:51 PM UTC+2, Anthony wrote: OK, my mistake -- the _next variable points to auth.settings.logout_next -- so just change that setting to whatever URL you want. Also, are you sure the Logout URL is pointing to /default/user/login and not /default/user/logout? Anthony On Wednesday, May 8, 2013 12:40:57 PM UTC-4, José Manuel López wrote: Now I think I know what you are asking me: auth = Auth(db) # all we need is login auth.settings.actions_disabled=['change_password','request_reset_password','retrieve_username','profile'] if request.controller != 'appadmin': auth.settings.actions_disabled +=['register'] ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = False auth.settings.login_after_registration = True Jose M. On Wednesday, May 8, 2013 6:35:30 PM UTC+2, Anthony wrote: If you don't know where it is, then I suppose you probably haven't changed it from the default scaffolding code -- but it would be in db.py by default. Can you create a basic application that replicates this problem, pack it, and attach it here? Anthony On Wednesday, May 8, 2013 12:30:49 PM UTC-4, José Manuel López wrote: Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login* ?_next=/AppName/*default/index* instead AppName/* default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost with this problem, maybe anyone can help me. Let's say I'm logged in this route: /AppName/*normalController*/ *index*, and then close the session. Why when I close the session web2py redirects me to this URL? - AppName/*default/user/login*?_next=/AppName/*default/index* , I was expecting something like: AppName/*default/user/login* ?_next= /AppName/*normalController/index *?. Why I think that?, because normalController is where the user comes... Is there any way to do it?, now when
[web2py] Re: Please need some help with URL after session close
Yes!, that's the problem!, both controllers needs login. Each controller has a index and each index needs to be logged, one for super users and the other for normal user. When a normal user logs out, then the superuser index is called and then this index needs to be logged, but when the normal user try it the the login is denied. Probably is better that every user enter using with the same URL now that I understand the problem... On Wednesday, May 8, 2013 8:04:28 PM UTC+2, Anthony wrote: Does the URL you are initially redirecting to after logout require login? If so, then when you attempt to go to that URL after having logged out, it will immediately redirect again to the login page. Anthony On Wednesday, May 8, 2013 1:42:19 PM UTC-4, José Manuel López wrote: For a moment I can see the logout that you mention, but then I'm redirect to login?_next=/AppName/*default/index*, I'll change the next to my URL. Thank you for your time Anthony!, it's very appreciated. On Wednesday, May 8, 2013 6:53:51 PM UTC+2, Anthony wrote: OK, my mistake -- the _next variable points to auth.settings.logout_next -- so just change that setting to whatever URL you want. Also, are you sure the Logout URL is pointing to /default/user/login and not /default/user/logout? Anthony On Wednesday, May 8, 2013 12:40:57 PM UTC-4, José Manuel López wrote: Now I think I know what you are asking me: auth = Auth(db) # all we need is login auth.settings.actions_disabled=['change_password','request_reset_password','retrieve_username','profile'] if request.controller != 'appadmin': auth.settings.actions_disabled +=['register'] ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = False auth.settings.login_after_registration = True Jose M. On Wednesday, May 8, 2013 6:35:30 PM UTC+2, Anthony wrote: If you don't know where it is, then I suppose you probably haven't changed it from the default scaffolding code -- but it would be in db.py by default. Can you create a basic application that replicates this problem, pack it, and attach it here? Anthony On Wednesday, May 8, 2013 12:30:49 PM UTC-4, José Manuel López wrote: Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login* ?_next=/AppName/*default/index* instead AppName/* default/user/login*?_next= /AppName/*normalController/index .* I hope this clarify the question. On Wednesday, May 8, 2013 4:04:53 PM UTC+2, Anthony wrote: What do you mean by close the session? On Wednesday, May 8, 2013 9:58:13 AM UTC-4, José Manuel López wrote: Hi!, I'm a lost
[web2py] Re: Please need some help with URL after session close
Now it's perfectly working! A simple if in the main index :) and a redirect... the most simple solution, like always... Thank you so much for your time and for let me understand (a little more) this awesome tool On Wednesday, May 8, 2013 8:12:54 PM UTC+2, José Manuel López wrote: Yes!, that's the problem!, both controllers needs login. Each controller has a index and each index needs to be logged, one for super users and the other for normal user. When a normal user logs out, then the superuser index is called and then this index needs to be logged, but when the normal user try it the the login is denied. Probably is better that every user enter using with the same URL now that I understand the problem... On Wednesday, May 8, 2013 8:04:28 PM UTC+2, Anthony wrote: Does the URL you are initially redirecting to after logout require login? If so, then when you attempt to go to that URL after having logged out, it will immediately redirect again to the login page. Anthony On Wednesday, May 8, 2013 1:42:19 PM UTC-4, José Manuel López wrote: For a moment I can see the logout that you mention, but then I'm redirect to login?_next=/AppName/*default/index*, I'll change the next to my URL. Thank you for your time Anthony!, it's very appreciated. On Wednesday, May 8, 2013 6:53:51 PM UTC+2, Anthony wrote: OK, my mistake -- the _next variable points to auth.settings.logout_next -- so just change that setting to whatever URL you want. Also, are you sure the Logout URL is pointing to /default/user/login and not /default/user/logout? Anthony On Wednesday, May 8, 2013 12:40:57 PM UTC-4, José Manuel López wrote: Now I think I know what you are asking me: auth = Auth(db) # all we need is login auth.settings.actions_disabled=['change_password','request_reset_password','retrieve_username','profile'] if request.controller != 'appadmin': auth.settings.actions_disabled +=['register'] ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = False auth.settings.login_after_registration = True Jose M. On Wednesday, May 8, 2013 6:35:30 PM UTC+2, Anthony wrote: If you don't know where it is, then I suppose you probably haven't changed it from the default scaffolding code -- but it would be in db.py by default. Can you create a basic application that replicates this problem, pack it, and attach it here? Anthony On Wednesday, May 8, 2013 12:30:49 PM UTC-4, José Manuel López wrote: Sorry my ignorance but am newbie ... where can I find it? On Wednesday, May 8, 2013 6:27:15 PM UTC+2, Anthony wrote: What does your Auth setup code look like? On Wednesday, May 8, 2013 12:01:48 PM UTC-4, José Manuel López wrote: Hi Anthony, This is the code regarding the Navbar in myApp/views/layout.html : !-- Navbar == -- div class=navbar navbar-inverse navbar-fixed-top div class=flash{{=response.flash or ''}}/div div class=navbar-inner div class=container !-- the next tag is necessary for bootstrap menus, do not remove -- button type=button class=btn btn-navbar data-toggle=collapse data-target=.nav-collapse span class=icon-bar/span span class=icon-bar/span span class=icon-bar/span /button a class=brand href=http://www.web2py.com/ bwebspan2/spanpy/btrade;nbsp;/a ul id=navbar class=nav pull-right{{='auth' in globals() and auth.navbar(mode=dropdown) or ''}}/ul div class=nav-collapse {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} /div!--/.nav-collapse -- /div /div /div!--/top navbar -- I have uploaded the file layout.html in case you need it (I think it's the default layout.html). Jose M On Wednesday, May 8, 2013 5:28:24 PM UTC+2, Anthony wrote: Can you show the code used to create the navbar? Is it just auth.navbar(mode=dropdown)? The logout link on the navbar should point to /appname/default/user/logout?_next=[URL of the current page] -- it should not point to /default/user/login at all. Anthony On Wednesday, May 8, 2013 10:16:51 AM UTC-4, José Manuel López wrote: Hi Anthony, Thank you for your answer. I've attached a screenshot, I mean the button in the bar over the user interface: https://lh5.googleusercontent.com/-jiao9-CTeYQ/UYpdspnYmHI/ACo/cFu6REJXGxQ/s1600/Captura+de+pantalla+2013-05-08+a+la%28s%29+16.13.39.png When click over Fin de sesión (close session) we are redirect to a login page with this URL: AppName/*default/user/login* ?_next=/AppName/*default/index* instead
[web2py] Re: Why contenttype(.png) is not image/png ?
it's fixed in trunk. if you need it, just copy over the gluon/contenttype.py file, it won't harm your installation. On Wednesday, May 8, 2013 4:36:53 PM UTC+2, Txema Vicente wrote: Hello. When loading static png, Chrome throws a lot of warnings like: Resource interpreted as Image but transferred with MIME type image/x-apple-ios-png: http://127.0.0.1:8000/nabla/static/js/dojo/dijit/themes/claro/form/images/buttonArrows.png . I don't want to modify gluon.contenttype, so I tried to override that in my model: from gluon.contenttype import contenttype, CONTENT_TYPE print CONTENT_TYPE['.png'] #- 'image/x-apple-ios-png' (only the first time) CONTENT_TYPE['.png']='image/png' print contenttype('.png') #- 'image/png' But web2py still sends image/x-apple-ios-png. What reason is there for this? How can I override it? Regards. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: model not updated in scheduled task
the task definitely runs in a fresh environment, but as it stands your explanation doesn't give me enough details to build a proof of concept. if you have some - even weird - code that basically looks up the projects table to build definitions of tables, then if that piece of code is executed in the task you should be perfectly fine. The only thing I can reproduce is that a task defined as def mytest_models(): db.define_table('whatever', Field('afield') ) db.whatever.insert(afield='foo') db.commit() works as intended. On Wednesday, May 8, 2013 6:02:07 PM UTC+2, DeanK wrote: So one of my model files is somewhat unique (and possibly a bad idea) and causing me problems...I'll try to describe things the best I can. My application creates tables dynamically based on user input. To stop web2py from defining all the tables on every request (which can be a lot in the whole app, but only 10ish per user), I check which tables the user has access to and define only those. This is done by looking at a table (projects) where each record specifies other tables that exist (the project support tables). The issue i'm having is the user fills out a form using smartgrid. In the oncreate callback I update the projects table which essentially specifies new tables. These new tables are not defined unless the model runs again. I know this will happen on a refresh, but is there any other way to force the models to update? If I then submit a job to the scheduler that references one of these new tables I get this error: 'DAL' object has no attribute 'test_project_proj' Where test_project_proj one of the support tables that should have been defined (in the model snippet below project.project_table = 'test_project_proj') . Example of key part of the model: user_allowed_ids = get_user_allowed_projects(False) for project in db(db. projects.id.belongs(user_allowed_ids)).select(): db.define_table(project.project_table,..) db.define_table(project.block_table,..) db.define_table(project.metadata_table,..) I thought that when a job runs on the scheduler it re-runs all the models, so i don't understand why the task isn't seeing the new tables. Thoughts? Thanks Dean -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Dynamically change highlighted class for response.menu
it's working as intended!!! li class=web2py-menu-last highlighta href=/highlight/default/menu2Menu2/a/li is what it becomes when you access the menu2 link. You just need to play with the css now... By default the home link is constructed with a SPAN('Home', _class='highlighted') that is inside the A link. if you don't want to play with the css you should build your A with the same logic response.menu = [ (SPAN('Home'), False, URL('default', 'index'), []), (SPAN('Menu1'), False, URL('default', 'menu1'), []), (SPAN('Menu2'), False, URL('default', 'menu2'), []) ] and then modify the javascript snippet a bit var path = location.pathname.substring(1); if ( path ) jQuery('ul.nav a[href$='+path+']').find('span').addClass('highlighted'); the logic step-by-step is more or less the same as before but find('span') now searches within the A instead of going on level up the class added is highlighted and not highlight if instead you don't want to use SPAN inside the menu elements, retain the previous javascript snippet and add this css rule ul.nav li.highlight a { color: #D8D800; } of course you should at least turn the first element of the menu to match the others, so response.menu = [ (T('Home'), False, URL('default', 'index'), []), (T('Menu1'), False, URL('default', 'menu1'), []), (T('Menu2'), False, URL('default', 'menu2'), []) ] would be needed. On Tuesday, May 7, 2013 11:41:48 PM UTC+2, Omi Chiba wrote: I created new app called highlight. Can you take a look? 1. Added your javascript code right before /head tag 2. Modifiled response.menu in menu.py response.menu = [ (SPAN('Home', _class='highlighted'), False, URL('default', 'index'), []), (T('Menu1'), False, URL('default', 'menu1'), []), (T('Menu2'), False, URL('default', 'menu2'), []) ] 3. created empty control and view for menu1 and menu2. On Tuesday, May 7, 2013 3:07:49 PM UTC-5, Niphlod wrote: well, that is a snippet that needs to be adjusted to the menu classes in your layout the point more or less is: you have a menu that has no children changing the highlight on the clicked one leaves you nowhere, cause once a link has been clicked you jump to the other page, so the second snippet is the only one where the functionality actually works (i.e. applying a different style on the page the user is in). To do that, you must assign the class looking at where the page stands, that is location.pathname. jQuery has a nice selector syntax where anything that is prefixed with $ means that ends with this string. So, assuming you are using the scaffolding app from trunk . script jQuery(function() { var path = location.pathname.substring(1); if ( path ) jQuery('ul.nav a[href$='+path+']').closest('li').addClass ('highlight'); }) /script works The broken-down functionality is: - path is the current url - please, find all A elements within the ul class=nav ( *jQuery(ul.nav a)*) - filter this set searching for the ones that have an href ending with the current location (i.e. the url of the page) *[href=$whatever]* - go up in the DOM until you find a li (*closest(li)*) - add a hihglight class (*addclass(highlight)*) On Tuesday, May 7, 2013 6:24:19 PM UTC+2, Omi Chiba wrote: Niphlod , thank you for the reply! Can you provide me actual code workis on new app? I'm not sure where I should put the javascript and what value should I specify for 'all a in the menu'. On Tuesday, May 7, 2013 11:05:27 AM UTC-5, Niphlod wrote: javascript .. something like $('all a in the menu').click(function(e) { $('all a in the menu').removeClass('highlighted'); $(this).addClass('highlighted'); }) should work . You can even generalize it to highlight the current page url automatically. var path = location.pathname.substring(1); if ( path ) $('all a in menu[href$=' + path + ']').closest('li'). addClass('highlight'); Il giorno martedì 7 maggio 2013 17:56:10 UTC+2, Omi Chiba ha scritto: I have a following response.menu in my menu.py. By default Home is highlighted but I want to highlight the menu clicked by the user. For example, when user click contact, 'highlighted' class should be added to contact and removed from home. response.menu = [ (SPAN('Home', _class='highlighted'), False, URL('default', 'index'), []), (T('Order Status'), False, URL('default', 'orderstatus'), []), (T('QA'), False, URL('default', 'qa'), []), (T('Contact'), False, URL('default', 'contact'), []) ] -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: model not updated in scheduled task
I just sort of figured it out. And yes i'm sorry i didn't give enough to go on. The key seemed to be in the method get_user_allowed_projects. It is in a module that is imported into the a model file. It uses current.auth.user_groups and some database tables to check project table permissions for the user and stores it in the session. I realized that the session is bogus and therefore forced this to update but it still didn't work. Then i realized that current.auth.user_groups was empty when run on the scheduler, which resulted in permission to 0 tables which resulted in 0 tables getting defined which resulted in my error... Do tasks run in the scheduler have no concept of the user who scheduled them? My current work around is if the model is getting executed in the scheduler (i check this by looking at the length of request.env...is there a better way?) then I just define all the tables. Since it's running on the scheduler a little overhead isn't going to kill things, but it's not ideal. On Wednesday, May 8, 2013 2:37:55 PM UTC-4, Niphlod wrote: the task definitely runs in a fresh environment, but as it stands your explanation doesn't give me enough details to build a proof of concept. if you have some - even weird - code that basically looks up the projects table to build definitions of tables, then if that piece of code is executed in the task you should be perfectly fine. The only thing I can reproduce is that a task defined as def mytest_models(): db.define_table('whatever', Field('afield') ) db.whatever.insert(afield='foo') db.commit() works as intended. On Wednesday, May 8, 2013 6:02:07 PM UTC+2, DeanK wrote: So one of my model files is somewhat unique (and possibly a bad idea) and causing me problems...I'll try to describe things the best I can. My application creates tables dynamically based on user input. To stop web2py from defining all the tables on every request (which can be a lot in the whole app, but only 10ish per user), I check which tables the user has access to and define only those. This is done by looking at a table (projects) where each record specifies other tables that exist (the project support tables). The issue i'm having is the user fills out a form using smartgrid. In the oncreate callback I update the projects table which essentially specifies new tables. These new tables are not defined unless the model runs again. I know this will happen on a refresh, but is there any other way to force the models to update? If I then submit a job to the scheduler that references one of these new tables I get this error: 'DAL' object has no attribute 'test_project_proj' Where test_project_proj one of the support tables that should have been defined (in the model snippet below project.project_table = 'test_project_proj') . Example of key part of the model: user_allowed_ids = get_user_allowed_projects(False) for project in db(db. projects.id.belongs(user_allowed_ids)).select(): db.define_table(project.project_table,..) db.define_table(project.block_table,..) db.define_table(project.metadata_table,..) I thought that when a job runs on the scheduler it re-runs all the models, so i don't understand why the task isn't seeing the new tables. Thoughts? Thanks Dean -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: model not updated in scheduled task
no, tasks are not executed in a normal request/response cycle, so ther's no user, session, etc. You can pass the current user as an argument and adjust your models/modules to take that in consideration e.g. queue_task(that_task, [auth.user_id]) PS: check out the lazy_tables argument, it's usually pretty fast even with a lot of tables. that being said, if you have 1k tables around it's best to load them dinamically (given that your lookup and build function takes less than building 1k lazy tables). On Wednesday, May 8, 2013 8:50:53 PM UTC+2, DeanK wrote: I just sort of figured it out. And yes i'm sorry i didn't give enough to go on. The key seemed to be in the method get_user_allowed_projects. It is in a module that is imported into the a model file. It uses current.auth.user_groups and some database tables to check project table permissions for the user and stores it in the session. I realized that the session is bogus and therefore forced this to update but it still didn't work. Then i realized that current.auth.user_groups was empty when run on the scheduler, which resulted in permission to 0 tables which resulted in 0 tables getting defined which resulted in my error... Do tasks run in the scheduler have no concept of the user who scheduled them? My current work around is if the model is getting executed in the scheduler (i check this by looking at the length of request.env...is there a better way?) then I just define all the tables. Since it's running on the scheduler a little overhead isn't going to kill things, but it's not ideal. On Wednesday, May 8, 2013 2:37:55 PM UTC-4, Niphlod wrote: the task definitely runs in a fresh environment, but as it stands your explanation doesn't give me enough details to build a proof of concept. if you have some - even weird - code that basically looks up the projects table to build definitions of tables, then if that piece of code is executed in the task you should be perfectly fine. The only thing I can reproduce is that a task defined as def mytest_models(): db.define_table('whatever', Field('afield') ) db.whatever.insert(afield='foo') db.commit() works as intended. On Wednesday, May 8, 2013 6:02:07 PM UTC+2, DeanK wrote: So one of my model files is somewhat unique (and possibly a bad idea) and causing me problems...I'll try to describe things the best I can. My application creates tables dynamically based on user input. To stop web2py from defining all the tables on every request (which can be a lot in the whole app, but only 10ish per user), I check which tables the user has access to and define only those. This is done by looking at a table (projects) where each record specifies other tables that exist (the project support tables). The issue i'm having is the user fills out a form using smartgrid. In the oncreate callback I update the projects table which essentially specifies new tables. These new tables are not defined unless the model runs again. I know this will happen on a refresh, but is there any other way to force the models to update? If I then submit a job to the scheduler that references one of these new tables I get this error: 'DAL' object has no attribute 'test_project_proj' Where test_project_proj one of the support tables that should have been defined (in the model snippet below project.project_table = 'test_project_proj') . Example of key part of the model: user_allowed_ids = get_user_allowed_projects(False) for project in db(db .projects.id.belongs(user_allowed_ids)).select(): db.define_table(project.project_table,..) db.define_table(project.block_table,..) db.define_table(project.metadata_table,..) I thought that when a job runs on the scheduler it re-runs all the models, so i don't understand why the task isn't seeing the new tables. Thoughts? Thanks Dean -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Manual Form Submission
I wanted to try and create my own view of a form and still have it submit the data to my table... I've got what seems to be a working form etc, but when i submit, it appears to do nothing... Model: # WORK ORDERS TABLE db.define_table('work_order', Field('work_date', 'datetime'), Field('work_desc', 'text')) Controller: def manual_new_order(): form = SQLFORM(db.work_order,onupdate=auth.archive) if form.process(session=None, formname='new_order').accepted: session.flash = 'form accepted' redirect(URL('index')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' return dict() View: {{extend 'layout.html'}} h2Create a new Work Order/h2 p form table trtdWork Date: /tdtdinput class=datetime type=datetime name=work_date //td/tr trtdWork Description: /tdtdtextarea rows=5 name=work_desc/textarea/td/tr /table input type=hidden name=order_num value={{=int(order.order_num) +1}}/ input type=hidden name=_formname value=new_order / input type=submit/ /form /p When I submit, I am always getting the 'please fill form' message, telling me that it did not process.. Hope I've made myself clear! Thanks!! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Manual Form Submission
You didn't specify a form method, so I think it defaults to GET, which means the values will end up in request.get_vars. If you fail to explicitly specify the request_vars argument of SQLFORM.process(), it will automatically use request.post_vars, but not request.get_vars. So, you should either do a POST form, via: form action=# enctype=multipart/form-data method=post or pass in the GET variables explicitly: if form.process(request_vars=request.get_vars, session=None, formname= 'new_order').accepted: Since you are using the form to add new records, I assume you really want the former (i.e., do a POST instead of a GET). Anthony On Wednesday, May 8, 2013 3:01:10 PM UTC-4, Doug Girard wrote: I wanted to try and create my own view of a form and still have it submit the data to my table... I've got what seems to be a working form etc, but when i submit, it appears to do nothing... Model: # WORK ORDERS TABLE db.define_table('work_order', Field('work_date', 'datetime'), Field('work_desc', 'text')) Controller: def manual_new_order(): form = SQLFORM(db.work_order,onupdate=auth.archive) if form.process(session=None, formname='new_order').accepted: session.flash = 'form accepted' redirect(URL('index')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' return dict() View: {{extend 'layout.html'}} h2Create a new Work Order/h2 p form table trtdWork Date: /tdtdinput class=datetime type=datetime name=work_date //td/tr trtdWork Description: /tdtdtextarea rows=5 name=work_desc/textarea/td/tr /table input type=hidden name=order_num value={{=int(order.order_num) +1}}/ input type=hidden name=_formname value=new_order / input type=submit/ /form /p When I submit, I am always getting the 'please fill form' message, telling me that it did not process.. Hope I've made myself clear! Thanks!! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Web Frameworks Performance
Just some comments about 4. Web2py was not meat as a teacher tool. Web2py was meant to enforce good practice and this made it a good teaching tool. Not quite the same. In fact web2py is based on WSGI and it does run on Heroku. There is a session in the manual about that. I never tried Iron.io or Azure but I am sure it runs there as any other WSGI server does. On Wednesday, 8 May 2013 11:54:43 UTC-5, Derek wrote: Well, if you look at the benchmarks, several things stand out. 1. All the WSGI servers are pre-loaded. That means the code is already pre-compiled and loaded in ram, ready to run. Web2py doesn't quite work that way, because each request loads the database, does migrations if necessary, and inserts a lot of objects into the scope. 2. They are all using gunicorn, which spawns about 4 workers on startup. We could certainly run Web2py in WSGI mode with gunicorn, but it wouldn't make much a difference. I believe if we are going to support sessions, they should be off by default and use a decorator @session_enabled or something like that. However, that may go against Web2py principles. 3. Those benchmarks are not development type setups. If we are going to compare benchmarks, we'll need to make sure that our configuration matches theirs. 4. Web2py was meant to be a teaching tool. However, as it is now, what it's teaching is years old. Now everything needs to be WSGI so you can run it on a PAAS such as Heroku, Iron.io, Azure, etc. It's good to know how we compare with performance, but at the same time, I think we need to be realistic. Web2py needs to be re-architectured if we're going to see wider adoption in the future. On Wednesday, May 8, 2013 5:31:19 AM UTC-7, Alfonso de la Guarda Reyes wrote: Hi, How we can improve web2py to match the fastest python web frameworks performance? http://www.techempower.com/benchmarks/#section=intro Surely, with many brains we can offer some method to improve that! Saludos, Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: what does please restart itx mean?
LOL. I think it is please restart it followed by the x to close the window. somehow there i no space between the message and the x. On Wednesday, 8 May 2013 12:56:18 UTC-5, JimK wrote: After upgrading web2py to 2.4.6, the admin tool stated that web2py was upgraded and to please restart itx. I restarted the webserver and everything seems to be working fine. Can someone please refer me to the magic decoder ring that can decipher this message? Jim -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: what does please restart itx mean?
Doh! I should have figured that outŠ From: Massimo Di Pierro massimo.dipie...@gmail.com Reply-To: web2py@googlegroups.com Date: Wednesday, May 8, 2013 12:57 PM To: web2py@googlegroups.com Subject: [web2py] Re: what does please restart itx mean? LOL. I think it is please restart it followed by the x to close the window. somehow there i no space between the message and the x. On Wednesday, 8 May 2013 12:56:18 UTC-5, JimK wrote: After upgrading web2py to 2.4.6, the admin tool stated that web2py was upgraded and to please restart itx. I restarted the webserver and everything seems to be working fine. Can someone please refer me to the magic decoder ring that can decipher this message? Jim -- --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/DchMzSaX_RA/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] How to add class to the TABLE in SQLFORM.grid
Hi Folks, I could see that all style related variables of SQLFORM.grid applies to the outside div. How can I style the table element of the SQLFORM.grid? THanks! Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How to add class to the TABLE in SQLFORM.grid
with javascript is the easiest way. You can go on the http://web2py.com/books/default/chapter/29/05#Server-side-DOM-and-parsing method but please do mind that the grid representation may change a bit in the future (it's not yet fixed in stone). Choose carefully your selectors. On Wednesday, May 8, 2013 10:05:08 PM UTC+2, Tito Garrido wrote: Hi Folks, I could see that all style related variables of SQLFORM.grid applies to the outside div. How can I style the table element of the SQLFORM.grid? THanks! Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Manual Form Submission
Anthony, you deserve some recognition, you are awesome!! On Wednesday, May 8, 2013 1:28:59 PM UTC-6, Anthony wrote: You didn't specify a form method, so I think it defaults to GET, which means the values will end up in request.get_vars. If you fail to explicitly specify the request_vars argument of SQLFORM.process(), it will automatically use request.post_vars, but not request.get_vars. So, you should either do a POST form, via: form action=# enctype=multipart/form-data method=post or pass in the GET variables explicitly: if form.process(request_vars=request.get_vars, session=None, formname= 'new_order').accepted: Since you are using the form to add new records, I assume you really want the former (i.e., do a POST instead of a GET). Anthony On Wednesday, May 8, 2013 3:01:10 PM UTC-4, Doug Girard wrote: I wanted to try and create my own view of a form and still have it submit the data to my table... I've got what seems to be a working form etc, but when i submit, it appears to do nothing... Model: # WORK ORDERS TABLE db.define_table('work_order', Field('work_date', 'datetime'), Field('work_desc', 'text')) Controller: def manual_new_order(): form = SQLFORM(db.work_order,onupdate=auth.archive) if form.process(session=None, formname='new_order').accepted: session.flash = 'form accepted' redirect(URL('index')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' return dict() View: {{extend 'layout.html'}} h2Create a new Work Order/h2 p form table trtdWork Date: /tdtdinput class=datetime type=datetime name=work_date //td/tr trtdWork Description: /tdtdtextarea rows=5 name=work_desc/textarea/td/tr /table input type=hidden name=order_num value={{=int(order.order_num) +1}}/ input type=hidden name=_formname value=new_order / input type=submit/ /form /p When I submit, I am always getting the 'please fill form' message, telling me that it did not process.. Hope I've made myself clear! Thanks!! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Markmin components
Thanks On Wednesday, May 8, 2013 4:23:24 PM UTC+1, Massimo Di Pierro wrote: There is an official syntax for this. @{component:controller/function/args} To enable this and enable OEMBED I do: def markmin(body): from gluon.contrib.autolinks import expand_one def component(text): items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() return MARKMIN(body, url=True, environment={'component':component}, autolinks=lambda link: expand_one(link, {})).xml() db.table.field.represent = lambda v,r: markmin(v or '') This is done automatically by auth.wiki() Massimo On Wednesday, 8 May 2013 09:16:21 UTC-5, villas wrote: For anyone interested in my monologue... Function to my previous ideas, a function as follows could handle both internal and external URLs. I also included a simple check for allowed domains: def __component(text): if text and text.lower().strip().startswith('http'): from urlparse import urlparse allowed_domains = [ 'www.domain1.com', 'www.domain2.com', ] if allowed_domains and not any(i in urlparse(text)[1] for i inallowed_domains ): return H1('domain not allowed').xml() else: return LOAD(url=text, ajax=True).xml() else: items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() MARKMIN(mytext,url=True,extra=dict(component = lambda value: __component( value))) In our Markmin we can then include... ``http://www.domain1.com/app/mycont/myfunc/arg1``:componenthttp://www.domain1.com/app/mycont/myfunc/arg1:component and/or ``mycont/myfunc/arg1``:component . Maybe someone has other better, or more flexibile, ideas? On Wednesday, May 8, 2013 2:09:28 AM UTC+1, villas wrote: I can do something like this... mytext = ``default/get_cms_article/4``:component def __component(text): items = text.split('/') controller, function, args = items[0], items[1], items[2:] return LOAD(controller, function, args=args, ajax=True).xml() MARKMIN_ENV = dict( component = lambda value: __component(value) ) MARKMIN(mytext,url=True,extra=MARKMIN_ENV) This uses LOAD. What is recommended for loading components from other domains? I think I have used JSON for that in the past, but maybe there are other ways, I am not sure that I am using the currently recommended methods for Markmin. Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: REF: Displaying a Virtual Field in SQLFORM.grid throws an exception....
By the way, I found http://www.web2py.com/book/default/chapter/06#before-and-after-callbacks which can help in some cases, where I thought to use virtual fields as with callbacks you can update needed info from foreign tables (or computed fields might also be enough in some cases) 2012 m. gruodis 18 d., antradienis 09:03:05 UTC+2, software.ted rašė: Does SQLFORM.grid support adding and display of a virtual field...am getting an exception...my code: db.file_subject_issue.file_name = Field.Virtual(lambda row: get_file_name(row.file_subject_issue.file_id)) fields = [db.file_subject_issue.file_id, db.file_subject_issue.date_created, db.file_subject_issue.file_name] query = form = SQLFORM.grid(query,fields=fields,...) I am getting the error type 'exceptions.AttributeError' 'FieldVirtual' object has no attribute '_tablename' 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/www-data/web2py/applications/intranet/controllers/administration.py https://192.168.0.251/admin/default/edit/intranet/controllers/administration.py, line 176, in module File /home/www-data/web2py/gluon/globals.py, line 188, in lambda self._caller = lambda f: f() File /home/www-data/web2py/applications/intranet/controllers/administration.py https://192.168.0.251/admin/default/edit/intranet/controllers/administration.py, line 71, in file_track selectable=False,csv=False , paginate=20, user_signature=False) File /home/www-data/web2py/gluon/sqlhtml.py, line 1796, in grid if field._tablename in tablenames] AttributeError: 'FieldVirtual' object has no attribute '_tablename' -- ... Teddy Lubasi Nyambe Opensource Zambia Lusaka, ZAMBIA Cell: +260 97 7760473 website: http://www.opensource.org.zm ~/ Human Knowledge belongs to the world! - AntiTrust Man is a tool-using animal. Without tools he is nothing, with tools he is all - Thomas Carlyle 1795-1881 /~ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Manual Form Submission
:-) On Wednesday, May 8, 2013 4:14:09 PM UTC-4, Doug Girard wrote: Anthony, you deserve some recognition, you are awesome!! On Wednesday, May 8, 2013 1:28:59 PM UTC-6, Anthony wrote: You didn't specify a form method, so I think it defaults to GET, which means the values will end up in request.get_vars. If you fail to explicitly specify the request_vars argument of SQLFORM.process(), it will automatically use request.post_vars, but not request.get_vars. So, you should either do a POST form, via: form action=# enctype=multipart/form-data method=post or pass in the GET variables explicitly: if form.process(request_vars=request.get_vars, session=None, formname ='new_order').accepted: Since you are using the form to add new records, I assume you really want the former (i.e., do a POST instead of a GET). Anthony On Wednesday, May 8, 2013 3:01:10 PM UTC-4, Doug Girard wrote: I wanted to try and create my own view of a form and still have it submit the data to my table... I've got what seems to be a working form etc, but when i submit, it appears to do nothing... Model: # WORK ORDERS TABLE db.define_table('work_order', Field('work_date', 'datetime'), Field('work_desc', 'text')) Controller: def manual_new_order(): form = SQLFORM(db.work_order,onupdate=auth.archive) if form.process(session=None, formname='new_order').accepted: session.flash = 'form accepted' redirect(URL('index')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' return dict() View: {{extend 'layout.html'}} h2Create a new Work Order/h2 p form table trtdWork Date: /tdtdinput class=datetime type=datetime name=work_date //td/tr trtdWork Description: /tdtdtextarea rows=5 name=work_desc/textarea/td/tr /table input type=hidden name=order_num value={{=int(order.order_num) +1}}/ input type=hidden name=_formname value=new_order / input type=submit/ /form /p When I submit, I am always getting the 'please fill form' message, telling me that it did not process.. Hope I've made myself clear! Thanks!! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Dynamically change highlighted class for response.menu
uhm. nope. you have to remove the _class=highlighted alltogether from the Home. Unless you need to highlight Home while you're in an hypotetical menu3. Is that the case ? On Wednesday, May 8, 2013 11:07:52 PM UTC+2, Omi Chiba wrote: It's almost there!! Your code works perfect but I want to highlight the Home by default. When I do, the highlight on home won't removed when I click menu1 or menu2. I user your span approach so this is my response.menu response.menu = [ (SPAN('Home', _class='highlighted'), False, URL('default', 'index'), []), (SPAN('Menu1'), False, URL('default', 'menu1'), []), (SPAN('Menu2'), False, URL('default', 'menu2'), []) ] and this is the javascript. No change for CSS. script jQuery(function() { var path = location.pathname.substring(1); if ( path ) jQuery('ul.nav a[href$='+path+']').find('span').addClass('highlighted'); }) /script On Wednesday, May 8, 2013 1:50:37 PM UTC-5, Niphlod wrote: it's working as intended!!! li class=web2py-menu-last highlighta href=/highlight/default/menu2Menu2/a/li is what it becomes when you access the menu2 link. You just need to play with the css now... By default the home link is constructed with a SPAN('Home', _class='highlighted') that is inside the A link. if you don't want to play with the css you should build your A with the same logic response.menu = [ (SPAN('Home'), False, URL('default', 'index'), []), (SPAN('Menu1'), False, URL('default', 'menu1'), []), (SPAN('Menu2'), False, URL('default', 'menu2'), []) ] and then modify the javascript snippet a bit var path = location.pathname.substring(1); if ( path ) jQuery('ul.nav a[href$='+path+']').find('span').addClass('highlighted'); the logic step-by-step is more or less the same as before but find('span') now searches within the A instead of going on level up the class added is highlighted and not highlight if instead you don't want to use SPAN inside the menu elements, retain the previous javascript snippet and add this css rule ul.nav li.highlight a { color: #D8D800; } of course you should at least turn the first element of the menu to match the others, so response.menu = [ (T('Home'), False, URL('default', 'index'), []), (T('Menu1'), False, URL('default', 'menu1'), []), (T('Menu2'), False, URL('default', 'menu2'), []) ] would be needed. On Tuesday, May 7, 2013 11:41:48 PM UTC+2, Omi Chiba wrote: I created new app called highlight. Can you take a look? 1. Added your javascript code right before /head tag 2. Modifiled response.menu in menu.py response.menu = [ (SPAN('Home', _class='highlighted'), False, URL('default', 'index'), []), (T('Menu1'), False, URL('default', 'menu1'), []), (T('Menu2'), False, URL('default', 'menu2'), []) ] 3. created empty control and view for menu1 and menu2. On Tuesday, May 7, 2013 3:07:49 PM UTC-5, Niphlod wrote: well, that is a snippet that needs to be adjusted to the menu classes in your layout the point more or less is: you have a menu that has no children changing the highlight on the clicked one leaves you nowhere, cause once a link has been clicked you jump to the other page, so the second snippet is the only one where the functionality actually works (i.e. applying a different style on the page the user is in). To do that, you must assign the class looking at where the page stands, that is location.pathname. jQuery has a nice selector syntax where anything that is prefixed with $ means that ends with this string. So, assuming you are using the scaffolding app from trunk . script jQuery(function() { var path = location.pathname.substring(1); if ( path ) jQuery('ul.nav a[href$='+path+']').closest('li'). addClass('highlight'); }) /script works The broken-down functionality is: - path is the current url - please, find all A elements within the ul class=nav ( *jQuery(ul.nav a)*) - filter this set searching for the ones that have an href ending with the current location (i.e. the url of the page) *[href=$whatever]* - go up in the DOM until you find a li (*closest(li)*) - add a hihglight class (*addclass(highlight)*) On Tuesday, May 7, 2013 6:24:19 PM UTC+2, Omi Chiba wrote: Niphlod , thank you for the reply! Can you provide me actual code workis on new app? I'm not sure where I should put the javascript and what value should I specify for 'all a in the menu'. On Tuesday, May 7, 2013 11:05:27 AM UTC-5, Niphlod wrote: javascript .. something like $('all a in the menu').click(function(e) { $('all a in the menu').removeClass('highlighted'); $(this).addClass('highlighted'); }) should work . You can even generalize it to highlight the current page url automatically. var path = location.pathname.substring(1); if ( path ) $('all a in menu[href$=' + path + ']').closest('li').
[web2py] Re: Dynamically change highlighted class for response.menu
ps: if you are on the case where you need to have home highlighted by default no matter what, use this javascript snippet (pretty straightforward) Added also a filter() to exclude the registration/login/etc links from being highlighted jQuery(function() { var path = location.pathname.substring(1); if ( path ) { var els = jQuery('ul.nav a[href$='+path+']').filter( [rel!=nofollow]); if (els.length != 0) { els.closest('li').addClass('highlighted'); } else { jQuery('ul.nav a[href$=/highlight/default/index]').closest( 'li').addClass('highlighted'); } } }) PS: maybe to make it more clearer, use a Home link with an id, such as (SPAN('Home', _id='default_highlighted'), False, URL('default', 'index'), []), so you can switch the last line from jQuery('ul.nav a[href$=/highlight/default/index]').closest('li').addClass( 'highlighted'); to jQuery('#default_highlighted').closest('li').addClass('highlighted'); -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] What would be the best way to optimize/resize images after upload
Is there a way to automatically optimize and convert images after users upload it on my web app? I am pretty sure lots of users will upload uncompressed .bmp pictures or extra large pictures directly from camera. I think it would be best if I could resize and compress them immediately after upload. What would be the best way to do it? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] _after_delete callback - how to access info of deleted Set?
Hi, I look at example: http://www.web2py.com/book/default/chapter/06#before-and-after-callbacks how can I find out what is the value of person.id from the set without select? (Set (person.id = 1),) as I tried: s.select(..)[0] # it worked for update but got Traceback (most recent call last): File /home/nijole/Downloads/EasyVet/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/nijole/Downloads/EasyVet/web2py/applications/apskaitele/controllers/appadmin.py http://localhost:8000/admin/default/edit/apskaitele/controllers/appadmin.py, line 569, in module File /home/nijole/Downloads/EasyVet/web2py/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/nijole/Downloads/EasyVet/web2py/applications/apskaitele/controllers/appadmin.py http://localhost:8000/admin/default/edit/apskaitele/controllers/appadmin.py, line 304, in update if form.accepts(request.vars, session): File /home/nijole/Downloads/EasyVet/web2py/gluon/sqlhtml.py, line 1398, in accepts self.table._db(qry).delete() File /home/nijole/Downloads/EasyVet/web2py/gluon/dal.py, line 9821, in delete ret and [f(self) for f in table._after_delete] File /home/nijole/Downloads/EasyVet/web2py/applications/apskaitele/models/db.py http://localhost:8000/admin/default/edit/apskaitele/models/db.py, line 329, in lambda db.Pardavimai._after_delete.append( lambda s: update_SandelioProduktai_likutis_from_Pardavimai(s.select(db.Pardavimai.sandelio_produktas)[0]) ) File /home/nijole/Downloads/EasyVet/web2py/gluon/dal.py, line 10075, in __getitem__ row = self.records[i] IndexError: list index out of range -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Dynamically change highlighted class for response.menu
Thank you for the additional explanation. I just want to highlight the home by defaut only first time user access the page. It should be removed when user click menu1 or menu2. The home will be highlighted again when user click home. By default. -- Home highlihgted Menu1 Menu2 User click menu1... Home Menu1 highlihgted Menu2 User click Home again... Home highlihgted Menu1 Menu2 On Wednesday, May 8, 2013 4:34:07 PM UTC-5, Niphlod wrote: ps: if you are on the case where you need to have home highlighted by default no matter what, use this javascript snippet (pretty straightforward) Added also a filter() to exclude the registration/login/etc links from being highlighted jQuery(function() { var path = location.pathname.substring(1); if ( path ) { var els = jQuery('ul.nav a[href$='+path+']').filter( [rel!=nofollow]); if (els.length != 0) { els.closest('li').addClass('highlighted'); } else { jQuery('ul.nav a[href$=/highlight/default/index]').closest( 'li').addClass('highlighted'); } } }) PS: maybe to make it more clearer, use a Home link with an id, such as (SPAN('Home', _id='default_highlighted'), False, URL('default', 'index'), []), so you can switch the last line from jQuery('ul.nav a[href$=/highlight/default/index]').closest('li'). addClass('highlighted'); to jQuery('#default_highlighted').closest('li').addClass('highlighted'); -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: wget and basic authentication
Indeed you did: https://github.com/web2py/web2py/pull/63 (linked for other people hitting this issue) Thanks for this, I've put more time into finding a fix for this than I care to admit. Ian On Wednesday, 8 May 2013 06:32:30 UTC-7, Michele Comitini wrote: No one opened a ticket so I fixed it a few months ago On a recent you can use auth.basic auth.basic(basic_auth_realm=any string you like) BONUS: *the realm string can be changed runtime to allow the user to be logged out i.e. the browser will ask authentication credentials again* 2013/5/8 Ian MacKinnon imac...@gmail.com javascript: Was a ticket ever filed for this? I'm encountering the same issue and I couldn't find a ticket for this issue. Ian On Monday, 31 October 2011 20:09:49 UTC-7, Massimo Di Pierro wrote: Please open a ticket. this is easy and I can take of it tomorrow. On Oct 31, 7:58 pm, mdorval rockingdor...@gmail.com wrote: Ok, so this command example is in the documentation under basic authentication (http://web2py.com/book/**default/chapter/08#Access-http://web2py.com/book/default/chapter/08#Access- Control-and-Basic-**Authentication): wget --user=[username] --password=[password] http://.../[app]/[controller]**/give_me_time but this command won't work with basic authentication in web2py, as web2py doesn't throw a 401 when the Authentication header is missing, but a 403 (at least with the current version of wget). In order for wget to work properly with basic authentication, one must do wget --user=[username] --password=[password] --auth-no-challengehttp://.../**[app]/[controller]/give_me_**time The documentation on wget's --auth-no-challenge flag is as follows: ‘--auth-no-challenge’ If this option is given, Wget will send Basic HTTP authentication information (plaintext username and password) for all requests, just like Wget 1.10.2 and prior did by default. Use of this option is not recommended, and is intended only to support some few obscure servers, which never send HTTP authentication challenges, but accept unsolicited auth info, say, in addition to form- based authentication. So my question is: Is there a way to get web2py to handle these requests properly (return a 401 status code to prompt the client to resend with credentials)? (on a related note, it seems requests using urllib2 run into a similar problem:http://stackoverflow.**com/questions/2407126/python-** urllib2-basic-auth-..http://stackoverflow.com/questions/2407126/python-urllib2-basic-auth-.. .) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: _after_delete callback - how to access info of deleted Set?
If the query only has that one condition, then you can do: s.query.second A Set object has a query attribute, which is a Query object, and a Query object has op, first, and second attributes. So, s.query gets the Query object of the Set, and s.query.second gets the second operand of the == operator. If instead you have multiple conditions in the query, keep in mind that the operands of the operator are themselves Query objects. So, if you have: set = db((db.person.id 10) (db.person.name.startswith('A'))) you can extract the 10 from the first part of the query via: set.query.first.second In that case, set.query.first itself returns a Query (i.e., db.person.id 10), so set.query.first.second gives you the 10. Keep in mind that these properties of Set and Query are internal and not part of the API, so this isn't guaranteed to remain backward compatible. Another option is to pass the Set to the str() function, which generates a string that contains the SQL produced by the query. You could then do some parsing of that string to get what you want. For example, in this case you get: str(db(db.person.id == 1)) 'Set (person.id = 1)' You can use a regex to get the 1 from that string. Anthony On Wednesday, May 8, 2013 6:10:05 PM UTC-4, Jurgis Pralgauskis wrote: Hi, I look at example: http://www.web2py.com/book/default/chapter/06#before-and-after-callbacks how can I find out what is the value of person.id from the set without select? (Set (person.id = 1),) as I tried: s.select(..)[0] # it worked for update but got Traceback (most recent call last): File /home/nijole/Downloads/EasyVet/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/nijole/Downloads/EasyVet/web2py/applications/apskaitele/controllers/appadmin.py http://localhost:8000/admin/default/edit/apskaitele/controllers/appadmin.py, line 569, in module File /home/nijole/Downloads/EasyVet/web2py/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/nijole/Downloads/EasyVet/web2py/applications/apskaitele/controllers/appadmin.py http://localhost:8000/admin/default/edit/apskaitele/controllers/appadmin.py, line 304, in update if form.accepts(request.vars, session): File /home/nijole/Downloads/EasyVet/web2py/gluon/sqlhtml.py, line 1398, in accepts self.table._db(qry).delete() File /home/nijole/Downloads/EasyVet/web2py/gluon/dal.py, line 9821, in delete ret and [f(self) for f in table._after_delete] File /home/nijole/Downloads/EasyVet/web2py/applications/apskaitele/models/db.py http://localhost:8000/admin/default/edit/apskaitele/models/db.py, line 329, in lambda db.Pardavimai._after_delete.append( lambda s: update_SandelioProduktai_likutis_from_Pardavimai(s.select(db.Pardavimai.sandelio_produktas)[0]) ) File /home/nijole/Downloads/EasyVet/web2py/gluon/dal.py, line 10075, in __getitem__ row = self.records[i] IndexError: list index out of range -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Regarding global variable
Hi, I wonder how to use global variable Let me show my code def emps_greylist(): import urllib2 from lepl.apps.rfc3696 import HttpUrl from urlparse import urlparse diff_list=[] temp_list=[] top_level_url = https://xxx/greylist.txt; greylist = urllib2.urlopen(top_level_url) if not temp_list: temp_list=greylist else : diff_list = [item for item in greylist if not item in temp_list] greylist=diff_list I would like to have temp_list as global variable I tried to look up some solutions. Session and cache are solutions. Can somebody tell me how to use them. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: _after_delete callback - how to access info of deleted Set?
Thanks, hm, ok, my usecase is more problematic, db.define_table('Product', Field('name',), Field('price', 'decimal(10,2)'), Field('quantity', 'integer'), Field('*quantity_sold*', 'integer'), # this could be virtual - but then it does not play with queries... ) I want to refresh *quantity_sold* after each Purchase (insert/update/delete) but after delete I'd like to still access which product it has been? if I do it before delete, the purchace is still there - and my aggregate function sums it (though I need it gone) ... db.define_table('Purchase', Field('product', db.Product), Field('quantity', 'integer'), ) def update_Product_quantity_from_Purchase( purchase ): q_sum = db.Purchase.quantity.sum() quantity_sold = db(db.Purchase.product== purchase.product ).select(q_sum).first()[q_sum] or 0 db.Product[purchase.product].update_record( *quantity_sold* =quantity_sold ) db.Pardavimai._after_insert.append( lambda f,id: update_Product_quantity_from_Purchase(f) ) db.Pardavimai._after_update.append( lambda s,f: update_Product_quantity_from_Purchase(s.select()[0]) ) db.Pardavimai._after_delete.append( lambda s: update_Product_quantity_from_Purchase(s.select()[0]) ) #ERR *** Ha, while writing I came up with workaround - _before_delete I add extra parameter to my update_Product... function, which tells that purchase stuff should be subtracted in advance (as it will be detelted) def update_Product_quantity_from_Purchase( purchase, deleting=False ): ... if deleting: quantity_sold -= purchace.quantity db.Product[purchase.product].update_record( *quantity_sold*=quantity_sold ) db.Pardavimai._before_delete.append( lambda s: update_Product_quantity_from_Purchase(s.select()[0], True) ) #OK *** ps.: Maybe similar functionality could be extended for compute'd field? If it knew what foreign tablesfields it depends on, the triggers/callbacks could be added automatically? On Thu, May 9, 2013 at 2:06 AM, Anthony abasta...@gmail.com wrote: If the query only has that one condition, then you can do: s.query.second A Set object has a query attribute, which is a Query object, and a Query object has op, first, and second attributes. So, s.query gets the Query object of the Set, and s.query.second gets the second operand of the == operator. If instead you have multiple conditions in the query, keep in mind that the operands of the operator are themselves Query objects. So, if you have: set = db((db.person.id 10) (db.person.name.startswith('A'))) you can extract the 10 from the first part of the query via: set.query.first.second In that case, set.query.first itself returns a Query (i.e., db.person.id 10), so set.query.first.second gives you the 10. Keep in mind that these properties of Set and Query are internal and not part of the API, so this isn't guaranteed to remain backward compatible. Another option is to pass the Set to the str() function, which generates a string that contains the SQL produced by the query. You could then do some parsing of that string to get what you want. For example, in this case you get: str(db(db.person.id == 1)) 'Set (person.id = 1)' You can use a regex to get the 1 from that string. Anthony On Wednesday, May 8, 2013 6:10:05 PM UTC-4, Jurgis Pralgauskis wrote: Hi, I look at example: http://www.web2py.com/book/**default/chapter/06#before-and-** after-callbackshttp://www.web2py.com/book/default/chapter/06#before-and-after-callbacks how can I find out what is the value of person.id from the set without select? (Set (person.id = 1),) as I tried: s.select(..)[0] # it worked for update but got Traceback (most recent call last): File /home/nijole/Downloads/**EasyVet/web2py/gluon/**restricted.py, line 212, in restricted exec ccode in environment File /home/nijole/Downloads/**EasyVet/web2py/applications/**apskaitele/controllers/**appadmin.py http://localhost:8000/admin/default/edit/apskaitele/controllers/appadmin.py, line 569, in module File /home/nijole/Downloads/**EasyVet/web2py/gluon/globals.**py, line 194, in lambda self._caller = lambda f: f() File /home/nijole/Downloads/**EasyVet/web2py/applications/**apskaitele/controllers/**appadmin.py http://localhost:8000/admin/default/edit/apskaitele/controllers/appadmin.py, line 304, in update if form.accepts(request.vars, session): File /home/nijole/Downloads/**EasyVet/web2py/gluon/sqlhtml.**py, line 1398, in accepts self.table._db(qry).delete() File /home/nijole/Downloads/**EasyVet/web2py/gluon/dal.py, line 9821, in delete ret and [f(self) for f in table._after_delete] File /home/nijole/Downloads/**EasyVet/web2py/applications/**apskaitele/models/db.py http://localhost:8000/admin/default/edit/apskaitele/models/db.py, line 329, in lambda db.Pardavimai._after_delete.ap**pend( lambda s:
Re: [web2py] Regarding global variable
To use in a session, simply assign as a session member: if not session.temp_list: session.temp_list = greylist Then, refer to session.temp_list everywhere you should do to temp_list. I think an example from the book will help you: http://web2py.com/books/default/chapter/29/03#Let's-count On Wed, May 8, 2013 at 8:11 PM, Nam Soo In sheldon.sooin@gmail.com wrote: Hi, I wonder how to use global variable Let me show my code def emps_greylist(): import urllib2 from lepl.apps.rfc3696 import HttpUrl from urlparse import urlparse diff_list=[] temp_list=[] top_level_url = https://xxx/greylist.txt; greylist = urllib2.urlopen(top_level_url) if not temp_list: temp_list=greylist else : diff_list = [item for item in greylist if not item in temp_list] greylist=diff_list I would like to have temp_list as global variable I tried to look up some solutions. Session and cache are solutions. Can somebody tell me how to use them. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Manual Form Submission
Second! On Wednesday, 8 May 2013 15:14:09 UTC-5, Doug Girard wrote: Anthony, you deserve some recognition, you are awesome!! On Wednesday, May 8, 2013 1:28:59 PM UTC-6, Anthony wrote: You didn't specify a form method, so I think it defaults to GET, which means the values will end up in request.get_vars. If you fail to explicitly specify the request_vars argument of SQLFORM.process(), it will automatically use request.post_vars, but not request.get_vars. So, you should either do a POST form, via: form action=# enctype=multipart/form-data method=post or pass in the GET variables explicitly: if form.process(request_vars=request.get_vars, session=None, formname ='new_order').accepted: Since you are using the form to add new records, I assume you really want the former (i.e., do a POST instead of a GET). Anthony On Wednesday, May 8, 2013 3:01:10 PM UTC-4, Doug Girard wrote: I wanted to try and create my own view of a form and still have it submit the data to my table... I've got what seems to be a working form etc, but when i submit, it appears to do nothing... Model: # WORK ORDERS TABLE db.define_table('work_order', Field('work_date', 'datetime'), Field('work_desc', 'text')) Controller: def manual_new_order(): form = SQLFORM(db.work_order,onupdate=auth.archive) if form.process(session=None, formname='new_order').accepted: session.flash = 'form accepted' redirect(URL('index')) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' return dict() View: {{extend 'layout.html'}} h2Create a new Work Order/h2 p form table trtdWork Date: /tdtdinput class=datetime type=datetime name=work_date //td/tr trtdWork Description: /tdtdtextarea rows=5 name=work_desc/textarea/td/tr /table input type=hidden name=order_num value={{=int(order.order_num) +1}}/ input type=hidden name=_formname value=new_order / input type=submit/ /form /p When I submit, I am always getting the 'please fill form' message, telling me that it did not process.. Hope I've made myself clear! Thanks!! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: What would be the best way to optimize/resize images after upload
There are numerous ways to resize uploaded images. Some are done via the web server. Others are done within the app. For a couple of my apps I use the python PIL package to resize uploaded images to thumbnails and the like. Here's a code fragment that shows how to do it: def resize_image(table, indx): from PIL import Image On Thursday, May 9, 2013 5:43:45 AM UTC+8, Dragan Matic wrote: Is there a way to automatically optimize and convert images after users upload it on my web app? I am pretty sure lots of users will upload uncompressed .bmp pictures or extra large pictures directly from camera. I think it would be best if I could resize and compress them immediately after upload. What would be the best way to do it? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: password encrypt during insert
i had forgotten to add [0], didnt help though. still got the same error login_bare worked though i could pass login and password and it validated the user for me... Does login_bare do anything with respect to the session or does it just validate the fact that the user exists and password is correct. How do I associate a session with a user login without calling the form. this is what I am doing right now. logged_user=auth.login_bare(myemail, mypassword.encode('utf8')) logger.debug(bare login returned - %s % logged_user) ret= if (logged_user == False): logger.debug(user with email - %s not found with bare login % myemail) ret=[error] else: logger.debug(user logged in with bare login, email - %s found % myemail) ret=response.session_id -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.