[web2py] How can I create new auth_user and auth_group on Web2py running on Google App Engine (GAE)?
I've created an app on my local computer with Web2py and it is running via WSGI with SQLite. I can successfully deploy my app to Google App Engine, using my own domain and doing all url rewrites I need. Now I need a way to create specific administrative users that will be responsible for update some tables. *Specific questions:* 1. Is there a way I can use Web2py admin interface when my appliation is running on GAE ? 2. Even if I do not want create news applications nor edit files, is it possible to use Web2py admin interface just to manage the database of an application running on Google App engine? 3. If not, how this kind of user management is done when using Web2py on GAE? http://stackoverflow.com/questions/10201300/how-can-i-create-new-auth-user-and-auth-group-on-web2py-running-on-google-app-en
[web2py] Web2py + Python 2.7 on GAE: Can I use PIL and resize an image when uploading to datastore?
This is my model. I upload the image to the logotipo_marca_blob field... I can already use from PIL import Image inside app engine SDK without problems... db.define_table('marcas', Field('nome_marca',unique=True), Field('site_marca'), Field('nome_marca_url', readable=False), Field('logotipo_marca_url', 'upload', uploadfield='logotipo_marca_blob'), Field('logotipo_marca_blob', 'blob'), ) How can I get the imagem from request.vars and change its size BEFORE insert in the datastore? Or... after insert... how can I get the image TO and OUT from PIL Image object ? I'm in doubt because PIL opens the image from a file... and Google App Engine does not allow access to file system. Web2py is really great... and I found myself really productive with it... but for this question... I aready take many hours and did not find any answers... Anyone can help-me with a piece of code and some ideias? Thanks!
Re: [web2py] Re: Web2py + Python 2.7 on GAE: Can I use PIL and resize an image when uploading to datastore?
Hi! Thank you for your answer. I want resize to 3 or 4 different sizes and store this values againd, on different fields... Should I do that on the function where I receive the post? Would it take to much time? And... I need to insert a logo inside the image, can it be done using images API? If not, how to use PIL direcly from the request.vars['imageblob'] field? On Thu, Apr 19, 2012 at 16:21, Wikus van de Merwe < dupakrop...@googlemail.com> wrote: > For simple things such as thumbnails, you can use the GAE images API > (which internally uses PIL): > https://developers.google.com/appengine/docs/python/images/imageclass > > from google.appengine.api import images > > blob = db.marcas(id).logotipo_marca_blob > image = images.Image(blob) > image.resize(32, 32) > data = image.execute_transforms() > > > -- -- Atenciosamente, Alex BENFICA -- "O que não se mede não se gerencia."
[web2py] Re: Time to move from Google Groups to a web2py or python??
Hi! Maybe move away from Google Groups is really a nice ideia... Even the App Engine groups did that... http://groups.google.com/group/google-appengine/browse_thread/thread/67a5cdffae1c03bc On Saturday, April 21, 2012 1:24:32 PM UTC-3, JoeCodeswell wrote: > > This new look that Google Groups has implemented is seriously debilitating > for a borderline dyslexic like me. > > Also the AJAX panel sizing is not working on my Chrome/WinXP system. > > Could this be a sign that web2py needs to eat the food it cooks and > implement its own web2py-users forum? > > PS When i tried to submit this post with a tag of "meta", Google Groups > told me "only suggested tags can be used". I chose "ajax" from "ajax, > sessions, cache, internationalization". I think this restriction by Google > Groups might be another reason to be web2py based. > > Thanks for any responses. > > Love and peace, > > Joe >
[web2py] Re: Reloading modules
I'm having a seriuos problem having to stop and start Google App Engine SDK when I want edit modules, otherwise, they are not reloaded. The problem is that, doing this, I lose the entire database content on GAE SDK... Is there a way to edit web2py modules and get then reloaded each time I run the app inside GAE SDK? I have these lines on the beginning of my first model file... and it is not working yet... from gluon.custom_import import track_changes track_changes(True) Any ideas? On Saturday, April 28, 2012 10:43:42 AM UTC-3, Yarin wrote: > > For dev purposes, it would be nice to be able to reload modules without > having to restart the server- or to have a setting that automatically > reloads on each request- Otherwise it's almost impossible to do active > module development from within web2py. On Saturday, April 28, 2012 10:43:42 AM UTC-3, Yarin wrote: > > For dev purposes, it would be nice to be able to reload modules without > having to restart the server- or to have a setting that automatically > reloads on each request- Otherwise it's almost impossible to do active > module development from within web2py.
Re: [web2py] Re: Reloading modules
Oi Ricardo, Thanks. I add the option to use sql lite and databse keeps data when I restart app engine SDK. And about the module reloading... did you have any problems with it? On Wed, May 9, 2012 at 5:54 PM, Ricardo Pedroso wrote: > On Wed, May 9, 2012 at 8:35 PM, Alex Benfica wrote: >> >> I'm having a seriuos problem having to stop and start Google App Engine SDK >> when I want edit modules, otherwise, they are not reloaded. >> The problem is that, doing this, I lose the entire database content on GAE >> SDK... > > You can persist the data on GAE SDK > > https://developers.google.com/appengine/docs/python/tools/devserver#Using_the_Datastore > > Ricardo -- -- Atenciosamente, Alex BENFICA -- "O que não se mede não se gerencia."
Re: [web2py] Re: Reloading modules
Hi... When you say "now that i'm doing more and more in modules it does slow things down"... are you talking about development time, right? is not about the performace of you web2py app... is that? The performance increase when using modules instead put code on models worth all this extra work? Do you have any measure about this performance gain? On Thu, May 10, 2012 at 1:17 PM, howesc wrote: > i use the persistent local datastore on GAE SDK as well. i have not tried > to turn on dynamic module re-loading on GAE, but i have a shell script that > starts/stops GAE and i just restart that. it's not as fast as > auto-reloading but it has been ok for me (though now that i'm doing more and > more in modules it does slow things down) > > > On Wednesday, May 9, 2012 2:27:33 PM UTC-7, Alex Benfica wrote: >> >> Oi Ricardo, >> >> Thanks. >> >> I add the option to use sql lite and databse keeps data when I restart >> app engine SDK. >> And about the module reloading... did you have any problems with it? >> >> On Wed, May 9, 2012 at 5:54 PM, Ricardo Pedroso >> wrote: >> > On Wed, May 9, 2012 at 8:35 PM, Alex Benfica >> > wrote: >> >> >> >> I'm having a seriuos problem having to stop and start Google App Engine >> >> SDK >> >> when I want edit modules, otherwise, they are not reloaded. >> >> The problem is that, doing this, I lose the entire database content on >> >> GAE >> >> SDK... >> > >> > You can persist the data on GAE SDK >> > >> > >> > https://developers.google.com/appengine/docs/python/tools/devserver#Using_the_Datastore >> > >> > Ricardo >> >> >> >> -- >> -- >> >> Atenciosamente, >> Alex BENFICA >> >> -- >> "O que não se mede não se gerencia." -- -- Atenciosamente, Alex BENFICA -- "O que não se mede não se gerencia."
[web2py] Re: Automatically reload custom modules?
Hi! I have it on my only file at models folder, at first line. from gluon.custom_import import track_changes; track_changes(True) When using GAE SDK, this option does NOTE reloads modules! The tickets shows erros on wrong line numbers... and changes made on module files are only displayed when App Engine is stoped and started again. I'm really in trouble now... since I found that there is a huge difference on performance when I keep filles on models compared to modules... but have to start \ stop the development server each time I want to test my code is not productive. Is there any way of make the reload work on Google App Engine? or... to avoid the problem... how can I develop using models and have no problems changing files to modules when I decide upload then to App Engine? I'm in Windows 7 64bits Web2py Version 1.99.7 (2012-03-04 22:12:08) stable App Engine SDK release: "1.6.5" timestamp: 1332880663 api_versions: ['1'] Python 2.5.2 wxPython 2.8.8.1 (msw-unicode) On Tuesday, February 21, 2012 10:14:06 PM UTC-2, Massimo Di Pierro wrote: > > from gluon.custom_import import track_changes; track_changes(True) > > On Feb 21, 5:18 pm, Bruce Wade wrote: > > Hi, > > > > I am starting to find this situation a little annoying. I have a package > at > > the same level as gluon, adviewerAPI. Which contains several modules > that I > > will be using across all my applications. (Main website, customer > service > > app etc...) > > > > Now the issue is whenever I make a change to any of the modules, I need > to > > stop and restart the development server. Is there a setting to for auto > > reload when a module changes? > > > > -- > > -- > > Regards, > > Bruce Wadehttp:// > ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
[web2py] Re: DAL query: limit ?
Hi! Massimo... does it really limits the number of entities queried from GAE datastore? I made some tests while observing quota limits... and seens that each time I do limitby=(0,10), all 845 entities I have are being returned... but web2py only shows 10 first... Is there a way I can only get then 10 first from database ? GAE costs increases when more entities are returned... How to solve that? On Thursday, January 14, 2010 1:34:31 PM UTC-2, mdipierro wrote: > > l = db().select(db.artikel.id,limitby=(0,10)) > > On Jan 14, 9:19 am, Johann Spies wrote: > > What is the equivalent in DAL for > > > > l = db.executesql("select id from artikel limit 10;") > > > > Regards > > Johann >
[web2py] Web2py and Projection Queries
Hello people! First of all... thank you Massimo and howesc! About this question that I did and Massimo and howesc answerd on Stack Overflow. I tried to put some code there... but I could't... http://stackoverflow.com/questions/10940995/does-google-app-engine-projection-queries-are-supported-by-web2py I did the web2py update to trunk and some parts of my code stopped working. Most of problems I got where like this below, that I still don't know how to solve and keep it efficient, as I need to find the values by "name", not by id. I order to make it work, I just removed the fields I specified. Was this way (causing errors) self.db(self.tabela.nome == nome).select(self.tabela.valor, self.tabela.valor_blob, self.tabela.nome) I did that... now it selects all fields again... but works! self.db(self.tabela.nome == nome).select() I'm problably missing something! How can I use projection queries with web2py? The ID field that web2py creates are the same ID used by datastore on GAE? I have a product that I need find by name... can I query it using projection queries? Is that? rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, self.tabela.valor_blob, self.tabela.nome) File "D:\Dropbox\Devel\www\web2py\gluon\dal.py", line 8161, in select return adapter.select(self.query,fields,attributes) File "D:\Dropbox\Devel\www\web2py\gluon\dal.py", line 4149, in select for t in fields] for item in items] File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 2313, in next return self.__model_class.from_entity(self.__iterator.next()) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2809, in next next_batch = self.__batcher.next() File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2671, in next return self.next_batch(self.AT_LEAST_ONE) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2708, in next_batch batch = self.__next_batch.get_result() File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 604, in get_result return self.__get_result_hook(self) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2450, in __query_result_hook self._batch_shared.conn.check_rpc_success(rpc) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py", line 1214, in check_rpc_success raise _ToDatastoreError(err) BadRequestError: cannot use projection on a property with an equality filter
[web2py] Re: Web2py and Projection Queries
Doing some research I found the docs... "You cannot project a property that also is referenced in an equality filter. For example SELECT A FROM kind WHERE A = 1 is not supported, but SELECT A FROM kind WHERE B = 1 or SELECT A FROM kind WHERE A > 1 is supported." So I did ... self.db(self.tabela.nome == nome).select(self.tabela.valor, self.tabela.valor_blob) I cannot (and it is obvioulsy not necessary too) use the field "nome" in query and "select". Now its working fine... Anyone can give any idea about how to test projection x "nomal" queries? I would like to benchmark each situation and post here. Thanks.
[web2py] Re: Web2py and Projection Queries
Hi Massimo and howesc! Testing again... I found a problem: Do not return errors ( but returns no rows... ). rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, self.tabela.valor_blob) Returns the desired rows... rows = self.db(self.tabela.nome == nome).select() On Monday, June 11, 2012 10:10:18 PM UTC-3, Alex Benfica wrote: > > Hello people! > > First of all... thank you Massimo and howesc! > > About this question that I did and Massimo and howesc answerd on Stack > Overflow. > I tried to put some code there... but I could't... > > > http://stackoverflow.com/questions/10940995/does-google-app-engine-projection-queries-are-supported-by-web2py > > I did the web2py update to trunk and some parts of my code stopped working. > Most of problems I got where like this below, that I still don't know how > to solve and keep it efficient, as I need to find the values by "name", not > by id. > > I order to make it work, I just removed the fields I specified. > > Was this way (causing errors) > self.db(self.tabela.nome == nome).select(self.tabela.valor, > self.tabela.valor_blob, self.tabela.nome) > > I did that... now it selects all fields again... but works! > self.db(self.tabela.nome == nome).select() > > I'm problably missing something! How can I use projection queries with > web2py? The ID field that web2py creates are the same ID used by datastore > on GAE? > I have a product that I need find by name... can I query it using > projection queries? Is that? > > > > > rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, > self.tabela.valor_blob, self.tabela.nome) > File "D:\Dropbox\Devel\www\web2py\gluon\dal.py", line 8161, in select > return adapter.select(self.query,fields,attributes) > File "D:\Dropbox\Devel\www\web2py\gluon\dal.py", line 4149, in select > for t in fields] for item in items] > File "C:\Program Files > (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line > 2313, in next > return self.__model_class.from_entity(self.__iterator.next()) > File "C:\Program Files > (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", > line 2809, in next > next_batch = self.__batcher.next() > File "C:\Program Files > (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", > line 2671, in next > return self.next_batch(self.AT_LEAST_ONE) > File "C:\Program Files > (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", > line 2708, in next_batch > batch = self.__next_batch.get_result() > File "C:\Program Files > (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", > line 604, in get_result > return self.__get_result_hook(self) > File "C:\Program Files > (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", > line 2450, in __query_result_hook > self._batch_shared.conn.check_rpc_success(rpc) > File "C:\Program Files > (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py", > line 1214, in check_rpc_success > raise _ToDatastoreError(err) > BadRequestError: cannot use projection on a property with an equality > filter >
[web2py] Re: Web2py and Projection Queries
Hi Anthony, You are rigth... but I left only the Field valor and still returns empty. :) That is the table... Field('nome', 'string', required = True, ), Field('valor', 'text', label="Valor: caso seja string ou numérico (opcional)", ), Field('valor_blob', 'blob',), Field('upl_valor', 'upload', uploadfield='valor_blob', label="Valor binario (opcional)", ), Field('descricao', 'text', ), On Monday, June 11, 2012 10:54:00 PM UTC-3, Anthony wrote: > > Is tabela.valor_blob a Blob field? The GAE documentation says projections > can only include indexed properties, so no Text or Blob properties -- see > https://developers.google.com/appengine/docs/python/datastore/queries#Query_Projection. > > I would think that would result in an error, though. > > Anthony > > On Monday, June 11, 2012 9:35:28 PM UTC-4, Alex Benfica wrote: >> >> Hi Massimo and howesc! >> >> Testing again... I found a problem: >> >> Do not return errors ( but returns no rows... ). >> rows = self.db(self.tabela.nome == >> nome).select(self.tabela.valor, self.tabela.valor_blob) >> >> Returns the desired rows... >> rows = self.db(self.tabela.nome == nome).select() >> >> >> >> >> >> >> On Monday, June 11, 2012 10:10:18 PM UTC-3, Alex Benfica wrote: >>> >>> Hello people! >>> >>> First of all... thank you Massimo and howesc! >>> >>> About this question that I did and Massimo and howesc answerd on Stack >>> Overflow. >>> I tried to put some code there... but I could't... >>> >>> >>> http://stackoverflow.com/questions/10940995/does-google-app-engine-projection-queries-are-supported-by-web2py >>> >>> I did the web2py update to trunk and some parts of my code stopped >>> working. >>> Most of problems I got where like this below, that I still don't know >>> how to solve and keep it efficient, as I need to find the values by "name", >>> not by id. >>> >>> I order to make it work, I just removed the fields I specified. >>> >>> Was this way (causing errors) >>> self.db(self.tabela.nome == nome).select(self.tabela.valor, >>> self.tabela.valor_blob, self.tabela.nome) >>> >>> I did that... now it selects all fields again... but works! >>> self.db(self.tabela.nome == nome).select() >>> >>> I'm problably missing something! How can I use projection queries with >>> web2py? The ID field that web2py creates are the same ID used by datastore >>> on GAE? >>> I have a product that I need find by name... can I query it using >>> projection queries? Is that? >>> >>> >>> >>> >>> rows = self.db(self.tabela.nome == nome).select(self.tabela.valor, >>> self.tabela.valor_blob, self.tabela.nome) >>> File "D:\Dropbox\Devel\www\web2py\gluon\dal.py", line 8161, in select >>> return adapter.select(self.query,fields,attributes) >>> File "D:\Dropbox\Devel\www\web2py\gluon\dal.py", line 4149, in select >>> for t in fields] for item in items] >>> File "C:\Program Files >>> (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line >>> 2313, in next >>> return self.__model_class.from_entity(self.__iterator.next()) >>> File "C:\Program Files >>> (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", >>> >>> line 2809, in next >>> next_batch = self.__batcher.next() >>> File "C:\Program Files >>> (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", >>> >>> line 2671, in next >>> return self.next_batch(self.AT_LEAST_ONE) >>> File "C:\Program Files >>> (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", >>> >>> line 2708, in next_batch >>> batch = self.__next_batch.get_result() >>> File "C:\Program Files >>> (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", >>> line 604, in get_result >>> return self.__get_result_hook(self) >>> File "C:\Program Files >>> (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", >>> >>> line 2450, in __query_result_hook >>> self._batch_shared.conn.check_rpc_success(rpc) >>> File "C:\Program Files >>> (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py", >>> line 1214, in check_rpc_success >>> raise _ToDatastoreError(err) >>> BadRequestError: cannot use projection on a property with an equality >>> filter >>> >>
[web2py] Probleme with 301 redirect when URL has hyphens!
Hi people! I'm creating a new website using Web2py [ Version 2.0.0 (2012-06-10 21:17:42) dev ] on GAE in a domain where previously I had a WordPress blog! This blog has some urls like these: http://domain.com/novo-modelo/hyundai-hb-20/ http://domain.com/carro-conceito/nanotata/testes/ In order to not lose the whole traffic to the old blog, it were transfered to another domain and I need to make http 301 redirects to all of his pages! I'm using the following approach: I catch the 404 erros and verify if the request_uri is one of the urls from the old blogs I need to redirect ( I have all urls taken from the sitemap.xml ). This works fine, except for urls like those before, that have hyphens in the first "arg" as in "novo-modelo" and "carro-conceito". I did that on routes.py: routes_onerror = [ (r'*/404', r'/init/httpcodes/cod404') ] And in the function cod404, I verify the URL and do the redirect if the URL is from the old blog! When the URL is http://domain.com/novo-modelo/hyundai-hb-20/ I got the error: "invalid request"... and it is not treated as 404! What can I do to allow web2py understand this URL as 404? I tryed map_hyphen = True but had no success! This are the some other informations on my router.py. default_router = dict( default_application = 'init', applications = 'ALL', default_controller = 'default', controllers = 'DEFAULT', default_function = 'index', functions = None, default_language = None, languages = None, root_static = ['favicon.ico', 'robots.txt'], domains = None, map_hyphen = False, acfe_match = r'\w+$', # legal app/ctlr/fcn/ext file_match = r'(\w+[-=./]?)+$',# legal file (path) name args_match = r'([\w@ -]+[=.]?)+$', # legal arg in args ) # This simple router set overrides only the default application name, # but provides full rewrite functionality. routers = dict( # base router BASE = dict( default_application = 'init', ), ) --
Re: [web2py] Re: Probleme with 301 redirect when URL has hyphens!
Hi howsec. Thank you for your help again. Now I did the following: I figured out that I could use map_hyphens as True and create the functions inside the default controller to treat the urls with hyphens that would be redirected! I did the following inside default.py... and things are working now, withtout using regex based router! def jogos_e_games(): return _trataRedirecionamentos() def carro_conceito(): return _trataRedirecionamentos() def novo_modelo(): return _trataRedirecionamentos() On Fri, Nov 2, 2012 at 8:07 PM, howesc wrote: > i use the regex based routerso i'm not up on all the options for the > parametric router. > > that said, 2 things come to mind: > - invalid controller might return a 500? you could try that in your > routes.on_error (try catching 500 errors i mean). > - for web2py to be happy you'd need to rewrite the URL to not have > hyphens in what gets mapped to the controller or function name (as that > breaks python). remember that in web2py URLs are > application/controller/function. to not raise an error your router will > need to attach an application, controller, and function to each of your > URLs with hyphens before they will parse without error. > > i hope that helps point you in the right direction > > cfh > > > On Friday, November 2, 2012 4:18:44 AM UTC-7, Alex Benfica wrote: >> >> Hi people! >> >> I'm creating a new website using Web2py [ Version 2.0.0 (2012-06-10 >> 21:17:42) dev ] on GAE in a domain where previously I had a WordPress blog! >> >> This blog has some urls like these: >> >> http://domain.com/novo-modelo/**hyundai-hb-20/<http://domain.com/novo-modelo/hyundai-hb-20/> >> http://domain.com/carro-**conceito/nanotata/testes/<http://domain.com/carro-conceito/nanotata/testes/> >> >> In order to not lose the whole traffic to the old blog, it were >> transfered to another domain and I need to make http 301 redirects to all >> of his pages! >> >> I'm using the following approach: >> >> I catch the 404 erros and verify if the request_uri is one of the urls >> from the old blogs I need to redirect ( I have all urls taken from the >> sitemap.xml ). >> This works fine, except for urls like those before, that have hyphens in >> the first "arg" as in "novo-modelo" and "carro-conceito". >> >> >> >> I did that on routes.py: >> >> routes_onerror = [ >> (r'*/404', r'/init/httpcodes/cod404') >> ] >> >> >> And in the function cod404, I verify the URL and do the redirect if the >> URL is from the old blog! >> >> >> When the URL is >> >> http://domain.com/novo-modelo/**hyundai-hb-20/<http://domain.com/novo-modelo/hyundai-hb-20/> >> >> I got the error: "invalid request"... and it is not treated as 404! >> >> What can I do to allow web2py understand this URL as 404? >> >> >> I tryed map_hyphen = True but had no success! >> >> This are the some other informations on my router.py. >> >> >> >> default_router = dict( >> default_application = 'init', >> applications = 'ALL', >> default_controller = 'default', >> controllers = 'DEFAULT', >> default_function = 'index', >> functions = None, >> default_language = None, >> languages = None, >> root_static = ['favicon.ico', 'robots.txt'], >> domains = None, >> map_hyphen = False, >> acfe_match = r'\w+$', # legal app/ctlr/fcn/ext >> file_match = r'(\w+[-=./]?)+$',# legal file (path) name >> args_match = r'([\w@ -]+[=.]?)+$', # legal arg in args >> ) >> >> >> >> >> >> >> # This simple router set overrides only the default application name, >> # but provides full rewrite functionality. >> >> routers = dict( >> >> # base router >> BASE = dict( >> default_application = 'init', >> ), >> ) >> >> >> -- > > > > -- -- Atenciosamente, Alex BENFICA -- "O que não se mede não se gerencia." --
[web2py] Re: Does web2py Cache Auth Queries
So... What can I do to make than faster? Or should I not be using "has_permission" each time I need to know which permission logged in user have? Em quarta-feira, 2 de março de 2011 12h48min55s UTC-3, Massimo Di Pierro escreveu: > > They are not cached. > > On Mar 2, 9:22 am, Ross Peoples wrote: > > I am finding myself using auth.has_membership() and > auth.has_permission() > > quite often in a module. Are either of these cached? I looked through > the > > Auth code a bit and didn't see anything, so I was wondering it if did it > > somewhere else. If not then I should probably write my own > > has_membership/has_permission function that returns a cached value or > calls > > the Auth methods. --
[web2py] Re: Virtual Fields on auth_user
Hi! I have the same problem and the virtual fields availble on auth.user would save me 1 RPC call per request on App Engine. Is that a bug or is it the natural behavior!? I'm using web2py version 2.2.1! Thanks! Em sábado, 23 de abril de 2011 16h55min28s UTC-3, Gregory Hellings escreveu: > > I have a virtual field attached to the auth_user table titled "name" > that renders the user's name with certain formatting based on auth > membership. I also have records in a second table that are linked to > the auth_user table. When I fetch these rows I can access the virtual > as expected: > > row.speaker.name > > However, when I access the "auth.user" variable to determine the > current user, it lacks the appropriate virtual field. Thus calling > "auth.user.name" returns the string '0' (when it is JSON-ified) > instead of the user's name with formatting. > > I'm supposing that the framework does not bind the virtual fields > until after the "auth" object has been initialized, since they are > declared in my db_auth.py file after the auth object is instantiated. > Is this missing virtual field intended behavior, a documented problem > that is a shortcoming of needing to declare the auth object before > binding the virtual fields, or a bug? > > --Greg --
[web2py] Re: Virtual Fields on auth_user
Hi! I found this... https://groups.google.com/forum/?fromgroups=#!topic/web2py/77ei0yBbuhw Wil this feature be included again some day? Web2py is fine... and it is getting better each day! Em sexta-feira, 23 de novembro de 2012 16h57min33s UTC-2, Alex Benfica escreveu: > > Hi! > > I have the same problem and the virtual fields availble on auth.user would > save me 1 RPC call per request on App Engine. > Is that a bug or is it the natural behavior!? > > I'm using web2py version 2.2.1! > > Thanks! > > > Em sábado, 23 de abril de 2011 16h55min28s UTC-3, Gregory Hellings > escreveu: >> >> I have a virtual field attached to the auth_user table titled "name" >> that renders the user's name with certain formatting based on auth >> membership. I also have records in a second table that are linked to >> the auth_user table. When I fetch these rows I can access the virtual >> as expected: >> >> row.speaker.name >> >> However, when I access the "auth.user" variable to determine the >> current user, it lacks the appropriate virtual field. Thus calling >> "auth.user.name" returns the string '0' (when it is JSON-ified) >> instead of the user's name with formatting. >> >> I'm supposing that the framework does not bind the virtual fields >> until after the "auth" object has been initialized, since they are >> declared in my db_auth.py file after the auth object is instantiated. >> Is this missing virtual field intended behavior, a documented problem >> that is a shortcoming of needing to declare the auth object before >> binding the virtual fields, or a bug? >> >> --Greg > > --
[web2py] Re: Getting web2py to reload module files for each return view
Hi! I'm afraid this solution does not work on App engine development environment. Is there any other way? Em sexta-feira, 24 de outubro de 2014 21:52:03 UTC-2, Massimo Di Pierro escreveu: > > Normally modules are not reloaded because they are cached by python. > web2py can bypass this, depending on where the modules are located. If you > kwwp in your modules in the web2py app/modules folder then you can do in > your models/db.py > > DEBUG=True > from gluon.custom_import import track_changes; track_changes(DEBUG) > > This will reload your modules when they change/ > > > > On Friday, 24 October 2014 03:33:33 UTC-5, tahnoon pasha wrote: >> >> Hi, >> >> Working with a team building a reasonably complex webapp for an >> investment management system, and I'm trying to learn something of the >> system too. >> >> I have a module that updates data from a file (simulating an FTP drop). >> Once the module has been loaded the first time, it doesn't update for >> either changes in code or in the underlying data no matter how often I >> refresh the page. >> >> Is there a particular way to force web2py to reload any files each time a >> page is refreshed? Am I doing something completely wrong? >> >> Thanks >> >> The code is as follows: >> >> module: *dataxl.py* >> >> from gluon import * >> import csv >> import json >> import os >> from xlrd import open_workbook as lox >> >> >> >> >> def mydata(): >> filepath = os.join(current.request.folder, 'static', 'sample-data', \ >>'20-10-2014_sample-data-for-designer.xls') >> oldbook = lox(filepath) >> names = oldbook.sheet_names() >> workbook = {} >> for name in names: >> worksheet = [] >> oldsheet = ws.sheet_by_name(name) >> nrows = oldsheet.nrows >> ncols = oldsheet.ncols >> colnames = [ oldsheet.cell(0,i).value for i in range(ncols) ] >> rownames = [ oldsheet.cell(i,0).value for i in range(nrows) ] >> for nrow in xrange(1,nrows): >> worksheet.append({colnames[ncol]: oldsheet.cell(nrow,ncol).value >> \ >> for ncol in xrange(ncols)}) >> workbook[name] = worksheet >> return workbook >> >> controller: *performance.py* >> >> import dataxl >> >> >> wsheet = dataxl.mydata() >> >> attr = wsheet[ 'Performance_Attr' ] >> >> @auth.requires_login() >> def perf_multi_asset(): >> >> clientId = set(i[ 'client' ] for i in attr.values()) >> portId = [ 'All' ] >> portId.append(j for j in set(i[0] for i in attr.items() \ >> if i[ 1 ][ 'Attribution Level' ] == 0 \ >> or i[ 1 ][ 'Attribution Level' ] == 1)) >> >> perform = SQLFORM.factory( >> Field('client', 'string'),requires=IS_IN_SET(clientId)), >> Field('portfolio', 'string'),requires=IS_IN_SET(portId)), >> Field('start_date', 'date'), >> Field('end_date', 'date') >> ).process() >> >> if perform.vars.portfolio == 'All': >> data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] >> == perform.vars.client} >> else: >> data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] >> == perform.vars.client \ >> and i[ 0 ] == perform.vars.portfolio} >> >> return locals() >> >> and view: *performance/perf_multi_asset.html* >> >> {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals >> ())}} >> {{extend 'layout.html'}} >> >> {{=STYLE(XML(".generic-widget,#no_table_start_date,#no_table_end_date >> {width:100px}"))}} >> >> >> {{=perform.custom.begin}} >> >> >> Client Name: >> {{=perform.custom.widget.client}} >> >> >> >> Portfolio ID: >> {{=perform.custom.widget.portfolio}} >> >> >> >> Start Date: >> {{=perform.custom.widget.start_date}} >> >> >> >> End Date: >> {{=perform.custom.widget.end_date}} >> >> >> >> >> {{=perform.custom.submit}} >> >> >> {{=perform.custom.end}} >> >> >> >> {{=BEAUTIFY(XML(data))}} >> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.