[web2py] Re: RESTful request args/vars with JSON array
what web2py version are you on ? On Friday, October 24, 2014 3:01:23 AM UTC+2, Henry Nguyen wrote: Niphlod, That does not appear to be the case, either for request.restful() requests or regular controller requests. For example, consider this controller method: def test(): logger.debug(request.env.content_type) logger.debug(request.post_vars) logger.debug(request.body.read()) return With the request data as a JSON array of objects, such as: [{id:1, is_read:true}] I get the following logs: 2014-10-23 17:51:47,488 DEBUG test.py test():14 : application/json 2014-10-23 17:51:47,490 DEBUG test.py test():15 : Storage {} 2014-10-23 17:51:47,490 DEBUG test.py test():16 : [{id:1, is_read:true}] With the data as a JSON object, such as {id:1, is_read:true} I get the following logs: 2014-10-23 17:54:46,468 DEBUG test.py test():14 : application/json 2014-10-23 17:54:46,469 DEBUG test.py test():15 : Storage {u'is_read': True, u'id': 1} 2014-10-23 17:54:46,470 DEBUG test.py test():16 : {id:1, is_read:true} Note that request data is not parsed into request.post_vars. This would make sense to me; since request.post_vars is a Storage object which inherits from a Python dictionary, there would be no dictionary key to store the array value, no? Henry On Thursday, October 23, 2014 7:16:00 AM UTC-7, Niphlod wrote: if the content-type of the POST request is application/json, mylist would actually be yet parsed into request.post_vars (i.e. you can skip body.read()) On Thursday, October 23, 2014 1:24:09 AM UTC+2, Henry Nguyen wrote: For posterity's sake, I was able to retrieve the array in the request body by using: import json my_list = json.loads(request.body.read()) and then iterating through the list items just like any other list. This was taken from http://web2py.com/books/default/chapter/29/04#request under request.body. Thanks for letting me know that request.restful() wouldn't parse it automatically, Niphlod. Henry On Monday, October 13, 2014 12:25:54 PM UTC-7, Niphlod wrote: you have to code your own methods. On Sunday, October 12, 2014 11:32:23 PM UTC+2, Henry Nguyen wrote: I have a function in my controller decorated with the @request.restful() decorator. I would like to be able to accept a JSON array of objects, [{id: 1, new_value: 1},{id: 2, new_value: 2}] , on a POST, PUT, or DELETE. For example, I'd like the client to be able to update a series of values on one request, as opposed to having to submit multiple requests for each individual update. However, the args and vars parameters being passed to the methods are empty when a request is sent with the JSON payload above. Specifically, args only gets populated from URL args and vars only get populated if the array is accompanied by a key, such as in: {update: [{id: 1, new_value: 1},{id: 2, new_value: 2}]} While it certainly isn't too much trouble to include that initial key, I was wondering if there's any way to retrieve the JSON objects from the request without having to specify the key so that I could pass a simple array instead? Thank you ahead of time for any help. -- 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 can I prevent a user from pressing the browser's back button?
You can do in the head section of the view script language=javascript type=text/javascript history.forward(); /script I use it in my applications. On Wednesday, August 27, 2014 3:06:45 AM UTC+5:30, Fotis Gioulekas wrote: Hello to everybody, I have built a quiz that randomlycreates questions. Each time a user submits it's answer, the app redirects to another question. When the user does not want to continue to another question it presses a button exit quiz and the app redirects to another url. When the user presses the browser's back button, it can return back to the quiz. How can I prevent this? Is there a solution that either closes the browser's tab or redirects to a default html page when the user presses the back broswer's button or My app does not requires user registratrion and login. Thank you in advance, Fotios -- 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] Sticky sessions in a distributed environment
I am trying to scale up my application deployed on Heroku by increasing the number of dynos and am currently confronted with the issue of handling sessions in a distributed environment. The regular solution (storing sessions in the database) does not seem to work anymore when multiple dynos run concurrently : clients get asked for login at every request. I have no idea why this doesn't work since databases are supposed to be shared between dynos on Heroku, but as far as I know there are 2 possible ways to manage scalable sticky sessions: 1. Memcache : couldn't use gluon/contrib to test this because the MemcacheClient does not allow authentication in a connection string (i.e. services like Memcached, MemCachier...) 2. Redis : same issue -- Redis client does not seem to work well with auth-based services that are available on Heroku (e.g. RedisCloud) Any idea why db-based sessions do not stick out of the box on Heroku, and/or how to use a Cloud-based service to achieve session stickiness ? -- 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] Question about a field boolean in MSSQL
Hello to everybody, I have a question, please answer for me! In the model, I define a field: *db.define_table('mytable',* * Field('is_imported', 'boolean', default = False), ...)* *db.**mytable* *.insert(is_imported = True,..)* *db.**mytable**.insert(is_imported = False,..)* In the controller, I write: *records = db(db.mytable.id).select(db.mytable.is_imported)* *for record in records:* *print record.**is_imported* Result: *False* * False* Expected result: *True* * False* And I see with boolean fields, command select always return *False *for every values (0, 1) in mssql. I were trying with all mssql and mssql2, they had same result. Please tell me why. Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Question about a field boolean in MSSQL
Sorry, this issue just occur in *mssql2.* Vào 17:36:52 UTC+7 Thứ sáu, ngày 24 tháng mười năm 2014, Gianganh Nguyen đã viết: Hello to everybody, I have a question, please answer for me! In the model, I define a field: *db.define_table('mytable',* * Field('is_imported', 'boolean', default = False), ...)* *db.**mytable* *.insert(is_imported = True,..)* *db.**mytable**.insert(is_imported = False,..)* In the controller, I write: *records = db(db.mytable.id http://db.mytable.id).select(db.mytable.is_imported)* *for record in records:* *print record.**is_imported* Result: *False* * False* Expected result: *True* * False* And I see with boolean fields, command select always return *False *for every values (0, 1) in mssql. I were trying with all mssql and mssql2, they had same result. Please tell me why. Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Question about a field boolean in MSSQL
Looks like the MSSQL2 adapter stores booleans as T and F character values, so you may need to convert your 1's and 0's to T and F. Anthony On Friday, October 24, 2014 7:14:47 AM UTC-4, Gianganh Nguyen wrote: Sorry, this issue just occur in *mssql2.* Vào 17:36:52 UTC+7 Thứ sáu, ngày 24 tháng mười năm 2014, Gianganh Nguyen đã viết: Hello to everybody, I have a question, please answer for me! In the model, I define a field: *db.define_table('mytable',* * Field('is_imported', 'boolean', default = False), ...)* *db.**mytable* *.insert(is_imported = True,..)* *db.**mytable**.insert(is_imported = False,..)* In the controller, I write: *records = db(db.mytable.id http://db.mytable.id).select(db.mytable.is_imported)* *for record in records:* *print record.**is_imported* Result: *False* * False* Expected result: *True* * False* And I see with boolean fields, command select always return *False *for every values (0, 1) in mssql. I were trying with all mssql and mssql2, they had same result. Please tell me why. Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] IS_EMPTY_OR not working for file upload
I gave this validator. requires=(IS_EMPTY_OR(IS_UPLOAD_FILENAME(extension='pdf'))) But when I submit the form I still get the error Enter a valid file name. Please help me. -- 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] Getting web2py to reload module files for each return view
Hi, Working with a team building a reasonably complex webapp for an investment management system, and I'm trying to learn something of the system too. I have a module that updates data from a file (simulating an FTP drop). Once the module has been loaded the first time, it doesn't update for either changes in code or in the underlying data no matter how often I refresh the page. Is there a particular way to force web2py to reload any files each time a page is refreshed? Am I doing something completely wrong? Thanks The code is as follows: module: *dataxl.py* from gluon import * import csv import json import os from xlrd import open_workbook as lox def mydata(): filepath = os.join(current.request.folder, 'static', 'sample-data', \ '20-10-2014_sample-data-for-designer.xls') oldbook = lox(filepath) names = oldbook.sheet_names() workbook = {} for name in names: worksheet = [] oldsheet = ws.sheet_by_name(name) nrows = oldsheet.nrows ncols = oldsheet.ncols colnames = [ oldsheet.cell(0,i).value for i in range(ncols) ] rownames = [ oldsheet.cell(i,0).value for i in range(nrows) ] for nrow in xrange(1,nrows): worksheet.append({colnames[ncol]: oldsheet.cell(nrow,ncol).value \ for ncol in xrange(ncols)}) workbook[name] = worksheet return workbook controller: *performance.py* import dataxl wsheet = dataxl.mydata() attr = wsheet[ 'Performance_Attr' ] @auth.requires_login() def perf_multi_asset(): clientId = set(i[ 'client' ] for i in attr.values()) portId = [ 'All' ] portId.append(j for j in set(i[0] for i in attr.items() \ if i[ 1 ][ 'Attribution Level' ] == 0 \ or i[ 1 ][ 'Attribution Level' ] == 1)) perform = SQLFORM.factory( Field('client', 'string'),requires=IS_IN_SET(clientId)), Field('portfolio', 'string'),requires=IS_IN_SET(portId)), Field('start_date', 'date'), Field('end_date', 'date') ).process() if perform.vars.portfolio == 'All': data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] == perform.vars.client} else: data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] == perform.vars.client \ and i[ 0 ] == perform.vars.portfolio} return locals() and view: *performance/perf_multi_asset.html* {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals ())}} {{extend 'layout.html'}} {{=STYLE(XML(.generic-widget,#no_table_start_date,#no_table_end_date {width:100px}))}} div class=row {{=perform.custom.begin}} div class=span2 Client Name: br {{=perform.custom.widget.client}} /div div class=span2 Portfolio ID: br {{=perform.custom.widget.portfolio}} /div div class=span2 Start Date: br {{=perform.custom.widget.start_date}} /div div class=span2 End Date: br {{=perform.custom.widget.end_date}} /div div class=span2 br {{=perform.custom.submit}} /div {{=perform.custom.end}} /div {{=BEAUTIFY(XML(data))}} -- 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: cool css3 hover effects
try this one too... http://www.corelangs.com/css/box/hover.html Ling On Friday, November 11, 2011 12:27:46 AM UTC+5:30, Massimo Di Pierro wrote: http://tympanus.net/Tutorials/OriginalHoverEffects/index.html -- 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] Exporting from a SQLFORM.grid with customized search queries
Hi All, This is my first time posting a question, so thanks to Massimo and they whole community for making web2py. Its great! I am trying to export results from a customized full-text search using SQLFORM.grid. My backend is a Postgres db, and I successfully define search_widget and searchable functions that are passed to the SQLFORM.grid to do the full-text search. It will works pretty well on the web app. However, once I click the export button, SQLFORM.grid apparently recreates the query using the default SQLFORM.build_query and ignores the correct query which I define in searchable. After poking around in sqlhtml.py, I found this is so because the exporter only conditions on request.vars.keywords before calling SQLFORM.build_query, and it does not check for callable(searchable) which I think it should do. In fact, I fixed it by editing sqlhtml.py to force the exporter to condition on (request.vars.keywords *and callable(searchable)*) before setting up the rows object to export. The code I added is in bold below (on line 2298 of sqlhtml.py): if request.vars.keywords *and callable(searchable)*: try: #the query should be constructed using searchable fields but not virtual fields sfields = reduce(lambda a, b: a + b, [[f for f in t if f.readable and not isinstance(f, Field.Virtual)] for t in tables]) dbset = dbset(SQLFORM.build_query( sfields, request.vars.get('keywords', ''))) rows = dbset.select(left=left, orderby=orderby, cacheable=True, *selectable_columns) except Exception, e: response.flash = T('Internal Error') rows = [] else: rows = dbset.select(left=left, orderby=orderby, cacheable=True, *selectable_columns) Is this a bug or is there a better way to do an export of customized search results using SQLFORM.grid? I'm using the current version of everything (web2py 2.9.11, Postgres 9.3, Python 2.7.8). Thx again, dex* -- 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 can I prevent a user from pressing the browser's back button?
Hello sir, thank you for the hint I am working on this. I hope it works also in my application. BR F On Friday, October 24, 2014 10:54:54 AM UTC+3, T.R.Rajkumar wrote: You can do in the head section of the view script language=javascript type=text/javascript history.forward(); /script I use it in my applications. On Wednesday, August 27, 2014 3:06:45 AM UTC+5:30, Fotis Gioulekas wrote: Hello to everybody, I have built a quiz that randomlycreates questions. Each time a user submits it's answer, the app redirects to another question. When the user does not want to continue to another question it presses a button exit quiz and the app redirects to another url. When the user presses the browser's back button, it can return back to the quiz. How can I prevent this? Is there a solution that either closes the browser's tab or redirects to a default html page when the user presses the back broswer's button or My app does not requires user registratrion and login. Thank you in advance, Fotios -- 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: db.commit() taking too long to update records
Thanks for the headsup Anthony!, luckly it's not my case. Cheers! On Thu, Oct 23, 2014 at 2:18 PM, Anthony abasta...@gmail.com wrote: On Thursday, October 23, 2014 12:52:33 PM UTC-4, Leonel Câmara wrote: Doesn't the database take care of that? I mean isn't db session handling inside a transaction anyway? Yes, but that doesn't help across requests (e.g., request A reads session request B reads session request A updates session request B overwrites request A's update). The session table in the db does include a locked field, but as far as I can tell, it is not actually used. Another option would be to do a select-for-update, which would result in the db locking the record until the transaction completes (though in the case of SQLite, I think the whole db gets locked). Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/6z13PTcZ5io/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Atte Luciano Laporta Podazza -- 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] Rocket use
Hello all, I am about ready to start deploying my site. It is a private site for about 8-10 users. I was wondering if, given the small size, whether it would be safe to use the rocket web server, rather than apache or nginx? Thanks Rod -- 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: Opening PDF files in web browser
Any Idea? Regards -- 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: RESTful request args/vars with JSON array
I'm on the latest version from the repo, 2.10.0-beta+timestamp.2014.10.16.15.58.50, though I had this issue on the mainline 2.9.11 as well. Henry On Friday, October 24, 2014 12:37:15 AM UTC-7, Niphlod wrote: what web2py version are you on ? On Friday, October 24, 2014 3:01:23 AM UTC+2, Henry Nguyen wrote: Niphlod, That does not appear to be the case, either for request.restful() requests or regular controller requests. For example, consider this controller method: def test(): logger.debug(request.env.content_type) logger.debug(request.post_vars) logger.debug(request.body.read()) return With the request data as a JSON array of objects, such as: [{id:1, is_read:true}] I get the following logs: 2014-10-23 17:51:47,488 DEBUG test.py test():14 : application/json 2014-10-23 17:51:47,490 DEBUG test.py test():15 : Storage {} 2014-10-23 17:51:47,490 DEBUG test.py test():16 : [{id:1, is_read:true}] With the data as a JSON object, such as {id:1, is_read:true} I get the following logs: 2014-10-23 17:54:46,468 DEBUG test.py test():14 : application/json 2014-10-23 17:54:46,469 DEBUG test.py test():15 : Storage {u'is_read': True, u'id': 1} 2014-10-23 17:54:46,470 DEBUG test.py test():16 : {id:1, is_read:true } Note that request data is not parsed into request.post_vars. This would make sense to me; since request.post_vars is a Storage object which inherits from a Python dictionary, there would be no dictionary key to store the array value, no? Henry On Thursday, October 23, 2014 7:16:00 AM UTC-7, Niphlod wrote: if the content-type of the POST request is application/json, mylist would actually be yet parsed into request.post_vars (i.e. you can skip body.read()) On Thursday, October 23, 2014 1:24:09 AM UTC+2, Henry Nguyen wrote: For posterity's sake, I was able to retrieve the array in the request body by using: import json my_list = json.loads(request.body.read()) and then iterating through the list items just like any other list. This was taken from http://web2py.com/books/default/chapter/29/04#request under request.body. Thanks for letting me know that request.restful() wouldn't parse it automatically, Niphlod. Henry On Monday, October 13, 2014 12:25:54 PM UTC-7, Niphlod wrote: you have to code your own methods. On Sunday, October 12, 2014 11:32:23 PM UTC+2, Henry Nguyen wrote: I have a function in my controller decorated with the @request.restful() decorator. I would like to be able to accept a JSON array of objects, [{id: 1, new_value: 1},{id: 2, new_value: 2}] , on a POST, PUT, or DELETE. For example, I'd like the client to be able to update a series of values on one request, as opposed to having to submit multiple requests for each individual update. However, the args and vars parameters being passed to the methods are empty when a request is sent with the JSON payload above. Specifically, args only gets populated from URL args and vars only get populated if the array is accompanied by a key, such as in: {update: [{id: 1, new_value: 1},{id: 2, new_value: 2}]} While it certainly isn't too much trouble to include that initial key, I was wondering if there's any way to retrieve the JSON objects from the request without having to specify the key so that I could pass a simple array instead? Thank you ahead of time for any help. -- 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: reference auth_user from a table in one database to the auth_user table in another database
On Thursday, October 23, 2014 7:11:19 AM UTC-7, Niphlod wrote: you can't reference fields from different databases. To work around that, you'd do a select on db1 to get the data you want, and then an update on db? /dps On Thursday, October 23, 2014 3:07:50 PM UTC+2, Carl Petersen wrote: Hello, I'm trying to reference the auth_user table in one database from a field definition for a table in a different database. Hopefully the code below will clarify: db1 = DAL('postgres://user:password@host1/database1',pool_size=1,check_reserved=None,migrate=False) db = DAL('postgres://user:password@host/database',pool_size=1,check_reserved=['all'],migrate=False) db1.executesql(set search_path to 'devxref','public';) db.executesql(set search_path to 'po','xref','dw','public';) *db*.define_table('x_vendor', Field('source_vendor_dwid',db.d_supplier_source), Field('source_vendor_id'), Field('source_system_dwid',db.d_source), Field('source_system_id'), Field('gp_vendor_dwid',db.d_supplier_source), Field('gp_vendor_id'), Field('changed_date_time','datetime', default=request.now, update=request.now, writable=False), Field('changed_user_id','reference *db1*.auth_user', default=auth.user_id, update=auth.user_id, writable=False), format='%(x_vendor)s') I get the following errors in the dump: Traceback (most recent call last): File /opt/web-apps/web2py/gluon/restricted.py, line 224, in restricted exec ccode in environment File /opt/web-apps/web2py/applications/wspg/controllers/x_vendor.py https://dc1ux544/admin/default/edit/wspg/controllers/x_vendor.py, line 127, in module File /opt/web-apps/web2py/gluon/globals.py, line 392, in lambda self._caller = lambda f: f() File /opt/web-apps/web2py/applications/wspg/controllers/x_vendor.py https://dc1ux544/admin/default/edit/wspg/controllers/x_vendor.py, line 85, in add if form.process().accepted: File /opt/web-apps/web2py/gluon/html.py, line 2303, in process self.validate(**kwargs) File /opt/web-apps/web2py/gluon/html.py, line 2240, in validate if self.accepts(**kwargs): File /opt/web-apps/web2py/gluon/sqlhtml.py, line 1671, in accepts self.vars.id = self.table.insert(**fields) File /opt/web-apps/web2py/gluon/dal.py, line 9320, in insert ret = self._db._adapter.insert(self, self._listify(fields)) File /opt/web-apps/web2py/gluon/dal.py, line 1354, in insert query = self._insert(table, fields) File /opt/web-apps/web2py/gluon/dal.py, line 2903, in _insert values = ','.join(self.expand(v, f.type) for f, v in fields) File /opt/web-apps/web2py/gluon/dal.py, line 2903, in genexpr values = ','.join(self.expand(v, f.type) for f, v in fields) File /opt/web-apps/web2py/gluon/dal.py, line 1555, in expand return str(self.represent(expression, field_type)) File /opt/web-apps/web2py/gluon/dal.py, line 3079, in represent return BaseAdapter.represent(self, obj, fieldtype) File /opt/web-apps/web2py/gluon/dal.py, line 2016, in represent ftype = self.db[p[0]][p[2]].type File /opt/web-apps/web2py/gluon/dal.py, line 8512, in __getitem__ return self.__getattr__(str(key)) File /opt/web-apps/web2py/gluon/dal.py, line 8522, in __getattr__ return ogetattr(self, key) AttributeError: 'DAL' object has no attribute 'db1' Any assistance would be greatly appreciated. Thanks! Carl -- 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] custom ordering on queries
This is a more general DB query, but I've learned to trust the web2py community, and web2py is where the answer will do me the most good. I'm looking at a table where I want to have a custom ordering on a field. Standard ascending and descending don't quite work for me in the use I'm interested in. What I want to do is sort the field (owner) so that the value I'm most interested in is at the top (owner='dave'), and the rest of the entries are sorted asc or desc. Is there a way to do that in a single query, or do I need to make 2 queries and concatenate the results? Is group by an appropriate SQL clause here? Also, would that solution generalize to sorting by a set of values of interest at the top (owner='dave'|'bob'|'andy')? Thanks. /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] Re: custom ordering on queries
db guy mode if the cardinality of owner is not high, fetch them all and use for row in rows.sort(yourownfunction). If the cardinality is high, either do two queries, or add a sort_index integer column that you can use for large sorts. /db guy mode developer use for row in rows.sort() /developer -- 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: RESTful request args/vars with JSON array
ok. got it. usually in APIs you don't post an array, you post an object. automatic parsing works only for objects, not for arrays. On Friday, October 24, 2014 8:08:02 PM UTC+2, Henry Nguyen wrote: I'm on the latest version from the repo, 2.10.0-beta+timestamp.2014.10.16.15.58.50, though I had this issue on the mainline 2.9.11 as well. Henry On Friday, October 24, 2014 12:37:15 AM UTC-7, Niphlod wrote: what web2py version are you on ? On Friday, October 24, 2014 3:01:23 AM UTC+2, Henry Nguyen wrote: Niphlod, That does not appear to be the case, either for request.restful() requests or regular controller requests. For example, consider this controller method: def test(): logger.debug(request.env.content_type) logger.debug(request.post_vars) logger.debug(request.body.read()) return With the request data as a JSON array of objects, such as: [{id:1, is_read:true}] I get the following logs: 2014-10-23 17:51:47,488 DEBUG test.py test():14 : application/json 2014-10-23 17:51:47,490 DEBUG test.py test():15 : Storage {} 2014-10-23 17:51:47,490 DEBUG test.py test():16 : [{id:1, is_read:true}] With the data as a JSON object, such as {id:1, is_read:true} I get the following logs: 2014-10-23 17:54:46,468 DEBUG test.py test():14 : application/json 2014-10-23 17:54:46,469 DEBUG test.py test():15 : Storage {u'is_read': True, u'id': 1} 2014-10-23 17:54:46,470 DEBUG test.py test():16 : {id:1, is_read: true} Note that request data is not parsed into request.post_vars. This would make sense to me; since request.post_vars is a Storage object which inherits from a Python dictionary, there would be no dictionary key to store the array value, no? Henry On Thursday, October 23, 2014 7:16:00 AM UTC-7, Niphlod wrote: if the content-type of the POST request is application/json, mylist would actually be yet parsed into request.post_vars (i.e. you can skip body.read()) On Thursday, October 23, 2014 1:24:09 AM UTC+2, Henry Nguyen wrote: For posterity's sake, I was able to retrieve the array in the request body by using: import json my_list = json.loads(request.body.read()) and then iterating through the list items just like any other list. This was taken from http://web2py.com/books/default/chapter/29/04#request under request.body. Thanks for letting me know that request.restful() wouldn't parse it automatically, Niphlod. Henry On Monday, October 13, 2014 12:25:54 PM UTC-7, Niphlod wrote: you have to code your own methods. On Sunday, October 12, 2014 11:32:23 PM UTC+2, Henry Nguyen wrote: I have a function in my controller decorated with the @request.restful() decorator. I would like to be able to accept a JSON array of objects, [{id: 1, new_value: 1},{id: 2, new_value: 2}] , on a POST, PUT, or DELETE. For example, I'd like the client to be able to update a series of values on one request, as opposed to having to submit multiple requests for each individual update. However, the args and vars parameters being passed to the methods are empty when a request is sent with the JSON payload above. Specifically, args only gets populated from URL args and vars only get populated if the array is accompanied by a key, such as in: {update: [{id: 1, new_value: 1},{id: 2, new_value: 2}]} While it certainly isn't too much trouble to include that initial key, I was wondering if there's any way to retrieve the JSON objects from the request without having to specify the key so that I could pass a simple array instead? Thank you ahead of time for any help. -- 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: Rocket use
rocket is perfectly fine. On Friday, October 24, 2014 7:29:47 PM UTC+2, Rod Watkins wrote: Hello all, I am about ready to start deploying my site. It is a private site for about 8-10 users. I was wondering if, given the small size, whether it would be safe to use the rocket web server, rather than apache or nginx? Thanks Rod -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: web2py website error with Chinese user
On Thursday, October 23, 2014 12:27:09 PM UTC-7, Niphlod wrote: if you're serving all assets from the same hostname, then Chinese network restrictions aren't the cause. Maybe a wrongly set proxy, but it's entirely not web2py's fault, nor your app's code. Could the user's browser have the setting set to use personal css instead of site's? I'm not sure how VPNs would play into that, though, except through identifying the site to apply the [local] css to. /dps On Thursday, October 23, 2014 5:11:57 PM UTC+2, Gael Princivalle wrote: Yes, everything's is in the same server. That's quite complicated to understand what's going wrong as I don't have a Chinese computer for testing. -- Gael Princivalle 2014-10-23 16:12 GMT+02:00 Niphlod nip...@gmail.com: who knows. Are you serving all assets from the same location as the site or not ? On Thursday, October 23, 2014 8:15:22 AM UTC+2, Gael Princivalle wrote: Hello all. I've got a Chinese user that complains he cannot login in a web2py website that I've done. He send me a printscreen where all CSS and Javascript are not loaded, so he can't login. If he use a VPN it's ok. Someone know why ? Perhaps it's due to Chinese network restrictions ? Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/FqV5p6za64E/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Rocket use
Good. I like its simplicity. Thanks! On Friday, 24 October 2014 12:42:43 UTC-7, Niphlod wrote: rocket is perfectly fine. On Friday, October 24, 2014 7:29:47 PM UTC+2, Rod Watkins wrote: Hello all, I am about ready to start deploying my site. It is a private site for about 8-10 users. I was wondering if, given the small size, whether it would be safe to use the rocket web server, rather than apache or nginx? Thanks Rod -- 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: Rocket use
Hi Rod, I am interrested in the same kind of setup. When you say Rocket, are you talking about : https://launchpad.net/rocket ? Thanks! Le vendredi 24 octobre 2014 22:03:12 UTC+2, Rod Watkins a écrit : Good. I like its simplicity. Thanks! On Friday, 24 October 2014 12:42:43 UTC-7, Niphlod wrote: rocket is perfectly fine. On Friday, October 24, 2014 7:29:47 PM UTC+2, Rod Watkins wrote: Hello all, I am about ready to start deploying my site. It is a private site for about 8-10 users. I was wondering if, given the small size, whether it would be safe to use the rocket web server, rather than apache or nginx? Thanks Rod -- 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: Rocket use
Yes, though it's actually the web server included with web2py: https://github.com/web2py/web2py/blob/master/gluon/rocket.py Anthony On Friday, October 24, 2014 5:03:36 PM UTC-4, Bilal El wrote: Hi Rod, I am interrested in the same kind of setup. When you say Rocket, are you talking about : https://launchpad.net/rocket ? Thanks! Le vendredi 24 octobre 2014 22:03:12 UTC+2, Rod Watkins a écrit : Good. I like its simplicity. Thanks! On Friday, 24 October 2014 12:42:43 UTC-7, Niphlod wrote: rocket is perfectly fine. On Friday, October 24, 2014 7:29:47 PM UTC+2, Rod Watkins wrote: Hello all, I am about ready to start deploying my site. It is a private site for about 8-10 users. I was wondering if, given the small size, whether it would be safe to use the rocket web server, rather than apache or nginx? Thanks Rod -- 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: Rocket use
Thanks Phyo! I didn't knew that web2py was built on Rocket for the developpement environnement. Thanks for the advice about uWSGI. Le Fri Oct 24 2014 at 23:07:44, Phyo Arkar phyo.arkarl...@gmail.com a écrit : Web2py is by default run on rocket. But even small set of users , i recommend uWSGI , it greatly improve perfornace and when doing big upload/download , it Shines! , ajax responses much faster . Plus very easy to install and setup uWSGI. On Sat, Oct 25, 2014 at 3:33 AM, Bilal El bilal...@gmail.com wrote: Hi Rod, I am interrested in the same kind of setup. When you say Rocket, are you talking about : https://launchpad.net/rocket ? Thanks! Le vendredi 24 octobre 2014 22:03:12 UTC+2, Rod Watkins a écrit : Good. I like its simplicity. Thanks! On Friday, 24 October 2014 12:42:43 UTC-7, Niphlod wrote: rocket is perfectly fine. On Friday, October 24, 2014 7:29:47 PM UTC+2, Rod Watkins wrote: Hello all, I am about ready to start deploying my site. It is a private site for about 8-10 users. I was wondering if, given the small size, whether it would be safe to use the rocket web server, rather than apache or nginx? Thanks Rod -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/ topic/web2py/dJiPC1LCxrw/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Sticky sessions in a distributed environment
Indeed the very structure of Heroku makes it difficult to retain session coherence. But is there a way to work around this ? I mean if Heroku's structure makes it so that web2py gets completely confused about which dyno is which, then any performance gain attained through a distributed architecture is practically useless (unless you do not need sessions). Is it safe to say that web2py as a framework is not fit to work with Heroku unless you only need one dyno ? Le 24 oct. 2014 à 15:24, Massimo Di Pierro massimo.dipie...@gmail.com a écrit : from https://devcenter.heroku.com/articles/java-faq quote The Heroku routing infrastructure does not support sticky sessions. Requests from clients will be distributed randomly to all dynos running your application. /quote On Friday, 24 October 2014 04:41:06 UTC-5, Louis Amon wrote: I am trying to scale up my application deployed on Heroku by increasing the number of dynos and am currently confronted with the issue of handling sessions in a distributed environment. The regular solution (storing sessions in the database) does not seem to work anymore when multiple dynos run concurrently : clients get asked for login at every request. I have no idea why this doesn't work since databases are supposed to be shared between dynos on Heroku, but as far as I know there are 2 possible ways to manage scalable sticky sessions: Memcache : couldn't use gluon/contrib to test this because the MemcacheClient does not allow authentication in a connection string (i.e. services like Memcached, MemCachier...) Redis : same issue -- Redis client does not seem to work well with auth-based services that are available on Heroku (e.g. RedisCloud) Any idea why db-based sessions do not stick out of the box on Heroku, and/or how to use a Cloud-based service to achieve session stickiness ? -- 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/aRIVySTv6hE/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Sticky sessions in a distributed environment
With sessions in a shared database, you shouldn't need sticky sessions, as the sessions are accessed in one central location. Not sure why it's not working in this case, but it bears further investigation. Anthony On Friday, October 24, 2014 5:41:06 AM UTC-4, Louis Amon wrote: I am trying to scale up my application deployed on Heroku by increasing the number of dynos and am currently confronted with the issue of handling sessions in a distributed environment. The regular solution (storing sessions in the database) does not seem to work anymore when multiple dynos run concurrently : clients get asked for login at every request. I have no idea why this doesn't work since databases are supposed to be shared between dynos on Heroku, but as far as I know there are 2 possible ways to manage scalable sticky sessions: 1. Memcache : couldn't use gluon/contrib to test this because the MemcacheClient does not allow authentication in a connection string (i.e. services like Memcached, MemCachier...) 2. Redis : same issue -- Redis client does not seem to work well with auth-based services that are available on Heroku (e.g. RedisCloud) Any idea why db-based sessions do not stick out of the box on Heroku, and/or how to use a Cloud-based service to achieve session stickiness ? -- 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: custom ordering on queries
On Friday, October 24, 2014 12:34:41 PM UTC-7, Niphlod wrote: db guy mode if the cardinality of owner is not high, fetch them all and use for row in rows.sort(yourownfunction). If the cardinality is high, either do two queries, or add a sort_index integer column that you can use for large sorts. /db guy mode developer use for row in rows.sort() /developer Sounds good to me! Both the db guy and the developer have been previously vetted, too! ;-) /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] Re: Limit SQLFORM.grid results
On Wednesday, October 8, 2014 1:00:56 PM UTC+2, Narūnas Krasauskas wrote: I have never said anything like you quoted, what I said though was: users who can get to the search page ideally would be able to search/see all the records. Meaning, that users has access to the 1+m records, however when they define search query, if one is not accurate enough, it can potentially return really large datasets, therefore I would like to limit output to the defined number of rows. Imagine you type in the google search web2py and hit enter. My browser yields ~373 000 matches, however I can only browse through the first 10 pages, that is equal to ~ 100 matches accessible to me, despite the fact that there are 372 900 other ones. My query was not accurate enough and it is obvious to me, obvious to google, that I will not click 37 290 more times, to browse among other matches, I must redefine my query. Does it make sense? What you have suggested is simply incorrect. seems we're in different worlds (or that any issue raised slightly changes the original requirements). This will be my last addition to this thread. Your last issue (4) became evident because users in grid CAN order the resultset as they please. google doesn't let you do that: ordering is strictly fixed and there's a top limit of 1000 elements for every query (~100 pages) tl;dr - if users has access to 1M records, and they can see everything, it doesn't matter how sloppy they are with searches. If the returned dataset for the query is - potentially - 1000 records, grid will by default FETCH EXACTLY 20 records (paginate default). If users click on SORT, grid will by default FETCH EXACTLY 20 records. - if your table has 1M records and for a sloppy search (i.e. web2py) your database takes one hour to fetch 20 records, web2py can't do anything about it - if your table has 1M records and for a sloppy search your database takes 2 seconds to fetch 20 records, but 40 minutes to fetch the exact count, and you're not concerned about having the count to be exact, figure your own logic and pass it to cache_count (that's probably what google does, a rough estimate). That's the main point of this original thread posts. - if you are concerned by NOT LETTING users reach page 4, pass cache_count = 80 (or inspect request.vars.page) - if you are concerned to show users that you have 1M records but they can see only 80 of them, grid is not the right tool (or you can meddle with javascript fixing the total records display at the top) summary of the summary: you simply can't trim a dataset to whatever you like and provide real ordering and let the user see the same set of records WITHOUT trimming the entire dataset beforehand. translation of the summary on issue 4) with evidence on the statement from the end of full dataset: given a dataset like [1,2,3,4,.1000] and your issue of displaying ALWAYS and IRREGARDLESS of ordering JUST [1,2,3,4] you CAN'T pass [1,2,3,4.1000] to the grid and expect that for every ordering only a combination of [1,2,3,4] (in whatever order) will be shown. If you want to do like google, that basically sells a [1,2,3,4,.373000] while providing a [1,2,3,4.1000], no matter what, AND let users choose an order, it means that the dataset is no longer 373000 records. it's 1000 (you can't order a 373000 dataset, then limit it to 1000, and expect that the same 1000 records will be shown). And so you can approach it doing: - use cache_count = 373 - instead of db.table pass db.table.id.contains([1,2,3,41000]) summary of the summary of the summary: the order of operations in a database (or a dataset) is filtering (sloppy search) -- ordering -- limiting. There's no way around that, is simple logic. If you want instead to do emulate a filtering -- limiting -- ordering behaviour, a database query won't fit the bill, because database follow the previously explained logic . and so you need to do it in 2 pass: database filtering -- fixed dataset rebuild (implicitely limited) -- ordering. -- 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: Sticky sessions in a distributed environment
+1 on anthony. Dynos are meant to scale as serving frontends. The data(base) that a dyno1 sees NEEDS to be the same data(base) dyno2 sees, or the whole concept of consistency is not assured (and there's little point of being distributed when the only consistency is assured by having a replicated static content). Being distributed doesn't mean being scalable by default. Being easily scalable needs consistency at infrastructure level, and that's what - supposedly - Heroku gets paid for. PS (on redis issue): I'm working towards a small rewrite of redis_cache and redis_session that will avoid having separate methods (and limited to the implementation of redis that was available at the time), with the added bonus of NOT requiring a separate connection for cache and session. That'll solve the issue because - ideally - if you can use service xyz with the redis library, you'd need to be able to use that in web2py too. -- 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: Exporting from a SQLFORM.grid with customized search queries
CORRECTION: I got the boolean wrong below... In fact, I fixed it by editing sqlhtml.py to force the exporter to condition on (request.vars.keywords *and not callable(searchable)*) before setting up the rows object to export. That is, if searchable is not defined, then SQLFORM.build_query gets called, else use the query as defined by searchable. Here is the correct working code: if request.vars.keywords *and not callable(searchable)*: try: #the query should be constructed using searchable fields but not virtual fields sfields = reduce(lambda a, b: a + b, [[f for f in t if f.readable and not isinstance(f, Field.Virtual)] for t in tables]) dbset = dbset(SQLFORM.build_query( sfields, request.vars.get('keywords', ''))) rows = dbset.select(left=left, orderby=orderby, cacheable=True, *selectable_columns) except Exception, e: response.flash = T('Internal Error') rows = [] else: rows = dbset.select(left=left, orderby=orderby, cacheable=True, *selectable_columns) My question still stands... Is this a bug or is there a better way to do an export of customized search results using SQLFORM.grid? THx, dex* On Thursday, October 23, 2014 11:23:16 AM UTC-7, Dexter Hadley wrote: Hi All, This is my first time posting a question, so thanks to Massimo and they whole community for making web2py. Its great! I am trying to export results from a customized full-text search using SQLFORM.grid. My backend is a Postgres db, and I successfully define search_widget and searchable functions that are passed to the SQLFORM.grid to do the full-text search. It will works pretty well on the web app. However, once I click the export button, SQLFORM.grid apparently recreates the query using the default SQLFORM.build_query and ignores the correct query which I define in searchable. After poking around in sqlhtml.py, I found this is so because the exporter only conditions on request.vars.keywords before calling SQLFORM.build_query, and it does not check for callable(searchable) which I think it should do. In fact, I fixed it by editing sqlhtml.py to force the exporter to condition on (request.vars.keywords *and callable(searchable)*) before setting up the rows object to export. The code I added is in bold below (on line 2298 of sqlhtml.py): if request.vars.keywords *and callable(searchable)*: try: #the query should be constructed using searchable fields but not virtual fields sfields = reduce(lambda a, b: a + b, [[f for f in t if f.readable and not isinstance(f, Field.Virtual)] for t in tables]) dbset = dbset(SQLFORM.build_query( sfields, request.vars.get('keywords', ''))) rows = dbset.select(left=left, orderby=orderby, cacheable=True, *selectable_columns) except Exception, e: response.flash = T('Internal Error') rows = [] else: rows = dbset.select(left=left, orderby=orderby, cacheable=True, *selectable_columns) Is this a bug or is there a better way to do an export of customized search results using SQLFORM.grid? I'm using the current version of everything (web2py 2.9.11, Postgres 9.3, Python 2.7.8). Thx again, dex* -- 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] Bad link at http://web2py.com/layouts
I couldn't find anyplace other than this group at http://web2py.com to report this. At http://web2py.com/layouts, Under About -- About plugins, the link is http://web2py.com/book/default/chapter/13#Plugins. I think that the 13 should probably be a 12. --Tim -- 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: SQLFORM.grid search with custom request.vars
I am on the same boat, any solutions? Dana subota, 18. listopada 2014. 20:57:46 UTC+2, korisnik Alfonso de la Guarda Reyes napisao je: Hi, Any change about this? or at lesat how to solve? El jueves, 8 de mayo de 2014 03:22:14 UTC-5, Paolo Valleri escribió: I opened an issue https://code.google.com/p/web2py/issues/detail?id=1931 On Wednesday, May 7, 2014 3:24:38 PM UTC+2, Anthony wrote: On Wednesday, May 7, 2014 4:00:33 AM UTC-4, Paolo Valleri wrote: The workaround of the hidden fields seems to be much more complex for this simple issue, isn't it? In this specific case, we make a search in my point of view the most appropriate action should be a POST since we submit data to be processed. A drawback of that change will be that with the post, a user is not able to bookmark the search result. In addition to not allowing bookmarking, POST will cause problems if the user does a refresh or hits the back button (i.e., the browser will ask if you want to re-submit the form data). Anyway, I think the hidden fields could be added with a few lines of code, so shouldn't be too complex. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: IS_EMPTY_OR not working for file upload
Please open an issue. this should work. On Friday, 24 October 2014 02:13:54 UTC-5, Nurendra Choudhary wrote: I gave this validator. requires=(IS_EMPTY_OR(IS_UPLOAD_FILENAME(extension='pdf'))) But when I submit the form I still get the error Enter a valid file name. Please help me. -- 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: Getting web2py to reload module files for each return view
Normally modules are not reloaded because they are cached by python. web2py can bypass this, depending on where the modules are located. If you kwwp in your modules in the web2py app/modules folder then you can do in your models/db.py DEBUG=True from gluon.custom_import import track_changes; track_changes(DEBUG) This will reload your modules when they change/ On Friday, 24 October 2014 03:33:33 UTC-5, tahnoon pasha wrote: Hi, Working with a team building a reasonably complex webapp for an investment management system, and I'm trying to learn something of the system too. I have a module that updates data from a file (simulating an FTP drop). Once the module has been loaded the first time, it doesn't update for either changes in code or in the underlying data no matter how often I refresh the page. Is there a particular way to force web2py to reload any files each time a page is refreshed? Am I doing something completely wrong? Thanks The code is as follows: module: *dataxl.py* from gluon import * import csv import json import os from xlrd import open_workbook as lox def mydata(): filepath = os.join(current.request.folder, 'static', 'sample-data', \ '20-10-2014_sample-data-for-designer.xls') oldbook = lox(filepath) names = oldbook.sheet_names() workbook = {} for name in names: worksheet = [] oldsheet = ws.sheet_by_name(name) nrows = oldsheet.nrows ncols = oldsheet.ncols colnames = [ oldsheet.cell(0,i).value for i in range(ncols) ] rownames = [ oldsheet.cell(i,0).value for i in range(nrows) ] for nrow in xrange(1,nrows): worksheet.append({colnames[ncol]: oldsheet.cell(nrow,ncol).value \ for ncol in xrange(ncols)}) workbook[name] = worksheet return workbook controller: *performance.py* import dataxl wsheet = dataxl.mydata() attr = wsheet[ 'Performance_Attr' ] @auth.requires_login() def perf_multi_asset(): clientId = set(i[ 'client' ] for i in attr.values()) portId = [ 'All' ] portId.append(j for j in set(i[0] for i in attr.items() \ if i[ 1 ][ 'Attribution Level' ] == 0 \ or i[ 1 ][ 'Attribution Level' ] == 1)) perform = SQLFORM.factory( Field('client', 'string'),requires=IS_IN_SET(clientId)), Field('portfolio', 'string'),requires=IS_IN_SET(portId)), Field('start_date', 'date'), Field('end_date', 'date') ).process() if perform.vars.portfolio == 'All': data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] == perform.vars.client} else: data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] == perform.vars.client \ and i[ 0 ] == perform.vars.portfolio} return locals() and view: *performance/perf_multi_asset.html* {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals ())}} {{extend 'layout.html'}} {{=STYLE(XML(.generic-widget,#no_table_start_date,#no_table_end_date {width:100px}))}} div class=row {{=perform.custom.begin}} div class=span2 Client Name: br {{=perform.custom.widget.client}} /div div class=span2 Portfolio ID: br {{=perform.custom.widget.portfolio}} /div div class=span2 Start Date: br {{=perform.custom.widget.start_date}} /div div class=span2 End Date: br {{=perform.custom.widget.end_date}} /div div class=span2 br {{=perform.custom.submit}} /div {{=perform.custom.end}} /div {{=BEAUTIFY(XML(data))}} -- 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: Bad link at http://web2py.com/layouts
Thanks for reporting this. On Friday, 24 October 2014 08:51:56 UTC-5, Tim Chase wrote: I couldn't find anyplace other than this group at http://web2py.com to report this. At http://web2py.com/layouts, Under About -- About plugins, the link is http://web2py.com/book/default/chapter/13#Plugins. I think that the 13 should probably be a 12. --Tim -- 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: SAML2 Service Provider app in web2py?
Yes. I've printed it. It shows empty dict On Oct 23, 2014 7:33 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Yes it works for me. Can you help debug? Can you print d['response'] and try figure out where the response attributes are? On Friday, 17 October 2014 00:42:29 UTC-5, Prasad Muley wrote: Hi Wel, Did you test SAML2 app? there is an experimental saml2 app in web2py_2.9.6 I need to use saml2(web2py app) as service provider with onelogin (which is idp) I am getting an error (Screen shot is attached PFA). here is my config settings 1) *private/sp_conf.py* # Make sure the same port number appear in service_conf.py BASE = http://localhost:8000; APPNAME = saml2 PATH = /home/prasad/Prasad/web2py_2.9.6_beta/applications/saml2/ private/ CONFIG = { entityid: %s/saml2/static/sp.xml % BASE, 'entity_category': [COC], accepted_time_diff: 5, # very important description: Example SP, service: { sp: { endpoints: { assertion_consumer_service: [ (%s/%s/default/user/login % (BASE, APPNAME), BINDING_HTTP_REDIRECT), ], } }, }, key_file: %s/pki/mykey.pem % PATH, cert_file: %s/pki/mycert.pem % PATH, xmlsec_binary: xmlsec_path, metadata: {local: [PATH+idp.xml]}, name_form: NAME_FORMAT_URI, } Here I've copied *assertion_consumer_service url *( http://localhost:8000/saml2/default/login ) in onelogin's app's SAML consumer url 2) I've downloaded a meta data file from onelogin app. copy it to *saml/private/*3) Created a *static/sp.xml file *as make_metadata.py sp_conf ../static/sp.xml 4) Ran web2py server * (python webpy.py)*5) Selected SAML2 app through administrator interface, 6) Clicked on login tab and It is redirecting to onelogin app's login window. 7) Entered username and password in onelogin app It it redirecting me to http://localhost:8000/saml2/default/login (which is a assertion consumer url) and I am getting an internal error . type 'exceptions.AttributeError' 'dict' object has no attribute 'assertion' Let me know If there are wrong settings in my app. Could you share your app settings (including web2py app and idp settings) On Thursday, August 21, 2014 7:35:29 PM UTC+5:30, Wei Wang wrote: I have the need to use a SAML2 identity provider (specifically, a NetIQ product) for authentication and authorization in some web2py apps. I searched in this group, also googled web2py and SAML, but did not find anything that seems readily available. My thoughts on building a Service Provider (in SAML2 terminology) app in web2py alongside other apps: - The SAML2 service provider would be /saml2sp: - The saml2sp app communicates to the SAML2 Id provider for authentication and authorization; - A web2py app is configured to use cas_auth, with localhost/saml2sp as the CAS server base URL; Does something like this exist? Does that sound reasonable? Thanks for any pointers, comments, thoughts. Wei -- 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/zn1OvErE6Wc/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: SAML2 Service Provider app in web2py?
I do not know what to say. It works with the provide I was using. Look into the provider log. perhaps there is an error message there. On Friday, 24 October 2014 19:30:24 UTC-5, Prasad Muley wrote: Yes. I've printed it. It shows empty dict On Oct 23, 2014 7:33 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Yes it works for me. Can you help debug? Can you print d['response'] and try figure out where the response attributes are? On Friday, 17 October 2014 00:42:29 UTC-5, Prasad Muley wrote: Hi Wel, Did you test SAML2 app? there is an experimental saml2 app in web2py_2.9.6 I need to use saml2(web2py app) as service provider with onelogin (which is idp) I am getting an error (Screen shot is attached PFA). here is my config settings 1) *private/sp_conf.py* # Make sure the same port number appear in service_conf.py BASE = http://localhost:8000; APPNAME = saml2 PATH = /home/prasad/Prasad/web2py_2.9.6_beta/applications/saml2/ private/ CONFIG = { entityid: %s/saml2/static/sp.xml % BASE, 'entity_category': [COC], accepted_time_diff: 5, # very important description: Example SP, service: { sp: { endpoints: { assertion_consumer_service: [ (%s/%s/default/user/login % (BASE, APPNAME), BINDING_HTTP_REDIRECT), ], } }, }, key_file: %s/pki/mykey.pem % PATH, cert_file: %s/pki/mycert.pem % PATH, xmlsec_binary: xmlsec_path, metadata: {local: [PATH+idp.xml]}, name_form: NAME_FORMAT_URI, } Here I've copied *assertion_consumer_service url *( http://localhost:8000/saml2/default/login ) in onelogin's app's SAML consumer url 2) I've downloaded a meta data file from onelogin app. copy it to *saml/private/*3) Created a *static/sp.xml file *as make_metadata.py sp_conf ../static/sp.xml 4) Ran web2py server * (python webpy.py)*5) Selected SAML2 app through administrator interface, 6) Clicked on login tab and It is redirecting to onelogin app's login window. 7) Entered username and password in onelogin app It it redirecting me to http://localhost:8000/saml2/default/login (which is a assertion consumer url) and I am getting an internal error . type 'exceptions.AttributeError' 'dict' object has no attribute 'assertion' Let me know If there are wrong settings in my app. Could you share your app settings (including web2py app and idp settings) On Thursday, August 21, 2014 7:35:29 PM UTC+5:30, Wei Wang wrote: I have the need to use a SAML2 identity provider (specifically, a NetIQ product) for authentication and authorization in some web2py apps. I searched in this group, also googled web2py and SAML, but did not find anything that seems readily available. My thoughts on building a Service Provider (in SAML2 terminology) app in web2py alongside other apps: - The SAML2 service provider would be /saml2sp: - The saml2sp app communicates to the SAML2 Id provider for authentication and authorization; - A web2py app is configured to use cas_auth, with localhost/saml2sp as the CAS server base URL; Does something like this exist? Does that sound reasonable? Thanks for any pointers, comments, thoughts. Wei -- 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/zn1OvErE6Wc/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.