Re: [web2py] Re: To DAL or not to DAL, that is the question!
On 8 October 2011 17:19, Massimo Di Pierro massimo.dipie...@gmail.comwrote: Almost any query an be build using the dal. How would this type of postgresql-query be translated into DAL? WITH regional_sales AS ( SELECT region, SUM(amount) AS total_sales FROM orders GROUP BY region ), top_regions AS ( SELECT region FROM regional_sales WHERE total_sales (SELECT SUM(total_sales)/10 FROM regional_sales) ) SELECT region, product, SUM(quantity) AS product_units, SUM(amount) AS product_sales FROM orders WHERE region IN (SELECT region FROM top_regions) GROUP BY region, product; Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Re: [web2py:31163] Re: Custom form builder appliance?
On Wed, 16 Sep 2009 19:08:57 -0700 (PDT) mdipierro mdipie...@cs.depaul.edu wrote: No but it would be really nice. If done right the same code would be use to build tables (models) and forms. I know it's an old thread, but I hope you won't mind... Playing with Instant Press in order to move my 1st site from PHP CMS to Web2py, but I wonder if there is something done in regard to form builder which could help with creating forms or we should build 'em manually ? Sincerely, Gour -- “In the material world, conceptions of good and bad are all mental speculations…” (Sri Caitanya Mahaprabhu) http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 signature.asc Description: PGP signature
Re: [web2py] Re: Threads :-)
I found the solution, I was making it too complicated. Thank you for indirectly solving my problem. I moved the whol stuff to the cron job and make the frontend lean and mean. So no need anymore for threads the frontend. One question. when I run web2py in a cronjob can I use thread there ? Or is it also connected to the webserver ? Thanks for the response, There are two problems: - do not do print, breaks mod_wsgi - do not start threads from an action because the threads are controller by the web server and it may kill it. Good warnings. you should queue the task in database or cache and then run a background task Well actually its function is to queue tasks in redis so a cronjob can excute it. Well it seems I get errors while accessing the database File gluon/contrib/pymysql/connections.py, line 184, in defaulterrorhandler raise errorclass, errorvalue gluon.contrib.pymysql.err.InterfaceError: (0, '') . If pushing data to redis takes too long it defies the purpose of using redis. Well its collecting the data and combining it in redis that takes time. On Oct 9, 11:22 pm, Mike Veltman mike.velt...@gmail.com wrote: Ok, I need to push data in a redis database. And my problem is that it takes a while while the data is pushed in. So the screen would be waiting and a user would be irritated. My solution would be something like this. if framequeue.check_frame_lock() == False: if session.deployment == True: pass else: import thread print session.deployment print Running deployment thread.start_new_thread(default_frame_deployment,()) So the thread is running in the background and the page displays the log. But then I get gluon (database) errors in the functions. Any idea's or is there a better/ more elegant solution to this problem ? With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman
[web2py] Multi tenency in web2py
hi , i am developing the configurable system for four clients . i want the code should be deployed on the single instance and should support the diffrent features depending upon who is logged in...also there should be a single database for all the clients..in order to impliment multi tenecy i tried to use request.tenent in web2py...but as this will store only the first part of URL into the database and will create the namespace by same name...so to have this solved i had to deploy the code on diffrent instances but this is voilating my systems configurability...is there any solution by which i can have the code deployed on single version and have diffrent namespaces in database depending upon who is logged in ...also a client should not be able to view other clients data for security purpose.
[web2py] Webfaction and SMTP
Hi web2py users, does anybody use Webfaction as hosting and use Webfactions SMTP servers to send mail? What settings are you using? I can´t web2py to send mails from Webfaction. Kenneth
[web2py] Re: Flash message: You are being redirected a href=app_namehere/a
Sorry it took so long to get back. Been a crazy couple of days: This is my controller: @auth.requires_login() def index(): form = SQLFORM.factory( Field('partnumber', length=30, requires=IS_NOT_EMPTY()), Field('quantity', 'double', default=1, requires=IS_FLOAT_IN_RANGE(0.1, 100, error_message='Quantity must be greater than 0')), Field('required_date', 'date', requires=IS_NOT_EMPTY()), Field('drawing', 'upload', uploadfolder=drawing_folder), table_name = 'rfq_item' ) if form.accepts(request): try: add_partnumber(form.vars.partnumber, form.vars.quantity, form.vars.required_date, form.vars.drawing) form.vars = Storage() session.flash = 'Part added' redirect(URL('index')) except HTTP as e: response.flash = e.body elif form.errors: output = '' for k, v in form.errors.items(): output += '%s: %s\n' % (k, v) response.flash = output query = db.batch.auth_user==auth.user.id toolbar = 'a href=# class=button suppliersSuppliers/aa href=# class=button create_rfqCreate RFQ/a' table = plugin_datatable(query, selectable=True, deletable=True, updatable=True, toolbar=toolbar) response.title = 'New RFQ' return dict(form=form, table=table) Basically, I have a view with a data table, and a form to add another item to the table. When the form is submitted, it adds the item, then has to do a redirect to itself to avoid the confirm form resubmission message when the page is refreshed after submitting the form.
[web2py] Re: Debug web2py service?
I used Python's PDB extensively. I develop a couple of JSONRPC/XMLRPC services with no GUI on web2py and logging helps, but sometimes you just need to step through the code. Anywhere I need the Python code to break execution, I just put in this line: import pdb; pdb.set_trace() Then you are given a Python console where you can print out variables. Then enter 'n' to execute the next line, 's' to step in to the next line, and 'c' to continue execution. PDB has saved me quite a lot of time tracking down bugs.
Re: Re : Re: [web2py] Re: fluxflex
thanks a lot Marin, I've missed this change in generic.html On 7 Ott, 12:06, Marin Pranjić marin.pran...@gmail.com wrote: https://groups.google.com/forum/#!msg/web2py/26g9XA_0ZXE/4yiIHs5FivkJhttp://groups.google.com/group/web2py/browse_thread/thread/485ee82885... It is related to security issue described above. Regards, Marin On Oct 7, 11:26 am, kralin andrea.pierle...@gmail.com wrote: I've been testing the web2py-for-fluxflex github forking approach and it works very well. however there is one problem when I deploy to fluxflex all the views that goes through generic.html gets 404 error. I'm using the 1.99.2 web2py version. maybe this is related to routes, but I don't have access to the web2py installation on fluxflex... any idea?
[web2py] Check to establish whether or not a record exists
Hi list, I have a database table which looks like this: postcode_cache postcode (UNIQUE) lat lon nearest I want to test first whether or not a record exists for 'postcode' and if a record does exist, I want to check whether the 'nearest' field contains any data. I've tried this: if db(db.postcode_cache.postcode==postcode).select().first()==None: create_a_new_postcode_record() elif db(db.postcode_cache.postcode==postcode).select(db.postcode_cache.nearest)==None: populate_the_nearest_field() else: nothing_to_do() And while the check to establish whether or not a record exists seems to work, the check to see whether or not the 'nearest' field within the record is populated doesn't seem to work. Can anyone tell me what I'm doing wrong please? Thank you, Chris
Re: [web2py] Webfaction and SMTP
in db.py mail.settings.server = 'smtp.webfaction.com' mail.settings.sender = 'some email of yours' mail.settings.login = 'user:pwd' # your webfaction name and password, you may change the password for mailboxes from webfaction panel then from controllers mail.send(to=['y...@whatever.com'], subject='Web2py email', message='Sent with Web2py!') just tested and works
[web2py] Re: To DAL or not to DAL, that is the question!
You cannot. The DAL does not support the WITH statement. You have to use db.executesql On Oct 10, 1:55 am, Johann Spies johann.sp...@gmail.com wrote: On 8 October 2011 17:19, Massimo Di Pierro massimo.dipie...@gmail.comwrote: Almost any query an be build using the dal. How would this type of postgresql-query be translated into DAL? WITH regional_sales AS ( SELECT region, SUM(amount) AS total_sales FROM orders GROUP BY region ), top_regions AS ( SELECT region FROM regional_sales WHERE total_sales (SELECT SUM(total_sales)/10 FROM regional_sales) ) SELECT region, product, SUM(quantity) AS product_units, SUM(amount) AS product_sales FROM orders WHERE region IN (SELECT region FROM top_regions) GROUP BY region, product; Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Re: Threads :-)
On Oct 10, 2:54 am, Mike Veltman mike.velt...@gmail.com wrote: I found the solution, I was making it too complicated. Thank you for indirectly solving my problem. I moved the whol stuff to the cron job and make the frontend lean and mean. So no need anymore for threads the frontend. One question. when I run web2py in a cronjob can I use thread there ? Or is it also connected to the webserver ? yes you can. Thanks for the response, There are two problems: - do not do print, breaks mod_wsgi - do not start threads from an action because the threads are controller by the web server and it may kill it. Good warnings. you should queue the task in database or cache and then run a background task Well actually its function is to queue tasks in redis so a cronjob can excute it. Well it seems I get errors while accessing the database File gluon/contrib/pymysql/connections.py, line 184, in defaulterrorhandler raise errorclass, errorvalue gluon.contrib.pymysql.err.InterfaceError: (0, '') . If pushing data to redis takes too long it defies the purpose of using redis. Well its collecting the data and combining it in redis that takes time. On Oct 9, 11:22 pm, Mike Veltman mike.velt...@gmail.com wrote: Ok, I need to push data in a redis database. And my problem is that it takes a while while the data is pushed in. So the screen would be waiting and a user would be irritated. My solution would be something like this. if framequeue.check_frame_lock() == False: if session.deployment == True: pass else: import thread print session.deployment print Running deployment thread.start_new_thread(default_frame_deployment,()) So the thread is running in the background and the page displays the log. But then I get gluon (database) errors in the functions. Any idea's or is there a better/ more elegant solution to this problem ? With regards, Mike Veltman With regards, Mike Veltman With regards, Mike Veltman
[web2py] Grid and links
I like the new grid/smartgrid a lot, but when you have many linked tables the grid appears a little bit cluttered. What do you think of an option that hide all links/buttons (but not detail button) from the grid, but show them on the detail view? Thank you -- Massimiliano
[web2py] Re: Multi tenency in web2py
http://web2py.com/book/default/chapter/06?search=tenant On Oct 10, 5:09 am, Saurabh S ggtestlo...@gmail.com wrote: hi , i am developing the configurable system for four clients . i want the code should be deployed on the single instance and should support the diffrent features depending upon who is logged in...also there should be a single database for all the clients..in order to impliment multi tenecy i tried to use request.tenent in web2py...but as this will store only the first part of URL into the database and will create the namespace by same name...so to have this solved i had to deploy the code on diffrent instances but this is voilating my systems configurability...is there any solution by which i can have the code deployed on single version and have diffrent namespaces in database depending upon who is logged in ...also a client should not be able to view other clients data for security purpose.
[web2py] Re: Check to establish whether or not a record exists
row = db.postcode_cache(postcode=postcode) if not row: db.postcode_cache.insert(postcode=postcode,nearset=nearest) elif not row.nearest: row.update_record(nearset=nearest) else: pass # do nothing On Oct 10, 8:22 am, Chris Rowson christopherrow...@gmail.com wrote: Hi list, I have a database table which looks like this: postcode_cache postcode (UNIQUE) lat lon nearest I want to test first whether or not a record exists for 'postcode' and if a record does exist, I want to check whether the 'nearest' field contains any data. I've tried this: if db(db.postcode_cache.postcode==postcode).select().first()==None: create_a_new_postcode_record() elif db(db.postcode_cache.postcode==postcode).select(db.postcode_cache.nearest)= =None: populate_the_nearest_field() else: nothing_to_do() And while the check to establish whether or not a record exists seems to work, the check to see whether or not the 'nearest' field within the record is populated doesn't seem to work. Can anyone tell me what I'm doing wrong please? Thank you, Chris
[web2py] Re: Grid and links
def grid(query, fields=None, field_id=None, left=None, headers={}, columns=None, orderby=None, searchable=True, sortable=True, paginate=20, deletable=True, editable=True, details=True, selectable=None, create=True, csv=True, links=None, upload = 'default', args=[], user_signature = True, maxtextlengths={}, maxtextlength=20, onvalidation=None, oncreate=None, onupdate=None, ondelete=None, sorter_icons=('[^]','[v]'), ui = 'web2py', showbuttontext=True, _class=web2py_grid, formname='web2py_grid', search_widget='default', ) Many of the options are True/False and you can switch them off. The smartgrid has the same arguments but they are dictionaries for example: SQLFORM.grid(db.mytable, editable=False) SQLFORM.smartgrid([db.mytable], editable = {'mytable',False}) On Oct 10, 8:52 am, Massimiliano mbelle...@gmail.com wrote: I like the new grid/smartgrid a lot, but when you have many linked tables the grid appears a little bit cluttered. What do you think of an option that hide all links/buttons (but not detail button) from the grid, but show them on the detail view? Thank you -- Massimiliano
Re: [web2py] Re: Check to establish whether or not a record exists
Thank you Massimo :-) Chris On Mon, Oct 10, 2011 at 2:55 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: row = db.postcode_cache(postcode=postcode) if not row: db.postcode_cache.insert(postcode=postcode,nearset=nearest) elif not row.nearest: row.update_record(nearset=nearest) else: pass # do nothing On Oct 10, 8:22 am, Chris Rowson christopherrow...@gmail.com wrote: Hi list, I have a database table which looks like this: postcode_cache postcode (UNIQUE) lat lon nearest I want to test first whether or not a record exists for 'postcode' and if a record does exist, I want to check whether the 'nearest' field contains any data. I've tried this: if db(db.postcode_cache.postcode==postcode).select().first()==None: create_a_new_postcode_record() elif db(db.postcode_cache.postcode==postcode).select(db.postcode_cache.nearest)= =None: populate_the_nearest_field() else: nothing_to_do() And while the check to establish whether or not a record exists seems to work, the check to see whether or not the 'nearest' field within the record is populated doesn't seem to work. Can anyone tell me what I'm doing wrong please? Thank you, Chris
[web2py] IE9
When I use IE9 to access admin and edit any file in an app, the contents of the editor window are all highlighted and there's no way to get out of it. This makes editing impossible. Has anyone else found this? Not that it really matters to me because I just use Chrome or Firefox, instead. But for any newbie who installs the Win32 web2py, IE9 will start automatically, and this is bound to be confusing. Richard
[web2py] Re: Flash message: You are being redirected a href=app_namehere/a
redirect() works by raising an HTTP exception, so I think the redirect in your try is triggering your except, so it ends up flashing the response body of the redirect. Why are you catching HTTP exceptions -- is anything in your try likely to trigger an HTTP? Anthony On Monday, October 10, 2011 8:11:04 AM UTC-4, Ross Peoples wrote: Sorry it took so long to get back. Been a crazy couple of days: This is my controller: @auth.requires_login() def index(): form = SQLFORM.factory( Field('partnumber', length=30, requires=IS_NOT_EMPTY()), Field('quantity', 'double', default=1, requires=IS_FLOAT_IN_RANGE(0.1, 100, error_message='Quantity must be greater than 0')), Field('required_date', 'date', requires=IS_NOT_EMPTY()), Field('drawing', 'upload', uploadfolder=drawing_folder), table_name = 'rfq_item' ) if form.accepts(request): try: add_partnumber(form.vars.partnumber, form.vars.quantity, form.vars.required_date, form.vars.drawing) form.vars = Storage() session.flash = 'Part added' redirect(URL('index')) except HTTP as e: response.flash = e.body elif form.errors: output = '' for k, v in form.errors.items(): output += '%s: %s\n' % (k, v) response.flash = output query = db.batch.auth_user==auth.user.id toolbar = 'a href=# class=button suppliersSuppliers/aa href=# class=button create_rfqCreate RFQ/a' table = plugin_datatable(query, selectable=True, deletable=True, updatable=True, toolbar=toolbar) response.title = 'New RFQ' return dict(form=form, table=table) Basically, I have a view with a data table, and a form to add another item to the table. When the form is submitted, it adds the item, then has to do a redirect to itself to avoid the confirm form resubmission message when the page is refreshed after submitting the form.
[web2py] Re: IE9
Yes, the default editor does not work on IE9. It's usable in IE7/IE8, though with an odd highlighting quirk. In IE9, you can switch to compatibility mode, or there is a toggle editor option that changes the editor to a regular text area (so no syntax highlighting). There's an alternative Amy editor that requires a one line change in a model file, and that does work in IE9 (but not IE9) -- maybe we should make that the default in IE9. Anthony On Monday, October 10, 2011 10:09:38 AM UTC-4, horridohobbyist wrote: When I use IE9 to access admin and edit any file in an app, the contents of the editor window are all highlighted and there's no way to get out of it. This makes editing impossible. Has anyone else found this? Not that it really matters to me because I just use Chrome or Firefox, instead. But for any newbie who installs the Win32 web2py, IE9 will start automatically, and this is bound to be confusing. Richard
[web2py] Re: Flash message: You are being redirected a href=app_namehere/a
I didn't think about the try/except. The add_partnumber method will throw an HTTP exception if something fails, so that's why I was catching it. I moved the redirect() outside of the try/except and it is working as expected now. Thanks for catching that!
Re: [web2py] Re: Threads :-)
On Oct 10, 2011, at 6:51 AM, Massimo Di Pierro wrote: On Oct 10, 2:54 am, Mike Veltman mike.velt...@gmail.com wrote: I found the solution, I was making it too complicated. Thank you for indirectly solving my problem. I moved the whol stuff to the cron job and make the frontend lean and mean. So no need anymore for threads the frontend. One question. when I run web2py in a cronjob can I use thread there ? Or is it also connected to the webserver ? yes you can. Except for softcron, presumably?
[web2py] Re: Threads :-)
oops. true. On Oct 10, 9:30 am, Jonathan Lundell jlund...@pobox.com wrote: On Oct 10, 2011, at 6:51 AM, Massimo Di Pierro wrote: On Oct 10, 2:54 am, Mike Veltman mike.velt...@gmail.com wrote: I found the solution, I was making it too complicated. Thank you for indirectly solving my problem. I moved the whol stuff to the cron job and make the frontend lean and mean. So no need anymore for threads the frontend. One question. when I run web2py in a cronjob can I use thread there ? Or is it also connected to the webserver ? yes you can. Except for softcron, presumably?
Re: [web2py] Re: Grid and links
Thank you Massimo, I'm aware of that. I was just looking for a way to show all buttons but detail only in the detail view (the one generated from the grid) and not in the table view. -- Massimiliano On Mon, Oct 10, 2011 at 3:58 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: def grid(query, fields=None, field_id=None, left=None, headers={}, columns=None, orderby=None, searchable=True, sortable=True, paginate=20, deletable=True, editable=True, details=True, selectable=None, create=True, csv=True, links=None, upload = 'default', args=[], user_signature = True, maxtextlengths={}, maxtextlength=20, onvalidation=None, oncreate=None, onupdate=None, ondelete=None, sorter_icons=('[^]','[v]'), ui = 'web2py', showbuttontext=True, _class=web2py_grid, formname='web2py_grid', search_widget='default', ) Many of the options are True/False and you can switch them off. The smartgrid has the same arguments but they are dictionaries for example: SQLFORM.grid(db.mytable, editable=False) SQLFORM.smartgrid([db.mytable], editable = {'mytable',False}) On Oct 10, 8:52 am, Massimiliano mbelle...@gmail.com wrote: I like the new grid/smartgrid a lot, but when you have many linked tables the grid appears a little bit cluttered. What do you think of an option that hide all links/buttons (but not detail button) from the grid, but show them on the detail view? Thank you -- Massimiliano -- Massimiliano
[web2py] Re: Grid and links
You cannot, but open a ticket and we may add a flag for that. On Oct 10, 9:35 am, Massimiliano mbelle...@gmail.com wrote: Thank you Massimo, I'm aware of that. I was just looking for a way to show all buttons but detail only in the detail view (the one generated from the grid) and not in the table view. -- Massimiliano On Mon, Oct 10, 2011 at 3:58 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: def grid(query, fields=None, field_id=None, left=None, headers={}, columns=None, orderby=None, searchable=True, sortable=True, paginate=20, deletable=True, editable=True, details=True, selectable=None, create=True, csv=True, links=None, upload = 'default', args=[], user_signature = True, maxtextlengths={}, maxtextlength=20, onvalidation=None, oncreate=None, onupdate=None, ondelete=None, sorter_icons=('[^]','[v]'), ui = 'web2py', showbuttontext=True, _class=web2py_grid, formname='web2py_grid', search_widget='default', ) Many of the options are True/False and you can switch them off. The smartgrid has the same arguments but they are dictionaries for example: SQLFORM.grid(db.mytable, editable=False) SQLFORM.smartgrid([db.mytable], editable = {'mytable',False}) On Oct 10, 8:52 am, Massimiliano mbelle...@gmail.com wrote: I like the new grid/smartgrid a lot, but when you have many linked tables the grid appears a little bit cluttered. What do you think of an option that hide all links/buttons (but not detail button) from the grid, but show them on the detail view? Thank you -- Massimiliano -- Massimiliano
[web2py] Storage {'region': lazyT 'no match 2 digits'}
I have a form containing the following validator: requires=IS_MATCH('\d{2}',error_message='no match 2 digits') When the user violates this constraint an error message is being displayed, however, this is written in the terminal: Storage {'region': lazyT 'no match 2 digits'} Why is that? Can I prevent this from happening in the production environment? Kind regards, Annet.
[web2py] Import/execute sql file
Until now i did all my db queries with the DAL from web2py. But first the first i now got a raw sql file that needs to be execute at a certain point. In the terminal i use the '\i' command to import and execute a sql script. If i try to use this with db.executesql(\i /path/to/file.sql) i get an error: = CESTERROR: syntax error at or near \ at character 1 . Escaping the character \\i doesn't help, still got the same error. Using psql from the system() call doesn't help (i don't have i currently installed =] ). Does someone ever came across this problem before?
[web2py] Re: Import/execute sql file
Calls are not executed with the psql command, they are done with psycopg2. You could try a subprocess.POpen call: import subprocess ... sp = subprocess.POpen(psql {insert remainder of command line here}, shell=True) For more on the options of the subprocess module: http://docs.python.org/library/subprocess.html
[web2py] Re: date picker on v1.99
The behavior of the date picker seems to have changed from a certain version. For now, we should apply a patch to the anytime.js: 545 - this.showPkr(null);event.preventDefault();},keyAhead:function() 545 + return;event.preventDefault();},keyAhead:function() [for readable version (http://www.ama3.com/anytime/AnyTime/ anytime.js)] 2696 - this.showPkr(null); 2696 + return; I think it is critical since it is difficult to turn the input back to empty. Regards, Kenji On 10月10日, 午前11:45, Nik Go nikolai...@gmail.com wrote: manual entry doesn't work on the ff browsers: - Chromium 15.0.871.0 - Epiphany/GNOME Web Browser 2.30.2 - Mozilla Firefox 3.6.22 I'm running ubuntu 10.04 On Friday, October 7, 2011, Massimo Di Pierro wrote: Which browser? When I tried it, if I remember, I was able to type. On Oct 6, 8:48 pm, niknok nikolai...@gmail.com javascript:; wrote: The new date picker looks very good. Is there a way to input dates by typing it directly (similar to default behaviour in older versions), in addition to selecting dates thru the calendar interface? /r Nik P.S. Though I couldn't type in a date, I could paste one. (which is a behavior I don't expect from users)
[web2py] Re: Google Cloud SQL
re the image application: my recommendation is use blobstore for the images. then you can use the google high-performance image serving URL (which last i checked both is faster than anything you can do directly and cheaper). That serves your images then using the same technology as picassa (i believe) cfh
Re: [web2py] Webfaction and SMTP
Many thanks Vasile, I´m 100% sure I tested the same setting many times before, but no luck. Now I copied your settings and voila it works. It´s sometimes so frustrating to search for errors and after hours of searching it just works without finding what was wrong. But I guess thats the life of a programmer. Kenneth in db.py mail.settings.server = 'smtp.webfaction.com http://smtp.webfaction.com' mail.settings.sender = 'some email of yours' mail.settings.login = 'user:pwd' # your webfaction name and password, you may change the password for mailboxes from webfaction panel then from controllers mail.send(to=['y...@whatever.com mailto:y...@whatever.com'], subject='Web2py email', message='Sent with Web2py!') just tested and works
[web2py] migration fails when modifying field with notnull=True
I've an existing table: db.define_table('service_type', Field('cost_car_km', 'decimal(7,2)', notnull=True), ...) there is already some data in the table. Now I changed the field to Field('cost_car_km', 'decimal(7,3)', notnull=True), the next time I try to call a page I get this error: IntegrityError: FEHLER: Spalte »cost_car_km__tmp« enthält NULL-Werte the sql.log contains this line: ALTER TABLE service_type ADD cost_car_km__tmp NUMERIC(7,3) NOT NULL; I'm using PostgreSQL, Win 7 and web2py 1.99.2. Am I doing something wrong because this happens quite often for me when I change a field for a table containing data? To solve it I manually change the column in the database, delete the .table file in the databases folder and set fake_migrate=True for this table (and later remove it again).
[web2py] Re: migration fails when modifying field with notnull=True
Specify a default value for the field, there may be NULLs in that column right now, which violates the NULL contraint you are adding to the table. Perhaps 0 would make a good default for your field.
Re: [web2py] Re: To DAL or not to DAL, that is the question!
Web2py DAL is Freaking Best Piece of Software Ever come into existance :) ! Use it , You Must! On Sat, Oct 8, 2011 at 9:54 PM, Chris Rowson christopherrow...@gmail.comwrote: Thanks Massimo, I'm very new at this and found the DAL a bit intimidating. I'm beginning to get the hang of it now though so I'm sticking with it. I think I was trying to overthink it before when in actual fact, the more I try and get my head around it, the more sense it makes. Chris On Sat, Oct 8, 2011 at 4:19 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You don't mind to write engine specific queries but who is going to use your app will mind because the app is not going to be portable. Almost any query an be build using the dal. Massimo On Oct 8, 6:20 am, Chris Rowson christopherrow...@gmail.com wrote: Call me wierd, but I'm finding it a little hard to get my head around putting together select statements using the DAL. I think I must just be having a stupid couple of weeks! I understand that using the DAL SQLFORM etc for inserts will help protect me against SQL Injection so I'm happy to keep on doing that, but is there any particular reason I shouldn't just use db.executesql to perform my selects (because I find it easier)? I also understand that raw SQL queries are database specific but I don't mind, as I don't intend to move databases. Chris
[web2py] Re: date picker on v1.99
Can you please email me the patch? On Oct 10, 11:35 am, kenji4569 hos...@s-cubism.jp wrote: The behavior of the date picker seems to have changed from a certain version. For now, we should apply a patch to the anytime.js: 545 - this.showPkr(null);event.preventDefault();},keyAhead:function() 545 + return;event.preventDefault();},keyAhead:function() [for readable version (http://www.ama3.com/anytime/AnyTime/ anytime.js)] 2696 - this.showPkr(null); 2696 + return; I think it is critical since it is difficult to turn the input back to empty. Regards, Kenji On 10月10日, 午前11:45, Nik Go nikolai...@gmail.com wrote: manual entry doesn't work on the ff browsers: - Chromium 15.0.871.0 - Epiphany/GNOME Web Browser 2.30.2 - Mozilla Firefox 3.6.22 I'm running ubuntu 10.04 On Friday, October 7, 2011, Massimo Di Pierro wrote: Which browser? When I tried it, if I remember, I was able to type. On Oct 6, 8:48 pm, niknok nikolai...@gmail.com javascript:; wrote: The new date picker looks very good. Is there a way to input dates by typing it directly (similar to default behaviour in older versions), in addition to selecting dates thru the calendar interface? /r Nik P.S. Though I couldn't type in a date, I could paste one. (which is a behavior I don't expect from users)
Re: [web2py] Re: To DAL or not to DAL, that is the question!
Is it possible to support with? On Mon, Oct 10, 2011 at 8:21 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You cannot. The DAL does not support the WITH statement. You have to use db.executesql On Oct 10, 1:55 am, Johann Spies johann.sp...@gmail.com wrote: On 8 October 2011 17:19, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Almost any query an be build using the dal. How would this type of postgresql-query be translated into DAL? WITH regional_sales AS ( SELECT region, SUM(amount) AS total_sales FROM orders GROUP BY region ), top_regions AS ( SELECT region FROM regional_sales WHERE total_sales (SELECT SUM(total_sales)/10 FROM regional_sales) ) SELECT region, product, SUM(quantity) AS product_units, SUM(amount) AS product_sales FROM orders WHERE region IN (SELECT region FROM top_regions) GROUP BY region, product; Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
[web2py] Re: migration fails when modifying field with notnull=True
As shown in the example above the field already had a notnull=True constraint so there were no NULLs in the existing rows. But nevertheless it works with a default value, thanks! It seems that a default value is needed for the migration process by web2py. Is this true?
[web2py] Re: migration fails when modifying field with notnull=True
I can't say for sure, sorry. Given the error comes from PostgreSQL (IntegrityError), I'd wager it's probably a PostgreSQL thing.
[web2py] SQLFORM and IS_IN_SET problem
This is the field def: Field('status', 'list:string'), then: db.mytable.status.requires = IS_IN_SET( {'n': 'New', 'I':'In process', 'C':'Complete'}, zero = 'Choose' ) When editing, SQLFORM shows the zero choice when on opening. The choices display correctly and can be changed. On the next go round, it shows the zero choice again. When viewing the object (readonly=True), SQLFORM shows the dictionary key, not the value. In other words, it will pick up the 'C' rather than showing 'Complete' I don't think it should matter, but because I'm using a generic form I call SQLFORM this way: return response.render(form=SQLFORM(db.mytable, request.args(0)), h1=Edit) Appadmin does the same thing and complains if I don't change the zero value to a value in the dictionary.
[web2py] Re: SQLFORM and IS_IN_SET problem
Since 'status' is a list:string field, why not set multiple=True? IS_IN_SET(..., multiple=True) Anthony On Monday, October 10, 2011 2:45:48 PM UTC-4, Cliff wrote: This is the field def: Field('status', 'list:string'), then: db.mytable.status.requires = IS_IN_SET( {'n': 'New', 'I':'In process', 'C':'Complete'}, zero = 'Choose' ) When editing, SQLFORM shows the zero choice when on opening. The choices display correctly and can be changed. On the next go round, it shows the zero choice again. When viewing the object (readonly=True), SQLFORM shows the dictionary key, not the value. In other words, it will pick up the 'C' rather than showing 'Complete' I don't think it should matter, but because I'm using a generic form I call SQLFORM this way: return response.render(form=SQLFORM(db.mytable, request.args(0)), h1=Edit) Appadmin does the same thing and complains if I don't change the zero value to a value in the dictionary.
[web2py] How to add more buttons to form that submits form to different actions ...
I would like to use concept of shared form (http://web2py.com/book/default/chapter/07#Sharing-Forms) and I want to have a more submit buttons, each to different action on controller. How can I sinmply make a more buttons each submiting form to different action.
[web2py] DAL level access to GAE entities by named key
Is there a way to use DAL to make a GAE query by entity name (not just numeric id)? I remember a discussion on the list about GAE keys with parents and a proposed patch for DAL to be able to pass GAE Key instead of if id. I see this implemented in the DAL code: http://code.google.com/p/web2py/source/browse/gluon/dal.py#3349 So, I was expecting something as simple as this to work: id = request.args[0] key = Key.from_path(data, label:+id) entity = db.data[key] But it doesn't. Neither do other variants of a DAL query: entity = db(db.data.id == key).select().first() entity = db.data(key) Only the direct reference to GAE worked: from google.appengine.ext import db as gae entity = gae.get(key) Do I expect too much and the access by GAE Key is not possible with DAL or this should work and can be fixed?
Re: [web2py] Re: Help for creating template
with {{=request.url}} i will get /some/my/url/address but when I tray next example it is not working: {{ myurl = request.url: i = /some/my/url/address: if i == myurl: response.writ('my first HTML output') else: response.write('my other HTML output') pass }} how to resolve this, I need one part layout.htm to be different for index page than an other pages, is there some other solutions - - Miroslav Gojic - - On Sun, Oct 9, 2011 at 13:22, Anthony abasta...@gmail.com wrote: On Sunday, October 9, 2011 1:56:18 AM UTC-4, miroslavgojic wrote: What if I need more than one menu. Usually I have 2 or 3 menus (top, bottom, and side) Can I do someting like this: in controller var1 = (response http://web2py.com/book/default/docstring/response.menu =(...)) var2 = (response http://web2py.com/book/default/docstring/response.menu =(...)) No, that won't work (not correct Python). But you don't have to use response.menu at all -- it's just a convenience. MENU() takes any list of tuples, so you could do: menu1 = [...] menu2 = [...] Note, in that case, you would have to define menu1 and menu2 in a model file (which is where response.menu is often set anyway) so they will be available in all controllers and views. Alternatively, you could make response.menu either a list or dictionary of menus: response.menu = {} response.menu['menu1'] = [...] response.menu['menu2'] = [...] and then call MENU(response.menu['menu1']), etc. Anthony in layout {{=MENU(var1,_class='sf-menu')**}} {{=MENU(var2,_class='sf-menu')**}} - - Miroslav Gojic - - On Fri, Oct 7, 2011 at 22:07, Anthony abas...@gmail.com wrote: See http://web2py.com/book/**default/chapter/05#Custom-**Helpershttp://web2py.com/book/default/chapter/05#Custom-Helpersfor details on using the MENU helper. You can see an example of using it in conjunction with Superfish (which is a Javascript library that turns the list structure generated by MENU into a dynamic menu) in the 'welcome' app: http://code.google.com/p/**web2py/source/browse/** applications/welcome/views/**layout.html#102http://code.google.com/p/web2py/source/browse/applications/welcome/views/layout.html#102 Anthony On Friday, October 7, 2011 3:08:37 PM UTC-4, miroslavgojic wrote: this is my controller from gluon.tools import Crud crud = Crud(db) def index(): form=SQLFORM(db.poruke,fields=['poruka','post_author']) if form.accepts(request.vars,**sess**ion): session.flash=new post accepted! redirect(URL(r=request)) poruke=db().select(db.poruke.**A**LL) return dict(form=form,poruke=poruke) def people(): crud.settings.formstyle = ('divs') form = crud.create(db.person,next=**URL**('people'),message=T(**record created)) persons = crud.select(db.person,fields=['name'],headers={'name': 'Name'}) return dict(form = form,persons=persons) def user(): auth.settings.formstyle = ('divs') return dict(form=auth()) this is my layout !DOCTYPE html html head titleWeb2Py/title /head body {{try:}}{{=auth.navbar(action=URL('default','user'))}}{{**exce* *pt:pass}}br / {{include}} div class=sidebar {{block mysidebar}} default sidebar {{end}} /div div class=ez-box id=footer {{=T('Copyright')}} © 2010 - {{=T('Powered by')}} a href=http://www.web2py.com;**w** eb2py/a /div /body /html this is my view {{extend 'layout.html'}} {{for poruke in poruke:}} {{if poruke.post_author:}} {{=poruke.post_author}} says {{=poruke.poruka}} br / {{else:}} Anonymous says {{=poruke.poruka}}br / {{pass}} {{pass}} {{=form}} {{include 'test.html'}} {{block mysidebar}} my block {{end}} How t make implementation of response http://web2py.com/book/default/docstring/response.menu = [('Google', False, 'http://www.google.com',[]), ('Index', True, URL http://web2py.com/book/default/docstring/URL('index'), [])] * * - - Miroslav Gojic - - On Fri, Oct 7, 2011 at 18:58, Anthony aba...@gmail.com wrote: On Friday, October 7, 2011 1:31:08 AM UTC-4, miroslavgojic wrote: Thanks for blocks - that work, this is similar to modules in joomla, I can write small block and get content on specific place at layout. I tray to use next code: response http://web2py.com/book/default/docstring/response.menu = [('Google', False, 'http://www.google.com',[]), ('Index', True, URL http://web2py.com/book/default/docstring/URL('index'), [])] but without any success. I reed in book that mentioned code I must put in controller but how to get same than in layout and does in controller I must use definition or haw. Can you show the relevant controller and view code related to the menu? What do you expect to see, and what do you actually see? Note, typically you would pass response.menu to the MENU()
[web2py] Re: checkbox input default value
Are you using list:string? Can you post the relevant parts of your model and controller?
[web2py] Re: SQLFORM and IS_IN_SET problem
Anthony, I don't want multiple values. I just want one of those values. Is IS_IN_SET the incorrect way to do what I want. On Oct 10, 2:52 pm, Anthony abasta...@gmail.com wrote: Since 'status' is a list:string field, why not set multiple=True? IS_IN_SET(..., multiple=True) Anthony On Monday, October 10, 2011 2:45:48 PM UTC-4, Cliff wrote: This is the field def: Field('status', 'list:string'), then: db.mytable.status.requires = IS_IN_SET( {'n': 'New', 'I':'In process', 'C':'Complete'}, zero = 'Choose' ) When editing, SQLFORM shows the zero choice when on opening. The choices display correctly and can be changed. On the next go round, it shows the zero choice again. When viewing the object (readonly=True), SQLFORM shows the dictionary key, not the value. In other words, it will pick up the 'C' rather than showing 'Complete' I don't think it should matter, but because I'm using a generic form I call SQLFORM this way: return response.render(form=SQLFORM(db.mytable, request.args(0)), h1=Edit) Appadmin does the same thing and complains if I don't change the zero value to a value in the dictionary.
[web2py] Re: To DAL or not to DAL, that is the question!
Open a ticket. It is not going to happen today but we are committed to make DAL more and more powerful. On Oct 10, 1:17 pm, Phyo Arkar phyo.arkarl...@gmail.com wrote: Is it possible to support with? On Mon, Oct 10, 2011 at 8:21 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You cannot. The DAL does not support the WITH statement. You have to use db.executesql On Oct 10, 1:55 am, Johann Spies johann.sp...@gmail.com wrote: On 8 October 2011 17:19, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Almost any query an be build using the dal. How would this type of postgresql-query be translated into DAL? WITH regional_sales AS ( SELECT region, SUM(amount) AS total_sales FROM orders GROUP BY region ), top_regions AS ( SELECT region FROM regional_sales WHERE total_sales (SELECT SUM(total_sales)/10 FROM regional_sales) ) SELECT region, product, SUM(quantity) AS product_units, SUM(amount) AS product_sales FROM orders WHERE region IN (SELECT region FROM top_regions) GROUP BY region, product; Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a
Re: [web2py] Re: SQLFORM and IS_IN_SET problem
On Mon, Oct 10, 2011 at 5:38 PM, Cliff cjk...@gmail.com wrote: Anthony, I don't want multiple values. I just want one of those values. If you want only one value, why are you using list:string? change to Field('status', 'string'),
[web2py] Re: Windows + Apache + mod_proxy
Paolo, I finished the setting and access http://ochiba-183(My PC Name) but it shows the default index.php under www and not web2py. d4 - open %WINDOWS%\system32\drivers\etc\hosts file and add the alias 127.0.0.1 web2py.localhost. Replace server's IP to 127.0.0.1 and access to web2py from not localhost; d5 - start UniServer, now you can access to web2py inserting web2py.localhost in address bar of your browser. I wasn't sure this part, so I just add 127.0.0.1 ochiba-183 to my hosts. Do you know what I'm doing wrong ? The following is my vhost_web2py.conf which is included by httpd.conf. ##VIRTUAL HOST SETUP## # WEB2PY.LOCALHOST VirtualHost 10.30.6.122:80 ServerName ochiba-183:80 DocumentRoot F:/UniServer/www/web2py WSGIScriptAlias / F:/UniServer/www/web2py/wsgihandler.py ServerAdmin ad...@gmail.com # static files do not need WSGI LocationMatch ^(/[\w_]*/static/.*) Order Allow,Deny Allow from all /LocationMatch # everything else goes to web2py via wsgi Location / Order deny,allow Allow from all /Location # Log. Can be disabled LogFormat %h %l %u %t \%r\ %s %b common LogLevel notice CustomLog F:/UniServer/tmp/web2py.access.log common ErrorLog F:/UniServer/tmp/web2py.error.log /VirtualHost # VirtualHost 10.30.6.122:443 ServerName ochiba-183:443 ServerAdmin ad...@gmail.com DocumentRoot F:/UniServer/www/web2py WSGIScriptAlias / F:/UniServer/www/web2py/wsgihandler.py # static files do not need WSGI LocationMatch ^(/[\w_]*/static/.*) Order Allow,Deny Allow from all /LocationMatch Location / Order deny,allow Allow from all /Location Directory F:/UniServer/www/web2py Order allow,deny Deny from all /Directory LogFormat %h %l %u %t \%r\ %s %b common LogLevel notice CustomLog F:/UniServer/tmp/web2py.access.log common ErrorLog F:/UniServer/tmp/web2py.error.log SSLEngine on SSLProtocol -all +TLSv1 +SSLv3 SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM SSLCertificateFile F:/UniServer/usr/local/apache2/conf/ssl.crt/ server.crt SSLCertificateKeyFile F:/UniServer/usr/local/apache2/conf/ssl.key/ server.key SetEnvIf User-Agent .*MSIE.* \ #nokeepalive ssl-unclean-shutdown \ #downgrade-1.0 force-response-1.0 /VirtualHost ##END VIRTUAL HOST SETUP## On Oct 9, 10:33 am, Omi Chiba ochib...@gmail.com wrote: Paolo, Thank you again. so it's simple compare it with your, downloading uniform server (that is portable and install less) I will try uniform server next monday and tuesday, then update the result here. On Oct 9, 2:46 am, Paolo Caruccio paolo.carucci...@gmail.com wrote: My enviroment windows7 64 bit Apache/2.2.21 (Win32) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0e mod_wsgi/3.3 Python/2.7.2 PHP/5.3.8 pywin32-216.win32-py2.7 pyodbc-2.1.11.win32-py2.7 web2py 1.99.2 stable db2exc_974_WIN_x86_64 - IBM DB2 Express-C httpd.conf is the same as that one comes with uniform server, I only added to it two rows: # to load mod_wsgi LoadModule wsgi_module modules/mod_wsgi.so # vhost_web2py is a separated file (see my previous message for its content) Include conf/vhost_web2py.conf so it's simple compare it with your, downloading uniform server (that is portable and install less) Regarding db2 driver after I installed IBM DB2 Express-C I made the following steps: 1) in db2 control center I created a new empty database and named it TEST alias TEST 2) activated IBM DB2 ODBC DRIVER : 2a) in win7 control panel administrative tools Data Sources (ODBC) 2b) in opened window tab User DSN Add button 2c) in new popup window select IBM DB2 ODBC DRIVER End button 2d) in next window 2d1) Data Name Source = TEST 2d2) Database alias = TEST 2d3) Pressed OK button In web2py I created a new simple application and connected to database through the string: db = DAL('db2://DSN=TEST;UID=userid;PWD=password') where userid and password are the same as accessing to IBM DB2 Express- C. At the end I succesfully registered a new user, so all worked fine for me. Ciao. Paolo On 7 Ott, 21:31, Omi Chiba ochib...@gmail.com wrote: Paolo, You gave me a hope because it looks you tried it recently and it's very similar to my environment. (Is your OS Windows 7, XP, or Windows Server ??) My environment: OS: Windows 7 SP1 - 32bit Python: 2.7.2 Apache: httpd-2.2.21-win32-x86-openssl-0.9.8r.msi mod_wsgi: mod_wsgi-win32-ap22py27-3.3.so pyodbc: pyodbc-2.1.11.win32-py2.7.exe pywin32: pywin32-216.win32-py2.7.exe I was keep thinking what makes the difference. I know you use Uniform Server but the version of apache included is the same as mine. So it should be the same. Only possible difference is an apache config, The below is the part of httpd.conf let me know if you find anything wrong. It's running fine
Re: [web2py] Re: Help for creating template
On Monday, October 10, 2011 4:03:49 PM UTC-4, miroslavgojic wrote: with {{=request.url}} i will get /some/my/url/address but when I tray next example it is not working: {{ myurl = request.url: i = /some/my/url/address: if i == myurl: response.writ('my first HTML output') else: response.write('my other HTML output') pass }} how to resolve this, I need one part layout.htm to be different for index page than an other pages, is there some other solutions How about using a block: http://web2py.com/book/default/chapter/05#Blocks-in-Views? Define the default content of the block in layout.html, and define the index specific content in index.html. A few other points: - I believe request.url will contain the rewritten version of the requested URL if you're using routes.py, so it may not match your hand-coded URL. - If you need to determine the current function (and/or controller), it's better to match request.function (and/or request.controller) rather than trying to match the full URL (which could get tricky if the are args, a query string, or any rewrites going on). - Using response.write is generally discouraged and usually unnecessary -- instead, just do: {{if condition:}} your html goes here {{else:}} alternative html goes here {{pass}} Anthony
[web2py] Re: How to add more buttons to form that submits form to different actions ...
Do you mean one form with multiple submit buttons? On the form: {{=INPUT(_type='submit', _name='submit_one')}} {{=INPUT(_type='submit', _name='submit_two')}} In the controller: if request.vars['submit_one']: do something ## maybe call a function elif request.vars['submit_two'] do something else ## call a different function Both submit buttons come back to the same controller action. On Oct 10, 3:29 pm, David Marko dma...@tiscali.cz wrote: I would like to use concept of shared form (http://web2py.com/book/default/chapter/07#Sharing-Forms) and I want to have a more submit buttons, each to different action on controller. How can I sinmply make a more buttons each submiting form to different action.
[web2py] Re: SQLFORM and IS_IN_SET problem
If you want only one value, why are you using list:string? Misread the book :( Thanks, anyway.
[web2py] Re: How to add more buttons to form that submits form to different actions ...
I'm not sure there's an easy way to do that in HTML, as the form's 'action' attribute determines where the form is posted. But you might use Javascript (jQuery) to dynamically change the form's action based on the button that is clicked. See http://www.samburdge.co.uk/development/a-single-html-form-with-multiple-submit-buttons-changing-a-forms-action-attribute-using-jquery. Anthony On Monday, October 10, 2011 3:29:03 PM UTC-4, David Marko wrote: I would like to use concept of shared form ( http://web2py.com/book/default/chapter/07#Sharing-Forms) and I want to have a more submit buttons, each to different action on controller. How can I sinmply make a more buttons each submiting form to different action.
[web2py] Re: SQLFORM and IS_IN_SET problem
Wait a minute, though. I want a drop down menu. So if I do this: Field('status', 'string', requires = IS_IN_SET({'A' : 'Apple', 'B': 'Banana'})) I will get a drop down? On Oct 10, 4:40 pm, Bruno Rocha rochacbr...@gmail.com wrote: On Mon, Oct 10, 2011 at 5:38 PM, Cliff cjk...@gmail.com wrote: Anthony, I don't want multiple values. I just want one of those values. If you want only one value, why are you using list:string? change to Field('status', 'string'),
[web2py] Re: SQLFORM and IS_IN_SET problem
On Monday, October 10, 2011 5:01:52 PM UTC-4, Cliff wrote: Wait a minute, though. I want a drop down menu. So if I do this: Field('status', 'string', requires = IS_IN_SET({'A' : 'Apple', 'B': 'Banana'})) I will get a drop down? Yes.
[web2py] Re: SQLFORM and IS_IN_SET problem
Made the change as recommended - still not working. On Oct 10, 5:01 pm, Cliff cjk...@gmail.com wrote: Wait a minute, though. I want a drop down menu. So if I do this: Field('status', 'string', requires = IS_IN_SET({'A' : 'Apple', 'B': 'Banana'})) I will get a drop down? On Oct 10, 4:40 pm, Bruno Rocha rochacbr...@gmail.com wrote: On Mon, Oct 10, 2011 at 5:38 PM, Cliff cjk...@gmail.com wrote: Anthony, I don't want multiple values. I just want one of those values. If you want only one value, why are you using list:string? change to Field('status', 'string'),
[web2py] Re: SQLFORM and IS_IN_SET problem
See http://web2py.com/book/default/chapter/07#Widgets. On Monday, October 10, 2011 5:09:03 PM UTC-4, Anthony wrote: On Monday, October 10, 2011 5:01:52 PM UTC-4, Cliff wrote: Wait a minute, though. I want a drop down menu. So if I do this: Field('status', 'string', requires = IS_IN_SET({'A' : 'Apple', 'B': 'Banana'})) I will get a drop down? Yes.
Re: [web2py] Re: Help for creating template
This is much better ... just how to define condition only for index page (or function or controller) {{if condition:}} how to make definition of condition - there no need to be request.url it can be request.controller when I tray this I get an error: {{if {{=request.function}} == index:}} your html goes here {{else:}} alternative html goes here {{pass}} But this is work {{if request.function == 'index':}} your html goes here {{else:}} alternative html goes here {{pass}} Thanks - - Miroslav Gojic - - On Mon, Oct 10, 2011 at 22:53, Anthony abasta...@gmail.com wrote: On Monday, October 10, 2011 4:03:49 PM UTC-4, miroslavgojic wrote: with {{=request.url}} i will get /some/my/url/address but when I tray next example it is not working: {{ myurl = request.url: i = /some/my/url/address: if i == myurl: response.writ('my first HTML output') else: response.write('my other HTML output') pass }} how to resolve this, I need one part layout.htm to be different for index page than an other pages, is there some other solutions How about using a block: http://web2py.com/book/default/chapter/05#Blocks-in-Views? Define the default content of the block in layout.html, and define the index specific content in index.html. A few other points: - I believe request.url will contain the rewritten version of the requested URL if you're using routes.py, so it may not match your hand-coded URL. - If you need to determine the current function (and/or controller), it's better to match request.function (and/or request.controller) rather than trying to match the full URL (which could get tricky if the are args, a query string, or any rewrites going on). - Using response.write is generally discouraged and usually unnecessary -- instead, just do: {{if condition:}} your html goes here {{else:}} alternative html goes here {{pass}} Anthony
[web2py] Re: Windows + Apache + mod_proxy
Hi Omi, I wasn't sure this part, so I just add 127.0.0.1 ochiba-183 to my hosts. Try to replace with 10.30.6.122 ochiba-183 Let me know if it works. Ciao. Paolo
Re: [web2py] Re: Help for creating template
{{if {{=request.function}} == index:}} Yes, once you're inside a {{}}, you can write any Python and refer to any global (or local) variables -- so no need to nest another {{=}} in there.
[web2py] Re: SQLFORM and IS_IN_SET problem
Mostly fixed now. There was also a bug in my controller code that was complicating things. One problem remains. With readonly=True, the field still shows the dictionary key rather than the value. On Oct 10, 5:09 pm, Cliff cjk...@gmail.com wrote: Made the change as recommended - still not working. On Oct 10, 5:01 pm, Cliff cjk...@gmail.com wrote: Wait a minute, though. I want a drop down menu. So if I do this: Field('status', 'string', requires = IS_IN_SET({'A' : 'Apple', 'B': 'Banana'})) I will get a drop down? On Oct 10, 4:40 pm, Bruno Rocha rochacbr...@gmail.com wrote: On Mon, Oct 10, 2011 at 5:38 PM, Cliff cjk...@gmail.com wrote: Anthony, I don't want multiple values. I just want one of those values. If you want only one value, why are you using list:string? change to Field('status', 'string'),
Re: [web2py] Re: SQLFORM and IS_IN_SET problem
just tested values = ((0, 'value 1'), (1, 'value 2)) db.table.field.requires = IS_IN_SET(values) works ok. On Mon, Oct 10, 2011 at 7:01 PM, Cliff cjk...@gmail.com wrote: Mostly fixed now. There was also a bug in my controller code that was complicating things. One problem remains. With readonly=True, the field still shows the dictionary key rather than the value. On Oct 10, 5:09 pm, Cliff cjk...@gmail.com wrote: Made the change as recommended - still not working. On Oct 10, 5:01 pm, Cliff cjk...@gmail.com wrote: Wait a minute, though. I want a drop down menu. So if I do this: Field('status', 'string', requires = IS_IN_SET({'A' : 'Apple', 'B': 'Banana'})) I will get a drop down? On Oct 10, 4:40 pm, Bruno Rocha rochacbr...@gmail.com wrote: On Mon, Oct 10, 2011 at 5:38 PM, Cliff cjk...@gmail.com wrote: Anthony, I don't want multiple values. I just want one of those values. If you want only one value, why are you using list:string? change to Field('status', 'string'), -- -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] [ Aprenda a programar: http://CursoDePython.com.br ] [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ] [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
[web2py] Re: Help for creating template
In fact this {{if {{=request.function}} == index:}} is wrong because web2py would look for the first {{ and the first }} and try interpret the code in between as python. By if {{=request.function is not valid python. You want: {{if request.function == 'index':}} On Oct 10, 4:28 pm, Anthony abasta...@gmail.com wrote: {{if {{=request.function}} == index:}} Yes, once you're inside a {{}}, you can write any Python and refer to any global (or local) variables -- so no need to nest another {{=}} in there.
Re: [web2py] Re: checkbox input default value
I'm using the Field in a rather unconventional way - I just have a number of Field objects in a class that I refer to as my model (its not actually connected to any database), and I use the SQLFORM.factory to generate the form. The actual Field entry in the form looks like this: AutoStart = Field('AutoStart', 'boolean', label=T(info)) in the view I use it inside a custom form like so: dd{{=form.custom.widget.AutoStart}}{{=form.custom.label.AutoStart}}/dd the resulting HTML is: ddinput class=boolean id=no_table_AutoStart name=AutoStart type=checkbox value=oninfo/dd pretty straight forward, but you can see that the value is somehow there. Matt On Mon, Oct 10, 2011 at 4:05 PM, Wikus van de Merwe dupakrop...@googlemail.com wrote: Are you using list:string? Can you post the relevant parts of your model and controller?
[web2py] Re: Windows + Apache + mod_proxy
Paolo, You made my day !! web2py is up and pyodbc works fine under wsgi !!! Grazie molto! On Oct 10, 4:20 pm, Paolo Caruccio paolo.carucci...@gmail.com wrote: Hi Omi, I wasn't sure this part, so I just add 127.0.0.1 ochiba-183 to my hosts. Try to replace with 10.30.6.122 ochiba-183 Let me know if it works. Ciao. Paolo
[web2py] Re: Windows + Apache + mod_proxy
I am very glad I helped Ciao. Paolo
[web2py] Re: new feature - need help
The result is splendid with your changes. I want only suggest to replace the row # 1344 in /gluon/sqlhtml.py with this jQuery('#w2p_query_fields').val('').change(); so the change event is fired and when you query again the .w2p_query_row is hidden. Ciao. Paolo
[web2py] Re: SQLFORM and IS_IN_SET problem
On Monday, October 10, 2011 6:01:49 PM UTC-4, Cliff wrote: Mostly fixed now. There was also a bug in my controller code that was complicating things. One problem remains. With readonly=True, the field still shows the dictionary key rather than the value. With readonly, I guess it's not using the widget, so it will just show the value stored in the field itself. Maybe you can define a represent function for the field so it shows the label associated with the value. Anthony
[web2py] Re: Help! import winrandom gives dll load failed error under Apache on Vista, but works under Rocket.
Resolved: After researching, I see this problem plagues many other developers as well. The root cause is that the Distribution Windows Build of Apache 2.2 is built with msvcr71.dll which is the C++ runtime dll for Visual Studio 2003!!! But, most recent builds of python .pyd files which link to C/C++ code, are built with msvcr90.dll which is the one from Visual Studio 2008. As a result, Apache chokes with this obscure error (failure to load a dll) whenever a pyd is imported that is built with any C/C+ runtime which is not msvrcr71.dll. If you run httpd.exe from a command prompt, you will get an error popup for Microsoft error R6034. In particular, if you want to used sftp in python on Apache 2.2, you cannot do so using the distributed Windows build of Apache 2.2. However, there are lots of postings showing how to build Apache 2.2 yourself under Visual Studio 2008, so that would be the workaround for running web2py on a Windows platform under Apache 2.2 when you are doing sftp or something using C/C++ code. See http://comments.gmane.org/gmane.comp.apache.devel/43600 where it mentions that Apache 2.4 will finally be built with a current Microsoft C++ runtime dll. Another workaround if you do not want to build Apache in VS 2008, is to try to run web2py under IIS. I got it working under IIS 7 on Vista, but yes, it is quite difficult to do even with the easiest of the 3 methods described in the web2py slice about IIS. The easiest method is to use Rocket together with IIS 7, where IIS 7 is used as a proxy for Rocket. Additional steps to take regarding what is mentioned in the slice is to create web application in IIS 7 to serve as a kind of surrogate for the web2py application. Plus the specifics of the routes.py entries and of the .NET URL rewriter file ManagedFusion.Rewriter.txt are pretty much have to discovered by experimentation. Here is what works for my web2py app named 'UETR' on IIS 7: ManagedFusion.Rewriter.txt --- RewriteEngine On RewriteBase / RewriteRule ^(/) http://138.85.50.99:8000/UETR?r=$1 [R,NC] c:\web2py\routes.py --- default_application = 'UETR'# ordinarily set in base routes.py default_controller = 'default' # ordinarily set in app-specific routes.py default_function = 'index' # ordinarily set in app-specific routes.py routes_app = ((r'/(?Pappwelcome|admin|uetr)\b.*', r'\gapp'), (r'(.*)', r'UETR'), (r'/?(.*)', r'UETR')) routes_in = ((r'.*:/favicon.ico', r'/examples/static/favicon.ico'), (r'.*:/robots.txt', r'/examples/static/robots.txt'), (r'.*:/LTE1/index', r':8000/UETR/default/ index'), ((r'.*http:/localhost.* (?Pany.*)', r'http://localhost: 8000/UETR/default/index'))) routes_out = ((r'.*http://otherdomain.com.* /app/ctr(?Pany.*)', r'\gany'), (r'/app(?Pany.*)', r'\gany')) -- I created an ASP.NET 4.0 web application on IIS 7 whose Virtual Directory name is 'LTE1' In it, I used the Visual Studio 2010 wizard to create a basic web application (hello world roughly). In that web application I had to modify the web.config as per the documentation for ManagedFusion.Rewriter I also created a 'bin' folder in LTE1 and copied the Managed Fusion dll into into it. The actual content of the .aspx pages in this .NET web app are irrelevant as this app is never rendered. Only its web.config is read and acted upon by Managed Fusion, to cause the request to be passed to the URL where web2py is running on Rocket at port 8000. - Now if I browse to http://138.85.50.99/LTE1 It hits IIS 7 and magically reroutes to my UETR web2py app at http://138.85.50.99:8000/UETR?r=/LTE1 More work is needed to refine it, but the basic functionality is shown. On Oct 6, 9:19 pm, dlypka dly...@gmail.com wrote: My web2py app which uses paramiko sftp, works fine under the Rocket webserver, but fails here when run under the Apache 2.2 webserver, under WINDOWS VISTA Enterprise: • File C:\Python27\lib\site-packages\Crypto\Random\OSRNG\nt.py, line 28 import winrandom -- failing to load some DLL at line 28 -- from rng_base import BaseRNG I imagine it is some kind of permissions problem, maybe with having to load a cryptographic C dll I have already run a Process viewer and cleaned up the PATH to avoid dll search failures. This is a proof of concept app to a major U.S. corporation. They have already seen it work under Rocket and are very excited to see it deployed under a standard webserver. An alternative is to use IIS7 but the web2py slice I read looked very difficult to follow so I am trying Apache first. We are also running Symantec anti virus (corporate edition) and we are locked out from being able to disable it. Not
[web2py] Tag handling suggestions
Anyone have a quick perspective on the pros/cons of handling tags like this: Option 1: db.define_table('item',Field('tags','list:string')) Option 2: db.define_table('tag') db.define_table('item',Field('tags','list:reference tag')) Options 3: db.define_table('item') db.define_table('tag') db.define_table('item_tag',Field('item'),Field('tag'))
Re: [web2py] Tag handling suggestions
On Mon, Oct 10, 2011 at 9:36 PM, pbreit pbreitenb...@gmail.com wrote: Option 1: db.define_table('item',Field('tags','list:string')) I am using the Option 1. for me it is better because I end with pure Python list, which I can run map, reduce, filter etc... also contains and belongs are very helpful and fast. I also think it is the less complicated way. -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] [ Aprenda a programar: http://CursoDePython.com.br ]
Re: [web2py] Tag handling suggestions
Clarifying: Option 1: db.define_table('item',Field('tags','list:string')) *Pro*: Easy search: tag = request.args(0) results = db(db.item.tags.contains(tag)).select() *Con*: build a tag cloud records = db(db.item.id0).select(db.item.tags) alltags = [] # loop thought records to populate the tags list (here you can use reduce, list comprehension) Option 2: db.define_table('tag') db.define_table('item',Field('tags','list:reference tag')) *Pro*: build a tag clous alltags = [ r.tag for r in db(db.tag.id0).select('tag')] *Con:* Search is expensive tag = request.args(0) # it is a string like: book tag_id = db.tag(tag=tag)[0].id # or a taglist records = db(db.item.tag.contains(tag_id)).select() Options 3: db.define_table('item') db.define_table('tag') db.define_table('item_tag',Field('item'),Field('tag')) *Con:* In this case I see Tag searching and tagcloud as a expensive process. But, certainly Massimo has a DAL trick to solve this use case in one line of code ;) -- Bruno Rocha [ About me: http://zerp.ly/rochacbruno ] [ Aprenda a programar: http://CursoDePython.com.br ]
[web2py] Re: new feature - need help
Done. Thank you! On Oct 10, 6:11 pm, Paolo Caruccio paolo.carucci...@gmail.com wrote: The result is splendid with your changes. I want only suggest to replace the row # 1344 in /gluon/sqlhtml.py with this jQuery('#w2p_query_fields').val('').change(); so the change event is fired and when you query again the .w2p_query_row is hidden. Ciao. Paolo
[web2py] Re: Tag handling suggestions
I think Option 1 if faster on GAE Datastore. Option 3 is the best on SQL because you can do db.define_table('data', Field('value')) db.define_table('tag', Field('record_id', db.data), Field('name')) def search_or(data=db.data, tag=db.tag, tags=[]): rows = db(data.id==tag.record_id)\ (tag.name.belongs(tags)).select( data.ALL, orderby=data.id, groupby=data.id, distinct=True) return rows def search_and(data=db.data,tag=db.tag,tags=[]): n = len(tags) rows = db(data.id==tag.record_id)\ (tag.name.belongs(tags)).select( data.ALL, orderby=data.id, groupby=data.id, having=data.id.count()==n) return rows @Bruno. It is in the recipes book. ;-) On Oct 10, 8:53 pm, Bruno Rocha rochacbr...@gmail.com wrote: Clarifying: Option 1: db.define_table('item',Field('tags','list:string')) *Pro*: Easy search: tag = request.args(0) results = db(db.item.tags.contains(tag)).select() *Con*: build a tag cloud records = db(db.item.id0).select(db.item.tags) alltags = [] # loop thought records to populate the tags list (here you can use reduce, list comprehension) Option 2: db.define_table('tag') db.define_table('item',Field('tags','list:reference tag')) *Pro*: build a tag clous alltags = [ r.tag for r in db(db.tag.id0).select('tag')] *Con:* Search is expensive tag = request.args(0) # it is a string like: book tag_id = db.tag(tag=tag)[0].id # or a taglist records = db(db.item.tag.contains(tag_id)).select() Options 3: db.define_table('item') db.define_table('tag') db.define_table('item_tag',Field('item'),Field('tag')) *Con:* In this case I see Tag searching and tagcloud as a expensive process. But, certainly Massimo has a DAL trick to solve this use case in one line of code ;) -- Bruno Rocha [ About me:http://zerp.ly/rochacbruno] [ Aprenda a programar:http://CursoDePython.com.br]
Re: [web2py] Re: Tag handling suggestions
I like this, and it is really smarter than list:string option, but, imagine a blog where users include tags in an INPUT text field, this will be more difficult to store tags in other table (you can do using ajax or building a checkbox list of tags) but it is easy just to let the user put tags in a text field comma separated or space sepated, then split and store in list:string field.
[web2py] Re: date picker on v1.99
Massimo, I sent a patch with two more minor updates. On 10月11日, 午前3:17, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you please email me the patch? On Oct 10, 11:35 am, kenji4569 hos...@s-cubism.jp wrote: The behavior of the date picker seems to have changed from a certain version. For now, we should apply a patch to the anytime.js: 545 - this.showPkr(null);event.preventDefault();},keyAhead:function() 545 + return;event.preventDefault();},keyAhead:function() [for readable version (http://www.ama3.com/anytime/AnyTime/ anytime.js)] 2696 - this.showPkr(null); 2696 + return; I think it is critical since it is difficult to turn the input back to empty. Regards, Kenji On 10月10日, 午前11:45, Nik Go nikolai...@gmail.com wrote: manual entry doesn't work on the ff browsers: - Chromium 15.0.871.0 - Epiphany/GNOME Web Browser 2.30.2 - Mozilla Firefox 3.6.22 I'm running ubuntu 10.04 On Friday, October 7, 2011, Massimo Di Pierro wrote: Which browser? When I tried it, if I remember, I was able to type. On Oct 6, 8:48 pm, niknok nikolai...@gmail.com javascript:; wrote: The new date picker looks very good. Is there a way to input dates by typing it directly (similar to default behaviour in older versions), in addition to selecting dates thru the calendar interface? /r Nik P.S. Though I couldn't type in a date, I could paste one. (which is a behavior I don't expect from users)
[web2py] windows + apache + mod_wsgi error
Hi, has any one gotten this error when using this combination: windows + apache + mod_wsgi ? Syntax error on line 518 of C:/Program Files (x86)/Apache Software Foundation/Ap ache2.2/conf/httpd.conf: LogFormat takes 1-2 arguments, a log format string (see docs) and an optional fo rmat name Note the errors or messages above, and press the ESC key to exit. 23... Any help is appreciated, Thanks, Mart :)
[web2py] Re: windows + apache + mod_wsgi error
Sorry, the error points to line 518, which is this: LogFormat %h %l %u %t %r %s %b common Thanks, Mart :) On Oct 10, 11:24 pm, mart msenecal...@gmail.com wrote: Hi, has any one gotten this error when using this combination: windows + apache + mod_wsgi ? Syntax error on line 518 of C:/Program Files (x86)/Apache Software Foundation/Ap ache2.2/conf/httpd.conf: LogFormat takes 1-2 arguments, a log format string (see docs) and an optional fo rmat name Note the errors or messages above, and press the ESC key to exit. 23... Any help is appreciated, Thanks, Mart :)
[web2py] Re: Import/execute sql file
Try opening your file, reading its contents and then having db.executesql() execute what was read. Should work assuming the file's contents can be run by psycopg2 (i.e some special psql stuff might not work) #untested code f = open('/path/to/file.sql', 'r') db.executesql(f.read())
[web2py] Re: windows + apache + mod_wsgi error
found the problem :) line should be: LogFormat %h %l %u %t \%r\ %s %b common instead of LogFormat %h %l %u %t %r %s %b common Service started properly now. Thanks, Mart :) On Oct 10, 11:29 pm, mart msenecal...@gmail.com wrote: Sorry, the error points to line 518, which is this: LogFormat %h %l %u %t %r %s %b common Thanks, Mart :) On Oct 10, 11:24 pm, mart msenecal...@gmail.com wrote: Hi, has any one gotten this error when using this combination: windows + apache + mod_wsgi ? Syntax error on line 518 of C:/Program Files (x86)/Apache Software Foundation/Ap ache2.2/conf/httpd.conf: LogFormat takes 1-2 arguments, a log format string (see docs) and an optional fo rmat name Note the errors or messages above, and press the ESC key to exit. 23... Any help is appreciated, Thanks, Mart :)
[web2py] windows + apache + mod_wsgi -- question 2
Hi, So this combination seems to be working well, except I can't log in to the admin interface. Getting this msg/exception: admin disabled because unable to access password file Is there a quick fix? Thanks, Mart :)
[web2py] Re: windows + apache + mod_wsgi -- question 2
heya mart, I think that is an easy one, you need rename a file parameters_nnn,py to parameters_.py where is the port your app listens to. Enjoy
[web2py] Re: windows + apache + mod_wsgi -- question 2
Hey MidGe, well, now its an easy one, but that's only because you gave me the answer! :) Thanks for that!, now its working great! Much appreciated, Mart :) On Oct 10, 11:58 pm, MidGe degreef.mic...@gmail.com wrote: heya mart, I think that is an easy one, you need rename a file parameters_nnn,py to parameters_.py where is the port your app listens to. Enjoy
[web2py] Re: windows + apache + mod_wsgi -- question 2
By the way, the original file gets created the very first time you run the rocket server. So you need run the server once for a minute or so to let the file be created.. and then rename the file if needed to the port you are listening to.
Re: [web2py] Re: Import/execute sql file
On Tue, Oct 11, 2011 at 12:32 AM, Brian M bmere...@gmail.com wrote: Try opening your file, reading its contents and then having db.executesql() execute what was read. Should work assuming the file's contents can be run by psycopg2 (i.e some special psql stuff might not work) #untested code f = open('/path/to/file.sql', 'r') db.executesql(f.read()) That works, but prefer to run inside a context: with open(/path/to/file,sql, r) as sql: code = sql.read() # here you can do some parsing, remove spaces, replace things db.executesql(code)
[web2py] Re: windows + apache + mod_wsgi -- question 2
thanks for the tip! :) mart On Oct 11, 12:04 am, MidGe degreef.mic...@gmail.com wrote: By the way, the original file gets created the very first time you run the rocket server. So you need run the server once for a minute or so to let the file be created.. and then rename the file if needed to the port you are listening to.