[web2py] Re: how to debug function view error
When I tried to directly view the page, I am getting this error. Even though the URL uses correct controller "resource", web2py is looking for the function in he default.py controller -- 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] how to debug function view error
Hello, I have an existing application and defined new functions in the controller default.py and also defined the corresponding views. The view includes {{extend 'layout.html'}}. However, when the function is invoked, the page is displayed as if there is no view defined. It works fine for the functions and views that were created earlier. This problem occurs only for newly created functions/views. I checked several times the function name and the view name are exactly the same. How can I debug this problem? version 2.8.2-stable+timestamp.2013.11.28.13.54.07 (Running on Apache/2.4.9 (Win64) OpenSSL/1.0.1g mod_wsgi/3.5-BRANCH Python/2.7.6, Python 2.7.6) Thanks for your help, PT -- 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 debug function view error
Thank you Leonel and Stifan. Initially, I had the function in default.py and the view in the default folder. But, this view behaved as if I didn't include the {{extend 'layout.html'}}. Then, I moved the function to a new control resource.py and also created a new view in the resource folder. Some how this did not work (see the screenshots I posted earlier). But, I made a mistake in the function definition by returning the variable. def resources_assigned(): assign_form1 = SQLFORM.grid(db.assigned, maxtextlength=150, csv=True, details=True, editable=True, formstyle='bootstrap', paginate=100) return assign_form1 Once I changed return assign_form1 to return locals() or return ( assign_form1=assign_form1), its all working fine. Thank you for your time and suggestions. Best Regards, PT -- 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] SQL query equivalent in DAL
Hello Forum, Please help me in getting the equivalent DAL query for the following SQL query. I intend to pass this on to SQLFORM.grid Select * from db.pc where db.pc.id not in (select unique db.assigned.computer from db.assigned) Web2Py Version 2.9.12-stable+timestamp.2015.02.15.23.04.25 (Running on Rocket 1.2.6, Python 2.7.9) db.define_table('staff', Field('name', 'string', unique=True), format='%(name)s') db.define_table('pc', Field('csi', 'string', unique=True), format='%(csi)s') db.define_table('assigned', Field('staff', db.staff), Field('computer', db.pc)) Thanks, PT -- 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] SQL query equivalent in DAL
Thank you Richard, your expression returns ROWS and can't be used in SQLFORM.grid. When I removed the last select db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id)) then I get File "E:\web2py 2.9.12\gluon\sqlhtml.py", line 2139, in grid field_id = tables[0]._id IndexError: list index out of range Dave, the tables are related. e.g. the table "assigned" has a field "computer" of type db.pc Thanks, PT On Friday, September 4, 2015 at 3:23:47 PM UTC-5, Dave S wrote: > > I'm puzzled about the why ... > > On Friday, September 4, 2015 at 12:42:32 PM UTC-7, Richard wrote: >> >> db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id >> )).select(db.pc.ALL) >> >> Richard >> >> >> >> On Fri, Sep 4, 2015 at 3:35 PM, P T <pthimm...@gmail.com> wrote: >> >>> >>> Hello Forum, >>> >>> Please help me in getting the equivalent DAL query for the following SQL >>> query. I intend to pass this on to SQLFORM.grid >>> >>> Select * from db.pc where db.pc.id not in (select unique >>> db.assigned.computer from db.assigned) >>> >>> > when there's no reference between tables: > > > > >> Web2Py Version >>> 2.9.12-stable+timestamp.2015.02.15.23.04.25 >>> (Running on Rocket 1.2.6, Python 2.7.9) >>> >>> db.define_table('staff', >>> Field('name', 'string', unique=True), >>>format='%(name)s') >>> >>> db.define_table('pc', >>> Field('csi', 'string', unique=True), >>>format='%(csi)s') >>> >>> db.define_table('assigned', >>> Field('staff', db.staff), >>> Field('computer', db.pc)) >>> >>> Thanks, >>> PT >>> >>> >> > (see, no "Field('name', 'reference othertable', ...)") > > /dps > > > > -- 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] SQL query equivalent in DAL
Got it. I need to remove the initial db to make that into a query (~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id)) On Friday, September 4, 2015 at 3:37:50 PM UTC-5, P T wrote: > > Thank you Richard, your expression returns ROWS and can't be used in > SQLFORM.grid. When I removed the last select > > db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id)) > > then I get > > File "E:\web2py 2.9.12\gluon\sqlhtml.py", line 2139, in grid > field_id = tables[0]._id > IndexError: list index out of range > > > Dave, the tables are related. e.g. the table "assigned" has a field > "computer" of type db.pc > > > > Thanks, > PT > > > On Friday, September 4, 2015 at 3:23:47 PM UTC-5, Dave S wrote: >> >> I'm puzzled about the why ... >> >> On Friday, September 4, 2015 at 12:42:32 PM UTC-7, Richard wrote: >>> >>> db(~db.pc.id.belongs(db(db.assigned.id > 0)._select(db.assigned.id >>> )).select(db.pc.ALL) >>> >>> Richard >>> >>> >>> >>> On Fri, Sep 4, 2015 at 3:35 PM, P T <pthimm...@gmail.com> wrote: >>> >>>> >>>> Hello Forum, >>>> >>>> Please help me in getting the equivalent DAL query for the following >>>> SQL query. I intend to pass this on to SQLFORM.grid >>>> >>>> Select * from db.pc where db.pc.id not in (select unique >>>> db.assigned.computer from db.assigned) >>>> >>>> >> when there's no reference between tables: >> >> >> >> >>> Web2Py Version >>>> 2.9.12-stable+timestamp.2015.02.15.23.04.25 >>>> (Running on Rocket 1.2.6, Python 2.7.9) >>>> >>>> db.define_table('staff', >>>> Field('name', 'string', unique=True), >>>>format='%(name)s') >>>> >>>> db.define_table('pc', >>>> Field('csi', 'string', unique=True), >>>>format='%(csi)s') >>>> >>>> db.define_table('assigned', >>>> Field('staff', db.staff), >>>> Field('computer', db.pc)) >>>> >>>> Thanks, >>>> PT >>>> >>>> >>> >> (see, no "Field('name', 'reference othertable', ...)") >> >> /dps >> >> >> >> > -- 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] File download - disable link when no files are available
Hello All, Currently using Web2Py 2.8.2-stable+timestamp.2013.11.28.13.54.07 I have a simple page for announcing seminars and for downloading presentation files. Here are definitions for table, controller and view : db.define_table(seminars, Field('sem_date', 'date', label='Date'), Field('Sem_Time', 'string', label='Time'), Field('room', 'string', label='Location'), Field('person', 'string', label='Presenter'), Field('title', 'string', label='Seminar Title'), Field('sem_file', 'upload', label='Files', requires=False) ) db.seminars.sem_file.represent = lambda value,row:A('Download', _href=URL( 'download', args=value)) -- def index(): db.seminars.id.readable=False grid = SQLFORM.grid(db.seminars, maxtextlength=150, details=False, deletable=False, searchable=False, csv=False, editargs=dict(id=False), formstyle='bootstrap') grid.element('.web2py_counter', replace=None) return dict(grid=grid) -- {{extend 'seminar_layout.html'}} {{=grid}} It works fine as intended. But, I want to replace Download link with No Files Available and disable the link when there are there are no files available. Any suggestion or help is appreciated. Thanks, PT -- 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 download - disable link when no files are available
Thanks Leonel, it works great. But, I am stumped by the syntax. On Friday, February 27, 2015 at 11:45:03 AM UTC-6, P T wrote: Hello All, Currently using Web2Py 2.8.2-stable+timestamp.2013.11.28.13.54.07 I have a simple page for announcing seminars and for downloading presentation files. Here are definitions for table, controller and view : db.define_table(seminars, Field('sem_date', 'date', label='Date'), Field('Sem_Time', 'string', label='Time'), Field('room', 'string', label='Location'), Field('person', 'string', label='Presenter'), Field('title', 'string', label='Seminar Title'), Field('sem_file', 'upload', label='Files', requires=False) ) db.seminars.sem_file.represent = lambda value,row:A('Download', _href=URL( 'download', args=value)) -- def index(): db.seminars.id.readable=False grid = SQLFORM.grid(db.seminars, maxtextlength=150, details=False, deletable=False, searchable=False, csv=False, editargs=dict(id=False), formstyle='bootstrap') grid.element('.web2py_counter', replace=None) return dict(grid=grid) -- {{extend 'seminar_layout.html'}} {{=grid}} It works fine as intended. But, I want to replace Download link with No Files Available and disable the link when there are there are no files available. Any suggestion or help is appreciated. Thanks, PT -- 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 download - disable link when no files are available
Thank you Leonel for taking the time to explain the syntax! Best Regards, PT On Friday, February 27, 2015 at 11:45:03 AM UTC-6, P T wrote: Hello All, Currently using Web2Py 2.8.2-stable+timestamp.2013.11.28.13.54.07 I have a simple page for announcing seminars and for downloading presentation files. Here are definitions for table, controller and view : db.define_table(seminars, Field('sem_date', 'date', label='Date'), Field('Sem_Time', 'string', label='Time'), Field('room', 'string', label='Location'), Field('person', 'string', label='Presenter'), Field('title', 'string', label='Seminar Title'), Field('sem_file', 'upload', label='Files', requires=False) ) db.seminars.sem_file.represent = lambda value,row:A('Download', _href=URL( 'download', args=value)) -- def index(): db.seminars.id.readable=False grid = SQLFORM.grid(db.seminars, maxtextlength=150, details=False, deletable=False, searchable=False, csv=False, editargs=dict(id=False), formstyle='bootstrap') grid.element('.web2py_counter', replace=None) return dict(grid=grid) -- {{extend 'seminar_layout.html'}} {{=grid}} It works fine as intended. But, I want to replace Download link with No Files Available and disable the link when there are there are no files available. Any suggestion or help is appreciated. Thanks, PT -- 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: Password Transmitted in plain text
It took a while, but I created a self-signed certificate, installed and configured Apache. Now, all the packets are transmitted as encrypted. Thanks for your help! PT On Tuesday, December 17, 2013 4:37:27 PM UTC-6, Jonathan Lundell wrote: On 17 Dec 2013, at 2:28 PM, P T pthimm...@gmail.com javascript: wrote: Thank you Leonel and Jonathan, But, thees lines require that I run a https server. Can we configure Rocket server for https or should I deploy something like Apache? Rocket supports SSL if the ssl module is available on the system. You'll need a certificate. Depending on what you're doing with it, a self-signed certificate might be adequate. Otherwise you can get a free single-host certificate from someone like: http://www.startssl.com/?app=40 Thanks for the help, PT On Tuesday, December 17, 2013 4:11:57 PM UTC-6, Leonel Câmara wrote: Of course they are. Use HTTPS if you don't want that to happen. request.requires_https() and session.secure() Are your friends. Terça-feira, 17 de Dezembro de 2013 22:08:34 UTC, P T escreveu: I deployed a small app on the intranet and noticed that the username and password are transmitted in plain text (using a tool WireShark, http://www.wireshark.org/). Here is my setup: 2.8.2-stable+timestamp.2013.11.28.13.54.07 (Running on Rocket 1.2.6, Python 2.7.6) Database: Postgresql So, I checked the model and noticed that my auth did not include hmac_key. So, I changed that to auth = Auth(db, hmac_key=Auth.get_or_create_key()) But, this did not help either. What should I do to make sure that user's passwords are transmitted as encrypted? Thanks, PT -- 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) -- 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/groups/opt_out.
[web2py] How to represent dynamic fields in table
I am using the following for represent fields in the table: *{Field(name, 'integer', default=0, represent = lambda value, row: DIV(value if value else '-',_class='month', _id=str(row.id) +'.'+name)) for name infields } The intention is to use jeditable for which I need a class and an id for each td element. But, all the td elements in a row are getting the same month (specifically last month in the list) in the id, e.g. each td element id is 72.Dec_2014. I am expecting 72.Jan_2014, 72.Feb_2014, 72.Mar_2014,..., 72.Dec_2014. How should do I modify definition of represent? Here is complete definition of tables: fields=[] for row in db(db.months).select(): fields.append(row.effort_month.strftime('%b_%Y')) db.define_table(monthly_projections, Field('employee', 'reference auth_user', default=auth. user_id, writable=False), Field('costcode', 'reference costcodes', notnull=True), *{Field(name, 'integer', default=0, represent = lambda value , row: DIV(value if value else '-',_class='month', _id=str(row.id) +'.'+name )) for name in fields} ) Thanks for your help, PT -- 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/groups/opt_out.
[web2py] Re: web2py Jobs and meetups
I am also interested in meet ups in Chicago area. PT On Wednesday, December 18, 2013 12:06:05 PM UTC-6, Michael Gheith wrote: I would love to attend any and all meet ups in Chicago. web2py has been my bread and butter ever since I learned it :) On Tuesday, December 17, 2013 2:06:48 PM UTC-6, Massimo Di Pierro wrote: I am interested in knowing who are the web2py developers in Illinois and in California (possibly around San Francisco) for possible meet ups. If you live near Chicago or near San Francisco, please email me. If you do not leave in one of these places but you would be interested in moving to the US for a web2py job, also let me know. Massimo -- 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/groups/opt_out.
[web2py] Re: How to represent dynamic fields in table
Thank you Anthony, that worked like a charm. Is this technique I should learn in Python or Web2Py? PT On Monday, December 23, 2013 3:17:56 PM UTC-6, Anthony wrote: Try: lambda value, row, name=name: ... Anthony On Monday, December 23, 2013 11:38:08 AM UTC-5, P T wrote: I am using the following for represent fields in the table: *{Field(name, 'integer', default=0, represent = lambda value, row: DIV(value if value else '-',_class='month', _id=str(row.id) +'.'+name)) for name infields } The intention is to use jeditable for which I need a class and an id for each td element. But, all the td elements in a row are getting the same month (specifically last month in the list) in the id, e.g. each td element id is 72.Dec_2014. I am expecting 72.Jan_2014, 72.Feb_2014, 72.Mar_2014,..., 72.Dec_2014. How should do I modify definition of represent? Here is complete definition of tables: fields=[] for row in db(db.months).select(): fields.append(row.effort_month.strftime('%b_%Y')) db.define_table(monthly_projections, Field('employee', 'reference auth_user', default=auth. user_id, writable=False), Field('costcode', 'reference costcodes', notnull=True), *{Field(name, 'integer', default=0, represent = lambdavalue , row: DIV(value if value else '-',_class='month', _id=str(row.id) +'.'+ name)) for name in fields} ) Thanks for your help, PT -- 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/groups/opt_out.
[web2py] Password Transmitted in plain text
I deployed a small app on the intranet and noticed that the username and password are transmitted in plain text (using a tool WireShark, http://www.wireshark.org/). Here is my setup: 2.8.2-stable+timestamp.2013.11.28.13.54.07 (Running on Rocket 1.2.6, Python 2.7.6) Database: Postgresql So, I checked the model and noticed that my auth did not include hmac_key. So, I changed that to auth = Auth(db, hmac_key=Auth.get_or_create_key()) But, this did not help either. What should I do to make sure that user's passwords are transmitted as encrypted? Thanks, PT -- 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/groups/opt_out.
[web2py] Re: Password Transmitted in plain text
Thank you Leonel and Jonathan, But, thees lines require that I run a https server. Can we configure Rocket server for https or should I deploy something like Apache? Thanks for the help, PT On Tuesday, December 17, 2013 4:11:57 PM UTC-6, Leonel Câmara wrote: Of course they are. Use HTTPS if you don't want that to happen. request.requires_https() and session.secure() Are your friends. Terça-feira, 17 de Dezembro de 2013 22:08:34 UTC, P T escreveu: I deployed a small app on the intranet and noticed that the username and password are transmitted in plain text (using a tool WireShark, http://www.wireshark.org/). Here is my setup: 2.8.2-stable+timestamp.2013.11.28.13.54.07 (Running on Rocket 1.2.6, Python 2.7.6) Database: Postgresql So, I checked the model and noticed that my auth did not include hmac_key. So, I changed that to auth = Auth(db, hmac_key=Auth.get_or_create_key()) But, this did not help either. What should I do to make sure that user's passwords are transmitted as encrypted? Thanks, PT -- 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/groups/opt_out.
[web2py] Re: how to build field list from string for SQLFORM.grid?
I rigged the sqlhtml.py, so that I can rearrange the fields in the form as well. The following worked for me, but not sure if it has any side effects: In sqlhtml.py, after the line create_form = update_form = view_form = search_form = None insert fieldnames = [f.name for f in fields] and include fieldnames in the following calls: create_form = SQLFORM(table, fields=fieldnames, **sqlformargs) view_form = SQLFORM(table, record, fields=fieldnames,**sqlformargs) update_form = SQLFORM(table, record, fields=fieldnames, **sqlformargs) I think, it would be nice to see the fields in the same arrangement both in grid and forms. This will also filter fields in the form. Currently, forms show all fields from the table. Thanks, PT On Wednesday, December 11, 2013 8:34:36 PM UTC-6, Massimo Di Pierro wrote: Now I understand better. The order of the parameters in forms is specified in the table definition. You can rearrange in the grid view but not in form. I assume the order is fixed. You should change it in the define_table(..., *fields) On Tuesday, 10 December 2013 00:09:49 UTC-6, P T wrote: I think, the problem is due to the following calls in gluon.sqlhtml.py (lines 2050, 2072, and 2093), which does not include the optional parameter fields create_form = SQLFORM(table, **sqlformargs) view_form = SQLFORM(table, record, **sqlformargs) update_form = SQLFORM(table, record, **sqlformargs) So, I tried something like update_form = SQLFORM(table, record, fields=fields, **sqlformargs) and this generates the ticket type 'exceptions.AttributeError' 'Field' object has no attribute 'find' Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) Traceback (most recent call last): File C:\web2py-src\gluon\restricted.py, line 217, in restricted exec ccode in environment File C:/web2py-src/applications/Test/controllers/default.py, line 77, in module File C:\web2py-src\gluon\globals.py, line 372, in lambda self._caller = lambda f: f() File C:\web2py-src\gluon\tools.py, line 3239, in f return action(*a, **b) File C:/web2py-src/applications/Test/controllers/default.py, line 20, in index grid = SQLFORM.grid(query, fields=fields) File C:\web2py-src\gluon\sqlhtml.py, line 2093, in grid update_form = SQLFORM(table, record, fields=fields, **sqlformargs) File C:\web2py-src\gluon\sqlhtml.py, line 1053, in __init__ if fieldname.find('.') = 0: AttributeError: 'Field' object has no attribute 'find' There must be something wrong in how I included the fields param 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/groups/opt_out.
[web2py] Re: how to build field list from string for SQLFORM.grid?
Anthony, Excellent!!! That works perfectly, no need to mess up with sqlhtml.py. Massimo, Thanks for insight. PT On Thursday, December 12, 2013 8:45:35 AM UTC-6, Anthony wrote: How about doing: SQLFORM.grid(..., formargs=dict(fields=[f.name for f in fields])) Anthony On Thursday, December 12, 2013 9:04:21 AM UTC-5, P T wrote: I rigged the sqlhtml.py, so that I can rearrange the fields in the form as well. The following worked for me, but not sure if it has any side effects: In sqlhtml.py, after the line create_form = update_form = view_form = search_form = None insert fieldnames = [f.name for f in fields] and include fieldnames in the following calls: create_form = SQLFORM(table, fields=fieldnames, **sqlformargs) view_form = SQLFORM(table, record, fields=fieldnames,**sqlformargs) update_form = SQLFORM(table, record, fields=fieldnames, **sqlformargs) I think, it would be nice to see the fields in the same arrangement both in grid and forms. This will also filter fields in the form. Currently, forms show all fields from the table. Thanks, PT On Wednesday, December 11, 2013 8:34:36 PM UTC-6, Massimo Di Pierro wrote: Now I understand better. The order of the parameters in forms is specified in the table definition. You can rearrange in the grid view but not in form. I assume the order is fixed. You should change it in the define_table(..., *fields) On Tuesday, 10 December 2013 00:09:49 UTC-6, P T wrote: I think, the problem is due to the following calls in gluon.sqlhtml.py (lines 2050, 2072, and 2093), which does not include the optional parameter fields create_form = SQLFORM(table, **sqlformargs) view_form = SQLFORM(table, record, **sqlformargs) update_form = SQLFORM(table, record, **sqlformargs) So, I tried something like update_form = SQLFORM(table, record, fields=fields, **sqlformargs) and this generates the ticket type 'exceptions.AttributeError' 'Field' object has no attribute 'find' Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) Traceback (most recent call last): File C:\web2py-src\gluon\restricted.py, line 217, in restricted exec ccode in environment File C:/web2py-src/applications/Test/controllers/default.py, line 77, in module File C:\web2py-src\gluon\globals.py, line 372, in lambda self._caller = lambda f: f() File C:\web2py-src\gluon\tools.py, line 3239, in f return action(*a, **b) File C:/web2py-src/applications/Test/controllers/default.py, line 20, in index grid = SQLFORM.grid(query, fields=fields) File C:\web2py-src\gluon\sqlhtml.py, line 2093, in grid update_form = SQLFORM(table, record, fields=fields, **sqlformargs) File C:\web2py-src\gluon\sqlhtml.py, line 1053, in __init__ if fieldname.find('.') = 0: AttributeError: 'Field' object has no attribute 'find' There must be something wrong in how I included the fields param 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/groups/opt_out.
[web2py] Re: column orders in View and New/Edit pages of SQLFORM.grid
This has been resolved. See the related post at https://groups.google.com/forum/#!topic/web2py/5sz_w4S-czE On Monday, December 9, 2013 11:54:27 AM UTC-6, P T wrote: I am building the field list as given here https://groups.google.com/forum/#!topic/web2py/5sz_w4S-czE fields=[db.monthly_projections.employee, db.monthly_projections.id, db. monthly_projections.costcode] for row in db(db.months).select(): fields.append(db.monthly_projections[row.effort_month.strftime('%b_%Y' )]) The columns in the View page are in the order as given by the field list. But, in New and Edit pages the columns are in different order. How can I get consistent ordering across all the three pages? See the attached pdf file for the screenshots. Thanks! PT PS: I posted this question as a followup to https://groups.google.com/forum/#!topic/web2py/5sz_w4S-czE . But, posting here again as I marked that thread as Answered -- 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/groups/opt_out.
[web2py] Re: how to build field list from string for SQLFORM.grid?
Thank you! On Monday, December 9, 2013 7:12:32 AM UTC-6, Massimo Di Pierro wrote: assuming the fields exist: fields=[db.monthly_projections.employee, db.monthly_projections.id, db. monthly_projections.costcode] for row in db(db.months).select(): fields.append(db.monthly_projections[row.effort_month.strftime('%b_%Y' )]) or fields=[db.monthly_projections.employee, db.monthly_projections.id, db. monthly_projections.costcode] + \ [db.monthly_projections[row.effort_month.strftime('%b_%Y')] for row in db(db.months).select()] On Sunday, 8 December 2013 23:40:10 UTC-6, P T wrote: I am dynamically creating the fields in a table from entries in another table. I am using SQLFORM.grid to view/edit the table. For the grid, the following field list works fine: fields=[db.monthly_projections.employee, db.monthly_projections.id, db .monthly_projections.costcode, db.monthly_projections.Dec_2013, db.monthly_projections. Jan_2014, db.monthly_projections.Feb_2014] But, the problem is I don't know the complete field list ahead of time. So, I am using this instead: fields=[db.monthly_projections.employee, db.monthly_projections.id, db .monthly_projections.costcode] for row in db(db.months).select(): fields.append('db.monthly_projections.'+ row.effort_month.strftime( '%b_%Y')) This is giving an error type 'exceptions.AttributeError' 'str' object has no attribute 'tablename' On debugging, I see that the fields is created as three gluon.dal.Fields and three strings fields [gluon.dal.Field object at 0x05414470, gluon.dal.Field object at 0x046D7A58, gluon.dal.Field object at 0x09F15D30, 'db.monthly_projections.Dec_2013', 'db.monthly_projections.Jan_2014', 'db.monthly_projections.Feb_2014'] So, I changed the definition of fields to: fields=[db.monthly_projections.employee, db.monthly_projections.id, db .monthly_projections.costcode] for row in db(db.months).select(): fields.append(Field('db.monthly_projections.'+ row.effort_month. strftime('%b_%Y'))) and this gives an error: type 'exceptions.SyntaxError' invalid table or field name: db.monthly_projections.Dec_2013 So, in short, how do I build the field list from string for SQLFORM.grid? Thanks for your help! PT -- 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/groups/opt_out.
[web2py] Re: how to build field list from string for SQLFORM.grid?
open a ticket http://code.google.com/p/web2py/issues/detail?id=1812sort=-id On Monday, December 9, 2013 3:38:18 PM UTC-6, Massimo Di Pierro wrote: Strange. Please open a ticket about this. On Monday, 9 December 2013 09:25:57 UTC-6, P T wrote: file attached On Monday, December 9, 2013 9:17:29 AM UTC-6, P T wrote: That works fine, but I have another problem - the order of columns is different in View and Edit (see attached screenshots). How can I make the columns present in Edit the same order as the View? On Monday, December 9, 2013 8:38:11 AM UTC-6, P T wrote: Thank you! On Monday, December 9, 2013 7:12:32 AM UTC-6, Massimo Di Pierro wrote: assuming the fields exist: fields=[db.monthly_projections.employee, db.monthly_projections.id, db .monthly_projections.costcode] for row in db(db.months).select(): fields.append(db.monthly_projections[row.effort_month.strftime( '%b_%Y')]) or fields=[db.monthly_projections.employee, db.monthly_projections.id, db .monthly_projections.costcode] + \ [db.monthly_projections[row.effort_month.strftime('%b_%Y')] for row in db(db.months).select()] On Sunday, 8 December 2013 23:40:10 UTC-6, P T wrote: I am dynamically creating the fields in a table from entries in another table. I am using SQLFORM.grid to view/edit the table. For the grid, the following field list works fine: fields=[db.monthly_projections.employee, db.monthly_projections.id , db.monthly_projections.costcode, db.monthly_projections.Dec_2013, db.monthly_projections. Jan_2014, db.monthly_projections.Feb_2014] But, the problem is I don't know the complete field list ahead of time. So, I am using this instead: fields=[db.monthly_projections.employee, db.monthly_projections.id , db.monthly_projections.costcode] for row in db(db.months).select(): fields.append('db.monthly_projections.'+ row.effort_month.strftime ('%b_%Y')) This is giving an error type 'exceptions.AttributeError' 'str' object has no attribute 'tablename' On debugging, I see that the fields is created as three gluon.dal.Fields and three strings fields [gluon.dal.Field object at 0x05414470, gluon.dal.Field object at 0x046D7A58, gluon.dal.Field object at 0x09F15D30, 'db.monthly_projections.Dec_2013', 'db.monthly_projections.Jan_2014', 'db.monthly_projections.Feb_2014'] So, I changed the definition of fields to: fields=[db.monthly_projections.employee, db.monthly_projections.id , db.monthly_projections.costcode] for row in db(db.months).select(): fields.append(Field('db.monthly_projections.'+ row.effort_month. strftime('%b_%Y'))) and this gives an error: type 'exceptions.SyntaxError' invalid table or field name: db.monthly_projections.Dec_2013 So, in short, how do I build the field list from string for SQLFORM.grid? Thanks for your help! PT -- 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/groups/opt_out.
[web2py] Re: how to build field list from string for SQLFORM.grid?
I think, the problem is due to the following calls in gluon.sqlhtml.py (lines 2050, 2072, and 2093), which does not include the optional parameter fields create_form = SQLFORM(table, **sqlformargs) view_form = SQLFORM(table, record, **sqlformargs) update_form = SQLFORM(table, record, **sqlformargs) So, I tried something like update_form = SQLFORM(table, record, fields=fields, **sqlformargs) and this generates the ticket type 'exceptions.AttributeError' 'Field' object has no attribute 'find' Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) Traceback (most recent call last): File C:\web2py-src\gluon\restricted.py, line 217, in restricted exec ccode in environment File C:/web2py-src/applications/Test/controllers/default.py, line 77, in module File C:\web2py-src\gluon\globals.py, line 372, in lambda self._caller = lambda f: f() File C:\web2py-src\gluon\tools.py, line 3239, in f return action(*a, **b) File C:/web2py-src/applications/Test/controllers/default.py, line 20, in index grid = SQLFORM.grid(query, fields=fields) File C:\web2py-src\gluon\sqlhtml.py, line 2093, in grid update_form = SQLFORM(table, record, fields=fields, **sqlformargs) File C:\web2py-src\gluon\sqlhtml.py, line 1053, in __init__ if fieldname.find('.') = 0: AttributeError: 'Field' object has no attribute 'find' There must be something wrong in how I included the fields param 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/groups/opt_out.
[web2py] how to build field list from string for SQLFORM.grid?
I am dynamically creating the fields in a table from entries in another table. I am using SQLFORM.grid to view/edit the table. For the grid, the following field list works fine: fields=[db.monthly_projections.employee, db.monthly_projections.id, db. monthly_projections.costcode, db.monthly_projections.Dec_2013, db.monthly_projections.Jan_2014,db .monthly_projections.Feb_2014] But, the problem is I don't know the complete field list ahead of time. So, I am using this instead: fields=[db.monthly_projections.employee, db.monthly_projections.id, db. monthly_projections.costcode] for row in db(db.months).select(): fields.append('db.monthly_projections.'+ row.effort_month.strftime( '%b_%Y')) This is giving an error type 'exceptions.AttributeError' 'str' object has no attribute 'tablename' On debugging, I see that the fields is created as three gluon.dal.Fields and three strings fields [gluon.dal.Field object at 0x05414470, gluon.dal.Field object at 0x046D7A58, gluon.dal.Field object at 0x09F15D30, 'db.monthly_projections.Dec_2013', 'db.monthly_projections.Jan_2014', 'db.monthly_projections.Feb_2014'] So, I changed the definition of fields to: fields=[db.monthly_projections.employee, db.monthly_projections.id, db. monthly_projections.costcode] for row in db(db.months).select(): fields.append(Field('db.monthly_projections.'+ row.effort_month.strftime( '%b_%Y'))) and this gives an error: type 'exceptions.SyntaxError' invalid table or field name: db.monthly_projections.Dec_2013 So, in short, how do I build the field list from string for SQLFORM.grid? Thanks for your help! PT -- 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/groups/opt_out.
[web2py] Re: Error in using the web2py.app.dataspreadsheets.w2p
Thank you, I opened a ticket http://code.google.com/p/web2py/issues/detail?id=1800 On Wednesday, December 4, 2013 8:42:24 AM UTC-6, Massimo Di Pierro wrote: please open a ticket, this is clearly a bug. On Tuesday, 3 December 2013 23:34:33 UTC-6, P T wrote: I am using Web2py 2.8.2 source and installed installed the app web2py.app.dataspreadsheets.w2p from https://code.google.com/p/web2py/issues/detail?id=860#c1 and getting the following errors: 1) Cannot import module 'simplejson' Ticket ID 127.0.0.1.2013-12-03.23-17-52.b5368c20-df03-4a22-b20e-35dab70c9eb0 type 'exceptions.ImportError' Cannot import module 'simplejson' Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) This is resolved by changing the line 4 in default.py from import simplejson to from gluon.contrib import simplejson With this I am able to access all pages except for database driven pages, which generate the following error. 2) global name '_class' is not defined Ticket ID 127.0.0.1.2013-12-03.23-21-14.e61d83f2-af1b-4d39-88cf-59909da11f56 type 'exceptions.NameError' global name '_class' is not defined Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) Traceback (most recent call last): File C:\web2py-src\gluon\restricted.py, line 217, in restricted exec ccode in environment File C:\web2py-src\applications\SpreadSheet\views\default/database_first.html, line 119, in module File C:\web2py-src\gluon\globals.py, line 381, in write self.body.write(xmlescape(data)) File C:\web2py-src\gluon\html.py, line 120, in xmlescape return data.xml() File C:\web2py-src\gluon\contrib\spreadsheet.py, line 873, in xml return self.sheet().xml() File C:\web2py-src\gluon\contrib\spreadsheet.py, line 862, in sheet attributes[_class]})) NameError: global name '_class' is not defined Can somebody help me to fix this? Thanks, PT -- 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/groups/opt_out.
[web2py] Re: Error in using the web2py.app.dataspreadsheets.w2p
I am posting here the solution I received by e-mail. This resolved this issue. I guess I missed the quotes for the _class dictionary key, so replacing this line **{_class: %s_fieldnames % with this **{_class: %s_fieldnames % in gluon/contrib/spreadsheet.py should avoid the error Thanks, PT On Tuesday, December 3, 2013 11:34:33 PM UTC-6, P T wrote: I am using Web2py 2.8.2 source and installed installed the app web2py.app.dataspreadsheets.w2p from https://code.google.com/p/web2py/issues/detail?id=860#c1 and getting the following errors: 1) Cannot import module 'simplejson' Ticket ID 127.0.0.1.2013-12-03.23-17-52.b5368c20-df03-4a22-b20e-35dab70c9eb0 type 'exceptions.ImportError' Cannot import module 'simplejson' Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) This is resolved by changing the line 4 in default.py from import simplejson to from gluon.contrib import simplejson With this I am able to access all pages except for database driven pages, which generate the following error. 2) global name '_class' is not defined Ticket ID 127.0.0.1.2013-12-03.23-21-14.e61d83f2-af1b-4d39-88cf-59909da11f56 type 'exceptions.NameError' global name '_class' is not defined Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) Traceback (most recent call last): File C:\web2py-src\gluon\restricted.py, line 217, in restricted exec ccode in environment File C:\web2py-src\applications\SpreadSheet\views\default/database_first.html, line 119, in module File C:\web2py-src\gluon\globals.py, line 381, in write self.body.write(xmlescape(data)) File C:\web2py-src\gluon\html.py, line 120, in xmlescape return data.xml() File C:\web2py-src\gluon\contrib\spreadsheet.py, line 873, in xml return self.sheet().xml() File C:\web2py-src\gluon\contrib\spreadsheet.py, line 862, in sheet attributes[_class]})) NameError: global name '_class' is not defined Can somebody help me to fix this? Thanks, PT -- 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/groups/opt_out.
[web2py] Error in using the web2py.app.dataspreadsheets.w2p
I am using Web2py 2.8.2 source and installed installed the app web2py.app.dataspreadsheets.w2p from https://code.google.com/p/web2py/issues/detail?id=860#c1 and getting the following errors: 1) Cannot import module 'simplejson' Ticket ID 127.0.0.1.2013-12-03.23-17-52.b5368c20-df03-4a22-b20e-35dab70c9eb0 type 'exceptions.ImportError' Cannot import module 'simplejson' Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) This is resolved by changing the line 4 in default.py from import simplejson to from gluon.contrib import simplejson With this I am able to access all pages except for database driven pages, which generate the following error. 2) global name '_class' is not defined Ticket ID 127.0.0.1.2013-12-03.23-21-14.e61d83f2-af1b-4d39-88cf-59909da11f56 type 'exceptions.NameError' global name '_class' is not defined Version web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07 Python Python 2.7.5: C:\Python27\python.exe (prefix: C:\Python27) Traceback (most recent call last): File C:\web2py-src\gluon\restricted.py, line 217, in restricted exec ccode in environment File C:\web2py-src\applications\SpreadSheet\views\default/database_first.html, line 119, in module File C:\web2py-src\gluon\globals.py, line 381, in write self.body.write(xmlescape(data)) File C:\web2py-src\gluon\html.py, line 120, in xmlescape return data.xml() File C:\web2py-src\gluon\contrib\spreadsheet.py, line 873, in xml return self.sheet().xml() File C:\web2py-src\gluon\contrib\spreadsheet.py, line 862, in sheet attributes[_class]})) NameError: global name '_class' is not defined Can somebody help me to fix this? Thanks, PT -- 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/groups/opt_out.
[web2py] Re: Change SQLFORM.grid Submit button label
Thanks, here I what I used to just rename the Submit label (see the picture below) if not grid.create_form and not grid.update_form and not grid.view_form: o = grid.element(_type='submit', _value='%s' % T('Submit')) o['_value'] = T(Compare Selected) On Wednesday, October 2, 2013 11:15:07 PM UTC-5, P T wrote: Hello All, I want change the label of Submit button in the SQLFORm.grid. I found two solutions in the forum and both seems to be not working. The first solution given here Changing SQLFORM.grid submit label from python without javascript?https://groups.google.com/forum/#!searchin/web2py/sqlform.grid$20submit$20label/web2py/NCYWvrJMeWM/RMgZNZbGSC8J is grid.element(_type='submit')['_value'] = T(something) But, the above code is changing the label of the Search button. The second solution given here SQLFORM.RID Selectablehttps://groups.google.com/forum/#!searchin/web2py/grid.element($27.web2py_table$20input%5Btype$3Dsubmit%5D$27)/web2py/HzjctWX6qYM/ogILzykUPq4J is grid.element('.web2py_table input[type=submit]')['_value'] = T('something' ) This indeed changes the label of the Submit button but break the functionality of other buttons such as Edit, View and Delete and issues a ticket. What I am doing wrong? By the way I am using the latest version 2.6.4-stable+timestamp.2013.09.22.17.43.26 on Windows 7 and here is the controller function: def listscenarios(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, links = [lambda row: A(I('',_class=icon-picture)+' Results',_class ='btn', _href=URL(default,calculate, args=[row.id], user_signature= True, hash_vars=True))], selectable=lambda ids: compare(ids), csv=False, fields=[db.scenario.id, db.scenario.name, db.scenario.description, db.scenario.avg_mass, db.scenario.cell_type, db.scenario. tap_charge, db.scenario.first_cycle, db.scenario.reverse_cycle], oncreate=scenario_create) ## grid.element('.web2py_table input[type=submit]')['_value'] = T('Something') ## this causes problems with View and Edit buttons ## grid.element(_type='submit')['_value'] = T(something) ## this chnages the label of the Search button? grid.element('.web2py_counter', replace=None) return dict(grid=grid) Thanks, PT -- 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/groups/opt_out.
[web2py] Re: Change SQLFORM.grid Submit button label
Thanks Massimo, but that didn't work. I resorted to using the following jQuery in the view: script $('input[type=submit][value=Submit]').attr('value', 'Compare Selected' );; /script May be there is an equivalent expression in Web2Py. Thanks, PT On Thursday, October 3, 2013 8:19:57 AM UTC-5, Massimo Di Pierro wrote: if grid.create_form or grid.update_form: grid.element(_type='submit')[ '_value'] = T(something) On Wednesday, 2 October 2013 23:15:07 UTC-5, P T wrote: Hello All, I want change the label of Submit button in the SQLFORm.grid. I found two solutions in the forum and both seems to be not working. The first solution given here Changing SQLFORM.grid submit label from python without javascript?https://groups.google.com/forum/#!searchin/web2py/sqlform.grid$20submit$20label/web2py/NCYWvrJMeWM/RMgZNZbGSC8J is grid.element(_type='submit')['_value'] = T(something) But, the above code is changing the label of the Search button. The second solution given here SQLFORM.RID Selectablehttps://groups.google.com/forum/#!searchin/web2py/grid.element($27.web2py_table$20input%5Btype$3Dsubmit%5D$27)/web2py/HzjctWX6qYM/ogILzykUPq4J is grid.element('.web2py_table input[type=submit]')['_value'] = T( 'something') This indeed changes the label of the Submit button but break the functionality of other buttons such as Edit, View and Delete and issues a ticket. What I am doing wrong? By the way I am using the latest version 2.6.4-stable+timestamp.2013.09.22.17.43.26 on Windows 7 and here is the controller function: def listscenarios(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, links = [lambda row: A(I('',_class=icon-picture)+' Results',_class ='btn', _href=URL(default,calculate, args=[row.id], user_signature= True, hash_vars=True))], selectable=lambda ids: compare(ids), csv=False, fields=[db.scenario.id, db.scenario.name, db.scenario.description, db.scenario.avg_mass, db.scenario.cell_type, db.scenario. tap_charge, db.scenario.first_cycle, db.scenario.reverse_cycle], oncreate=scenario_create) ## grid.element('.web2py_table input[type=submit]')['_value'] = T('Something') ## this causes problems with View and Edit buttons ## grid.element(_type='submit')['_value'] = T(something) ## this chnages the label of the Search button? grid.element('.web2py_counter', replace=None) return dict(grid=grid) Thanks, PT -- 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/groups/opt_out.
[web2py] help with user_signature
I am using version 2.6.4 on Windows 7 machine and having a problem with using user_signature and auth.requires_signature. I am using SQLFORM.grid to display a list of scenarios created by the logged-in user. I included an additional button Results, which calls another function calculate and passing the row.id. This works fine but the logged-in user can simply type an url like http://127.0.0.1:8000/test/default/calculate/12; and view results from other users' scenarios. @auth.requires_login() def listscenarios(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, links = [lambda row: A('Results', _class='btn' , _href=URL(default,calculate, args=[row.id]))],csv=False, oncreate= scenario_create) return dict(grid=grid) def calculate(): if not request.args(0): return '' else: ## do the required calculations redirect(URL('voltageprofile')) By reading the book and searching the group, I decorated the functions with user_signature and auth.requires_signature. But, now I get Not authorized page for all users. @auth.requires_login() def listscenarios(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, links = [lambda row: A('Results', _class='btn' , _href=URL(default,calculate, args=[row.id]),user_signature=True,hash_vars =True)],csv=False, oncreate=scenario_create) return dict(grid=grid) @auth.requires_signature() def calculate(): if not request.args(0): return '' else: ## do the required calculations redirect(URL('voltageprofile')) Please help in correctly implementing this. Thanks, PT -- 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/groups/opt_out.
[web2py] Re: help with user_signature
Sorry, I made a silly error is using the user_signature. It should be a part of URL call. This line should read (note the change in ) bracket) grid = SQLFORM.grid(query, links = [lambda row: A('Results', _class='btn',_href =URL(default,calculate, args=[row.id],user_signature=True, hash_vars= True))],csv=False, oncreate=scenario_create) On Wednesday, October 2, 2013 2:39:42 PM UTC-5, P T wrote: I am using version 2.6.4 on Windows 7 machine and having a problem with using user_signature and auth.requires_signature. I am using SQLFORM.grid to display a list of scenarios created by the logged-in user. I included an additional button Results, which calls another function calculate and passing the row.id. This works fine but the logged-in user can simply type an url like http://127.0.0.1:8000/test/default/calculate/12; and view results from other users' scenarios. @auth.requires_login() def listscenarios(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, links = [lambda row: A('Results', _class= 'btn', _href=URL(default,calculate, args=[row.id]))],csv=False,oncreate =scenario_create) return dict(grid=grid) def calculate(): if not request.args(0): return '' else: ## do the required calculations redirect(URL('voltageprofile')) By reading the book and searching the group, I decorated the functions with user_signature and auth.requires_signature. But, now I get Not authorized page for all users. @auth.requires_login() def listscenarios(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, links = [lambda row: A('Results', _class= 'btn', _href=URL(default,calculate, args=[row.id]),user_signature=True , hash_vars=True)],csv=False, oncreate=scenario_create) return dict(grid=grid) @auth.requires_signature() def calculate(): if not request.args(0): return '' else: ## do the required calculations redirect(URL('voltageprofile')) Please help in correctly implementing this. Thanks, PT -- 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/groups/opt_out.
[web2py] Change SQLFORM.grid Submit button label
Hello All, I want change the label of Submit button in the SQLFORm.grid. I found two solutions in the forum and both seems to be not working. The first solution given here Changing SQLFORM.grid submit label from python without javascript?https://groups.google.com/forum/#!searchin/web2py/sqlform.grid$20submit$20label/web2py/NCYWvrJMeWM/RMgZNZbGSC8J the solution is grid.element(_type='submit')['_value'] = T(something) But, the above code is changing the label of the Search button. The second solution given here SQLFORM.RID Selectablehttps://groups.google.com/forum/#!searchin/web2py/grid.element($27.web2py_table$20input%5Btype$3Dsubmit%5D$27)/web2py/HzjctWX6qYM/ogILzykUPq4J is grid.element('.web2py_table input[type=submit]')['_value'] = T('something') This indeed changes the label of the Submit button but break the functionality of other buttons such as Edit, View and Delete and issues a ticket. What I am doing wrong? By the way I am using the latest version 2.6.4-stable+timestamp.2013.09.22.17.43.26 on Windows 7 and here is the controller function: def listscenarios(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, links = [lambda row: A(I('',_class=icon-picture)+' Results', _class ='btn', _href=URL(default,calculate, args=[row.id], user_signature=True,hash_vars =True))], selectable=lambda ids: compare(ids), csv=False, fields=[db.scenario.id, db.scenario.name, db.scenario.description, db.scenario.avg_mass, db.scenario.cell_type, db.scenario. tap_charge, db.scenario.first_cycle, db.scenario.reverse_cycle], oncreate=scenario_create) ## grid.element('.web2py_table input[type=submit]')['_value'] = T('Something') ## this causes problems with View and Edit buttons ## grid.element(_type='submit')['_value'] = T(something) ## this chnages the label of the Search button? grid.element('.web2py_counter', replace=None) return dict(grid=grid) Thanks, PT -- 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/groups/opt_out.
[web2py] Re: upload and a process file using SQLFORM.grid
Found the answer by searching the forum for sqlform.grid oncreate and specifically the answer by Niphlod in this post https://groups.google.com/forum/#!searchin/web2py/sqlform.grid$20oncreate/web2py/ShebcblC9pM/rrdI9F6ZgV8J On Thursday, September 12, 2013 12:05:45 AM UTC-5, P T wrote: Hello All, Just started to learn web2py and here is an idea that I am trying to implement. Users creates scenarios, which includes an uploaded file. After the new scenario is created, the uploaded file should be processed and computed values written to results table. So far, I am successful in creating the scenarios and uploading the files. But, I am not sure where I would write the controller form.process().accepted. By the way, I am using SQLFORM.grid and here is complete code. Any help and/or pointers is highly appreciated. - db.py from gluon.tools import * db=DAL(sqlite://storage.sqlite) auth = Auth(db) auth.define_tables(username=True) crud = Crud(db) db.define_table(scenario, Field('title'), Field('body', 'text'), Field('created_on', 'datetime', default=request.now), Field('created_by', 'reference auth_user', default=db.auth_user.id), Field('file', 'upload'), Field('file_status', default='file uploaded')) db.scenario.created_by.requires=IS_IN_DB(db, db.auth_user.id) db.scenario.title.requires = IS_NOT_EMPTY() db.scenario.created_on.readable = False db.scenario.created_by.readable = False db.define_table(results, Field('scenario_id', 'reference scenario'), Field('amps', 'double'), Field('volts', 'double')) default.py @auth.requires_login() def index(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, selectable=lambda ids: []) return dict(grid=grid) default/index.html {{extend 'layout.html'}} {{if auth.user.id:}} h2Your Current Scenarios/h2 {{=grid}} {{pass}} -- I tested the following code and see that the form accepted is flashed. But, how do I link this form to the Add button in the SQLFORM.grid def scenario(): form = SQLFORM(db.scenario) if form.process().accepted: response.flash = form accepted ##get the uploaded file, process and write results return dict(form=form) Thanks, PT -- 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/groups/opt_out.
[web2py] upload and a process file using SQLFORM.grid
Hello All, Just started to learn web2py and here is an idea that I am trying to implement. Users creates scenarios, which includes an uploaded file. After the new scenario is created, the uploaded file should be processed and computed values written to results table. So far, I am successful in creating the scenarios and uploading the files. But, I am not sure where I would write the controller form.process().accepted. By the way, I am using SQLFORM.grid and here is complete code. Any help and/or pointers is highly appreciated. - db.py from gluon.tools import * db=DAL(sqlite://storage.sqlite) auth = Auth(db) auth.define_tables(username=True) crud = Crud(db) db.define_table(scenario, Field('title'), Field('body', 'text'), Field('created_on', 'datetime', default=request.now), Field('created_by', 'reference auth_user', default=db.auth_user.id), Field('file', 'upload'), Field('file_status', default='file uploaded')) db.scenario.created_by.requires=IS_IN_DB(db, db.auth_user.id) db.scenario.title.requires = IS_NOT_EMPTY() db.scenario.created_on.readable = False db.scenario.created_by.readable = False db.define_table(results, Field('scenario_id', 'reference scenario'), Field('amps', 'double'), Field('volts', 'double')) default.py @auth.requires_login() def index(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, selectable=lambda ids: []) return dict(grid=grid) default/index.html {{extend 'layout.html'}} {{if auth.user.id:}} h2Your Current Scenarios/h2 {{=grid}} {{pass}} -- I tested the following code and see that the form accepted is flashed. But, how do I link this form to the Add button in the SQLFORM.grid def scenario(): form = SQLFORM(db.scenario) if form.process().accepted: response.flash = form accepted ##get the uploaded file, process and write results return dict(form=form) Thanks, PT -- 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/groups/opt_out.