[web2py] Shortcut for fetching a row
According to the book, for what I understand record = db(db.owner.name=='test').select(db.owner.id).first() could be shortcut with record = db.owner(id, name='test') But the latter return None. How can I shortcut the first statement properly? Thank you so very much.
Re: [web2py] Re: Autocomplete Widget changed after upgrade
Hi Massimo, Solved the issue. The new widget / ajax is looking for a ID in the table. I just added the id to the view, and it works fine! regards Martin On Thu, Nov 17, 2011 at 2:45 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you helps us debug? Use chrome, check out the callback url, call it directly, does it return a ticket? On Nov 17, 1:53 am, Ole Martin Maeland olemael...@gmail.com wrote: Hi Massimo, upgrade from version 1.89.5 (2010-11-21), so old version. I have tried to substitute the built in autocomplete with s-cubism suggest_widget. It works the same way - no function when I try to read from db view, but works fine when directly from db. regards Martin On Thu, Nov 17, 2011 at 7:47 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: what did you upgrade from? On Nov 16, 3:07 pm, Ole Martin Maeland olemael...@gmail.com wrote: Hi, I upgraded web2py to latest version. everything works fine exept the autocomplete widget I use MySQL as my database. The autocomplete is reading from a db VIEW. The reason for this is that I have 2 columns in a db: short_name and ISIN that is the name, and ISIN that is the ID. By doing union select it worked fine until I upgraded. after the upgrade to the latest version it is not recognising the VIEW as a DB. in my db setup I have set it to be a DB with migrate=False. I have tried to use the widget directly with a DB, and then it works fine. Initially I thought the problem were due to new adapter: pymysql, but I have changed it using: import MySQLdb from gluon.dal import MySQLAdapter MySQLAdapter.driver = MySQLdb but that is not the problem. It does not read the VIEW as a DB anymore.. I have several VIEW's in my DB and it works fine for all other queries.. any idea how to fix it ? regards martin -- Hilsen Ole Martin Mob: 95227471 -- Hilsen Ole Martin Mob: 95227471
Re: [web2py] jquery mobile 1.0 released
This should be absolutely in web2py! 2011/11/18 Massimo Di Pierro massimo.dipie...@gmail.com: http://jquerymobile.com/blog/2011/11/16/announcing-jquery-mobile-1-0/ -- Profile: http://www.gild.com/compagnucciangelo Register on Gild: http://www.gild.com/referral/compagnucciangelo
[web2py] RBAC
Hello, I am trying to figure out a way to allow users to register into a specific group/ membership. for example: registration form 1 is for group 1 registration form 2 is for group 2 Thank you, -Ric
[web2py] Authorization decorators always generate db queries
Hi, I think we found a serious bug (at least, we hope it is not a designed feature). If you create a simple controller (like test.py) with the following actions: def test(): return dict() @auth.requires_permission('foo bar') def test2(): return dict() And a simple view (like test.html) with: {{extend 'layout.html'}} h1Test/h1 {{=response.toolbar()}} And then open the first action ( app/test/test ) in your browser and inspect the db stats from the response toolbar, you'll see: SELECT auth_permission.group_id FROM auth_permission WHERE (((auth_permission.name = 'foo bar') AND (auth_permission.table_name = '')) AND (auth_permission.record_id = 0)); If you comment out the decorator, there are no db queries. So this means that somehow all decorators are executed and because the do check the database you will get unnecessary database queries. If you have a controller file with for example 10 actions and all of them have a auth decorator, you will at least get 10 queries for this simple single request. We noticed this because I had multiple decorated actions in one controller file and we got about 30 db queries for a simple request (like test above). Most of the queries were of course even duplicates, because of the same decorator. We noticed this behavior on Version 1.99.2 (2011-09-26 06:55:33) stable and Version 1.99.3 (2011-11-16 22:36:13) dev I think this should be fixed, because this will result in unnecessary bad performance in larger apps. Regards, Ids
[web2py] help on rewrite
Hi @all, I have a small problem with routes.py and the routes_onerror parameter. Basically I have one and only application mounted in the webserver and I'd like to strip the application part from all urls. Leave alone the redirections for static folder, favicon, robots, sitemap etc, this is done wonderfully setting: routes_in = ( ('/(?Pany.*)', '/appname/\gany') ) routes_out = ( ('/appname/(?Pany.*)', '/\gany') ) Now, let's say I want to display a simple page instead of the default error page. routes_onerror = [ ('*/*', '/errors/index') ] Working perfectly fine this one also. I created a simple errors controller, with an index() function in it, and created a view /errors/index.html. Request.vars is populated accordingly to the errors, so I can change the content of the page dinamically, there's only a small problem: if I try to change the response.status code (if there's a 404 Not Found it's not polite to return a 200 OK status) rewrite kicks in and loops forever. Any hints on how to achieve the same result with different parameters, if this is not a bug ?
Re: [web2py] routers only exposing default controller
yes only the default controller is available by default, until I defined the controllers variable.
[web2py] Re: help on rewrite
What does your /errors/index function look like? Also, is that your exact routes_onerror? I ask because there is a bug (now fixed in trunk) that leads to a loop if your routes_onerror path is missing the leading '/' (i.e., 'errors/index' would create a loop, whereas '/errors/index' would not). Anthony On Friday, November 18, 2011 8:20:38 AM UTC-5, Niphlod wrote: Hi @all, I have a small problem with routes.py and the routes_onerror parameter. Basically I have one and only application mounted in the webserver and I'd like to strip the application part from all urls. Leave alone the redirections for static folder, favicon, robots, sitemap etc, this is done wonderfully setting: routes_in = ( ('/(?Pany.*)', '/appname/\gany') ) routes_out = ( ('/appname/(?Pany.*)', '/\gany') ) Now, let's say I want to display a simple page instead of the default error page. routes_onerror = [ ('*/*', '/errors/index') ] Working perfectly fine this one also. I created a simple errors controller, with an index() function in it, and created a view /errors/index.html. Request.vars is populated accordingly to the errors, so I can change the content of the page dinamically, there's only a small problem: if I try to change the response.status code (if there's a 404 Not Found it's not polite to return a 200 OK status) rewrite kicks in and loops forever. Any hints on how to achieve the same result with different parameters, if this is not a bug ?
[web2py] Re: Shortcut for fetching a row
On Nov 18, 3:31 am, Cahya Dewanta cahya...@gmail.com wrote: According to the book, for what I understand record = db(db.owner.name=='test').select(db.owner.id).first() could be shortcut with record = db.owner(id, name='test') record = db.owner(name='test') # if you want just the id do record = db.owner(name='test').id But the latter return None. How can I shortcut the first statement properly? Thank you so very much.
[web2py] Re: Shortcut for fetching a row
On Friday, November 18, 2011 3:31:21 AM UTC-5, Cahya Dewanta wrote: According to the book, for what I understand record = db(db.owner.name=='test').select(db.owner.id).first() could be shortcut with record = db.owner(id, name='test') But the latter return None. How can I shortcut the first statement properly? Perhaps the book could be more clear. record = db.owner(id, name='test') is a shortcut for: record = db((db.owner.id == id) (db.owner.name == 'test')).select().first() In other words, the first argument to db.owner(...) can simply be the id of the record you want to fetch. It does not represent the name of the field you want to return. Anthony
[web2py] Re: help on rewrite
Hi Anthony, /errors/index function is a simple: def index(): #response.status = request.vars.code return dict(vars=request.vars) Notice the response.status line commented, it's the one triggering the loop. The template is very simple, in fact I simulated all kinds of error and it gets rendered correctly. It's only setting the status on the controller (the commented line in the index() function) that triggers the infinite loop. routes_onerror is exactly as reported, with the leading '/'. BTW, I'm using 1.99.2 On 18 Nov, 08:56, Anthony abasta...@gmail.com wrote: What does your /errors/index function look like? Also, is that your exact routes_onerror? I ask because there is a bug (now fixed in trunk) that leads to a loop if your routes_onerror path is missing the leading '/' (i.e., 'errors/index' would create a loop, whereas '/errors/index' would not). Anthony On Friday, November 18, 2011 8:20:38 AM UTC-5, Niphlod wrote: Hi @all, I have a small problem with routes.py and the routes_onerror parameter. Basically I have one and only application mounted in the webserver and I'd like to strip the application part from all urls. Leave alone the redirections for static folder, favicon, robots, sitemap etc, this is done wonderfully setting: routes_in = ( ('/(?Pany.*)', '/appname/\gany') ) routes_out = ( ('/appname/(?Pany.*)', '/\gany') ) Now, let's say I want to display a simple page instead of the default error page. routes_onerror = [ ('*/*', '/errors/index') ] Working perfectly fine this one also. I created a simple errors controller, with an index() function in it, and created a view /errors/index.html. Request.vars is populated accordingly to the errors, so I can change the content of the page dinamically, there's only a small problem: if I try to change the response.status code (if there's a 404 Not Found it's not polite to return a 200 OK status) rewrite kicks in and loops forever. Any hints on how to achieve the same result with different parameters, if this is not a bug ?
Re: [web2py] Authorization decorators always generate db queries
Hi, I think this is due to the fact of using RBAC (role based access control), which is for very secure applications, large apps are normaly not that much secured, but there are other solutions like fo example loading those tables into memory. Khalil
Re: [web2py] RBAC
Hi, I think this is an administrator's job to affect teams to members but you can as well create an action that allows a user to choose his team, in both cases there would be the same registration form. Khalil
Re: [web2py] routers only exposing default controller
On Nov 18, 2011, at 5:28 AM, Richard Baron Penman wrote: yes only the default controller is available by default, until I defined the controllers variable. Send me your routes.py privately, please.
Re: [web2py] Re: Shortcut for fetching a row
Hi, This is why I almost never use shortcuts. When something goes wrong and you have poeple waiting for you to resolve the problem so they can get back to work, you always dont have enough attention to decrypt shortcuts. Khalil
[web2py] Re: Authorization decorators always generate db queries
Sure, but if I hit request A in a browser, I do not expect any decorators on action B to hit the database. Actually, you wouldn't expect a decorator on action B to be executed at all This would potentially give lots of nasty side effects.. On Nov 18, 3:35 pm, Khalil KHAMLICHI khamlichi.kha...@gmail.com wrote: Hi, I think this is due to the fact of using RBAC (role based access control), which is for very secure applications, large apps are normaly not that much secured, but there are other solutions like fo example loading those tables into memory. Khalil
[web2py] GAE (AppEngine) Datastore models under web2py - can they coexist?
I invested a year in a pure GAE (AppEngine) project, needed to have auth and after much research decided to switch to web2py. This full stack framework blew me away! It is so simple and powerful, but it needs learning. My plan is to switch gradually to web2py because I have paying customers and other waiting to subscribe which I am holding on. One part of quick switching is replacing the Django templates I use with web2py. That part is relatively easy. The product is developed entirely for mobile using jQuery Mobile. It has the capability to run on desktop too but Internet Explorer creates issues - clicking on buttons and submit does not fires always. I believe web2py addresses this - I created layout_mobile.html template based on layout.html which has IE related code and tested it - it seems to work. But the main part is I have to use the native AppEngine Datastore because my database models and code is optimized and tested for thousand users for which Datastore is very good - nonSQL is very quick on this. The bottom line - how to use the native Google Datastore inside web2py? Are there any nasty incompatibilities? Thanks in advance, Regards, --Constantine
Re: [web2py] Re: Authorization decorators always generate db queries
Sorry pressed send button by mistake. I was saying that I believe auth lives in memory so no db access is supposed to happen, and I go back and say that RBAC will need db access all times. Khalil On Nov 18, 2011 3:37 PM, Khalil KHAMLICHI khamlichi.kha...@gmail.com wrote: I am not an expert in this, but I believe that : @auth.requires_login() there would be no database quieries because auth is stored in session which I believelives in
Re: [web2py] GAE (AppEngine) Datastore models under web2py - can they coexist?
On Nov 18, 2011, at 7:30 AM, Constantine Vasil wrote: But the main part is I have to use the native AppEngine Datastore because my database models and code is optimized and tested for thousand users for which Datastore is very good - nonSQL is very quick on this. The bottom line - how to use the native Google Datastore inside web2py? Are there any nasty incompatibilities? I've been doing this a bit, using web2py's DAL for its auth tables and some web pages, and the Datastore for a faceless JSON-RPC service (through a web2py controller). It seems to work fine. If you look at the Datastore through GAE's inspection tools, you'll see the web2py stuff as entities in the Datastore. I don't think there's likely to be a conflict as long as you keep your namespaces from colliding. Caveat: I don't have this in production.
[web2py] Re: Authorization decorators always generate db queries
But I only expect it to hit the database i.e. execute the permission check, when I request a protected action in a controller. Not if I request an unprotected action. So, using the example above, if I call/request test I DO NOT expect database avtivity, if I call test2 I DO expect database activity. It probably has to do with the way python decorators with parameters work, but these side effects are really bad. On Nov 18, 4:40 pm, Khalil KHAMLICHI khamlichi.kha...@gmail.com wrote: Sorry pressed send button by mistake. I was saying that I believe auth lives in memory so no db access is supposed to happen, and I go back and say that RBAC will need db access all times. Khalil On Nov 18, 2011 3:37 PM, Khalil KHAMLICHI khamlichi.kha...@gmail.com wrote: I am not an expert in this, but I believe that : @auth.requires_login() there would be no database quieries because auth is stored in session which I believelives in
[web2py] Re: Authorization decorators always generate db queries
Maybe a better example is this: def index(): # create public index page stuff return dict(...) @auth.requires_permission('administrate users') def admin_users(): # private stuff return dict(...) Opening the index page would still hit the database and request details about the 'administrate users' permission.The index page is shown, but you still have an totally unnecessary database query. Add more similarly protected actions in this controller file and the request for the index page executes even more database queries. On Nov 18, 4:51 pm, Ids idsvandermo...@gmail.com wrote: But I only expect it to hit the database i.e. execute the permission check, when I request a protected action in a controller. Not if I request an unprotected action. So, using the example above, if I call/request test I DO NOT expect database avtivity, if I call test2 I DO expect database activity. It probably has to do with the way python decorators with parameters work, but these side effects are really bad. On Nov 18, 4:40 pm, Khalil KHAMLICHI khamlichi.kha...@gmail.com wrote: Sorry pressed send button by mistake. I was saying that I believe auth lives in memory so no db access is supposed to happen, and I go back and say that RBAC will need db access all times. Khalil On Nov 18, 2011 3:37 PM, Khalil KHAMLICHI khamlichi.kha...@gmail.com wrote: I am not an expert in this, but I believe that : @auth.requires_login() there would be no database quieries because auth is stored in session which I believelives in
[web2py] Re: Authorization decorators always generate db queries
Further tests reveal that decorators @auth.requires_membership and @auth.requires_permission do hit the database and @auth.requires_login does not hit the database. @auth.requires_login probably only checks a session cookie.
[web2py] Re: edge case of SQLFORM.grid search not working on 1.99.2
there is not type 'reference:string'. Don't you get a ticket? On Nov 17, 10:08 am, Cliff cjk...@gmail.com wrote: grid search fails to find values if - the field type is reference:string - the field value contains a space db.define_table(mytable, Field('silly_strings', 'reference:string)) db.mytable.sillystrings.requires = IS_IN_SET(['one', 'two', 'buckle my shoe'], zero='pick one' ) grid search finds 'one' or 'two' but fails on 'buckle my shoe' Should I submit a ticket?
[web2py] Re: Autocomplete Widget changed after upgrade
:-) On Nov 18, 3:11 am, Ole Martin Maeland olemael...@gmail.com wrote: Hi Massimo, Solved the issue. The new widget / ajax is looking for a ID in the table. I just added the id to the view, and it works fine! regards Martin On Thu, Nov 17, 2011 at 2:45 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Can you helps us debug? Use chrome, check out the callback url, call it directly, does it return a ticket? On Nov 17, 1:53 am, Ole Martin Maeland olemael...@gmail.com wrote: Hi Massimo, upgrade from version 1.89.5 (2010-11-21), so old version. I have tried to substitute the built in autocomplete with s-cubism suggest_widget. It works the same way - no function when I try to read from db view, but works fine when directly from db. regards Martin On Thu, Nov 17, 2011 at 7:47 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: what did you upgrade from? On Nov 16, 3:07 pm, Ole Martin Maeland olemael...@gmail.com wrote: Hi, I upgraded web2py to latest version. everything works fine exept the autocomplete widget I use MySQL as my database. The autocomplete is reading from a db VIEW. The reason for this is that I have 2 columns in a db: short_name and ISIN that is the name, and ISIN that is the ID. By doing union select it worked fine until I upgraded. after the upgrade to the latest version it is not recognising the VIEW as a DB. in my db setup I have set it to be a DB with migrate=False. I have tried to use the widget directly with a DB, and then it works fine. Initially I thought the problem were due to new adapter: pymysql, but I have changed it using: import MySQLdb from gluon.dal import MySQLAdapter MySQLAdapter.driver = MySQLdb but that is not the problem. It does not read the VIEW as a DB anymore.. I have several VIEW's in my DB and it works fine for all other queries.. any idea how to fix it ? regards martin -- Hilsen Ole Martin Mob: 95227471 -- Hilsen Ole Martin Mob: 95227471
[web2py] Re: best way to contact a programmer
+dlypka * * I am developing web services for already 7 years (SOAP, REST, XML, etc.) using .NET. At this time back in the beginning yes it was the most solid technology to get things working quickly. Now - there are much better technologies. So what you are telling is true - I can confirm that. Currently I am heavy invested in GAE - a year of development of a highly scalable app serving a thousand of users. But it was linked to Google accounts and I realized while it saved my time about auth, users don't like signing up via third party auth like Google. So after a long research I decided to use web2py. I generated my auth also using jQuery Mobile for 30 minutes as a proof of concept. While web2py is completely different from GAE(AppEngine) + Django, actually it was much easier to accomplish this. So I am sold on web2py 100%. By the way, dlypka I saw a a post of you going while back 3 years ago: DALnr Proof of Concept is available for download https://groups.google.com/forum/?hl=en#!searchin/web2py/hybrid$20GAE$20SQL$20model.$20/web2py/lp9ANObQGmM/V2FhSGjbWEoJ I appreciate a lot your posting of a code and work on a hybrid GAE+web2py. What it needs your code to work on latest version of web2py? Do you have one? Thanks in advance, Regards, --Constantine
[web2py] Re: jquery mobile 1.0 released
How? We can upgrade plugin_mobile. Or are you thinking about something else? I would like to have a version of admin (or perhaps a better wizard) based on jquery mobile. On Nov 18, 4:26 am, Angelo Compagnucci angelo.compagnu...@gmail.com wrote: This should be absolutely in web2py! 2011/11/18 Massimo Di Pierro massimo.dipie...@gmail.com: http://jquerymobile.com/blog/2011/11/16/announcing-jquery-mobile-1-0/ -- Profile:http://www.gild.com/compagnucciangelo Register on Gild:http://www.gild.com/referral/compagnucciangelo
[web2py] Re: DAL caching values automatically?
This solved it (in models/db.py): db.executesql('SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;') Muchas gracias, nick On Nov 17, 12:09 pm, John Duddy jdu...@gmail.com wrote: I think you may have nailed it - my cron does run continuously. I always commit my transactions. Do you know how to force it to reset manually? On Nov 16, 9:17 pm, nick name i.like.privacy@gmail.com wrote: Does your cron program run continuously? what database are you using? If you are using a database that supports mvcc (Oracle, Postgres, MySQL with InnoDB tables, possibly others), your first select (of any kind, not just this query) logically freezes the state of the database, and you will not see any updates until you start a new transaction (which would happen by starting the cron job again, but might be done manually). Lookup ACID trait of databases - you might be seeing the I=Isolated property in action.
Re: [web2py] Re: Authorization decorators always generate db queries
That is exactly my point, il you go beyond authenticating users, you need db access to do it. usualy you dont need RBAC for all your actions. but if you really do, you can move auth tables to RAM (mysql) Khalil
Re: [web2py] GAE (AppEngine) Datastore models under web2py - can they coexist?
+Jonathan Lundell Thank you. Before to post my question I made extensive research on this group and web and most information is dispersed. For example there are postings about web2py in the trunk which are addressing these questions but it is not clear at what stage is this.
Re: [web2py] GAE (AppEngine) Datastore models under web2py - can they coexist?
On Nov 18, 2011, at 9:25 AM, Constantine Vasil wrote: Thank you. Before to post my question I made extensive research on this group and web and most information is dispersed. For example there are postings about web2py in the trunk which are addressing these questions but it is not clear at what stage is this. Right. FWIW, I'm using the current stable release, with some changes of my own to gaehandler to support profiling.
Re: [web2py] Re: jquery mobile 1.0 released
Well yes! Thinking of a sortable list plugin, it should be in jquery for desktop and automatically switch to jquery mobile if os is_mobile. A sortable list works very diffrently whith mouse and gestures. We should have a comprehensive set of pugins covering a wide range of cases, and each one should be mobile friendly. The welcome apps is mobilized very well right now, it could be used for basic apps. But what the case if you want more? I'm thinking of chart, sortable lists, and generally all the gesture enabled widget that can be used on a phone. Jquery mobile seems to not offer a comprehensive mobile widget catalog, but these http://jquerymobile.com/demos/1.0/docs/lists/lists-forms-inset.html lonely makes the ui very attractive and functional on mobile os. I'm glad to help writing code for this! Angelo 2011/11/18 Massimo Di Pierro massimo.dipie...@gmail.com: How? We can upgrade plugin_mobile. Or are you thinking about something else? I would like to have a version of admin (or perhaps a better wizard) based on jquery mobile. On Nov 18, 4:26 am, Angelo Compagnucci angelo.compagnu...@gmail.com wrote: This should be absolutely in web2py! 2011/11/18 Massimo Di Pierro massimo.dipie...@gmail.com: http://jquerymobile.com/blog/2011/11/16/announcing-jquery-mobile-1-0/ -- Profile:http://www.gild.com/compagnucciangelo Register on Gild:http://www.gild.com/referral/compagnucciangelo -- Profile: http://www.gild.com/compagnucciangelo Register on Gild: http://www.gild.com/referral/compagnucciangelo
[web2py] Re: edge case of SQLFORM.grid search not working on 1.99.2
Ha ha. :) How about 'list:string'? On Nov 18, 11:06 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: there is not type 'reference:string'. Don't you get a ticket? On Nov 17, 10:08 am, Cliff cjk...@gmail.com wrote: grid search fails to find values if - the field type is reference:string - the field value contains a space db.define_table(mytable, Field('silly_strings', 'reference:string)) db.mytable.sillystrings.requires = IS_IN_SET(['one', 'two', 'buckle my shoe'], zero='pick one' ) grid search finds 'one' or 'two' but fails on 'buckle my shoe' Should I submit a ticket?
[web2py] os.js
http://osjs.0o.no/ php based but should be easy to rewrite in web2py
[web2py] Re: edge case of SQLFORM.grid search not working on 1.99.2
You have to write the full query field contains buckle my shoe On Nov 18, 11:41 am, Cliff cjk...@gmail.com wrote: Ha ha. :) How about 'list:string'? On Nov 18, 11:06 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: there is not type 'reference:string'. Don't you get a ticket? On Nov 17, 10:08 am, Cliff cjk...@gmail.com wrote: grid search fails to find values if - the field type is reference:string - the field value contains a space db.define_table(mytable, Field('silly_strings', 'reference:string)) db.mytable.sillystrings.requires = IS_IN_SET(['one', 'two', 'buckle my shoe'], zero='pick one' ) grid search finds 'one' or 'two' but fails on 'buckle my shoe' Should I submit a ticket?
[web2py] GAE (AppEngine) Datastore - web2py
I have this extremely efficient object oriented hierarchical construct (working parallel) under GAE: class *my_object_Root*(BaseModel): *total_counter *= db.IntegerProperty() class *my_object*(db.Model): *name *= db.StringProperty() #That's it ! Super fast ! @classmethod def *get_profile*(self, name): if not name: return None root = my_object_Root.get_profile() #cache self._cache = get_cache(memcached://) skey = name key_cache = 'my_object' + skey + str(root.key()) profile = self._cache.get(key_cache) #cache if not profile: key = db.Key.from_path('my_object', skey, parent=root.key()) profile = db.get(key) # not found - create if not profile: root = my_object_Root.get_profile_del_cache() profile = my_object(key_name=skey, parent=root.key()) profile.put() return profile #cache self._cache.set(key_cache, profile, timeout=CACHE_TIMEOUT) #cache return profile *Usage:* my_object_name = Test Name my_name = models.my_object.get_profile(my_object_name) name = my_name.name *total_counter* is in the root: *my_object_Root* of the object *my_object. *We can have many children of *my_object *under *my_object_Root *and* *additional code is updating *total_counter* when I am adding another *my_object. *That way one very difficult to implement and slow operation - counting is done very efficiently on the fly and it works very quick. This and other construct are impossible to achieve the same efficiency under SQL so the only way I see to achieve this under web2py is web2py abstraction layer to have a way transparently to use GAE. Are there currently a way to achieve this? Thanks in advance,
Re: [web2py] GAE (AppEngine) Datastore models under web2py - can they coexist?
What is the status if current stable release regarding hybrid GAE + web2py usage? Is this documented somewhere?
[web2py] Re: help on rewrite
Looks like this is a bug. I may have a fix... Anthony On Friday, November 18, 2011 9:31:00 AM UTC-5, Niphlod wrote: Hi Anthony, /errors/index function is a simple: def index(): #response.status = request.vars.code return dict(vars=request.vars) Notice the response.status line commented, it's the one triggering the loop. The template is very simple, in fact I simulated all kinds of error and it gets rendered correctly. It's only setting the status on the controller (the commented line in the index() function) that triggers the infinite loop. routes_onerror is exactly as reported, with the leading '/'. BTW, I'm using 1.99.2 On 18 Nov, 08:56, Anthony abas...@gmail.com wrote: What does your /errors/index function look like? Also, is that your exact routes_onerror? I ask because there is a bug (now fixed in trunk) that leads to a loop if your routes_onerror path is missing the leading '/' (i.e., 'errors/index' would create a loop, whereas '/errors/index' would not). Anthony On Friday, November 18, 2011 8:20:38 AM UTC-5, Niphlod wrote: Hi @all, I have a small problem with routes.py and the routes_onerror parameter. Basically I have one and only application mounted in the webserver and I'd like to strip the application part from all urls. Leave alone the redirections for static folder, favicon, robots, sitemap etc, this is done wonderfully setting: routes_in = ( ('/(?Pany.*)', '/appname/\gany') ) routes_out = ( ('/appname/(?Pany.*)', '/\gany') ) Now, let's say I want to display a simple page instead of the default error page. routes_onerror = [ ('*/*', '/errors/index') ] Working perfectly fine this one also. I created a simple errors controller, with an index() function in it, and created a view /errors/index.html. Request.vars is populated accordingly to the errors, so I can change the content of the page dinamically, there's only a small problem: if I try to change the response.status code (if there's a 404 Not Found it's not polite to return a 200 OK status) rewrite kicks in and loops forever. Any hints on how to achieve the same result with different parameters, if this is not a bug ?
[web2py] Re: edge case of SQLFORM.grid search not working on 1.99.2
Ah, like grep. Didn't try that. On Nov 18, 12:44 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You have to write the full query field contains buckle my shoe On Nov 18, 11:41 am, Cliff cjk...@gmail.com wrote: Ha ha. :) How about 'list:string'? On Nov 18, 11:06 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: there is not type 'reference:string'. Don't you get a ticket? On Nov 17, 10:08 am, Cliff cjk...@gmail.com wrote: grid search fails to find values if - the field type is reference:string - the field value contains a space db.define_table(mytable, Field('silly_strings', 'reference:string)) db.mytable.sillystrings.requires = IS_IN_SET(['one', 'two', 'buckle my shoe'], zero='pick one' ) grid search finds 'one' or 'two' but fails on 'buckle my shoe' Should I submit a ticket?
Re: [web2py] os.js
What could I use for make something exactly the same? Jquery? Ext? and what's the easier to use with web2py?? On Fri, Nov 18, 2011 at 11:42 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: http://osjs.0o.no/ php based but should be easy to rewrite in web2py
Re: [web2py] os.js
We alerady have something similar made with web2py: http://www.skytoop.com/login?_next=/ On Fri, Nov 18, 2011 at 4:42 PM, Ismael Serratos ialejandr...@gmail.comwrote: What could I use for make something exactly the same? Jquery? Ext? and what's the easier to use with web2py?? On Fri, Nov 18, 2011 at 11:42 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: http://osjs.0o.no/ php based but should be easy to rewrite in web2py -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] os.js
is it practical do make a website that behave like a desktop?
Re: [web2py] RBAC
Yes, I want to allow a user to select a team upon registration. Thank you. Sent from my iPod On Nov 18, 2011, at 6:50 AM, Khalil KHAMLICHI khamlichi.kha...@gmail.com wrote: Hi, I think this is an administrator's job to affect teams to members but you can as well create an action that allows a user to choose his team, in both cases there would be the same registration form. Khalil
[web2py] Re: help on rewrite
feel free to suggest anything you want, I'm happy to test it heavily :D On 18 Nov, 18:50, Anthony abasta...@gmail.com wrote: Looks like this is a bug. I may have a fix... Anthony On Friday, November 18, 2011 9:31:00 AM UTC-5, Niphlod wrote: Hi Anthony, /errors/index function is a simple: def index(): #response.status = request.vars.code return dict(vars=request.vars) Notice the response.status line commented, it's the one triggering the loop. The template is very simple, in fact I simulated all kinds of error and it gets rendered correctly. It's only setting the status on the controller (the commented line in the index() function) that triggers the infinite loop. routes_onerror is exactly as reported, with the leading '/'. BTW, I'm using 1.99.2 On 18 Nov, 08:56, Anthony abas...@gmail.com wrote: What does your /errors/index function look like? Also, is that your exact routes_onerror? I ask because there is a bug (now fixed in trunk) that leads to a loop if your routes_onerror path is missing the leading '/' (i.e., 'errors/index' would create a loop, whereas '/errors/index' would not). Anthony On Friday, November 18, 2011 8:20:38 AM UTC-5, Niphlod wrote: Hi @all, I have a small problem with routes.py and the routes_onerror parameter. Basically I have one and only application mounted in the webserver and I'd like to strip the application part from all urls. Leave alone the redirections for static folder, favicon, robots, sitemap etc, this is done wonderfully setting: routes_in = ( ('/(?Pany.*)', '/appname/\gany') ) routes_out = ( ('/appname/(?Pany.*)', '/\gany') ) Now, let's say I want to display a simple page instead of the default error page. routes_onerror = [ ('*/*', '/errors/index') ] Working perfectly fine this one also. I created a simple errors controller, with an index() function in it, and created a view /errors/index.html. Request.vars is populated accordingly to the errors, so I can change the content of the page dinamically, there's only a small problem: if I try to change the response.status code (if there's a 404 Not Found it's not polite to return a 200 OK status) rewrite kicks in and loops forever. Any hints on how to achieve the same result with different parameters, if this is not a bug ?
[web2py] Re: help on rewrite
See https://groups.google.com/d/topic/web2py-developers/JsY5uO02664/discussion. On Friday, November 18, 2011 2:20:24 PM UTC-5, Niphlod wrote: feel free to suggest anything you want, I'm happy to test it heavily :D On 18 Nov, 18:50, Anthony abas...@gmail.com wrote: Looks like this is a bug. I may have a fix... Anthony On Friday, November 18, 2011 9:31:00 AM UTC-5, Niphlod wrote: Hi Anthony, /errors/index function is a simple: def index(): #response.status = request.vars.code return dict(vars=request.vars) Notice the response.status line commented, it's the one triggering the loop. The template is very simple, in fact I simulated all kinds of error and it gets rendered correctly. It's only setting the status on the controller (the commented line in the index() function) that triggers the infinite loop. routes_onerror is exactly as reported, with the leading '/'. BTW, I'm using 1.99.2 On 18 Nov, 08:56, Anthony aba...@gmail.com wrote: What does your /errors/index function look like? Also, is that your exact routes_onerror? I ask because there is a bug (now fixed in trunk) that leads to a loop if your routes_onerror path is missing the leading '/' (i.e., 'errors/index' would create a loop, whereas '/errors/index' would not). Anthony On Friday, November 18, 2011 8:20:38 AM UTC-5, Niphlod wrote: Hi @all, I have a small problem with routes.py and the routes_onerror parameter. Basically I have one and only application mounted in the webserver and I'd like to strip the application part from all urls. Leave alone the redirections for static folder, favicon, robots, sitemap etc, this is done wonderfully setting: routes_in = ( ('/(?Pany.*)', '/appname/\gany') ) routes_out = ( ('/appname/(?Pany.*)', '/\gany') ) Now, let's say I want to display a simple page instead of the default error page. routes_onerror = [ ('*/*', '/errors/index') ] Working perfectly fine this one also. I created a simple errors controller, with an index() function in it, and created a view /errors/index.html. Request.vars is populated accordingly to the errors, so I can change the content of the page dinamically, there's only a small problem: if I try to change the response.status code (if there's a 404 Not Found it's not polite to return a 200 OK status) rewrite kicks in and loops forever. Any hints on how to achieve the same result with different parameters, if this is not a bug ?
[web2py] Custom name for uploaded file
I have upload form, and it's work. I use example from book. But file get new name by web2py, can I control this name and how on other words can I give my name for uploaded file. Regards Miroslav
[web2py] Re: packaging return from executesql as Rows object?
Hi Bruno, I tried both of these but neither one worked. I just wound up with an empty table. I wasn't sure why you used Row objects in one list comprehension and Storage objects in the other, but neither one produced a list that the table likes. :( Not sure what's going on there but there were no exceptions thrown and I know the raw rows list is properly populated prior to the conversion to Rows. Thanks, David On Nov 16, 8:09 pm, Bruno Rocha rochacbr...@gmail.com wrote: wait, there is a better way. from gluon.dal import Rows, Row result = access.db.executesql(SELECT first_name, last_name FROM auth_user, as_dict=True) rows = Rows(records=[Row(item) for item in result]) rows[0].first_name u'Bruno' You can set other values for each Row.
[web2py] Re: Shortcut for fetching a row
DenesL, That works and just what I need. Thank you! Anthony, I did think that the first argument is the field to return :) Thank you for the clear explanation. Khalil, Thanks for the tips. I'd consider that for my projects.
[web2py] Re: packaging return from executesql as Rows object?
This produces a table with a single column and the rows consisting of what should have been the header columns followed by the body columns manifested as rows also. On Nov 17, 10:25 am, DenesL denes1...@yahoo.ca wrote: Why not just: table = TABLE(THEAD(columns), TBODY(raw_rows)) On Nov 16, 3:43 pm, David Watson davidthewat...@gmail.com wrote: Does anybody have example code showing how to package the return from executesql as a gluon.sql.Rows object? I have tried: raw_rows = legacy_db.executesql(sqlstr, as_dict=True) from gluon import sql columns = ['col1', 'col2', 'col3'] rowsobj = sql.Rows(legacy_db, raw_rows, columns) table = SQLTABLE(rowsobj) but this blows up in sql.Rows. I'm just looking for a quick and dirty (throw-away) way to do some reports with existing complex SQL queries. Thanks, Dave
[web2py] how to hide function
In controller I have two functions def func1(): body of function return value1 def func2(): body of function return value2 In EDIT APPLICATION NAME (administrative panel) I see default.py exposes func1,func2 In my browser I can access to both functions http://127.0.0.1:8000/name/default/func1 http://127.0.0.1:8000/name/default/func2 in my browser I need to access only to func1 but not in func2 Is some other way to make functions, or is just like this and I need to use this way for my functions Visible functions should be index, contact, ... but how to hide some functions for making some calculations from direct access from browser. Regards Miroslav
[web2py] Re: how to hide function
And I have answer for me just use extra space :) for hiding def func1 (): body of function return value1 or without extra space is normally visible: def func2(): body of function return value2 Miroslav On Nov 18, 9:35 pm, miroslavgojic miroslavgo...@gmail.com wrote: In controller I have two functions def func1(): body of function return value1 def func2(): body of function return value2 In EDIT APPLICATION NAME (administrative panel) I see default.py exposes func1,func2 In my browser I can access to both functionshttp://127.0.0.1:8000/name/default/func1http://127.0.0.1:8000/name/default/func2 in my browser I need to access only to func1 but not in func2 Is some other way to make functions, or is just like this and I need to use this way for my functions Visible functions should be index, contact, ... but how to hide some functions for making some calculations from direct access from browser. Regards Miroslav
[web2py] Re: how to hide function
The extra space method is probably a bug (so don't count on it working in the future) -- instead, you can start the function name with two underscores, or make sure the function takes at least one argument (even if it's a dummy argument that isn't used). See http://web2py.com/book/default/chapter/04#Dispatching (callout box). Anthony On Friday, November 18, 2011 3:39:29 PM UTC-5, miroslavgojic wrote: And I have answer for me just use extra space :) for hiding def func1 (): body of function return value1 or without extra space is normally visible: def func2(): body of function return value2 Miroslav On Nov 18, 9:35 pm, miroslavgojic mirosl...@gmail.com wrote: In controller I have two functions def func1(): body of function return value1 def func2(): body of function return value2 In EDIT APPLICATION NAME (administrative panel) I see default.py exposes func1,func2 In my browser I can access to both functionshttp:// 127.0.0.1:8000/name/default/func1http://127.0.0.1:8000/name/default/func2 in my browser I need to access only to func1 but not in func2 Is some other way to make functions, or is just like this and I need to use this way for my functions Visible functions should be index, contact, ... but how to hide some functions for making some calculations from direct access from browser. Regards Miroslav
[web2py] Re: packaging return from executesql as Rows object?
I think Bruno's method will create a Rows object, but it might be missing some metadata about the db and fields that are required by SQLTABLE. Anthony On Friday, November 18, 2011 3:31:07 PM UTC-5, David Watson wrote: Hi Bruno, I tried both of these but neither one worked. I just wound up with an empty table. I wasn't sure why you used Row objects in one list comprehension and Storage objects in the other, but neither one produced a list that the table likes. :( Not sure what's going on there but there were no exceptions thrown and I know the raw rows list is properly populated prior to the conversion to Rows. Thanks, David On Nov 16, 8:09 pm, Bruno Rocha rocha...@gmail.com wrote: wait, there is a better way. from gluon.dal import Rows, Row result = access.db.executesql(SELECT first_name, last_name FROM auth_user, as_dict=True) rows = Rows(records=[Row(item) for item in result]) rows[0].first_name u'Bruno' You can set other values for each Row.
[web2py] Re: packaging return from executesql as Rows object?
DenesL's method should work as long as you have as_dict=False (the default) in your call to executesql(). Anthony On Friday, November 18, 2011 3:33:05 PM UTC-5, David Watson wrote: This produces a table with a single column and the rows consisting of what should have been the header columns followed by the body columns manifested as rows also. On Nov 17, 10:25 am, DenesL dene...@yahoo.ca wrote: Why not just: table = TABLE(THEAD(columns), TBODY(raw_rows)) On Nov 16, 3:43 pm, David Watson davidth...@gmail.com wrote: Does anybody have example code showing how to package the return from executesql as a gluon.sql.Rows object? I have tried: raw_rows = legacy_db.executesql(sqlstr, as_dict=True) from gluon import sql columns = ['col1', 'col2', 'col3'] rowsobj = sql.Rows(legacy_db, raw_rows, columns) table = SQLTABLE(rowsobj) but this blows up in sql.Rows. I'm just looking for a quick and dirty (throw-away) way to do some reports with existing complex SQL queries. Thanks, Dave
[web2py] Re: Custom name for uploaded file
web2py renames the file for security purposes, and to enable it to retrieve the file later via response.download. It encodes the original filename within the new filename and decodes it upon download. What exactly do you need to do? Anthony On Friday, November 18, 2011 3:03:48 PM UTC-5, miroslavgojic wrote: I have upload form, and it's work. I use example from book. But file get new name by web2py, can I control this name and how on other words can I give my name for uploaded file. Regards Miroslav
Re: [web2py] GAE (AppEngine) Datastore models under web2py - can they coexist?
i doubt there is any documentation on the subject per-se. note that the web2py DAL simply translates the web2py style schema definitions and queries into raw GAE datastore queries. if you get really bored and read the DAL you'll see it's just a wrapper around what you already know. you'll also find that there are some GAE features that are not implemented in the DAL yet. if the web2py models and raw GAE models are all different models there should be no problem. if you are accessing a particular model via GAE and web2py just make sure that the web2py represent and requires are written in such a way that any data that may be inserted by the raw GAE access will not cause them to break. for my largest web2py project (starmakerstudios.com and the associated iphone app that talks to the DB) i do all my day-to-day work with web2py DAL, but schema migrations are often done with raw GAE access. hope that helps. feel free to fire off specific questions. cfh
[web2py] Re: GAE (AppEngine) Datastore - web2py
nothing is preventing you from using memcache in this way in web2py. you could port the get_profile() method to web2py with no problem a oft requested by still missing GAE web2py feature is to deal with hierarchical models and queries since GAE supports them. learning them and then proposing a web2py patch has been on my TODO list for a few months nowbut i have not gotten far with it. side question - how do you keep your counter up to date without having write contention on the object? (i'm using sharded counters for some things, but i don't like them)
[web2py] Re: how to hide function
I tray both methods, dummy argument and two underscore The dummy argument can be fanny :) but I chose to use two underscore (_ + _) = __ Thanks Anthony Miroslav On Nov 18, 9:43 pm, Anthony abasta...@gmail.com wrote: The extra space method is probably a bug (so don't count on it working in the future) -- instead, you can start the function name with two underscores, or make sure the function takes at least one argument (even if it's a dummy argument that isn't used). Seehttp://web2py.com/book/default/chapter/04#Dispatching(callout box). Anthony On Friday, November 18, 2011 3:39:29 PM UTC-5, miroslavgojic wrote: And I have answer for me just use extra space :) for hiding def func1 (): body of function return value1 or without extra space is normally visible: def func2(): body of function return value2 Miroslav On Nov 18, 9:35 pm, miroslavgojic mirosl...@gmail.com wrote: In controller I have two functions def func1(): body of function return value1 def func2(): body of function return value2 In EDIT APPLICATION NAME (administrative panel) I see default.py exposes func1,func2 In my browser I can access to both functionshttp:// 127.0.0.1:8000/name/default/func1http://127.0.0.1:8000/name/default/func2 in my browser I need to access only to func1 but not in func2 Is some other way to make functions, or is just like this and I need to use this way for my functions Visible functions should be index, contact, ... but how to hide some functions for making some calculations from direct access from browser. Regards Miroslav
Re: [web2py] Re: Authorization decorators always generate db queries
the distinction being made here is that decorators appear to be executed for methods that are not called during this request. whether or not a query is run is not really the point, the point is that it seems that code is being executed that the user never intended. that said, i don't know enough about decorators to know how they work under the covers. i would tend to agree with Ids that this behavior is not what i expect, and with the auth decorators that run queries can significantly slow down an application. can anyone comment on whether Ids and my expectation of how decorators work are correct? thanks, cfh
Re: [web2py] Re: SQLForm.grid - How do I use it properly?
On 18 November 2011 09:00, Rahul rahul.dhak...@gmail.com wrote: Hi Johan, All, Sorry but I am not able to get it. With your code above I get an invalid controller You are not supposed to use that code exactly as it is. You must adapt it for your circumstances: links = [lambda row: A('Edit',_href=URL(controller,edit,args=[update, tablename, a.id])) Replace controller with your controller e.g. 'default' Replace 'edit' with your function in the controller referred to. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: Custom name for uploaded file
What I need to do? It is hard to explain but I will tray. On my faculty I need to setup small web for professors and students. Professors can upload files (*.pdf, and possibly some *.zip) and they need to login for putting content - uploading files. Filter is make like SELECT(OPTION(),OPTION()), and I have 4 SELECT (4 drop-down list) From Select and options I use professor name and his id, subject name and subject id ... from professor.id and subject.id and some other parameters I need to create file name... example of my file name in upload folder: professor.id_subject.id_year_number.pdf number is some number like number of row in database or just simply ++ counter year is current year, can be setup from list or from date() The content is not confidential, now is on open FTP, just some lectures from mathematics or other subjects. We have problems with FTP, professors have problem to upload files on FTP (ftp tools are complicated for them - some of professors are old ...) On student side I have multi apply filter, after students select list options and apply filter they will get list of file for download. I hope so that is understandable. Miroslav On Nov 18, 9:54 pm, Anthony abasta...@gmail.com wrote: web2py renames the file for security purposes, and to enable it to retrieve the file later via response.download. It encodes the original filename within the new filename and decodes it upon download. What exactly do you need to do? Anthony On Friday, November 18, 2011 3:03:48 PM UTC-5, miroslavgojic wrote: I have upload form, and it's work. I use example from book. But file get new name by web2py, can I control this name and how on other words can I give my name for uploaded file. Regards Miroslav
Re: [web2py] Re: Authorization decorators always generate db queries
The problem isn't with the decorator per se, but with the condition being evaluated. If you have: @auth.requires_permission('read') def secrets(): etc. that is equivalent to: @auth.requires(condition=auth.has_permission('read')) def secrets(): etc. In this case, the decorator takes an argument (the condition to be evaluated), and the argument itself is a function call that does a db query. So, setting up the decorated function ends up running the db query in auth.has_permission. In trunk, there is a new feature that allows a way around this -- the condition argument to auth.requires can be a callable, so you can do: @auth.requires(lambda: auth.has_permission('read')) def secrets(): In that case, when the decorator is created, it simply passes the lambda as the condition, rather than calling auth.has_permission. The lambda doesn't actually get called until the secrets() function is called. Perhaps we should change auth.requires_membership and auth.requires_permission to use lambda in this way. Anthony On Friday, November 18, 2011 4:07:28 PM UTC-5, howesc wrote: the distinction being made here is that decorators appear to be executed for methods that are not called during this request. whether or not a query is run is not really the point, the point is that it seems that code is being executed that the user never intended. that said, i don't know enough about decorators to know how they work under the covers. i would tend to agree with Ids that this behavior is not what i expect, and with the auth decorators that run queries can significantly slow down an application. can anyone comment on whether Ids and my expectation of how decorators work are correct? thanks, cfh
[web2py] Re: Authorization decorators always generate db queries
I created issue 526 for this ( http://code.google.com/p/web2py/issues/detail?id=526#c0 ). I'm not sure how the decorators are implemented, but I think Anthony's solution using lambda points in the right direction to fix this.
[web2py] Re: Authorization decorators always generate db queries
I've already submitted a patch. Anthony On Friday, November 18, 2011 5:00:10 PM UTC-5, Ids wrote: I created issue 526 for this ( http://code.google.com/p/web2py/issues/detail?id=526#c0 ). I'm not sure how the decorators are implemented, but I think Anthony's solution using lambda points in the right direction to fix this.
[web2py] Re: Custom name for uploaded file
some questions: Can I turnoff default changing name with upload function? Can I before upload start, change file name (rename(from.first.name, to.second.name)) and than proceed to upload... User select file for upload, application first give new name to file and than start upload with new name, and new name can be changed or not from upload function. On Nov 18, 9:54 pm, Anthony abasta...@gmail.com wrote: web2py renames the file for security purposes, and to enable it to retrieve the file later via response.download. It encodes the original filename within the new filename and decodes it upon download. What exactly do you need to do? Anthony On Friday, November 18, 2011 3:03:48 PM UTC-5, miroslavgojic wrote: I have upload form, and it's work. I use example from book. But file get new name by web2py, can I control this name and how on other words can I give my name for uploaded file. Regards Miroslav
[web2py] routes.py
If I put routes_onerror = [ (r'*/*', r'/myapp/errors/index') ] Then it allows me to capture domain/abc and do what I want according to what is after the slash. However if I just put domain it goes to the welcome page. So if I change routes.py to routers = dict( BASE = dict(default_application='myApp'), ) routes_onerror = [ (r'*/*', r'/images/errors/index') ] Then domain does get routed to myapp, but when I do domain/abc although it does get routed to myapp/errors/index, request.vars just contains Storage {'ticket': 'None', 'code': '400', 'request_url': 'None', 'requested_uri ': 'None'} i.e. no information about what is after the slash. is there any way that I can get domain to route to myapp, and to reroute domain/whatever myself according to what 'whatever' is? Thanks Peter
[web2py] Serving non-uploaded, permission based files
I am starting a web2py app and need some help with the high level design. I am familiar with web2py but how to do what I am after is not immediately clear. My app will take jobs submitted by users that will eventually create CSVs files using a cron script and store them on the server's filesystem. Users will then be able to download their specific CSVs. Should I use the static directory with a subfolder for each user and then authenticate and authorize each user to only access their own folder? Also, since the file was never uploaded how would I go about creating URLs to the files to be downloaded? I'm sure there is a better way of doing this and a point in the right direction would be appreciated. Thanks, Dave
[web2py] Re: Serving non-uploaded, permission based files
You won't be able to restrict access to files in static (they are served without touching the application code). Instead, check out http://web2py.com/book/default/chapter/06#Manual-Uploads. Anthony On Friday, November 18, 2011 6:14:16 PM UTC-5, Dave wrote: I am starting a web2py app and need some help with the high level design. I am familiar with web2py but how to do what I am after is not immediately clear. My app will take jobs submitted by users that will eventually create CSVs files using a cron script and store them on the server's filesystem. Users will then be able to download their specific CSVs. Should I use the static directory with a subfolder for each user and then authenticate and authorize each user to only access their own folder? Also, since the file was never uploaded how would I go about creating URLs to the files to be downloaded? I'm sure there is a better way of doing this and a point in the right direction would be appreciated. Thanks, Dave
[web2py] Re: Custom name for uploaded file
On Friday, November 18, 2011 5:55:59 PM UTC-5, miroslavgojic wrote: some questions: Can I turnoff default changing name with upload function? I don't think so. As an alternative, process the form with dbio=False so it doesn't do the upload or database insert, and then manually process the upload however you want and store your filename in the db. See http://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO. Anthony
[web2py] Re: GAE (AppEngine) Datastore - web2py
Thank you! nothing is preventing you from using memcache in this way in web2py. you could port the get_profile() method to web2py with no problem This is a great relief. Actually what is the downside using pure GAE vs. web2py? What will be missing? And I suppose I have just to import the appengine libraries as usual and begin to define the model, etc? Are there any code where this is already done? I will spend a time with Eclipse debugger to understand it better when I am able to run it. I am running it at localhost:8080, the breakpoint comes to gaehandler.wsgiapp, I am placing a breakpoint on my app code but the debugger does not stops there. side question - how do you keep your counter up to date without having write contention on the object? (i'm using sharded counters for some things, but i don't like them) Sharded counters seems too complicated and since counting is an essential function I decided early to increase/descrease when addind/deleting on the spot. Because it is a hierarchical structure when I put the code in a transaction I guarantee its update is valid for this branch of the tree. GAE keeps track for the rest. When there is a contention GAE tries several more times until success. Most of the time I do that in a deferred process and this is configurable - how often to try again, how long to wait till next try, basically it is an exponential back off - it is very sophisticated mechanism on which Google worked a lot of time on to perfect it. Another consideration for hierarchical structure is HRD requires it. So this is essential. I watched the logs and this happened several times, the deferred process keeps trying till there is a success. This is one of the reasons I keep staying with pure GAE - you cannot achieve a scale without it and it is related to Google infrastructure, nothing else.
[web2py] problem while connecting to database when password contains '@'
Hi , While trying to connect to a mysql server I found that the URI string used in DAL() was not parsed properly. I have a '@' in my password and gets parsed first changing the hostname to some non existent value, I tried escaping the '@' but dosen't work. Did anyone have this same problem ? If so can you please help me ? Thanks -Syed
Re: [web2py] GAE (AppEngine) Datastore models under web2py - can they coexist?
if the web2py models and raw GAE models are all different models there should be no problem. Actually the GAE models will stay the same because all the system is already tested and working. I decided to move to web2py when I saw it has auth and I implemented it for 30 minutes including jQuery Mobile layout. Which impressed me and I needed to learn more. So basically how I see it I will use only auth from web2py database all the rest would be GAE. for my largest web2py project (starmakerstudios.com and the associated iphone app that talks to the DB) It looks cool. Does the web2py handles the traffic in a stable way?
[web2py] Eclipse+Pydev+GAE+Debugging
there is a trouble setting the visual Eclipse+PyDev debugger to work with web2py. I got the Eclipse debugger to come to a breakpoint in *applications/welcome/models*/db.py but if I set up a breakpoint in *applications/welcome/controllers*/default.py at *index* the debugger does not stops at the breakpoint. If I insert: import pdb, sys debugger = pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__) debugger.set_trace() before index, pdb stops there. Why Eclipse debugger cannot stops at controllers?
[web2py] Re: os.js
Jquery and ajax make it pretty close, I think. Response time, it seems to me, is the big issue. Server/network latency can be a problem. Sometimes it just takes a while for the packets to get through, even though the amount of data being exchanged is very small. Of course, you can send a lot of data and show/hide as circumstances require, but then the payload to the browser gets a little big. On Nov 18, 1:48 pm, Vasile Ermicioi elff...@gmail.com wrote: is it practical do make a website that behave like a desktop?
[web2py] Re: help on rewrite
The patch is now in trunk -- please test. If you can, it would be helpful if you could try it out with different types of rewrite rules. Also, try it using the parameter-based rewrite system, as well as with no rewrite rules at all (want to make sure we didn't break anything). FYI, an easier way to strip the application name from your URLs is to use the parameter-based rewrite system -- put this in routes.py instead of your routes_in, routes_out: routers = dict( BASE = dict( default_application = 'appname', ), ) See http://web2py.com/book/default/chapter/04#Parameter-Based-System. Another option is simply to name your app 'init'. Anthony On Friday, November 18, 2011 2:20:24 PM UTC-5, Niphlod wrote: feel free to suggest anything you want, I'm happy to test it heavily :D On 18 Nov, 18:50, Anthony abas...@gmail.com wrote: Looks like this is a bug. I may have a fix... Anthony On Friday, November 18, 2011 9:31:00 AM UTC-5, Niphlod wrote: Hi Anthony, /errors/index function is a simple: def index(): #response.status = request.vars.code return dict(vars=request.vars) Notice the response.status line commented, it's the one triggering the loop. The template is very simple, in fact I simulated all kinds of error and it gets rendered correctly. It's only setting the status on the controller (the commented line in the index() function) that triggers the infinite loop. routes_onerror is exactly as reported, with the leading '/'. BTW, I'm using 1.99.2 On 18 Nov, 08:56, Anthony aba...@gmail.com wrote: What does your /errors/index function look like? Also, is that your exact routes_onerror? I ask because there is a bug (now fixed in trunk) that leads to a loop if your routes_onerror path is missing the leading '/' (i.e., 'errors/index' would create a loop, whereas '/errors/index' would not). Anthony On Friday, November 18, 2011 8:20:38 AM UTC-5, Niphlod wrote: Hi @all, I have a small problem with routes.py and the routes_onerror parameter. Basically I have one and only application mounted in the webserver and I'd like to strip the application part from all urls. Leave alone the redirections for static folder, favicon, robots, sitemap etc, this is done wonderfully setting: routes_in = ( ('/(?Pany.*)', '/appname/\gany') ) routes_out = ( ('/appname/(?Pany.*)', '/\gany') ) Now, let's say I want to display a simple page instead of the default error page. routes_onerror = [ ('*/*', '/errors/index') ] Working perfectly fine this one also. I created a simple errors controller, with an index() function in it, and created a view /errors/index.html. Request.vars is populated accordingly to the errors, so I can change the content of the page dinamically, there's only a small problem: if I try to change the response.status code (if there's a 404 Not Found it's not polite to return a 200 OK status) rewrite kicks in and loops forever. Any hints on how to achieve the same result with different parameters, if this is not a bug ?
[web2py] Re: Authorization decorators always generate db queries
This has been fixed in trunk. Please try it out if you can and report back. Anthony On Friday, November 18, 2011 5:00:10 PM UTC-5, Ids wrote: I created issue 526 for this ( http://code.google.com/p/web2py/issues/detail?id=526#c0 ). I'm not sure how the decorators are implemented, but I think Anthony's solution using lambda points in the right direction to fix this.
[web2py] forms and validators
Hello, I am trying to figure out a way which I can have a select (drop down menu) form, where based on the option that is selected the rest of the form validators change. To try and explain it better here's the example I am trying to work on. I am working on a web2py powerdns front end (to learn web2py).. In the type form field I have TR(Type:, SELECT('A', 'CNAME', '', 'MX', 'NS', 'TXT', _name='type', value='yes', requires=IS_IN_SET(['A', 'CNAME', '', 'MX', 'NS', 'TXT']))), If the user selects A from the drop down menu I would like to have requires=IS_IPV4() for the record type validator. Is it possible to do that? Thanks Jimmy.
[web2py] Re: Custom name for uploaded file
I reed all in online book about upload and forms... Can I make my upload manually, something like: brows_file - upload_to_some_folder. What is happening after I submit button 'upload' - can I have control on this activity. I'm new with Web2Py and Python, but on PHP this is no problem, I make all my code upload form and files go to folders what I chose, and file name is my will same or changed... In Python I see some functions os.rename for renaming files, but it is directly rename file name. Can I have may custom upload form with two way first: sending file to folder - no need for database second: sending data to database - and don'n need to know is file or something else. On download process I can us something like list folder content and make links for download (from file list and database data I will generate links for download) If you have doubts why so complicated, and why I don't use simply way shown in book - answer is: the chairman of department what that files stored as early mentioned... Miroslav On Nov 19, 12:40 am, Anthony abasta...@gmail.com wrote: On Friday, November 18, 2011 5:55:59 PM UTC-5, miroslavgojic wrote: some questions: Can I turnoff default changing name with upload function? I don't think so. As an alternative, process the form with dbio=False so it doesn't do the upload or database insert, and then manually process the upload however you want and store your filename in the db. Seehttp://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO. Anthony