Re: [web2py] Re: web2py inspired framework
That's the kind of thing I write with my students in 3hrs of class. It is a bit too simple to be useful. On Friday, 31 July 2015 13:33:37 UTC-5, Ramos wrote: this is another simple python web framework . http://toastdriven.com/blog/2009/mar/07/itty-sinatra-inspired-micro-framework/ 2015-07-31 18:26 GMT+01:00 Massimo Di Pierro massimo.dipie...@gmail.com: I think the more the merrier. It has less batteries included when compared to web2py but it will be appealing to people who like Flask over web2py. The author, Giovanni, is one of the core web2py developers so he knows what he is doing! On Friday, 31 July 2015 12:11:18 UTC-5, eric cuver wrote: What do you think of this framework which is clearly inspired by web2py http://weppy.org/ -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: view and edit on same page
Thanks for for taking the time to write detailed examples Jorge. Might have minor questions later but works great so far! Alex -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: web2py inspired framework
On Friday, July 31, 2015 at 10:26:30 AM UTC-7, Massimo Di Pierro wrote: I think the more the merrier. It has less batteries included when compared to web2py but it will be appealing to people who like Flask over web2py. The author, Giovanni, is one of the core web2py developers so he knows what he is doing! You ought to get him to do a cat gallery demonstration on vimeo. /dps On Friday, 31 July 2015 12:11:18 UTC-5, eric cuver wrote: What do you think of this framework which is clearly inspired by web2py http://weppy.org/ -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: Auth_user dynamic cascading registration fields
Hi Massimo On Wednesday, July 29, 2015 at 6:30:18 AM UTC+8, Wabbajack wrote: I have created a *factory,department,section and team* table in the database and a *factory* is on a *one to many* relationship with *department* a *department* is on a *one to many* relationship with* section* a *section* is on a *one to many* relationship with* team* *Table names* factory = portal_factory department = portal_department section = portal_section team = portal_team *db.py codes* ## *Factory* db.define_table('portal_factory', Field('name', notnull=True , required=True,unique=True) ) ## *Department* db.define_table('portal_department', Field('factory_id',db.portal_factory,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_factory.id,'%(name)s')), Field('name',notnull=True,required=True,unique=True) ) ## *Section* db.define_table('portal_section', Field('department_id',db.portal_department,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## *Team* db.define_table('portal_team', Field('section_id',db.portal_section,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_section.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## This is the tricky part ##i want to dynamically make an option list in the *t_department based on the selected t_factory* ##i want to dynamically make an option list in the* t_section based on the selected t_department* ##i want to dynamically make an option list in the* t_team based on the selected t_section* ## Extra fields on auth_user for registration auth.settings.extra_fields['auth_user']=[ Field('t_factory','reference portal_factory',label='Factory',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_factory.id ,'%(name)s')), Field('t_department','reference portal_department',label='Department',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('t_section','reference portal_section',label='Section',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_section.id ,'%(name)s')), Field('t_team','reference portal_team',label='Team',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_team.id,'%(name)s')), ] i have an attached file where this what i want to happen upon registration Upon registration if i select *factory* *A *there are different *department *selections in the dropdown (dropdown.png) same as if i select *factory B *there are different *department *selections in the dropdown (dropdown2.png) this setup will just follow for *department *to *section *and *section *to *team* Thank you in advance for your help...More power to web2py -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: File upload/download over https freezes site
I appreciate you sharing your knowledge on this! Sounds like it may have been a bad commit? Or, at least there should be some mention in web2py documentation about changing these values, mainly based on hardware? Thanks again, sounds like my best bet is to reconfigure the server for quad core CPU, and set processes=4, and leave threads=15 (or lower, but not 1) Dave On Friday, 31 July 2015 00:24:32 UTC-6, Niphlod wrote: let's not spread misinformations python has the GIL, true, and 15 threads with a single process won't use any cpu a single thread can use, nor span multiple cpus. But for anyone's sake, we're deploying a webapp in PRODUCTION, whose purpose should be - at the very least - be concurrent. If we force 1 process and a single thread, make ourselves a clap, than bang the head to the wall. we're serializing everything! tl;dr: I understand someone may think that 1 process with 15 threads (defaults of the apache directive) slow things down when you have 4xcpu and 3 of them remain underutilized while serving concurrently 15 requests (buh huh GIL, but I'd like to see test results), and that maybe a 4 processes with each 5 threads would be a smarter choice (really?!) but 1 process and 1 thread is a complete joke. On Friday, July 31, 2015 at 8:18:23 AM UTC+2, Derek wrote: I believe that's what Massimo is trying to say. Each processor has it's own GIL. On Thursday, July 30, 2015 at 6:31:57 PM UTC-7, Dave wrote: Thanks for tracking that down! So based on that post, and this one, it looks like i should be setting proccesses = # of cores, and threads = 1? https://groups.google.com/forum/#!topic/web2py/mPdn1ClxLTI Massimo DI Pierro: There are pros and cons. If you use threads in a python program, the more computing cores you have, the slower - not faster - the program gets. This is a python feature because even if you have threads, there is only one interpreted and therefore execution is serialized anyway. For scalability you should have processes (not threads) one per core. On Thursday, 30 July 2015 14:15:36 UTC-6, Derek wrote: looks like that change came from here: https://groups.google.com/forum/#!searchin/web2py/processes$3D1$20threads$3D1|sort:date/web2py/jumZFKX2614/pu-NNXSMKHgJ based on the post from Thomas... Thomas J. 10/3/13 I've recently been comparing Web2py and PHP, this is what i found, maybe it helps: 1.: PHP is faster whereever it can do stuff within the interpreter, that includes handling post/get-data or templates. The PHP interpreter is written in C, so these things are really fast, whereas Web2py has to to them in Python. 2. DB access is heavily dependent on how many records you retrieve. Translating a query from DAL to SQL is basically free (so using the DAL syntax for DB access isn't an issue), putting the data into Python objects is quite expensive however. Only query what you really need. Also, using executesql() instead of the regular DAL syntax may help there, as it returns tuples, not complex data structures 3. I've found the default config for Apache2 to be somewhat broken as far as concurrency is concerned. Check your Apache/WSGI config, you probably have a line like WSGIDaemonProcess web2py user=www-data group=www-data in there. This actually defaults to 1 process with 15 threads, which -- on my machine -- completely kills performance (Python doesn't do threads well because of the global interpreter lock). I've found that even something like WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 improves performance for concurrent requests dramatically. Try tinkering with the processes-value to find the best config for your machine. You should probably change processes before you change threads. On Wednesday, July 29, 2015 at 3:40:30 PM UTC-7, Dave wrote: That would be good to know. Nothing in the web2py docs suggests that Apache should not be used in production, it actually seems more like the default since it is the first discussed in the documentation and it's used in the one-step production deployment. The line of code in question is also in the one-step deployment script here: http://web2py.googlecode.com/hg/scripts/setup-web2py-ubuntu.sh On Wednesday, 29 July 2015 14:32:19 UTC-6, Niphlod wrote: I dropped off the apache train too soon to have any issues with it, but frankly, given the total sum of issues encountered so far on the forums, I'm starting to think that we'd need to officially discontinue our apache support.. may be total lack of luck in setting it up or very biased perspective, or total lack of internal knowledge but it seems that every problem that pops up with deployments have apache as the common ground. looks like this is the commit to be blamed https://github.com/web2py/web2py/commit/2a062a2ff5aa1e07e7bfcfdbf36b7f72e8aac5b4 I don't know the specifics around it but if
[web2py] Re: Auth_user dynamic cascading registration fields
Hi Derek, Ive tried and its working... Thanks (see attached) i will just have to create a separate user registration view and not use the default 'user/register' to have this function in my auth_user registration Thanks... On Friday, July 31, 2015 at 2:30:56 PM UTC+8, Derek wrote: You will want to take a look at my example here: http://www.web2pyslices.com/slice/show/1724/cascading-dropdowns-simplified let me know if you have questions. You should be able to easily extend it to do multi level cascading. On Tuesday, July 28, 2015 at 3:30:18 PM UTC-7, Wabbajack wrote: I have created a *factory,department,section and team* table in the database and a *factory* is on a *one to many* relationship with *department* a *department* is on a *one to many* relationship with* section* a *section* is on a *one to many* relationship with* team* *Table names* factory = portal_factory department = portal_department section = portal_section team = portal_team *db.py codes* ## *Factory* db.define_table('portal_factory', Field('name', notnull=True , required=True,unique=True) ) ## *Department* db.define_table('portal_department', Field('factory_id',db.portal_factory,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_factory.id,'%(name)s')), Field('name',notnull=True,required=True,unique=True) ) ## *Section* db.define_table('portal_section', Field('department_id',db.portal_department,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## *Team* db.define_table('portal_team', Field('section_id',db.portal_section,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_section.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## This is the tricky part ##i want to dynamically make an option list in the *t_department based on the selected t_factory* ##i want to dynamically make an option list in the* t_section based on the selected t_department* ##i want to dynamically make an option list in the* t_team based on the selected t_section* ## Extra fields on auth_user for registration auth.settings.extra_fields['auth_user']=[ Field('t_factory','reference portal_factory',label='Factory',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_factory.id ,'%(name)s')), Field('t_department','reference portal_department',label='Department',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('t_section','reference portal_section',label='Section',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_section.id ,'%(name)s')), Field('t_team','reference portal_team',label='Team',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_team.id ,'%(name)s')), ] i have an attached file where this what i want to happen upon registration Upon registration if i select *factory* *A *there are different *department *selections in the dropdown (dropdown.png) same as if i select *factory B *there are different *department *selections in the dropdown (dropdown2.png) this setup will just follow for *department *to *section *and *section *to *team* Thank you in advance for your help...More power to web2py -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Good way to implement multiple file upload with previews?
I'd like to implement an editor interface for posting articles to my site. The left side of the interface will be the editor window, and the right side is the preview window (which shows changes, as they are made by the user, in real-time). The editor interface will also allow the user to bring up (by pressing a hotkey combo) a multi-part file-upload dialog, of the sort which is found in popular blogging platforms - I've attached an image of an example of such a dialog: The editor window of the file dialog contains some markup which permits the user to assign a label/title to the image. The preview window of the file dialog contains a image dropbox. Once the image is dropped in, the dropbox shows a preview of the image. The user should be able to create these ad hoc image upload boxes at any point of the article which they are writing/editing. Has anyone here implemented anything similar to this in web2py? Can you offer me some recommendations on how to go about implementing this feature? Thank you. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] web2py inspired framework
What do you think of this framework which is clearly inspired by web2py http://weppy.org/ -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Test1
Test -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Binding a form field to a user field
Hello Guys, Just starting with Web2Py. I'm working on a project and need to do the following: I have image defined in the DB like this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) And then: db.image.user_id.requires = IS_IN_DB(db, db.auth_user.id, '%(displayed_name)s') Then I created a function, so only registered users may upload or send pictures: @auth.requires_login() def upload(): form = SQLFORM(db.image) if form.process().accepted: response.flash = 'Your Photo has been sent!' return dict(form=form) The problem I've been having is I need to bind every uploaded picture by a user to that specific user. I don't even need the form to show a list of users to select which one is the owner of the photo, because the owner must always be the logged in user. However, I haven't managed to find a way of doing that. Read the documentation but couldn't find an example. Right now, with the code I have, the form would show me the list of all registered users to select one to bind the photo with. I really appreciate your help. Thanks! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] date format of date picker
I have form with date field i have setup default format(dd/mm/). i am using web2py sqlform. when i select date from date picker. it used to take dd/mm/yy. i know its very silly question. i had tried in ajax.html file and check my db file also but i am not able to find the solution. can any one help me to solve. i set default value: dd/mm/. when i edit the date it change to dd/mm/yy my ajax file script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_disable_with_message = {{=T('Working...')}}; var w2p_ajax_date_format = {{=T('%d-%m-%y')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; var ajax_error_500 = '{{=T.M('An error occured, please [[reload %s]] the page') % URL(args=request.args, vars=request.get_vars) }}' //--/script {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: File upload/download over https freezes site
Thanks for weighing in on this. I'll update my apache config and keep an eye on memory usage. Are there any plans for a one-step deployment script for a web server other than apache? Which web server is the next most popular option with web2py community? Dave On Friday, 31 July 2015 11:19:54 UTC-6, Massimo Di Pierro wrote: I think that commit should be reversed. O changed to processes=5 threads=1. but this may cause an increased memory usage and it is not a good thing with apache. Agreed that Apache is no longer recommended (not just for web2py users) but we should continue to support it because it is still the mots popular web server. On Wednesday, 29 July 2015 15:32:19 UTC-5, Niphlod wrote: I dropped off the apache train too soon to have any issues with it, but frankly, given the total sum of issues encountered so far on the forums, I'm starting to think that we'd need to officially discontinue our apache support.. may be total lack of luck in setting it up or very biased perspective, or total lack of internal knowledge but it seems that every problem that pops up with deployments have apache as the common ground. looks like this is the commit to be blamed https://github.com/web2py/web2py/commit/2a062a2ff5aa1e07e7bfcfdbf36b7f72e8aac5b4 I don't know the specifics around it but if it acts like it suggests, 1 thread and 1 process as a total sum aren't really worth of a production deployment. On Wednesday, July 29, 2015 at 6:00:47 PM UTC+2, Dave wrote: Actually, it looks like i was chasing the wrong issue... It wasn't https after all. Everything seems to be working after changing this line in apache default.conf: WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 to: WSGIDaemonProcess web2py user=www-data group=www-data processes=5 threads=15 Is there any reason not to change this default setting from one-step deployment? Can I likely set these values higher based on my hardware? Thanks again, Dave On Wednesday, 29 July 2015 02:52:20 UTC-6, Niphlod wrote: uhm, you left out some pretty specific details what resources has the server web2py is deployed on ? moreover, what's the size of the file ? and what code are you using to handle the upload? are you using the default 'upload' Field or is it in conjunction with a 'blob' one to store the file on the database ? On Wednesday, July 29, 2015 at 4:59:29 AM UTC+2, Dave wrote: I have this same behavior on multiple web2py servers. If a large file is being uploaded using a SQLFORM or downloaded using the default download controller, over HTTPS, the entire web server becomes unresponsive until the transfer is completed or cancelled. However, I have no issues uploading/downloading the same file over HTTP, which can also take several minutes to complete, but the web server is still responsive during those transfers. I am using the one-step deployment with Apache and a wildcard certificate (RapidSSL). Would switching to nginx or cherokee give better performance for https file transfers, or is this likely an issue with the SSL certificate format? Or if the file transfers over HTTPS are too CPU intensive, am i better off setting up multiple servers and a load balancer? Thanks! Dave R -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: Binding a form field to a user field
Using auth.signature is a good approach (though may be overkill if you don't need the other fields it creates). But for reference, to achieve what you want, just hide the user_id field and give it a default value: Field('user_id', 'reference auth_user', writable=False, default=auth.user_id ) Anthony On Friday, July 31, 2015 at 1:24:29 PM UTC-4, Massimo Di Pierro wrote: Do not do this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) do db.define_table('image', Field('file', 'upload'), Field('description', 'text'), auth.signature) and the db.image.created_by will be a reference to the user who uploaded the image. On Friday, 31 July 2015 12:11:35 UTC-5, Pablo Andrés Ortega Chávez wrote: Hello Guys, Just starting with Web2Py. I'm working on a project and need to do the following: I have image defined in the DB like this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) And then: db.image.user_id.requires = IS_IN_DB(db, db.auth_user.id, '%(displayed_name)s') Then I created a function, so only registered users may upload or send pictures: @auth.requires_login() def upload(): form = SQLFORM(db.image) if form.process().accepted: response.flash = 'Your Photo has been sent!' return dict(form=form) The problem I've been having is I need to bind every uploaded picture by a user to that specific user. I don't even need the form to show a list of users to select which one is the owner of the photo, because the owner must always be the logged in user. However, I haven't managed to find a way of doing that. Read the documentation but couldn't find an example. Right now, with the code I have, the form would show me the list of all registered users to select one to bind the photo with. I really appreciate your help. Thanks! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: Binding a form field to a user field
Do not do this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) do db.define_table('image', Field('file', 'upload'), Field('description', 'text'), auth.signature) and the db.image.created_by will be a reference to the user who uploaded the image. On Friday, 31 July 2015 12:11:35 UTC-5, Pablo Andrés Ortega Chávez wrote: Hello Guys, Just starting with Web2Py. I'm working on a project and need to do the following: I have image defined in the DB like this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) And then: db.image.user_id.requires = IS_IN_DB(db, db.auth_user.id, '%(displayed_name)s') Then I created a function, so only registered users may upload or send pictures: @auth.requires_login() def upload(): form = SQLFORM(db.image) if form.process().accepted: response.flash = 'Your Photo has been sent!' return dict(form=form) The problem I've been having is I need to bind every uploaded picture by a user to that specific user. I don't even need the form to show a list of users to select which one is the owner of the photo, because the owner must always be the logged in user. However, I haven't managed to find a way of doing that. Read the documentation but couldn't find an example. Right now, with the code I have, the form would show me the list of all registered users to select one to bind the photo with. I really appreciate your help. Thanks! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: how to validate field that depend on each other in the model rather than form
I'm wondering just the same. How can this be done in model?. Particularly I want to use IS_IN_DB on a referenced field based on a query filtering by the value of another field of the table. I've tried this but didn't work: db.table1.field1.requires = lambda x,row: IS_IN_DB(db(db.table2.field2==row. field2)), 'table2.id') Nor did this one: db.table1.field1.requires = IS_IN_DB(db(db.table2.field2==db.table1.field2 )), 'table2.id') where field1 is field of table1: Field('field1', 'reference table2') Regards. El lunes, 16 de septiembre de 2013, 8:49:08 (UTC+2), Hadi Sunyoto escribió: from: http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators http://www.google.com/url?q=http%3A%2F%2Fwww.web2py.com%2Fbooks%2Fdefault%2Fchapter%2F29%2F07%2Fforms-and-validators%23Database-validatorssa=Dsntz=1usg=AFQjCNE4_4fAPTYEpCZJVvLy1ejv7Tcocw Validators with dependencies Usually validators are set once for all in models. Occasionally, you need to validate a field and the validator depends on the value of another field. This can be done in various ways. It can be done in the model or in the controller. There is an example validation done in controller but there is no example validation done in model My table: db.define_table('config', Field('config_name', 'string', length=255, required=True, unique=True), Field('convert_option', 'string', length=255, requires=IS_IN_SET(CONVERSION, zero=None)), Field('config_value', 'string', length=255, required=True), Field('default_value', 'string', length=255, required=True)) I want to validate if config_value is greater than default value (for example), but i don't want to do it in SQLFORM or FORM. or is it a bad idea to put validation that depend on other fields in model rather than form? Thank you Hadi -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] web2py inspired framework
:) The DAL (now pyDAL) have been extracted from web2py just for it!! Richard On Thu, Jul 30, 2015 at 5:13 PM, eric cuver amihaconsult...@gmail.com wrote: What do you think of this framework which is clearly inspired by web2py http://weppy.org/ -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: Binding a form field to a user field
Thank You Massimo! Yesterday after I posted my question, I found another post here and went ahead and do this: On the image table I defined: *Field('user_id', db.auth_user, default=auth.user_id, writable=False, readable=False),* And then I also defined this: *db.image.user_id.requires = IS_IN_DB(db, db.auth_user.id, '%(displayed_name)s')* That worked like a charm. I understand there are some differences between the approach I implemented yesterday and the one you're suggesting. I see that there are additional fields in the image table created, with the information from the user. What would be the main disadvantages of using the first method, instead of the *auth.signature* method? And, the field* image.is_active* was also created, and the value for the picture I uploaded is *True*. Is that possible to be changed by default to *False*, for example? What is the use for that field? Thank you very much for your support! PD: I found last night your Vimeo account with the tutorials. Very nice. I watched one and learned how to use the Bootstrap 3 features, I'm playing with that and the application I'm building is growing fast! I think that, so far, Web2Py is a really powerful framework and helps you build applications fast. I'm gonna be around here asking questions a lot, hahaha. Thanks again. El viernes, 31 de julio de 2015, 12:24:29 (UTC-5), Massimo Di Pierro escribió: Do not do this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) do db.define_table('image', Field('file', 'upload'), Field('description', 'text'), auth.signature) and the db.image.created_by will be a reference to the user who uploaded the image. On Friday, 31 July 2015 12:11:35 UTC-5, Pablo Andrés Ortega Chávez wrote: Hello Guys, Just starting with Web2Py. I'm working on a project and need to do the following: I have image defined in the DB like this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) And then: db.image.user_id.requires = IS_IN_DB(db, db.auth_user.id, '%(displayed_name)s') Then I created a function, so only registered users may upload or send pictures: @auth.requires_login() def upload(): form = SQLFORM(db.image) if form.process().accepted: response.flash = 'Your Photo has been sent!' return dict(form=form) The problem I've been having is I need to bind every uploaded picture by a user to that specific user. I don't even need the form to show a list of users to select which one is the owner of the photo, because the owner must always be the logged in user. However, I haven't managed to find a way of doing that. Read the documentation but couldn't find an example. Right now, with the code I have, the form would show me the list of all registered users to select one to bind the photo with. I really appreciate your help. Thanks! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: Binding a form field to a user field
Thank you Anthony! That was exactly what I did last night, with a post I found here. I just replied here with some questions, so I'll have to wait for my post to be approved and published so you can see it. I'd appreciate any insights. Regards, Pablo. El viernes, 31 de julio de 2015, 12:53:52 (UTC-5), Anthony escribió: Using auth.signature is a good approach (though may be overkill if you don't need the other fields it creates). But for reference, to achieve what you want, just hide the user_id field and give it a default value: Field('user_id', 'reference auth_user', writable=False, default=auth. user_id) Anthony On Friday, July 31, 2015 at 1:24:29 PM UTC-4, Massimo Di Pierro wrote: Do not do this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) do db.define_table('image', Field('file', 'upload'), Field('description', 'text'), auth.signature) and the db.image.created_by will be a reference to the user who uploaded the image. On Friday, 31 July 2015 12:11:35 UTC-5, Pablo Andrés Ortega Chávez wrote: Hello Guys, Just starting with Web2Py. I'm working on a project and need to do the following: I have image defined in the DB like this: db.define_table('image', Field('user_id', 'reference auth_user'), Field('file', 'upload'), Field('description', 'text')) And then: db.image.user_id.requires = IS_IN_DB(db, db.auth_user.id, '%(displayed_name)s') Then I created a function, so only registered users may upload or send pictures: @auth.requires_login() def upload(): form = SQLFORM(db.image) if form.process().accepted: response.flash = 'Your Photo has been sent!' return dict(form=form) The problem I've been having is I need to bind every uploaded picture by a user to that specific user. I don't even need the form to show a list of users to select which one is the owner of the photo, because the owner must always be the logged in user. However, I haven't managed to find a way of doing that. Read the documentation but couldn't find an example. Right now, with the code I have, the form would show me the list of all registered users to select one to bind the photo with. I really appreciate your help. Thanks! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Re: web2py inspired framework
this is another simple python web framework . http://toastdriven.com/blog/2009/mar/07/itty-sinatra-inspired-micro-framework/ 2015-07-31 18:26 GMT+01:00 Massimo Di Pierro massimo.dipie...@gmail.com: I think the more the merrier. It has less batteries included when compared to web2py but it will be appealing to people who like Flask over web2py. The author, Giovanni, is one of the core web2py developers so he knows what he is doing! On Friday, 31 July 2015 12:11:18 UTC-5, eric cuver wrote: What do you think of this framework which is clearly inspired by web2py http://weppy.org/ -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: how to validate field that depend on each other in the model rather than form
On Monday, September 16, 2013 at 2:49:08 AM UTC-4, Hadi Sunyoto wrote: There is an example validation done in controller but there is no example validation done in model My table: db.define_table('config', Field('config_name', 'string', length=255, required=True, unique=True), Field('convert_option', 'string', length=255, requires=IS_IN_SET(CONVERSION, zero=None)), Field('config_value', 'string', length=255, required=True), Field('default_value', 'string', length=255, required=True)) I want to validate if config_value is greater than default value (for example), but i don't want to do it in SQLFORM or FORM. or is it a bad idea to put validation that depend on other fields in model rather than form? You could use request.post_vars in the validator. For example, assuming these values are integers: Field('config_value', ..., requires=IS_EXPR(lambda value: value int(request.post_vars. default_value))) Assuming these fields store numbers, you should use the appropriate field type (integer, double, decimal) rather than string. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: File upload/download over https freezes site
I think that commit should be reversed. O changed to processes=5 threads=1. but this may cause an increased memory usage and it is not a good thing with apache. Agreed that Apache is no longer recommended (not just for web2py users) but we should continue to support it because it is still the mots popular web server. On Wednesday, 29 July 2015 15:32:19 UTC-5, Niphlod wrote: I dropped off the apache train too soon to have any issues with it, but frankly, given the total sum of issues encountered so far on the forums, I'm starting to think that we'd need to officially discontinue our apache support.. may be total lack of luck in setting it up or very biased perspective, or total lack of internal knowledge but it seems that every problem that pops up with deployments have apache as the common ground. looks like this is the commit to be blamed https://github.com/web2py/web2py/commit/2a062a2ff5aa1e07e7bfcfdbf36b7f72e8aac5b4 I don't know the specifics around it but if it acts like it suggests, 1 thread and 1 process as a total sum aren't really worth of a production deployment. On Wednesday, July 29, 2015 at 6:00:47 PM UTC+2, Dave wrote: Actually, it looks like i was chasing the wrong issue... It wasn't https after all. Everything seems to be working after changing this line in apache default.conf: WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 to: WSGIDaemonProcess web2py user=www-data group=www-data processes=5 threads=15 Is there any reason not to change this default setting from one-step deployment? Can I likely set these values higher based on my hardware? Thanks again, Dave On Wednesday, 29 July 2015 02:52:20 UTC-6, Niphlod wrote: uhm, you left out some pretty specific details what resources has the server web2py is deployed on ? moreover, what's the size of the file ? and what code are you using to handle the upload? are you using the default 'upload' Field or is it in conjunction with a 'blob' one to store the file on the database ? On Wednesday, July 29, 2015 at 4:59:29 AM UTC+2, Dave wrote: I have this same behavior on multiple web2py servers. If a large file is being uploaded using a SQLFORM or downloaded using the default download controller, over HTTPS, the entire web server becomes unresponsive until the transfer is completed or cancelled. However, I have no issues uploading/downloading the same file over HTTP, which can also take several minutes to complete, but the web server is still responsive during those transfers. I am using the one-step deployment with Apache and a wildcard certificate (RapidSSL). Would switching to nginx or cherokee give better performance for https file transfers, or is this likely an issue with the SSL certificate format? Or if the file transfers over HTTPS are too CPU intensive, am i better off setting up multiple servers and a load balancer? Thanks! Dave R -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: Auth_user dynamic cascading registration fields
You do not need another controller in my opinion. You can simply do: def user(): if request.args(0)=='register': response.files.append(URL('static','js/deal-with-fields.js')) return dict(form=auth()) and then you put what you need in the deal-with-fields.js On Friday, 31 July 2015 08:27:31 UTC-5, Wabbajack wrote: Hi Massimo Ive read your reply...thats what we have been working on today... We tried using static dictionaries with sub groups...to a registration form with our factories , department, section and teams... :) But if we do that i think we cannot use the 'user/register' page? It is still possible if we can manipulate the 'user/register' page? Right now we are making a new_registration controller and view...with static dictionaries i will just post the code once its done... Im sorry im just a 2 months old in python and a month old in web2py..and a new comer in web development Its just our boss really... But the web2py community is very goodrapid development using web2py is very impressing ive never expect a reply actually...but also i have never expect it coming from you... Thank you very much.. On Wednesday, July 29, 2015 at 6:30:18 AM UTC+8, Wabbajack wrote: I have created a *factory,department,section and team* table in the database and a *factory* is on a *one to many* relationship with *department* a *department* is on a *one to many* relationship with* section* a *section* is on a *one to many* relationship with* team* *Table names* factory = portal_factory department = portal_department section = portal_section team = portal_team *db.py codes* ## *Factory* db.define_table('portal_factory', Field('name', notnull=True , required=True,unique=True) ) ## *Department* db.define_table('portal_department', Field('factory_id',db.portal_factory,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_factory.id,'%(name)s')), Field('name',notnull=True,required=True,unique=True) ) ## *Section* db.define_table('portal_section', Field('department_id',db.portal_department,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## *Team* db.define_table('portal_team', Field('section_id',db.portal_section,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_section.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## This is the tricky part ##i want to dynamically make an option list in the *t_department based on the selected t_factory* ##i want to dynamically make an option list in the* t_section based on the selected t_department* ##i want to dynamically make an option list in the* t_team based on the selected t_section* ## Extra fields on auth_user for registration auth.settings.extra_fields['auth_user']=[ Field('t_factory','reference portal_factory',label='Factory',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_factory.id ,'%(name)s')), Field('t_department','reference portal_department',label='Department',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('t_section','reference portal_section',label='Section',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_section.id ,'%(name)s')), Field('t_team','reference portal_team',label='Team',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_team.id ,'%(name)s')), ] i have an attached file where this what i want to happen upon registration Upon registration if i select *factory* *A *there are different *department *selections in the dropdown (dropdown.png) same as if i select *factory B *there are different *department *selections in the dropdown (dropdown2.png) this setup will just follow for *department *to *section *and *section *to *team* Thank you in advance for your help...More power to web2py -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: web2py inspired framework
I think the more the merrier. It has less batteries included when compared to web2py but it will be appealing to people who like Flask over web2py. The author, Giovanni, is one of the core web2py developers so he knows what he is doing! On Friday, 31 July 2015 12:11:18 UTC-5, eric cuver wrote: What do you think of this framework which is clearly inspired by web2py http://weppy.org/ -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: web2py inspired framework
+1. Quite like it for our use case and plan to direct more resources to it. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Re: File upload/download over https freezes site
nginx coupled with uwsgi is quite popular and easy to maintain compared to apache. scripts are in the scripts directory they also take care of installing uwsgi 2015-07-31 20:38 GMT+02:00 Dave davidramsayreinh...@gmail.com: Thanks for weighing in on this. I'll update my apache config and keep an eye on memory usage. Are there any plans for a one-step deployment script for a web server other than apache? Which web server is the next most popular option with web2py community? Dave On Friday, 31 July 2015 11:19:54 UTC-6, Massimo Di Pierro wrote: I think that commit should be reversed. O changed to processes=5 threads=1. but this may cause an increased memory usage and it is not a good thing with apache. Agreed that Apache is no longer recommended (not just for web2py users) but we should continue to support it because it is still the mots popular web server. On Wednesday, 29 July 2015 15:32:19 UTC-5, Niphlod wrote: I dropped off the apache train too soon to have any issues with it, but frankly, given the total sum of issues encountered so far on the forums, I'm starting to think that we'd need to officially discontinue our apache support.. may be total lack of luck in setting it up or very biased perspective, or total lack of internal knowledge but it seems that every problem that pops up with deployments have apache as the common ground. looks like this is the commit to be blamed https://github.com/web2py/web2py/commit/2a062a2ff5aa1e07e7bfcfdbf36b7f72e8aac5b4 I don't know the specifics around it but if it acts like it suggests, 1 thread and 1 process as a total sum aren't really worth of a production deployment. On Wednesday, July 29, 2015 at 6:00:47 PM UTC+2, Dave wrote: Actually, it looks like i was chasing the wrong issue... It wasn't https after all. Everything seems to be working after changing this line in apache default.conf: WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 to: WSGIDaemonProcess web2py user=www-data group=www-data processes=5 threads=15 Is there any reason not to change this default setting from one-step deployment? Can I likely set these values higher based on my hardware? Thanks again, Dave On Wednesday, 29 July 2015 02:52:20 UTC-6, Niphlod wrote: uhm, you left out some pretty specific details what resources has the server web2py is deployed on ? moreover, what's the size of the file ? and what code are you using to handle the upload? are you using the default 'upload' Field or is it in conjunction with a 'blob' one to store the file on the database ? On Wednesday, July 29, 2015 at 4:59:29 AM UTC+2, Dave wrote: I have this same behavior on multiple web2py servers. If a large file is being uploaded using a SQLFORM or downloaded using the default download controller, over HTTPS, the entire web server becomes unresponsive until the transfer is completed or cancelled. However, I have no issues uploading/downloading the same file over HTTP, which can also take several minutes to complete, but the web server is still responsive during those transfers. I am using the one-step deployment with Apache and a wildcard certificate (RapidSSL). Would switching to nginx or cherokee give better performance for https file transfers, or is this likely an issue with the SSL certificate format? Or if the file transfers over HTTPS are too CPU intensive, am i better off setting up multiple servers and a load balancer? Thanks! Dave R -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Multiprocessing queue and web2py
Dear Developers, I really would like to use multiprocessing python queue in web2py but I'm asking for an advice. I googled the forum but cannot find an answer. I have a worker process (a can bus message processing daemon) that actually it's a web2py application that shares a database table with the main application. Unfortunately I'm on an embedded arm (400mhz with slow uSD card) and accessing the database for sharing messages it's really killing my app. Using multiprocessing queues would solve my problems but I have a several questions popping around: * I have to maintain a queue handler in main process but web2py doesn't support writing a singleton shared by all controllers, is a cache.ram that never expires the only way to keep that handler in memory for the application lifetime? * The worker process should be spawned by web2py, but again, I should keep an handler in cache.ram and check if the process was previously spawned at each request, right? * This is not the most elegant solution, do you know of a more elegant one? Thank you for you advice! -- Profile: http://it.linkedin.com/in/compagnucciangelo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Re: File upload/download over https freezes site
let's not spread misinformations python has the GIL, true, and 15 threads with a single process won't use any cpu a single thread can use, nor span multiple cpus. But for anyone's sake, we're deploying a webapp in PRODUCTION, whose purpose should be - at the very least - be concurrent. If we force 1 process and a single thread, make ourselves a clap, than bang the head to the wall. we're serializing everything! tl;dr: I understand someone may think that 1 process with 15 threads (defaults of the apache directive) slow things down when you have 4xcpu and 3 of them remain underutilized while serving concurrently 15 requests (buh huh GIL, but I'd like to see test results), and that maybe a 4 processes with each 5 threads would be a smarter choice (really?!) but 1 process and 1 thread is a complete joke. On Friday, July 31, 2015 at 8:18:23 AM UTC+2, Derek wrote: I believe that's what Massimo is trying to say. Each processor has it's own GIL. On Thursday, July 30, 2015 at 6:31:57 PM UTC-7, Dave wrote: Thanks for tracking that down! So based on that post, and this one, it looks like i should be setting proccesses = # of cores, and threads = 1? https://groups.google.com/forum/#!topic/web2py/mPdn1ClxLTI Massimo DI Pierro: There are pros and cons. If you use threads in a python program, the more computing cores you have, the slower - not faster - the program gets. This is a python feature because even if you have threads, there is only one interpreted and therefore execution is serialized anyway. For scalability you should have processes (not threads) one per core. On Thursday, 30 July 2015 14:15:36 UTC-6, Derek wrote: looks like that change came from here: https://groups.google.com/forum/#!searchin/web2py/processes$3D1$20threads$3D1|sort:date/web2py/jumZFKX2614/pu-NNXSMKHgJ based on the post from Thomas... Thomas J. 10/3/13 I've recently been comparing Web2py and PHP, this is what i found, maybe it helps: 1.: PHP is faster whereever it can do stuff within the interpreter, that includes handling post/get-data or templates. The PHP interpreter is written in C, so these things are really fast, whereas Web2py has to to them in Python. 2. DB access is heavily dependent on how many records you retrieve. Translating a query from DAL to SQL is basically free (so using the DAL syntax for DB access isn't an issue), putting the data into Python objects is quite expensive however. Only query what you really need. Also, using executesql() instead of the regular DAL syntax may help there, as it returns tuples, not complex data structures 3. I've found the default config for Apache2 to be somewhat broken as far as concurrency is concerned. Check your Apache/WSGI config, you probably have a line like WSGIDaemonProcess web2py user=www-data group=www-data in there. This actually defaults to 1 process with 15 threads, which -- on my machine -- completely kills performance (Python doesn't do threads well because of the global interpreter lock). I've found that even something like WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 improves performance for concurrent requests dramatically. Try tinkering with the processes-value to find the best config for your machine. You should probably change processes before you change threads. On Wednesday, July 29, 2015 at 3:40:30 PM UTC-7, Dave wrote: That would be good to know. Nothing in the web2py docs suggests that Apache should not be used in production, it actually seems more like the default since it is the first discussed in the documentation and it's used in the one-step production deployment. The line of code in question is also in the one-step deployment script here: http://web2py.googlecode.com/hg/scripts/setup-web2py-ubuntu.sh On Wednesday, 29 July 2015 14:32:19 UTC-6, Niphlod wrote: I dropped off the apache train too soon to have any issues with it, but frankly, given the total sum of issues encountered so far on the forums, I'm starting to think that we'd need to officially discontinue our apache support.. may be total lack of luck in setting it up or very biased perspective, or total lack of internal knowledge but it seems that every problem that pops up with deployments have apache as the common ground. looks like this is the commit to be blamed https://github.com/web2py/web2py/commit/2a062a2ff5aa1e07e7bfcfdbf36b7f72e8aac5b4 I don't know the specifics around it but if it acts like it suggests, 1 thread and 1 process as a total sum aren't really worth of a production deployment. On Wednesday, July 29, 2015 at 6:00:47 PM UTC+2, Dave wrote: Actually, it looks like i was chasing the wrong issue... It wasn't https after all. Everything seems to be working after changing this line in apache default.conf: WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 to:
[web2py] Re: File upload/download over https freezes site
I believe that's what Massimo is trying to say. Each processor has it's own GIL. On Thursday, July 30, 2015 at 6:31:57 PM UTC-7, Dave wrote: Thanks for tracking that down! So based on that post, and this one, it looks like i should be setting proccesses = # of cores, and threads = 1? https://groups.google.com/forum/#!topic/web2py/mPdn1ClxLTI Massimo DI Pierro: There are pros and cons. If you use threads in a python program, the more computing cores you have, the slower - not faster - the program gets. This is a python feature because even if you have threads, there is only one interpreted and therefore execution is serialized anyway. For scalability you should have processes (not threads) one per core. On Thursday, 30 July 2015 14:15:36 UTC-6, Derek wrote: looks like that change came from here: https://groups.google.com/forum/#!searchin/web2py/processes$3D1$20threads$3D1|sort:date/web2py/jumZFKX2614/pu-NNXSMKHgJ based on the post from Thomas... Thomas J. 10/3/13 I've recently been comparing Web2py and PHP, this is what i found, maybe it helps: 1.: PHP is faster whereever it can do stuff within the interpreter, that includes handling post/get-data or templates. The PHP interpreter is written in C, so these things are really fast, whereas Web2py has to to them in Python. 2. DB access is heavily dependent on how many records you retrieve. Translating a query from DAL to SQL is basically free (so using the DAL syntax for DB access isn't an issue), putting the data into Python objects is quite expensive however. Only query what you really need. Also, using executesql() instead of the regular DAL syntax may help there, as it returns tuples, not complex data structures 3. I've found the default config for Apache2 to be somewhat broken as far as concurrency is concerned. Check your Apache/WSGI config, you probably have a line like WSGIDaemonProcess web2py user=www-data group=www-data in there. This actually defaults to 1 process with 15 threads, which -- on my machine -- completely kills performance (Python doesn't do threads well because of the global interpreter lock). I've found that even something like WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 improves performance for concurrent requests dramatically. Try tinkering with the processes-value to find the best config for your machine. You should probably change processes before you change threads. On Wednesday, July 29, 2015 at 3:40:30 PM UTC-7, Dave wrote: That would be good to know. Nothing in the web2py docs suggests that Apache should not be used in production, it actually seems more like the default since it is the first discussed in the documentation and it's used in the one-step production deployment. The line of code in question is also in the one-step deployment script here: http://web2py.googlecode.com/hg/scripts/setup-web2py-ubuntu.sh On Wednesday, 29 July 2015 14:32:19 UTC-6, Niphlod wrote: I dropped off the apache train too soon to have any issues with it, but frankly, given the total sum of issues encountered so far on the forums, I'm starting to think that we'd need to officially discontinue our apache support.. may be total lack of luck in setting it up or very biased perspective, or total lack of internal knowledge but it seems that every problem that pops up with deployments have apache as the common ground. looks like this is the commit to be blamed https://github.com/web2py/web2py/commit/2a062a2ff5aa1e07e7bfcfdbf36b7f72e8aac5b4 I don't know the specifics around it but if it acts like it suggests, 1 thread and 1 process as a total sum aren't really worth of a production deployment. On Wednesday, July 29, 2015 at 6:00:47 PM UTC+2, Dave wrote: Actually, it looks like i was chasing the wrong issue... It wasn't https after all. Everything seems to be working after changing this line in apache default.conf: WSGIDaemonProcess web2py user=www-data group=www-data processes=1 threads=1 to: WSGIDaemonProcess web2py user=www-data group=www-data processes=5 threads=15 Is there any reason not to change this default setting from one-step deployment? Can I likely set these values higher based on my hardware? Thanks again, Dave On Wednesday, 29 July 2015 02:52:20 UTC-6, Niphlod wrote: uhm, you left out some pretty specific details what resources has the server web2py is deployed on ? moreover, what's the size of the file ? and what code are you using to handle the upload? are you using the default 'upload' Field or is it in conjunction with a 'blob' one to store the file on the database ? On Wednesday, July 29, 2015 at 4:59:29 AM UTC+2, Dave wrote: I have this same behavior on multiple web2py servers. If a large file is being uploaded using a SQLFORM or downloaded using the default download controller, over HTTPS, the entire web server
[web2py] Re: Auth_user dynamic cascading registration fields
You will want to take a look at my example here: http://www.web2pyslices.com/slice/show/1724/cascading-dropdowns-simplified let me know if you have questions. You should be able to easily extend it to do multi level cascading. On Tuesday, July 28, 2015 at 3:30:18 PM UTC-7, Wabbajack wrote: I have created a *factory,department,section and team* table in the database and a *factory* is on a *one to many* relationship with *department* a *department* is on a *one to many* relationship with* section* a *section* is on a *one to many* relationship with* team* *Table names* factory = portal_factory department = portal_department section = portal_section team = portal_team *db.py codes* ## *Factory* db.define_table('portal_factory', Field('name', notnull=True , required=True,unique=True) ) ## *Department* db.define_table('portal_department', Field('factory_id',db.portal_factory,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_factory.id,'%(name)s')), Field('name',notnull=True,required=True,unique=True) ) ## *Section* db.define_table('portal_section', Field('department_id',db.portal_department,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## *Team* db.define_table('portal_team', Field('section_id',db.portal_section,notnull=True,required=True,requires=IS_IN_DB(db, db.portal_section.id,'%(name)s')), Field('name', notnull=True, required=True, unique=True), ) ## This is the tricky part ##i want to dynamically make an option list in the *t_department based on the selected t_factory* ##i want to dynamically make an option list in the* t_section based on the selected t_department* ##i want to dynamically make an option list in the* t_team based on the selected t_section* ## Extra fields on auth_user for registration auth.settings.extra_fields['auth_user']=[ Field('t_factory','reference portal_factory',label='Factory',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_factory.id ,'%(name)s')), Field('t_department','reference portal_department',label='Department',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_department.id,'%(name)s')), Field('t_section','reference portal_section',label='Section',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_section.id ,'%(name)s')), Field('t_team','reference portal_team',label='Team',notnull = True,required = True,requires=IS_IN_DB(db, db.portal_team.id,'%(name)s')), ] i have an attached file where this what i want to happen upon registration Upon registration if i select *factory* *A *there are different *department *selections in the dropdown (dropdown.png) same as if i select *factory B *there are different *department *selections in the dropdown (dropdown2.png) this setup will just follow for *department *to *section *and *section *to *team* Thank you in advance for your help...More power to web2py -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] web2py on arch linux, for development and production
Hello! I've been developing with web2py in arch linux for some time now with no problem (just recall to run python2 web2py.py). It's a fine distro, and if you think it takes ages to install (it does), you can use manjaro linux which is basically archlinux preconfigured with very sensible choices (and xfce, of course (no flamewar intended ;-) )). Yesterday I had to reinstall a webapp, and found out that ovh offers arch linux for its vps, so I couldn't resist and tried to install web2py for production with nginx. As there is no deployment script, I looked at the other distros and translated as necessary. This is the log: - changing the package manager is as simple as always (but there is no build-essentials package, instead there's a collection called base-devel: pacman -S base-devel). - nginx and mariadb are pretty much the same everywhere, no problem there. However I liked the way ubuntu splits the nginx configuration into different sites, mimicking apache, so I borrowed the /etc/nginx from my earlier ubuntu server. - uwsgi compiles fine, install fine, but you have to write its own systemd unit. I was having a hard time configuring uwsgi.service (I had never done it) until I found the centos7 install script prepares a systemd unit, so I copied that one from there and it's working with minor changes. - archlinux has python=python3, so I have to adapt the deploy instructions here and there and change python for python2. - arch linux does less things by default, but I only recall having to edit /etc/locale.gen and then running locale-gen If there are more people interested, I can help them and eventually write a script, but I'm not an expert sysadmin and I prefer not to write a install script until someone else can proof read it. There's also the thing that the different install script for different distros have taken different choice for example for deploying uwsgi, and I don't have a clue which are best. For example, for ubuntu: [uwsgi] socket = /tmp/web2py.socket pythonpath = /home/www-data/web2py/ mount = /=wsgihandler:application processes = 4 master = true harakiri = 60 reload-mercy = 8 cpu-affinity = 1 stats = /tmp/stats.socket max-requests = 2000 limit-as = 512 reload-on-as = 256 reload-on-rss = 192 uid = www-data gid = www-data touch-reload = /home/www-data/web2py/routes.py cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o no-orphans = true but for centos7 [uwsgi] chdir = WEB2PY_PATH_PLACEHOLDER/WEB2PY_APP_PLACEHOLDER module = wsgihandler:application master = true processes = 5 uid = USERNAME_PLACEHOLDER socket = /run/uwsgi/WEB2PY_APP_PLACEHOLDER.sock chown-socket = USERNAME_PLACEHOLDER:nginx chmod-socket = 660 vacuum = true and I have the gutt feeling that does options in the ubuntu version of uwsgi.ini would be fine too for centos7, but damn if I know :-\ ! Another example: in the ubuntu install script it is possible to repackage all the static files whenever you call restart uwsgi-emperor That's a very good idea, isn't it? I've certainly grabbed that idea, so my uwsgi.service goes like this: [Unit] Description=uWSGI Emperor service [Service] ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown www-data:www-data /run/uwsgi; su www-data -c python2 /home/www-data/web2py/web2py.py -S YOUR_APP_HERE/appadmin -R scripts/zip_static_files.py' ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites Restart=always KillSignal=SIGQUIT Type=notify NotifyAccess=all [Install] WantedBy=multi-user.target -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
[web2py] Patch: LDAP AUTH TLS
I found that I was unable to authenticate to an OpenLDAP server running TLS on port 389 (which is the recommended way apparently). The following patch to ldap_auth.py fixes things for me; YMMV. Please add to upstream source if helpful. --- gluon/contrib/login_methods/ldap_auth.py.original 2015-07-31 23:22: 45.931751184 +0100 +++ gluon/contrib/login_methods/ldap_auth.py2015-07-31 23:19: 14.116922831 +0100 @@ -33,6 +33,7 @@ group_name_attrib='cn', group_member_attrib='memberUid', group_filterstr='objectClass=*', + tls=False, logging_level='error'): @@ -80,6 +81,13 @@ If ldap is using GnuTLS then you need cert_file=... instead cert_path because cert_path isn't implemented in GnuTLS :( +To enable TLS, set tls=True: + +auth.settings.login_methods.append(ldap_auth( +server='my.ldap.server', +base_dn='ou=Users,dc=domain,dc=com', +tls=True)) + If you need to bind to the directory with an admin account in order to search it then specify bind_dn bind_pw to use for this. - currently only implemented for Active Directory @@ -610,6 +618,8 @@ ldap_port = 389 con = ldap.initialize( ldap://; + ldap_server + : + str(ldap_port)) +if tls: +con.start_tls_s() return con def get_user_groups_from_ldap(username, -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.
Re: [web2py] Joined query help
What about table3 in your query? How is linked to table2? To see the generated sql you can use db(query)._select(...) On Thu, Jul 30, 2015 at 12:50 PM, Ian Ryder i.ry...@appichar.com.au wrote: Hi, I’m trying to construct a query in web2py which I’m struggling with - help appreciated :) Table 1 table1.batch_id Table 2 table2.table1 table2.table3 table2.amount Table 3 table3.name Query is roughly: select table3.name, sum(table2.amount), count(table2.table3) where table2.table1.batch_id = batch_x groupby table2.table3 Achievable without a subquery of table1s that have a batch_id of batch_x? I have this but not getting the results I’d like: query = db.table1.batch_id == batch_x query = db.table2.table1 == db.table1.id source_count = db.table2.id.count().with_alias(*'source_count'*) source_sum = db.tabel2.amount.sum().with_alias(*'source_sum'*) sources = db(query).select( db.table2.table3, db.table3.name, source_count, source_sum, groupby=db.table2.table3 ) Essentially the records are in a batch, but the batch is stamped on the parent record only. I need to count the children of the parent and get the details of the reference records on those children. Thanks Ian PS - the tables are more imaginatively named in reality, just simplified it for here :) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout. -- Massimiliano -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.