[web2py] how to trailing a slash in url automatically
e.g., from http://localhost/display === to http://localhost/display/ I tried edit router.py in the root folder, like routes_in=( ('/display4', '/display4/') ) not working, I guess, because '/display4/' is then further routed. Thanks in advance Chuan P.S. background about why I ask. It has sth to do with requirejs. when use http://localhost/display, I need to set my baseURL as 'display/static/js' while for http://localhost/display/, I only need to set my baseURL as 'static/js', which I prefer -- 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 trailing a slash in url automatically
I can't because I config requirejs in a static file On Monday, August 11, 2014 9:35:04 PM UTC+2, Massimo Di Pierro wrote: You should not be doing this. You need to ask web2py to generate URLs for you {{=URL('static','js/something.js')}} On Monday, 11 August 2014 04:22:34 UTC-5, chuan137 wrote: e.g., from http://localhost/display === to http://localhost/display/ I tried edit router.py in the root folder, like routes_in=( ('/display4', '/display4/') ) not working, I guess, because '/display4/' is then further routed. Thanks in advance Chuan P.S. background about why I ask. It has sth to do with requirejs. when use http://localhost/display, I need to set my baseURL as 'display/static/js' while for http://localhost/display/, I only need to set my baseURL as 'static/js', which I prefer -- 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: simplify parse_as_rest pattern?
Aha, I was not followed it yet. Quick question, would it be able to filter one-to-many or many-to-many relationship? On Wednesday, July 23, 2014 11:20:41 AM UTC+2, Massimo Di Pierro wrote: Actually I wanted to deprecate it in favor of the new hypermedia API. On Tuesday, 22 July 2014 07:43:08 UTC-5, chuan137 wrote: Maybe you want to expand the functionality for parse_as_rest(), since from the menu, there reads experimental feature. I would be interesting to get involved in the discussions. On Tuesday, July 22, 2014 8:40:28 AM UTC+2, Massimo Di Pierro wrote: currently no. On Monday, 21 July 2014 16:02:57 UTC-5, chuan137 wrote: Example of parse_as_rest function, there define tables db.define_table('person',Field('name'),Field('info')) db.define_table('pet',Field('ownedby',db.person),Field('name'),Field( 'info')) which are served with the pattern /{person.name}/pets[pet.ownedby]/{pet.name}. That means a valid URL is for instance /Tom/pets/BlackCat Is it possible to simplify the pattern, so that /Tom/BlackCat is also valid? I am aware that url routing does the trick, but I just wonder if there is a more direct way to set up the pattern? 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] load data for front end
Hi All, For quick and dirty develop, is it a good idea to do script var t=%=XML(response.json(rows))% /script in template page? Dear Massimo, can you share how do you use Ractivejs usually? For big project, I would divide front end codes from server end. But how about for simple page, where I only need to load data on startup? -- 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: simplify parse_as_rest pattern?
Maybe you want to expand the functionality for parse_as_rest(), since from the menu, there reads experimental feature. I would be interesting to get involved in the discussions. On Tuesday, July 22, 2014 8:40:28 AM UTC+2, Massimo Di Pierro wrote: currently no. On Monday, 21 July 2014 16:02:57 UTC-5, chuan137 wrote: Example of parse_as_rest function, there define tables db.define_table('person',Field('name'),Field('info')) db.define_table('pet',Field('ownedby',db.person),Field('name'),Field( 'info')) which are served with the pattern /{person.name}/pets[pet.ownedby]/{pet.name}. That means a valid URL is for instance /Tom/pets/BlackCat Is it possible to simplify the pattern, so that /Tom/BlackCat is also valid? I am aware that url routing does the trick, but I just wonder if there is a more direct way to set up the pattern? 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] simplify parse_as_rest pattern?
Example of parse_as_rest function, there define tables db.define_table('person',Field('name'),Field('info')) db.define_table('pet',Field('ownedby',db.person),Field('name'),Field('info' )) which are served with the pattern /{person.name}/pets[pet.ownedby]/{pet.name}. That means a valid URL is for instance /Tom/pets/BlackCat Is it possible to simplify the pattern, so that /Tom/BlackCat is also valid? I am aware that url routing does the trick, but I just wonder if there is a more direct way to set up the pattern? Thanks -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: How to deploy web2py under existing host
bump On Wednesday, July 16, 2014 11:03:58 AM UTC+2, chuan137 wrote: Hi All, I have to install web2py as part existing VirtualHost. It is serving a few directories, and web2py folder is one of them. this is my settings under VirtualHost superhostname:80 WSGIScriptAlias /newstatus /srv/www/hostRoot/web2py/wsgihandler.py Directory /srv/www/hostRoot/web2py AllowOverride None Order Allow,Deny Allow from all Files wsgihandler.py Allow from all /Files /Directory The first problem is When I try to access http://superhostname/web2py, I got invalid request error in the browser What configuration should I set for apache server? The other problem is about web2py wsgihandler And whn I try http://superhostname/web2py/, I got on error message from apache log, File does not exist: /srv/www/hostRoot/welcome How do I route correctly to /srv/www/hostRoot/web2py/welcome ? And lastly, When I try http://superhostname/web2py/welcome, the default index is served, but all static files are failed to load, because, I think, it is trying to search under hostRoot/static, how do I force config to search under hostRoot/web2py/static ? Maybe the second and third problem are related. Cheers, Chuan -- 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 deploy web2py under existing host
Hi All, I have to install web2py as part existing VirtualHost. It is serving a few directories, and web2py folder is one of them. this is my settings under VirtualHost superhostname:80 WSGIScriptAlias /newstatus /srv/www/hostRoot/web2py/wsgihandler.py Directory /srv/www/hostRoot/web2py AllowOverride None Order Allow,Deny Allow from all Files wsgihandler.py Allow from all /Files /Directory The first problem is When I try to access http://superhostname/web2py, I got invalid request error in the browser What configuration should I set for apache server? The other problem is about web2py wsgihandler And whn I try http://superhostname/web2py/, I got on error message from apache log, File does not exist: /srv/www/hostRoot/welcome How do I route correctly to /srv/www/hostRoot/web2py/welcome ? And lastly, When I try http://superhostname/web2py/welcome, the default index is served, but all static files are failed to load, because, I think, it is trying to search under hostRoot/static, how do I force config to search under hostRoot/web2py/static ? Maybe the second and third problem are related. Cheers, Chuan -- 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 use require js with web2py?
OK, I worked out myself, simply load web2py.js before require.js, besides, configure the baseUrl properly according to the system. here is my code {{ response.files.insert(0,URL('static','js/libs/jquery.js')) #response.files.insert(1,URL('static','css/calendar.css')) #response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.files.insert(4, 'http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.11/require.min.js') response.include_meta() response.include_files() }} script type=application/javascript require.config({ baseUrl: {{=URL('static','js/libs')}}, paths: { 'modules': {{=URL('static', 'js/modules')}}, 'templates': '{{=URL('static', 'templates')}}', 'canvas': {{=URL('static', 'js/canvas')}}, } }); require(['text!templates/hello.html', 'ractive'], function(template) { ractive = new Ractive({ el: 'container', template: template, data: { name: 'world' } }); }); /script On Monday, June 23, 2014 9:35:08 PM UTC+2, chuan137 wrote: how to load script data-main=scripts/main src=scripts/require.js/ script in web2py like in web2py_ajax.html I have response.files.insert(0,URL('static','js/libs/require.js')) then below script require.config({ paths: { 'text': {{=URL('static', 'js/libs/require/text')}}, 'modules': {{=URL('static', 'js/modules')}}, 'templates': {{=URL('static', 'templates')}}, 'jquery': {{=URL('static', 'js/libs/jquery')}}, }, require(['modules/test'], function(test) { test.test(); }); require(['modules/canvas'], function(canvas) { canvas.init(); }); /script it does not work because, a), web2py.js fails to find jQuery. b), paths generated by URL helper seem not compatible with require Any idea? Thanks, Chuan -- 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 use require js with web2py?
how to load script data-main=scripts/main src=scripts/require.js/ script in web2py like in web2py_ajax.html I have response.files.insert(0,URL('static','js/libs/require.js')) then below script require.config({ paths: { 'text': {{=URL('static', 'js/libs/require/text')}}, 'modules': {{=URL('static', 'js/modules')}}, 'templates': {{=URL('static', 'templates')}}, 'jquery': {{=URL('static', 'js/libs/jquery')}}, }, require(['modules/test'], function(test) { test.test(); }); require(['modules/canvas'], function(canvas) { canvas.init(); }); /script it does not work because, a), web2py.js fails to find jQuery. b), paths generated by URL helper seem not compatible with require Any idea? Thanks, Chuan -- 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: Brainstorming
Noelse mentioned Backbonejs yet? working on a project with it now, but do not care for it too much, I am thinking of switching to AngularJS actually. On Sunday, June 15, 2014 10:34:25 AM UTC+2, Massimo Di Pierro wrote: Often Angular comes up on this list. I tried it and I was un-impressed. Instead today my favorite client-side stack is based on these: - jquery.js - sugar.js - ractive.js - semantic-ui (css js) Have you tried sugar, ractive, and semantic-ui? What is your opinion? 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/d/optout.
[web2py] send json variable as parameters to RESTful api
Dear all, In my javascript code, I would like to have sth like this, $.getJSON(url_to_REST_api, { group: 0, sensors: sensorIDs }, function(res) { timestamp = res['timestamp']; data = res['data']; }); However, sensorIDs is a rather long array, which in turn generate a request url very ugly, like this http://localhost:8000/service/test/katrin?group=0sensors%5B%5D=2sensors%5B%5D=3sensors%5B%5D=4sensors%5B%5D=5sensors%5B%5D=6sensors%5B%5D=7sensors%5B%5D=8sensors%5B%5D=9sensors%5B%5D=74sensors%5B%5D=66sensors%5B%5D=68sensors%5B%5D=99sensors%5B%5D=75sensors%5B%5D=67sensors%5B%5D=69sensors%5B%5D=100sensors%5B%5D=102sensors%5B%5D=106sensors%5B%5D=107sensors%5B%5D=108sensors%5B%5D=149sensors%5B%5D=150sensors%5B%5D=103sensors%5B%5D=109sensors%5B%5D=110sensors%5B%5D=111sensors%5B%5D=151sensors%5B%5D=152sensors%5B%5D=59sensors%5B%5D=61sensors%5B%5D=75sensors%5B%5D=78sensors%5B%5D=80sensors%5B%5D=82sensors%5B%5D=145sensors%5B%5D=112sensors%5B%5D=113sensors%5B%5D=116sensors%5B%5D=117sensors%5B%5D=118sensors%5B%5D=146sensors%5B%5D=119sensors%5B%5D=120sensors%5B%5D=123sensors%5B%5D=124sensors%5B%5D=125sensors%5B%5D=186sensors%5B%5D=187sensors%5B%5D=188sensors%5B%5D=190sensors%5B%5D=191sensors%5B%5D=192sensors%5B%5D=180sensors%5B%5D=181sensors%5B%5D=182sensors%5B%5D=183sensors%5B%5D=184sensors%5B%5D=185 What best strategy should I take? Change the $.getJSON() to Post and Get? (I am not sure how to do it yet) And how to design my api? Thanks in advance. Chuan -- 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] import module once for all
Dear web2pyers, Some functions are packed into a class, which I put it under modules/myclass.py. To reuse the functions, say in the controllers, I usually import the module, create a new instance of myclass inside the controller function. I wonder is it possible to import the module when the server is started, and even initialize a global instance of myclass? Best, 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] what about the old web2py blog?
It is quite helpful for me, I read it and like the way it explains things. But why is it called 'old'? The techniques are no longer ideal or it just stop updating? I wish there is such a new web2py blog. -- 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] better way to find the updated or inserted record id
Before I insert a record, I need to check whether the record is already in database. If true, then I need to know the id of the record. Below is my implementation, I first does the query, and check whether record exist or not query = db(db.groups.name == 'some_name').select() if query.records: group_id = query[0].id else: group_id = db.groups.insert(.) I wonder is there any better way to do this task? may be use update_or_insert ? does it return the id of updated or inserted record? -- 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 modify form input before validation and insert into database?
Sorry for the late reply, but I just want to say thank you for the answer, I do not know how to create custom validator yet, but request.post_vars does the trick. On Tuesday, May 27, 2014 3:01:53 PM UTC+2, Anthony wrote: You could modify request.post_vars before creating the form, or create a custom validator for the relevant field(s). No need to use SQLFORM.factory. Anthony On Monday, May 26, 2014 5:26:15 PM UTC-4, chuan137 wrote: I want to replace white spaces with underscore and capitialize each word before insert them into database. I am using SQLFORM(...) and I find onvalidation is used after validation. but I want to use this field as a unique keyword, which used in query conditions. what I want is to use a function to do the job before validation. plz bear with my english and thanks in advance. -- 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: what is loader.js for?
anyone kowns what it is? On Monday, May 26, 2014 2:08:24 PM UTC+2, chuan137 wrote: looking at my simple example from chrome developer's tool, I noticed loader.js doing something in the background. seems related with statistics or ads. can someone explain it to me? is it possible to disable it, because I want to do some performance measurements? thanks :) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] how to modify form input before validation and insert into database?
Thank you. On Tuesday, May 27, 2014 9:14:07 AM UTC+2, Johann Spies wrote: On 26 May 2014 23:26, chuan137 chua...@gmail.com javascript: wrote: I want to replace white spaces with underscore and capitialize each word before insert them into database. I am using SQLFORM(...) and I find onvalidation is used after validation. but I want to use this field as a unique keyword, which used in query conditions. what I want is to use a function to do the job before validation. You can use SQLFORM.factory and after the submission of the form, apply those changes to the fields where it is needed and then submit them. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- 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] what is loader.js for?
looking at my simple example from chrome developer's tool, I noticed loader.js doing something in the background. seems related with statistics or ads. can someone explain it to me? is it possible to disable it, because I want to do some performance measurements? 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] how to modify form input before validation and insert into database?
I want to replace white spaces with underscore and capitialize each word before insert them into database. I am using SQLFORM(...) and I find onvalidation is used after validation. but I want to use this field as a unique keyword, which used in query conditions. what I want is to use a function to do the job before validation. plz bear with my english and thanks in advance. -- 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.