[web2py] Re: Upload to Static folder? Serve File without streaming?
With regards to storing the file, can you still use regex to validate the filename if you choose to utilize this direct upload method? I'm working on a project where a requirement is to store the files as-is on the filesystem as they will be utilized by other programs. On Jul 2, 8:27 pm, mdipierro wrote: > No. For large files use this instead: > > def index(): > > form=FORM((INPUT(_type='file',_name='myfile'),INPUT(_type='submit')) > if form.accepts(request.vars,session): > > shutil.copyfileobj(form.myfile.file,open(os.path.join(request.folder,'stati > c','filename.txt'),'wb')) > response.flash='uploaded' > return dict(form=form) > > On 2 Lug, 19:06, Phyo Arkar wrote: > > > > > Thanks a lot! > > this code can also write Large Files right? > > > On Fri, Jul 2, 2010 at 11:48 PM, mdipierro wrote: > > > > def index(): > > > > form=FORM((INPUT(_type='file',_name='myfile'),INPUT(_type='submit')) > > > if form.accepts(request.vars,session): > > > > open(os.path.join(request.folder,'static','filename.txt'),'wb').write(form. > > > myfile.file.read()) > > > response.flash='uploaded' > > > return dict(form=form) > > > > but you need to come up with a safe way to generate a 'filename.txt' > > > > On 2 Lug, 18:40, Phyo Arkar wrote: > > > > Anyway to Upload directly to Static Folder (none SQLForm, none DB) > > > > And Serve file without streaming and going through Controller?
[web2py] Re: Admin app (or much of it) can work on appengine
That would be fantastic!! If you need help, I'd be happy to lend a hand...
[web2py] Re: markmin, t2, t3, cube9 etc. (important update)
I just checked out the cube2py repository from code.google.com and am attempting to run it on the Source branch of web2py 1.79.2 (2010-06-08 22:45:26). Attempting to run it generates this error: Traceback (most recent call last): File "C:\Users\scott\Documents\workspace\web2py\gluon \restricted.py", line 178, in restricted exec ccode in environment File "C:\Users\scott\Documents\workspace\web2py\applications\cube2py/ views\default/user.html", line 40, in AttributeError: 'Auth' object has no attribute 'navbar' I checked the included db.py and sure enough auth.navbar is not defined. Suggestions? Thanks in advance!
[web2py] Re: markmin, t2, t3, cube9 etc. (important update)
I downloaded the nightly build and it's working correctly. Thanks! On Jul 8, 11:35 am, mdipierro wrote: > download the nigthly build from web2py.com/examples/default/dowload > > On 8 Lug, 09:46, Mathieu Clabaut wrote: > > > > > I guess you should update web2py from the development repository (on google > > code) > > > -Mathieu > > > On Thu, Jul 8, 2010 at 16:40, Scott wrote: > > > I just checked out the cube2py repository from code.google.com and am > > > attempting to run it on the Source branch of web2py 1.79.2 (2010-06-08 > > > 22:45:26). Attempting to run it generates this error: > > > > Traceback (most recent call last): > > > File "C:\Users\scott\Documents\workspace\web2py\gluon > > > \restricted.py", line 178, in restricted > > > exec ccode in environment > > > File "C:\Users\scott\Documents\workspace\web2py\applications\cube2py/ > > > views\default/user.html", line 40, in > > > AttributeError: 'Auth' object has no attribute 'navbar' > > > > I checked the included db.py and sure enough auth.navbar is not > > > defined. Suggestions? > > > > Thanks in advance!
[web2py] Re: fedora experts?
Line 28: change 'you' to 'yum' 28c28 < you install python2.5 --- > yum install python2.5 Other than that, I can test the script on a RedHat system tomorrow... Cheers! On Jul 9, 9:26 am, mdipierro wrote: > I managed to wrote this script > > http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-fe... > > It worked for me but I am no fedora expert. Any advice for > imrpovements?
[web2py] Re: web2py 1.93?
Massimo, Is it in the repository hosted on Google Code? I just checked it out and it's showing as version 1.79.2 (2010-06-08 16:40:21) in the Admin. Thanks! On Jul 9, 9:36 am, Massimo Di Pierro wrote: > I am planning to release the nightly build as stable 1.93 on Monday. > Please check it out if you have not done so.
[web2py] Re: markmin, t2, t3, cube9 etc. (important update)
I think this should replace the Welcome application and the documentation should be integrated into the web2py book. I'm impressed with the complete rewrite! I like the way that you get web2py-admin-esque functionality without having to use the admin directly, and it all works through Google App Engine. It certainly makes page creation easier. Out of curiosity, would you need to use a custom routes.py to remove (rewrite) "plugin_wiki" from the URL? I'd probably want to hide that from casual users. A few suggestions and questions: - Consider an internally-hosted chart generator (e.g. jqPlot) in lieu of Google Charts API; this will allow the charts to generate behind corporate firewalls - Can the tag cloud be made hyper-linkable? That is to say, clicking on a word in the tag cloud might show a list of relevant tagged pages. - What is the future direction of cube2py? It seems that most of the functionality coded in the View can be replaced with cube2py and markmin. It also replaces some of the code normally located in the Controller such as CRUD and jqGrid functionality. If this is the case, is it the intent to replace the admin with cube2py? Thanks!
[web2py] Re: markmin, t2, t3, cube9 etc. (important update)
Thank you Massimo! My comments are below. > > - Can the tag cloud be made hyper-linkable? That is to say, clicking > > on a word in the tag cloud might show a list of relevant tagged pages. > Can be done but right now there is a logic problem. Which pages should > the tags link to? I guess wiki pages with the names of the tags? Yes, I envisioned a list of wiki pages with that associated tag. Something like: Page Name (hyperlinked) | Synopsis (first 30 characters or so) | Associated Tags | Date Modified > > - What is the future direction of cube2py? It seems that most of the > > functionality coded in the View can be replaced with cube2py and > > markmin. It also replaces some of the code normally located in the > > Controller such as CRUD and jqGrid functionality. If this is the > > case, is it the intent to replace the admin with cube2py? > It cannot be a replacement. In admin you edit files and code is in > files. With cube2py you edit only the database and code is in the > database. I think they must coexist. Thank you for the explanation.
[web2py] Re: openwysiwyg?
Never used it.
[web2py] Re: cube2py news
Massimo, I'll take a look at the arguments and instructions tomorrow and give you a report. Cheers, --Scott On Jul 13, 5:49 am, mdipierro wrote: > Please checkout cube2py again. Now it has two new features: > > 1) a button [widget builder] that allows you to build widgets from a > menu with ajax popup. It could not get easier. > > I could use somebody to go over the list of arguments and instructions > shown in the builder to make sure they are consistent. > > 2) the widgets can also be embedded if plugin_wiki_mode='html' with > elRTE wysiwyg editor, but elRTE has to be in 'source' mode so you can > use cube2py without using MARKMIN. > > Massimo
[web2py] Re: SOAP Access
I use suds to authenticate users through a Web service call. I don't have a need at this time to expose a server interface, but I could see where it would be useful to add that functionality to the existing XMLRPC, RSS, plugins, etc. That having been said, client interfaces are a lot easier to implement... On Jul 14, 12:37 pm, mdipierro wrote: > SUDS is client only. We could add it to contrib but it seems not many > people use it. What do other poeple think? > > On 14 Lug, 10:02, Jeff S wrote: > > > > > > > > > Any chance that an easy tool will be added to web2py for SOAP access, > > both in service and client? > > > Although it is not that hard to add a third party like I did with > > SUDS, but a tightly coupled tool could be usefull. > > > Just a wish. > > > SOAP is a W3C Recommendation > > Reference:http://www.w3schools.com/soap/soap_intro.asp
[web2py] Profiler Suggestion
In the current trunk I propose modifying line 549 to read as follows: stat.strip_dirs().sort_stats("time").print_stats(80) This will cause the profile output to be sorted by the "tottime" column and limit the output to the first 80 lines. I follow a methodology similar to Google's in that I attempt to shave as much time from code. This statement will highlight code hot spots without cluttering the profiler log. If the user wants to display all calls they only need remove the "80" from the print_stats call. What do you think?
[web2py] Re: Profiler Suggestion
That would help, wouldn't it? :-) gluon/main.py, under def responder2(s, h). On Jul 17, 3:27 am, mdipierro wrote: > which file is this? > > On 16 Lug, 20:07, Scott wrote: > > > > > > > > > In the current trunk I propose modifying line 549 to read as follows: > > > stat.strip_dirs().sort_stats("time").print_stats(80) > > > This will cause the profile output to be sorted by the "tottime" > > column and limit the output to the first 80 lines. I follow a > > methodology similar to Google's in that I attempt to shave as much > > time from code. This statement will highlight code hot spots without > > cluttering the profiler log. If the user wants to display all calls > > they only need remove the "80" from the print_stats call. > > > What do you think?
[web2py] Re: cube2py news
Better late than never! Here are a few cosmetic changes for the Widget Builder page. Please note that I've only included the lines to be changed; the rest of the lines should remain as-is. Thanks! bar_chart: Uses Google charting API to embed a bar chart * names is a list of comma separated labels (one for data item) create: * hidden_fields is a list of comma separated fields jqgrid: * table is the table name * col_width is the width of each column (default) latex: Uses Google charting API to embed LaTeX map: Embeds a Google map The table must have columns: latidude, longitude and map_popup. When clicking on a dot, the map_popup message will appear. pie_chart: Uses Google charting API to embed a pie chart * names is a list of comma separated labels (one for data item) search: * fields is a list of comma separated fields to be displayed slideshow: * transition determines the type of transition, e.g. fade, etc. (***look @ code!!) tag_cloud: Embeds a tag cloud update: * hidden_fields is a list of comma separated fields On Jul 13, 10:46 pm, Scott wrote: > Massimo, > > I'll take a look at the arguments and instructions tomorrow and give > you a report. > > Cheers, > --Scott > > On Jul 13, 5:49 am, mdipierro wrote: > > > > > > > > > Please checkoutcube2pyagain. Now it has two new features: > > > 1) a button [widget builder] that allows you to build widgets from a > > menu with ajax popup. It could not get easier. > > > I could use somebody to go over the list of arguments and instructions > > shown in the builder to make sure they are consistent. > > > 2) the widgets can also be embedded if plugin_wiki_mode='html' with > > elRTE wysiwyg editor, but elRTE has to be in 'source' mode so you can > > usecube2pywithout using MARKMIN. > > > Massimo
[web2py] Re: The one video you should watch
It sounds like a cooling fan to me. Try an external microphone and see if the fan noise persists? On Jul 20, 6:08 pm, mdipierro wrote: > I wish I knew how. I do not know where the z comes from. > > On Jul 20, 4:07 pm, Mengu wrote: > > > > > > > > > great screencast but you should really stop that > > zz. :) > > > On 20 Temmuz, 17:22, mdipierro wrote: > > > > If you have not followed closes the latest developments, you should > > > watch this video: > > > >http://www.vimeo.com/13485916
[web2py] Controller result "escaped" - impacts sparklines web2py slice
All, It's been a few months since I've looked at the sparklines web2py slice (http://web2pyslices.com/main/slices/versions/79/169 or http://groups.google.com/group/web2py/browse_thread/thread/2a6a7b2cbfe97278/). It seems that the latest stable and dev builds break the slice because the controller result is "escaped". Arguably, this is correct as it prevents various scripting attacks, but in this case escaping the output breaks the ajax functionality. How can I get the controller to return the result without escaping the characters? http source output: $("#dynbar0").sparkline(data.dynbar0, {type: 'bar', barColor: 'green', 'chartRangeMin': '0', 'chartRangeMax': '20'}); Desired source output: $("#dynbar0").sparkline(data.dynbar0, {type: 'bar', barColor: 'green', 'chartRangeMin': '0', 'chartRangeMax': '20'}); Thanks!
[web2py] memcache error
I'm running Ubuntu 10.04 and installed memcached which works fine locally. I installed the web2py stable 1.84.1 build and the stable wiki plugin from web2py.com. I followed the instructions at: http://web2py.com/book/default/section/11/12 to store the sessions in memcache for the provided Welcome app. Specifically, I created the 0_memcache.py model as instructed and I've tried adding the lines: from gluon.contrib.memdb import MEMDB session.connect(request,response,db=MEMDB(cache.memcache)) to either db.py or 0_memcache.py. In either case, when I load the welcome app, the following ticket is generated: Traceback (most recent call last): File "/home/scott/Projects/web2py/gluon/main.py", line 391, in wsgibase session._try_store_in_db(request, response) File "/home/scott/Projects/web2py/gluon/globals.py", line 361, in _try_store_in_db record_id = table.insert(**dd) File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line 256, in insert id = self._create_id() File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line 291, in _create_id id = self._tableobj.incr(shard_id) File "/home/scott/Projects/web2py/gluon/contrib/memcache/ memcache.py", line 404, in incr return self._incrdecr("incr", key, delta) File "/home/scott/Projects/web2py/gluon/contrib/memcache/ memcache.py", line 428, in _incrdecr return int(line) ValueError: invalid literal for int() with base 10: 'NOT_FOUND' Suggestions are welcome!
[web2py] Re: memcache error
One other thing I've noted is that by setting this, attempting to view /welcome/appadmin/ccache will generate the following ticket: Traceback (most recent call last): File "/home/scott/Projects/web2py/gluon/restricted.py", line 178, in restricted exec ccode in environment File "/home/scott/Projects/web2py/applications/welcome/controllers/ appadmin.py", line 410, in File "/home/scott/Projects/web2py/gluon/globals.py", line 96, in self._caller = lambda f: f() File "/home/scott/Projects/web2py/applications/welcome/controllers/ appadmin.py", line 337, in ccache for key, value in cache.ram.storage.items(): AttributeError: '_MemcacheClient' object has no attribute 'storage'
[web2py] Re: memcache error
Massimo, That fixed the " ValueError: invalid literal for int() with base 10: 'NOT_FOUND' " error for missing sessions. Thanks! The " AttributeError: '_MemcacheClient' object has no attribute 'storage'" error remains. Maybe the code block and imports from gluon/cache.py need to be added to gluon/contrib/memcache/__init__.py? if not app in self.meta_storage: self.storage = self.meta_storage[app] = {CacheAbstract.cache_stats_name: { 'hit_total': 0, 'misses': 0, }} On Jul 21, 8:43 am, mdipierro wrote: > I do not remember who wrote that code but I just looked at it and I am > bit confused by it. > Anyway, I think I have a fix. Please try replace gluon/contribmemcache/ > memcache.py with this file: > > http://web2py.googlecode.com/hg/gluon/contrib/memcache/memcache.py > > Massimo > > On Jul 21, 7:27 am, Scott wrote: > > > I'm running Ubuntu 10.04 and installed memcached which works fine > > locally. I installed the web2py stable 1.84.1 build and the stable > > wiki plugin from web2py.com. I followed the instructions > > at:http://web2py.com/book/default/section/11/12tostore the sessions in > > memcache for the provided Welcome app. Specifically, I created the > > 0_memcache.py model as instructed and I've tried adding the lines: > > > from gluon.contrib.memdb import MEMDB > > session.connect(request,response,db=MEMDB(cache.memcache)) > > > to either db.py or 0_memcache.py. In either case, when I load the > > welcome app, the following ticket is generated: > > > Traceback (most recent call last): > > File "/home/scott/Projects/web2py/gluon/main.py", line 391, in > > wsgibase > > session._try_store_in_db(request, response) > > File "/home/scott/Projects/web2py/gluon/globals.py", line 361, in > > _try_store_in_db > > record_id = table.insert(**dd) > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line 256, > > in insert > > id = self._create_id() > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line 291, > > in _create_id > > id = self._tableobj.incr(shard_id) > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > memcache.py", line 404, in incr > > return self._incrdecr("incr", key, delta) > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > memcache.py", line 428, in _incrdecr > > return int(line) > > ValueError: invalid literal for int() with base 10: 'NOT_FOUND' > > > Suggestions are welcome! > >
[web2py] Re: memcache error
OK, I got an error, unknown global variable 'app' in gluon.contrib.memcache.__init__.py. Here are the proposed code fixes to memcache.__init__.py which I've tested locally and know to work: Add this import at the top of the file: from gluon.cache import CacheAbstract In class _MemcacheClient(Client):, def__init__..., directly below "self.request=request" add: if request: app = request.application else: app = '' Thanks for all your help Massimo! With these fixes, I think we have the issue resolved. I will investigate adding Memcache stats to the appadmin controller as a separate task. On Jul 21, 10:53 am, mdipierro wrote: > Please try trunk again and let me know. > > On Jul 21, 9:11 am, Scott wrote: > > > > > > > > > Massimo, > > > That fixed the " > > ValueError: invalid literal for int() with base 10: 'NOT_FOUND' " > > error for missing sessions. Thanks! > > > The " > > AttributeError: '_MemcacheClient' object has no attribute 'storage'" > > error remains. Maybe the code block and imports from gluon/cache.py > > need to be added to gluon/contrib/memcache/__init__.py? > > > if not app in self.meta_storage: > > self.storage = self.meta_storage[app] = > > {CacheAbstract.cache_stats_name: { > > 'hit_total': 0, > > 'misses': 0, > > }} > > > On Jul 21, 8:43 am, mdipierro wrote: > > > > I do not remember who wrote that code but I just looked at it and I am > > > bit confused by it. > > > Anyway, I think I have a fix. Please try replace gluon/contribmemcache/ > > > memcache.py with this file: > > > >http://web2py.googlecode.com/hg/gluon/contrib/memcache/memcache.py > > > > Massimo > > > > On Jul 21, 7:27 am, Scott wrote: > > > > > I'm running Ubuntu 10.04 and installed memcached which works fine > > > > locally. I installed the web2py stable 1.84.1 build and the stable > > > > wiki plugin from web2py.com. I followed the instructions > > > > at:http://web2py.com/book/default/section/11/12tostorethesessions in > > > > memcache for the provided Welcome app. Specifically, I created the > > > > 0_memcache.py model as instructed and I've tried adding the lines: > > > > > from gluon.contrib.memdb import MEMDB > > > > session.connect(request,response,db=MEMDB(cache.memcache)) > > > > > to either db.py or 0_memcache.py. In either case, when I load the > > > > welcome app, the following ticket is generated: > > > > > Traceback (most recent call last): > > > > File "/home/scott/Projects/web2py/gluon/main.py", line 391, in > > > > wsgibase > > > > session._try_store_in_db(request, response) > > > > File "/home/scott/Projects/web2py/gluon/globals.py", line 361, in > > > > _try_store_in_db > > > > record_id = table.insert(**dd) > > > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line 256, > > > > in insert > > > > id = self._create_id() > > > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line 291, > > > > in _create_id > > > > id = self._tableobj.incr(shard_id) > > > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > > > memcache.py", line 404, in incr > > > > return self._incrdecr("incr", key, delta) > > > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > > > memcache.py", line 428, in _incrdecr > > > > return int(line) > > > > ValueError: invalid literal for int() with base 10: 'NOT_FOUND' > > > > > Suggestions are welcome!
[web2py] Re: memcache error
Massimo, I just checked out the trunk and I'm seeing an issue preventing the loading of the Welcome app: File "C:\Users\scott\Documents\workspace\web2py-dev\gluon\main.py", line 384, in wsgibase if static_file: UnboundLocalError: local variable 'static_file' referenced before assignment I see static_file assigned a value on line 316 of main.py, but I think you might want to give it a default value in case the assignment fails, which is what appears to be happening. --Scott On Jul 21, 4:31 pm, mdipierro wrote: > Please check trunk again. Thanks for your help. > > On Jul 21, 1:25 pm, Scott wrote: > > > > > > > > > OK, I got an error, unknown global variable 'app' in > > gluon.contrib.memcache.__init__.py. Here are the proposed code fixes > > to memcache.__init__.py which I've tested locally and know to work: > > > Add this import at the top of the file: > > from gluon.cache import CacheAbstract > > > In class _MemcacheClient(Client):, def__init__..., directly below > > "self.request=request" add: > > if request: > > app = request.application > > else: > > app = '' > > > Thanks for all your help Massimo! With these fixes, I think we have > > the issue resolved. I will investigate adding Memcache stats to the > > appadmin controller as a separate task. > > > On Jul 21, 10:53 am, mdipierro wrote: > > > > Please try trunk again and let me know. > > > > On Jul 21, 9:11 am, Scott wrote: > > > > > Massimo, > > > > > That fixed the " > > > > ValueError: invalid literal for int() with base 10: 'NOT_FOUND' " > > > > error for missing sessions. Thanks! > > > > > The " > > > > AttributeError: '_MemcacheClient' object has no attribute 'storage'" > > > > error remains. Maybe the code block and imports from gluon/cache.py > > > > need to be added to gluon/contrib/memcache/__init__.py? > > > > > if not app in self.meta_storage: > > > > self.storage = self.meta_storage[app] = > > > > {CacheAbstract.cache_stats_name: { > > > > 'hit_total': 0, > > > > 'misses': 0, > > > > }} > > > > > On Jul 21, 8:43 am, mdipierro wrote: > > > > > > I do not remember who wrote that code but I just looked at it and I am > > > > > bit confused by it. > > > > > Anyway, I think I have a fix. Please try replace > > > > > gluon/contribmemcache/ > > > > > memcache.py with this file: > > > > > >http://web2py.googlecode.com/hg/gluon/contrib/memcache/memcache.py > > > > > > Massimo > > > > > > On Jul 21, 7:27 am, Scott wrote: > > > > > > > I'm running Ubuntu 10.04 and installed memcached which works fine > > > > > > locally. I installed the web2py stable 1.84.1 build and the stable > > > > > > wiki plugin from web2py.com. I followed the instructions > > > > > > at:http://web2py.com/book/default/section/11/12tostorethesessionsin > > > > > > memcache for the provided Welcome app. Specifically, I created the > > > > > > 0_memcache.py model as instructed and I've tried adding the lines: > > > > > > > from gluon.contrib.memdb import MEMDB > > > > > > session.connect(request,response,db=MEMDB(cache.memcache)) > > > > > > > to either db.py or 0_memcache.py. In either case, when I load the > > > > > > welcome app, the following ticket is generated: > > > > > > > Traceback (most recent call last): > > > > > > File "/home/scott/Projects/web2py/gluon/main.py", line 391, in > > > > > > wsgibase > > > > > > session._try_store_in_db(request, response) > > > > > > File "/home/scott/Projects/web2py/gluon/globals.py", line 361, in > > > > > > _try_store_in_db > > > > > > record_id = table.insert(**dd) > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line > > > > > > 256, > > > > > > in insert > > > > > > id = self._create_id() > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line > > > > > > 291, > > > > > > in _create_id > > > > > > id = self._tableobj.incr(shard_id) > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > > > > > memcache.py", line 404, in incr > > > > > > return self._incrdecr("incr", key, delta) > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > > > > > memcache.py", line 428, in _incrdecr > > > > > > return int(line) > > > > > > ValueError: invalid literal for int() with base 10: 'NOT_FOUND' > > > > > > > Suggestions are welcome!
[web2py] Re: memcache error
Massimo, please add the import: from gluon.cache import CacheAbstract to the top of gluon\contrib\memcache\__init__.py. Thanks! On Jul 21, 7:24 pm, Scott wrote: > Massimo, > > I just checked out the trunk and I'm seeing an issue preventing the > loading of the Welcome app: > > File "C:\Users\scott\Documents\workspace\web2py-dev\gluon\main.py", > line 384, in wsgibase > if static_file: > UnboundLocalError: local variable 'static_file' referenced before > assignment > > I see static_file assigned a value on line 316 of main.py, but I think > you might want to give it a default value in case the assignment > fails, which is what appears to be happening. > > --Scott > > On Jul 21, 4:31 pm, mdipierro wrote: > > > > > > > > > Please check trunk again. Thanks for your help. > > > On Jul 21, 1:25 pm, Scott wrote: > > > > OK, I got an error, unknown global variable 'app' in > > > gluon.contrib.memcache.__init__.py. Here are the proposed code fixes > > > to memcache.__init__.py which I've tested locally and know to work: > > > > Add this import at the top of the file: > > > from gluon.cache import CacheAbstract > > > > In class _MemcacheClient(Client):, def__init__..., directly below > > > "self.request=request" add: > > > if request: > > > app = request.application > > > else: > > > app = '' > > > > Thanks for all your help Massimo! With these fixes, I think we have > > > the issue resolved. I will investigate adding Memcache stats to the > > > appadmin controller as a separate task. > > > > On Jul 21, 10:53 am, mdipierro wrote: > > > > > Please try trunk again and let me know. > > > > > On Jul 21, 9:11 am, Scott wrote: > > > > > > Massimo, > > > > > > That fixed the " > > > > > ValueError: invalid literal for int() with base 10: 'NOT_FOUND' " > > > > > error for missing sessions. Thanks! > > > > > > The " > > > > > AttributeError: '_MemcacheClient' object has no attribute 'storage'" > > > > > error remains. Maybe the code block and imports from gluon/cache.py > > > > > need to be added to gluon/contrib/memcache/__init__.py? > > > > > > if not app in self.meta_storage: > > > > > self.storage = self.meta_storage[app] = > > > > > {CacheAbstract.cache_stats_name: { > > > > > 'hit_total': 0, > > > > > 'misses': 0, > > > > > }} > > > > > > On Jul 21, 8:43 am, mdipierro wrote: > > > > > > > I do not remember who wrote that code but I just looked at it and I > > > > > > am > > > > > > bit confused by it. > > > > > > Anyway, I think I have a fix. Please try replace > > > > > > gluon/contribmemcache/ > > > > > > memcache.py with this file: > > > > > > >http://web2py.googlecode.com/hg/gluon/contrib/memcache/memcache.py > > > > > > > Massimo > > > > > > > On Jul 21, 7:27 am, Scott wrote: > > > > > > > > I'm running Ubuntu 10.04 and installed memcached which works fine > > > > > > > locally. I installed the web2py stable 1.84.1 build and the > > > > > > > stable > > > > > > > wiki plugin from web2py.com. I followed the instructions > > > > > > > at:http://web2py.com/book/default/section/11/12tostorethesessionsin > > > > > > > memcache for the provided Welcome app. Specifically, I created > > > > > > > the > > > > > > > 0_memcache.py model as instructed and I've tried adding the lines: > > > > > > > > from gluon.contrib.memdb import MEMDB > > > > > > > session.connect(request,response,db=MEMDB(cache.memcache)) > > > > > > > > to either db.py or 0_memcache.py. In either case, when I load the > > > > > > > welcome app, the following ticket is generated: > > > > > > > > Traceback (most recent call last): > > > > > > > File "/home/scott/Projects/web2py/gluon/main.py", line 391, in > > > > > > > wsgibase > > > > > > > session._try_store_in_db(request, response) > > > > > > > File "/home/scott/Projects/web2py/gluon/globals.py", line 361, > > > > > > > in > > > > > > > _try_store_in_db > > > > > > > record_id = table.insert(**dd) > > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line > > > > > > > 256, > > > > > > > in insert > > > > > > > id = self._create_id() > > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memdb.py", line > > > > > > > 291, > > > > > > > in _create_id > > > > > > > id = self._tableobj.incr(shard_id) > > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > > > > > > memcache.py", line 404, in incr > > > > > > > return self._incrdecr("incr", key, delta) > > > > > > > File "/home/scott/Projects/web2py/gluon/contrib/memcache/ > > > > > > > memcache.py", line 428, in _incrdecr > > > > > > > return int(line) > > > > > > > ValueError: invalid literal for int() with base 10: 'NOT_FOUND' > > > > > > > > Suggestions are welcome!
[web2py] Re: please explain this twitter post
Any chance you might publish the paper on the web2py site? On Jul 21, 5:54 pm, mdipierro wrote: > Oops. It seems the link got > truncatedhttp://www.computer.org/portal/web/csdl/doi/10.1109/MCSE.2010.97
[web2py] Re: rocket performance issues
Please allow me to preface my comments: I have nothing against Rocket; my opinions come from years of experience with Java EE deployments. I think raising the max_threads to 1024 is a good idea. However, my opinion is that Rocket alone should not be used for a production deployment; much as I would not use the built-in Web server in JBoss, WebLogic, Geronimo, etc. as the front door. My suggestion for production would be to use an Apache front-end into Rocket. Apache is more battle-hardened in this area, and it's a lot easier to handle DoS attacks through modules such as mod_evasive. There are numerous other benefits too, such as easily enabling gzip compression and allowing you a better security model through Defense in Depth... but I digress. On Jul 23, 5:41 pm, mdipierro wrote: > On a second thought this open the door to more sever denial of service > attacks than caused by the original problem. How about, until there is > a better under understanding and solution, we just increase > max_threads from the original 128 to 1024. > > On Jul 22, 11:27 am, Timbo wrote: > > > > > > > > > Try one quick change for me please...rocketis constructed around line > > 655 in main.py > > > Add a parameter to the constructor call(s): max_threads=0 > > > Please let me know if that affects the problem. > > > -tim > > > On Jul 22, 10:34 am, mdipierro wrote: > > > > I can reproduce the problem. I did on localhost with two different > > > browsers. > > > Using firebug I can see it takes 25seconds to download base.css (the > > > problem is not always with the same file). > > > While I did the test, I also monitored httpserver.log and I find that > > > it NEVER takes more than 1.2ms serve base.css. > > > This is what the log shows: > > > > > > > 127.0.0.1, 2010-07-22 10:16:38, GET, /michealellistest/static/images/ > > > header.png, HTTP/1.1, 304, 0.000563 > > > 127.0.0.1, 2010-07-22 10:16:38, GET, /favicon.ico, HTTP/1.1, 400, > > > 0.000631 > > > 127.0.0.1, 2010-07-22 10:16:55, GET, /michealellistest/static/ > > > base.css, HTTP/1.1, 304, 0.000791 locks firefox for 25secs > > > > > > 127.0.0.1, 2010-07-22 10:22:42, GET, /michealellistest/static/ > > > jquery.timers-1.2.js, HTTP/1.1, 304, 0.000552 > > > 127.0.0.1, 2010-07-22 10:22:42, GET, /favicon.ico, HTTP/1.1, 400, > > > 0.000497 > > > 127.0.0.1, 2010-07-22 10:23:02, GET, /michealellistest/static/ > > > superfish.js, HTTP/1.1, 304, 0.000914 locks chrome for 25secs > > > > Do you see the time gaps? > > > > There is a clear pattern. Under heavy load a request that results in a > > > HTTP 400 error locksRocket. > > > > Notice that the logging is done by a wsgi application that calls > > > web2py wsgibase, i.e it time how long it takes web2py to receive the > > > request and send the response. The extra time must be spent inside the > > > web server. > > > > It is also important that the times showed in the logs are the actual > > > time when the data is being written in the logs. You can see firefox > > > waiting for base.css, the server waiting to log base.css and nothing > > > else is being printed during the wait, signifying that web2py is not > > > running any request. > > > > We need Tim! This is a problem. > > > > Massimo > > > > On Jul 22, 9:22 am, Michael Ellis wrote: > > > > > I've isolated the problem but absolutely do not understand it. I can > > > > reproduce it with a two-line change to web2py_ajax.html. Will someone > > > > with > > > > the time and equipment please attempt to replicate this as a sanity > > > > check? > > > > > Here's how: > > > > > In the welcome app's web2py_ajax.html, insert the following after line > > > > 3. > > > > response.files.insert(3,URL(r=request,c='static',f='jquery.sparkline.js')) > > > > response.files.insert(4,URL(r=request,c='static',f='jquery.timers-1.2.js')) > > > > > Copy the attached js files into welcome/static. They should be the > > > > same as > > > > the versions available online. > > > > > To reproduce the problem, serve web2py on your LAN. Open the welcome > > > > home > > > > page on two different machines. One of them can be on the server. > > > > Briskly > > > > reload the page 10 or more times on either machine then try to reload > > > > on the > > > > other. In my setup, the delay is reliably 25 seconds from the time I > > > > make > > > > the last click on the first machine. > > > > > I'm able to reproduce this in FF, Chrome, and Safari using the latest > > > > web2py > > > > from trunk. Haven't tried any other browsers yet. As noted previously > > > > both > > > > machines are MacBooks running Snow Leopard. > > > > > Mike > > > > > jquery.timers-1.2.js > > > > 4KViewDownload > > > > > jquery.sparkline.js > > > > 62KViewDownload
[web2py] Re: new in trunk: clone.py
Personally, I think this is a great idea particularly when designing Intranet sites. This makes it very easy to implement your company's look and feel without having to go through a lot of hoops. I say put in a warning or caveat that must be accepted when using the script to absolve web2py of liability, and let people use it. On Jul 23, 3:41 am, mdipierro wrote: > Let's say you have a web2py application "myapp" and you want it to > look like a existing web site, for example "http://www.reddit.com";, > here is what you do from the web2py/ folder: > > ./scripts/clone.py -m '.tabmenu' -c '.content' -u 'http://www.reddit.com' -o > applications/myapp/views/layout.html > > Done! > > In the script above: > -m '.tabmenu' is the class of the UL menu (. for class and # for id, > jQuery notation) > -c '.content' is the class of DIV that contains the main page > content. > -u is the url of the page you want to clone and > -o is the file you want to generate (a web2py layout). > > You will need to look at the page first (possibly with firebug) to > figure out the -m and -c values for the specific page you intend to > clone. > > The script converts the page into a web2py layout by inserting web2py > tags in the proper places. It does not download linked static files > but fixes links so that they do not break. > > It does not work on non-utf8 pages. > > I am not sure this is going to stay but I could use feedback on > whether this is useful or not. If somebody could help fix it for non > utf8 pages it would be great. > > The script is in trunk now. If you do not use trunk, just get this > file > > http://web2py.googlecode.com/hg/scripts/clone.py > > and store it in web2py/scripts. > > DISCLAIMER: Under certain conditions it is illegal to make a page look > too similar to an existing page because it may be considered phishing. > The code provided can help you for a quick demo but it should not be > used to generate production web sites unless the layout of the site > you are cloning explicitly allows it. > > Massimo
[web2py] Re: Step-by-step tutorial on getting Cube2py up and running?
What is the admin group name? That is, the group to create where you can add users who can edit existing pages. Thanks! On Jul 12, 11:47 am, mdipierro wrote: > I posted 1.80.1 stable. If you just download that you can install the > latest cube2py from here using web2py admin > > http://www.web2py.com/examples/static/web2py.app.cube2py.w2p > > On 12 Lug, 04:56, Albert Abril wrote: > > > mm.. just a typo in the url example -> examples :) > > the rest all ok. > > > regards! > > >http://www.web2py.com/examples/static/nightly/web2py_src.zip > > > On Mon, Jul 12, 2010 at 10:48 AM, mdipierro wrote: > > > curlhttp://web2py.com/example/static/nightly/web2py_src.zip
[web2py] Re: Recent change to string escaping breaks dynamic javascript
I think the JSON helper function should be implemented. This logic should be contained within the controller and not within the view as I would deem it business logic and not rendering logic. On Jul 24, 7:52 pm, mdipierro wrote: > Should we have a JSON helper (same as you JD)? > > On Jul 24, 1:15 pm, Michael Ellis wrote: > > > Something good has come out of this: while looking for a workaround I > > learned about simplejson.dumps(). So now I've defined my own little helper > > JD() > > > import simplejson > > def JD(obj): > > return XML(simplejson.dumps(obj,indent=4)) > > > In my view (or controller) I can lump into one variable everything I'm going > > to need to pass into my js at render time, e.g. > > > PT = dict( > > updatenow=False, > > schartoptions = dict( > > type ='bar', > > barColor ='green', > > chartRangeMin = chartmin, > > chartRangeMax = chartmax, > > ) > > ## add more objects here ... > > ) > > > then put a single line at the top of my js script and reference everything > > as part of that namespace, e.g. > > > > ... > > var PT = {{=JD(PT)}}; > > ... > > > $(#something).sparkline( ..., PT.schartoptions); > > ... > > > > > The JD(PT) expands to a nicely indented js declaration, e.g. > > > var PT = { > > "updatenow": false, > > "schartoptions": { > > "chartRangeMin": 0, > > "barColor": "green", > > "type": "bar", > > "chartRangeMax": 1 > > } > > > }; > > > What's also cool is that if all or part of that declaration corresponds to > > data coming in from a getJSON() loop after the page is loaded, then > > everything's already defined and initialized. > > > This feels like a definite improvement over what I was doing before. Far > > less clutter and definitely DRY'er. > > > Cheers, > > Mike > > > On Sat, Jul 24, 2010 at 9:34 AM, Phyo Arkar wrote: > > > > I am also doing more and more in JS for views. Even search engine for > > > tables, i am using JQGrid's local search (at latest version if JQGrid).It > > > dont need server side at all for search to work, which make it a lot > > > faster > > > + lesser hit on server performance. > > > > On Sat, Jul 24, 2010 at 7:53 PM, Michael Ellis > > > wrote: > > > >> My bad. It does work. In my earlier attempt to use it I forgot that a > > >> for loop variable isn't an object reference when looping over a list of > > >> strings. So the value of schartoptions wasn't being altered at all, just > > >> the loop variable. > > > >> I'm still in favor of an alternate operator, though. As it is now, I've > > >> moved all my chart options inside the script tag e.g. > > > >> var schartoptions = { > > >> type: 'bar', > > >> barColor: 'green', > > >> chartRangeMin: '{{=chartmin}}', > > >> chartRangeMax: '{{=chartmax}}' > > >> }; > > > >> and substitute only the things that have to be determined at run time > > >> rather than clutter up my expressions by wrapping them in XML(). > > > >> I'd much rather code in python than js, but I'm beginning to feel that > > >> using more js and less python in views makes a lot of sense. > > > >> Thanks, > > >> Mike > > > >> On Sat, Jul 24, 2010 at 8:40 AM, mdipierro > > >> wrote: > > > >>> I am confused: > > >>> Does this now work? > > > >>> {{ > > >>> schartoptions = """{ > > >>> type: 'bar', > > >>> barColor: 'green', > > >>> chartRangeMin: '%d', > > >>> chartRangeMax: '%d' > > >>> } > > >>> """%(chartmin,chartmax) > > > >>> }} > > > >>> and later on I use the variables within a script tag, e.g. > > > >>> > > >>> /* > >>> $("#{{=ks+kc}}").sparkline(data.wsc.{{=ks}}.{{=kc}}, > > >>> {{=XML(schartoptions)}} > > >>> > > > >>> If not, what are chartmin and chartmax, are they themselves helpers? > > > >>> On Jul 24, 7:28 am, Michael Ellis wrote: > > >>> > Massimo, I'm not following you. I tried using XML (see earlier post) > > >>> and it > > >>> > had no effect. Does it only work if applied immediately before the = > > >>> > operator? > > > >>> > Also, I think ":=" or something similar is much cleaner than wrapping > > >>> > everything in a function call. > > > >>> > Cheers, > > >>> > Mike > > > >>> > On Sat, Jul 24, 2010 at 8:19 AM, mdipierro > > >>> wrote: > > >>> > > This > > > >>> > > {{:=never_escaped}} > > > >>> > > would be the same as > > > >>> > > {{=XML(ever_escaped)}} > > > >>> > > so why introduce new syntax? > > > >>> > > On Jul 24, 7:14 am, Michael Ellis wrote: > > >>> > > > I could happily live with a solution that adds a 'no escape' > > >>> operator to > > >>> > > the > > >>> > > > template language, e.g. > > > >>> > > > {{:=never_escaped}} > > > >>> > > > vs > > > >>> > > > {{=always_escaped}} > > > >>> > > > 1. Backward compatible, > > > >>> > > > 2. Safe by default, > > > >>> > > > 3. Allows designer to decide what's safe and what isn't, > > > >>> > > > 4. Seems like an easier fix than trying to
[web2py] Re: book revision
Cube2py explanation along with examples for all of the widgets and how to implement. Since we're headed in that direction... :) On Jul 24, 9:08 pm, mdipierro wrote: > Thanks. this is very helpful > > On Jul 24, 7:57 pm, Jonathan Lundell wrote: > > >http://code.google.com/p/web2py-book/wiki/BookGeneralIssues
[web2py] Re: Step-by-step tutorial on getting Cube2py up and running?
Thanks! On Jul 24, 9:22 pm, Bruno Rocha wrote: > The admin group is 'editor' > > but you can change that login in plugin_wiki.py model > > I had to change it to run fine on GAE. > > 2010/7/24 Scott : > > > > > What is the admin group name? That is, the group to create where you > > can add users who can edit existing pages. Thanks! > > > On Jul 12, 11:47 am, mdipierro wrote: > >> I posted 1.80.1 stable. If you just download that you can install the > >> latest cube2py from here using web2py admin > > >>http://www.web2py.com/examples/static/web2py.app.cube2py.w2p > > >> On 12 Lug, 04:56, Albert Abril wrote: > > >> > mm.. just a typo in the url example -> examples :) > >> > the rest all ok. > > >> > regards! > > >> >http://www.web2py.com/examples/static/nightly/web2py_src.zip > > >> > On Mon, Jul 12, 2010 at 10:48 AM, mdipierro > >> > wrote: > >> > > curlhttp://web2py.com/example/static/nightly/web2py_src.zip > > -- > > http://rochacbruno.com.br
[web2py] Re: Recent change to string escaping breaks dynamic javascript
I agree that it should be available in either context, which means including the helper. If folks wish to implement it in the view, they could continue to do so... On Jul 24, 10:40 pm, Michael Ellis wrote: > I'm of two minds on this. It's a one-liner to implement as I've done it, > but my implementation hides the rich argument set available in > simplejson.dumps(): > > dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, > allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', > default=None, use_decimal=False, **kw) > > It also hides the arguments available to XML(). > > If implemented, I think it would be good to provide as many of the > arguments as make sense for its use as a helper -- which probably means all > of them. > > Regarding controller vs view, I think it should be available, like all the > other helpers, in either context. > > Whether we implement it or not, I think the technique of passing python > objects into javascript at render time with json serialization is quite > useful and merits an example in the next revision of the book. > > Cheers, > Mike > > > > > > > > On Sat, Jul 24, 2010 at 9:18 PM, Scott wrote: > > I think the JSON helper function should be implemented. This logic > > should be contained within the controller and not within the view as I > > would deem it business logic and not rendering logic. > > > On Jul 24, 7:52 pm, mdipierro wrote: > > > Should we have a JSON helper (same as you JD)? > > > > On Jul 24, 1:15 pm, Michael Ellis wrote: > > > > > Something good has come out of this: while looking for a workaround I > > > > learned about simplejson.dumps(). So now I've defined my own little > > helper > > > > JD() > > > > > import simplejson > > > > def JD(obj): > > > > return XML(simplejson.dumps(obj,indent=4)) > > > > > In my view (or controller) I can lump into one variable everything I'm > > going > > > > to need to pass into my js at render time, e.g. > > > > > PT = dict( > > > > updatenow=False, > > > > schartoptions = dict( > > > > type ='bar', > > > > barColor ='green', > > > > chartRangeMin = chartmin, > > > > chartRangeMax = chartmax, > > > > ) > > > > ## add more objects here ... > > > > ) > > > > > then put a single line at the top of my js script and reference > > everything > > > > as part of that namespace, e.g. > > > > > > > > ... > > > > var PT = {{=JD(PT)}}; > > > > ... > > > > > $(#something).sparkline( ..., PT.schartoptions); > > > > ... > > > > > > > > > The JD(PT) expands to a nicely indented js declaration, e.g. > > > > > var PT = { > > > > "updatenow": false, > > > > "schartoptions": { > > > > "chartRangeMin": 0, > > > > "barColor": "green", > > > > "type": "bar", > > > > "chartRangeMax": 1 > > > > } > > > > > }; > > > > > What's also cool is that if all or part of that declaration corresponds > > to > > > > data coming in from a getJSON() loop after the page is loaded, then > > > > everything's already defined and initialized. > > > > > This feels like a definite improvement over what I was doing before. > > Far > > > > less clutter and definitely DRY'er. > > > > > Cheers, > > > > Mike > > > > > On Sat, Jul 24, 2010 at 9:34 AM, Phyo Arkar > >wrote: > > > > > > I am also doing more and more in JS for views. Even search engine for > > > > > tables, i am using JQGrid's local search (at latest version if > > JQGrid).It > > > > > dont need server side at all for search to work, which make it a lot > > faster > > > > > + lesser hit on server performance. > > > > > > On Sat, Jul 24, 2010 at 7:53 PM, Michael Ellis < > > michael.f.el...@gmail.com>wrote: > > > > > >> My bad. It does work. In my earlier attempt to use it I forgot > > that a > > > > >> for loop variable isn't an object reference when looping over a list > &g
[web2py] cube2py system (meta) page example request
Massimo provided excellent examples of meta-menu and meta-code on Vimeo. However, could someone post examples of meta-header, meta- sidebar, and meta-footer? Thanks!
[web2py] Re: "Why I hate Django" by Cal Henderson
I do not agree with item 1. Session data should never be stored client-side as it opens a rather large attack vector. The only thing which should be stored client-side is the session token in a secure, HTTPOnly cookie (which web2py currently supports). If cookies are disabled, a hidden POST field might be acceptable. Please do not store session data client-side. References: http://www.owasp.org/index.php/Session_Management http://www.technicalinfo.net/papers/WebBasedSessionManagement.html OWASP Top 10 On Jul 29, 5:05 pm, mdipierro wrote: > The speaker raises some good issue with Django and some do apply to > web2py > > Aside for the many jokes which are indeed funny he complains about > scalability and make these valid points: > > 1) session should be stored client side for scalability (web2py and > Django both store them server side, although it it would be trivial to > have a client side option and it is on my todo list, I will take a > patch if somebody does this first) > > 2) it is important to be able to connect to multiple databases > depending on the request (Django cannot do it, web2py can) I also just > added a modification in trunk that allows to do: > > db=DAL([uri1,uri2,uri3]) > > and it will try to connect to uri1, then uri2, then uri3. Of course > you can do > > db=DAL(random_permute(uri1,uri2,uri3)) > > to share the load at random. web2py will also try them all in case of > failure and re-try 5 times. > > 3) it would be nice if the ORM and DAL were to be smart about de- > normalization and about multiple db connection. There is a lot that > can be done in this direction. web2py allows an easy API to > denormalize many2many: > > # define some shortcuts > D,F=db.define_table, Field > # define a table dog, a person, and ownership > d=D('dog',F('name')) > p=D('person',F('name'),F('dogs')) > L=D('ownership',F('person',p),F('dog',d)) > # denormalize p.dogs > p.dogs.requires=IS_IN_DB(db,d.id,d.name,multiple=True) > # p.dogs will be used in forms, when it changes update L > def f(form): > db(L.person==form.vars.id).delete() > [L.insert(person=form.var.id,dog=k) for k in > form.request_vars.dogs] > crud.settings.create_onaccept.person.append(f) > crud.settings.update_onaccept.person.append(f) > > In principle the job of the last 5 lines could be automated and be > done under the hood (what the user speaks about). It would be too much > magic but it would be convenient. We have been discussing some of > this. > > On Jul 29, 2:53 pm, Vidul Petrov wrote: > > > > > > > > > Django (the opposite of RoR) sucks likes RoR (the Denmark salesman vs > > the desparate Kanzas Python programmers ambitions to create everything > > out of nothing). > > > Probably you know what's the definition of the Nobel winners for > > intellect - adequacy. > > > And in order to achieve adequacy we need compromises - web2py. > > > On Jul 29, 7:08 pm, Wobmofo wrote: > > > > Cal Henderson delivered a very enterteining keynote at DjangoCon 2008. > > > Go watch the video if you haven't, it's really funny > > > !http://www.youtube.com/watch?v=i6Fr65PFqfk
[web2py] Re: fun with metaclasses
I support community contributions but there still needs to be an "editor" or someone ultimately responsible for the changes. On Jul 31, 11:27 am, VP wrote: > I completely support these ideas. It seems the book is Massimo's > effort, not a community's effort. Documentation needs to be a > community effort; look at Django, Drupal. > > On Jul 30, 11:03 pm, Bruno Rocha wrote: > > > > > > > > > I completelly agree with Jonathan, I also want to have a deeper explanation > > on DAL backgrounds. > > > web2py is Agile enough for me and for my development team, but, sometimes we > > spent more time trying to figure out "how to" to some things, and testing > > alternatives than developing real solutions. > > > The book is very good when we need to solve common and trivial things, > > otherwise when we need to go further. The only solution has been testing, > > looking for examples, using this list, or in many cases reading the source > > code and trying to understand what is happening behind the scenes. It costs > > a great time. > > > As was mentioned in the "why I hate Django" video, using frameworks you gain > > time in the early stages, but lost much more in that we need to refine and > > tune up applications. > > > For this reason I support a forum , IMHO, until we have a > > broader and deeper documentation, a forum would be much more usable than > > this list, and the DRY concept could be applied more easily to posts in a > > forum, rather than messages in this list. > > Forum can do things like a good search engine, sintax highlighting, > > screenshots embeded in to the context > > and yet it is possible to create mechanisms for threads to be followed by > > email, and people could start new threads by email as well. Perhaps using > > markmin syntax to include files, highlight the code, and things ... more > > > This type of platform could be better used to build further documentation. > > > why not support and start an official web2py forum? > > > 2010/7/30 Jonathan Lundell > > > > On Jul 30, 2010, at 7:22 PM, Iceberg wrote: > > > > > On Jul 31, 1:15 am, Jonathan Lundell wrote: > > > >> On Jul 30, 2010, at 9:19 AM, VP wrote: > > > >>> On Jul 30, 9:35 am, mdipierro wrote: > > > >http://gluonframework.wordpress.com/2010/07/30/web2py-and-metaclasses/ > > > > >>> This is really nice. Please do more of this. > > > > >> My initial reaction is the opposite. The result might be more readable, > > > but it doesn't strike me as more writable. > > > > >> What would be most helpful for me would be a deeper explanation (in the > > > book) of what's going on behind the existing DAL "magic" syntax, rather > > > than > > > adding yet another layer of magic. > > > > > You make a good point, Jonathan. And I think there is a underlying > > > > question here. Which kind of audience is web2py targeting to? If for > > > > developers, the existing DAL syntax is already powerful and magical > > > > enough (the document is also good, here it is. > > >http://web2py.com/book/default/chapter/06 > > > > ). Developers don't need another layer which is more fancy but not > > > > more powerful. > > > > I'm not satisfied with the treatment in the book. I'd like to see each of > > > the DAL objects more completely described, especially as to the underlying > > > Python types and the operations that they implicitly support. Several of > > > them IIRC are polymorphic wrt their argument types, and you either have to > > > divine this telepathically or read the source in detail. Likewise operator > > > overloading. > > > > I'm sure it's second nature to Massimo, but for most of us, we have to > > > hunt > > > around for an example that matches our situation, and blindly copy & > > > paste. > > > Either that or experiment until it stops raising exceptions > > > -- > > >http://rochacbruno.com.br
[web2py] Re: "Why I hate Django" by Cal Henderson
In essence your argument is that it would take too much time and you could change the hmac key monthly to prevent an attack. I understand and respect that signed cookies are one way to solve the problem, but I do not believe they are the "most correct" way. My analogy would be the difference between a handheld portable safe (signed cookie) and a bank (server-side session). If your money is stored in the bank, it's a lot harder to steal it because a thief would need to break into the bank whereas a thief has all the time in the world with a portable safe (which are also a lot easier to break). With computer processing speed and algorithms (particularly distributed computing) I am not sure that signed cookies will remain as "safe" as they are today. With regard to changing the hmac key, you are right they should be periodically changed although this would need to be carefully planned as it essentially invalidates sessions when it changes. I believe it would also would invalidate stored encrypted data unless you use a one-time method to decrypt then re- encrypt the data using the new hmac key. In summary, I believe server-side sessions to be more secure than client-side cookies, period. On Jul 31, 2:39 pm, Thadeus Burgess wrote: > To crack a signed cookie you need the secret hmac key that is usually > stored within the application. Brute forcing an hmac key will take > more time than any hacker has, especially if you change it once a > month or so. > > -- > Thadeus > > On Sat, Jul 31, 2010 at 1:00 PM, Armin Ronacher > > > > > > > > wrote: > > That is incorrect. That is indeed true for a regular cookie, bit that > > has all kimds of problems. I was referring to actual signed cookies. > > > On Jul 31, 9:56 am, mdipierro wrote: > >> There is a difference. > > >> If you have a uuid sessions cookie and a serverside session and an > >> attacker hijacks the cookie, he can only get access to the account of > >> the compromised user. > > >> If the session is stored client side and the attackers hijacks the > >> cookie, he can tamper with the data in the session and, depending on > >> what the session cookie stores, may get access to more than data of > >> the compromised user. > > >> Massimo > > >> On Jul 31, 1:58 am, Armin Ronacher > >> wrote: > > >> > Hi, > > >> > On Jul 31, 2:38 am, Scott wrote:> I do not agree > >> > with item 1. Session data should never be stored > >> > > client-side as it opens a rather large attack vector. > > >> > Which attack vector exists for signed cookies with a signed timeout > >> > compared to just session IDs in cookies? Both can be hijacked by a man > >> > in the middle. > > >> > Regards, > >> > Armin
[web2py] Re: "Why I hate Django" by Cal Henderson
True, the PCI-DSS mandates things like that, such as tokenizing credit cards and only passing the tokens, using a centralized secure database to store the data, etc. WRT the site cookie, you'd have access to what that user has been authorized to see, sure. There are other standard-practice methods like associating the IP address to the session (again, built into web2py)... I just happen to be paranoid about these types of things and would rather give out as little information as humanly possible to the client. That is to say, only the session token. Call it the Principle of Least Information =) WRT this not being an issue on today's hardware, sure I agree. I have a tendency to look for what not only works today but works for the future to prevent having to redesign the system a few years down the road. I'd rather do the hard work now to pay dividends down the road. So how about a compromise - let's switch to using secure, HTTPOnly, signed and encrypted cookies which store the session token and give the programmer the option to store some data in the cookie if required. Just put a caveat that the least amount should be stored (and in any case, less than the 4k limit). On Jul 31, 8:38 pm, Thadeus Burgess wrote: > @Scott, I think your argument is based on assuming a bad programming > design. If you have any type of data that needs to be secure to that > detail, I hope to god your not storing them in the session in the > first place! I mean, if I somehow copy your sites cookie from a user, > I now have access to the entire site anyways. > > You should only be storing data in a session that won't compromise > your data in the first place. Userid doesn't mean anything even if the > cookie was cracked (though on todays hardware would take 900 trillion > years to crack a good hmac key). If your storing an encrypted tree of > credit cards in the session, don't you think it would be appropriate > to redesign your application and store that in the database instead? > > Not to mention, google, facebook, twitter, microsoft, quicken, chase, > capitalone, visa, etc. etc.. all use signed cookies... They are the > "most correct" way to do it on todays hardware, and todays software, > and todays browsers. Perhaps when we have flying cars it won't be the > best way anymore, but until then =) > > -- > Thadeus > > > > > > > > On Sat, Jul 31, 2010 at 7:28 PM, Jonathan Lundell wrote: > > On Jul 31, 2010, at 5:09 PM, Scott wrote: > > >> In essence your argument is that it would take too much time and you > >> could change the hmac key monthly to prevent an attack. I understand > >> and respect that signed cookies are one way to solve the problem, but > >> I do not believe they are the "most correct" way. > > >> My analogy would be the difference between a handheld portable safe > >> (signed cookie) and a bank (server-side session). If your money is > >> stored in the bank, it's a lot harder to steal it because a thief > >> would need to break into the bank whereas a thief has all the time in > >> the world with a portable safe (which are also a lot easier to > >> break). With computer processing speed and algorithms (particularly > >> distributed computing) I am not sure that signed cookies will remain > >> as "safe" as they are today. With regard to changing the hmac key, > >> you are right they should be periodically changed although this would > >> need to be carefully planned as it essentially invalidates sessions > >> when it changes. I believe it would also would invalidate stored > >> encrypted data unless you use a one-time method to decrypt then re- > >> encrypt the data using the new hmac key. > > >> In summary, I believe server-side sessions to be more secure than > >> client-side cookies, period. > > > As a practical matter, I don't think it's much of an issue. A SHA-1 based > > HMAC, or SHA-2 if you're feeling especially paranoid, is not going to be > > cracked within the lifetime of a session. Notice that unlike encryption of > > sensitive data, cracking the session HMAC has no value once the session has > > expired. So the ability to attack it for months offline isn't of much use. > > > The expiration problem could be handled by having two keys active at any > > given time, with their valid-time overlapped, so you have an 'old' key and > > a 'new' key. If someone comes in with an old key, replace the HMAC with a > > new version.
[web2py] Re: book 3rd edition call of help
Regarding the article, this was started up in a second thread: http://groups.google.com/group/web2py/browse_thread/thread/1142aa8ab1de80cb Regarding the IDE, my preference is Wing IDE for its superior debugging capabilities and there are detailed instructions on using it with web2py here: http://wingware.com/doc/howtos/web2py On Aug 1, 3:51 pm, Anthony wrote: > This article > --http://www.ahmedsoliman.com/2010/07/29/the-good-and-bad-about-web2py/ > -- brings to mind another topic that could possibly use some more > coverage in the book: tips on testing, debugging, and IDE setup (I > mean IDE's other than the built-in web-based IDE). > > On Jul 29, 2:32 am, Anthony wrote: > > > > > > > > > Regarding content, it looks like the focus of the book revision has > > been documenting all the newer features, and that should certainly be > > the priority. Perhaps this is beyond the intended scope of the current > > revision, but at some point I think it would also be helpful to expand > > the discussion of some conceptual issues, especially the distinctive > > design decisions of the framework and their implications for > > programming practice. In particular: > > > (1) Exec vs. Import of Models, Views, Controllers: A better > > explanation of the distinction at a technical level would be helpful > > (this would be particularly helpful for those new to Python and Python > > frameworks). What are the benefits and possible drawbacks of executing > > everything? How is this similar to or different from other frameworks, > > such as Django, Rails? What are the implications for programming > > (e.g., possible performance hit with many/large model files)? > > > (2) DAL vs. ORM: Since ORM's seem to be the more common approach among > > full stack frameworks, it might be worth explaining how a DAL differs > > and why the DAL approach was chosen. What are the benefits? How does > > it impact they way you write models and controllers compared with ORM- > > based frameworks? > > > A discussion of the web2py approach to MVC would also be helpful, > > especially as it relates to the above two issues. For example: > > > - I've seen a lot of references encouraging "fat models and skinny > > controllers" when developing MVC applications. Is web2py's design > > consistent with that approach? Does using a DAL instead of an ORM > > impact what you can or should put in your models? Also, does the fact > > that all models get executed on every request suggest that models > > should actually be as "skinny" as possible in order to avoid > > performance problems? > > > - In addition to using web2py models files for defining data models, > > it appears a lot of folks use the models files for settings, helpers, > > and other objects they want to make available globally. It seems this > > is not necessarily because such items are rightly construed as > > "models," but simply a convenience, taking advantage of the fact that > > everything in the models files is available globally on every request. > > Is this the recommended practice? Should we think of the models files > > as having two distinct purposes: (1) defining data models, and (2) > > creating global objects, functions, settings, etc.? If so, it might be > > worth making that explicit and providing some guidance and examples. > > > - More generally, I've seen a lot of questions asking about what > > should go where. Are there web2py-specific best practices for what > > should go in controllers, models, modules, etc.? > > > Some other topics that would be helpful: > > - Expand the scalability/performance recommendations as > > perhttp://groups.google.com/group/web2py/msg/10fa4709c2a28c9b > > - When/why to use local_import vs. import. > > - Example of using exec_environment for loading site-wide helper > > libraries (which is one of the recommended use cases). > > - LOAD > > - How to do REST with web2py (is it possible? encouraged?). Seems to > > be a big thing with Rails. > > - Documentation of cube2py/plugin_wiki > > - I saw some references to "lazy tables" at some point -- do they > > exist? > > - I've seen a lot of confusion regarding what is meant by "Enterprise" > > in describing web2py -- perhaps worth clarifying in the book. > > > Apologies if any of the above doesn't make sense or seems confused. > > I'm just starting to learn web programming, MVC, Python, and web2py. > > Wouldn't normally be comfortable chiming in with all this at such an > > early stage in my learning, but the book is being revised now, so it's > > either now or (next year?). Plus, this seems like a friendly > > community. In any case, this should at least give you an idea of the > > questions on the mind of a complete noob. > > > Thanks. > > > Anthony > > > On Jul 27, 6:49 am, mdipierro wrote: > > > > This is very very preliminary: > > > > http://web2py.com/book2 > > > > It is not editable (yet) and I am still adding material but it does > > > address a lot of issues. > > > Please use this thread t
[web2py] Re: ARTICLE: The good and bad about web2py
Here are my thoughts, point by point: - web2py does support unit testing as it uses python code. I think the article author means you cannot currently set up unit tests within the administration console. You can configure tests as much or as little as you like from the command line. - I think the article author should elaborate on the meaning of the phrase “used in a twisted way to design the framework”. I don't see anything twisted about the implementation; web2py is a WSGI application. Personally, I think following Style Guide for Python Code (PEP-8) is a good thing. Why is following the standard Style Guide a bad thing? It promotes readability, consistency and reusability. - I cannot disagree with the author more on his view of error reporting. I prefer having the list of errors viewable from the administration console so I can refer to previous errors without grepping through logs. Not only that, but web2py built-in error reporting gives you hyperlinks to the files so you can track down the root cause. This is a Good Thing™! Furthermore, you could just enable & tail the debug log if it bothers you that much. On Aug 1, 1:28 pm, David Marko wrote: > http://www.ahmedsoliman.com/2010/07/29/the-good-and-bad-about-web2py/
[web2py] Re: ARTICLE: The good and bad about web2py
I missed the last few sections when I pasted in my response :-) - web2py uses the DAL as documented here: http://en.wikipedia.org/wiki/Web2py#Database_handling; why is an ORM needed? - web2py has excellent IDE support through Eclipse and Wing IDE. Maybe we need more details on his issue. - As he rightly points out the single-core question is an interpreter limitation of sorts and really has nothing to do with web2py. That having been said, you can easily set up multiple instances and load- balance them. All of which is heavily documented in the scalability section of the web2py book. On Aug 1, 4:36 pm, Scott wrote: > Here are my thoughts, point by point: > > - web2py does support unit testing as it uses python code. I think > the article author means you cannot currently set up unit tests within > the administration console. You can configure tests as much or as > little as you like from the command line. > > - I think the article author should elaborate on the meaning of the > phrase “used in a twisted way to design the framework”. I don't see > anything twisted about the implementation; web2py is a WSGI > application. Personally, I think following Style Guide for Python > Code (PEP-8) is a good thing. Why is following the standard Style > Guide a bad thing? It promotes readability, consistency and > reusability. > > - I cannot disagree with the author more on his view of error > reporting. I prefer having the list of errors viewable from the > administration console so I can refer to previous errors without > grepping through logs. Not only that, but web2py built-in error > reporting gives you hyperlinks to the files so you can track down the > root cause. This is a Good Thing™! Furthermore, you could just > enable & tail the debug log if it bothers you that much. > > On Aug 1, 1:28 pm, David Marko wrote: > > > > > > > > >http://www.ahmedsoliman.com/2010/07/29/the-good-and-bad-about-web2py/
[web2py] Re: ARTICLE: The good and bad about web2py
I knew IntelliJ had a few plugins for PHP, Ruby, etc. but didn't think the Python plugin made it out of beta. I'll go take another look. Thanks! On Aug 1, 5:08 pm, "Robert O'Connor" wrote: > -Rob > > On Sun, Aug 1, 2010 at 4:42 PM, Scott wrote: > > I missed the last few sections when I pasted in my response :-) > > > - web2py uses the DAL as documented here: > >http://en.wikipedia.org/wiki/Web2py#Database_handling; > > why is an ORM needed? > > > - web2py has excellent IDE support through Eclipse and Wing IDE. > > Maybe we need more details on his issue. > > It also happens to work *out of the box* with IntelliJ IDEA --- with full > debugging support! > > > > > > > > > > > - As he rightly points out the single-core question is an interpreter > > limitation of sorts and really has nothing to do with web2py. That > > having been said, you can easily set up multiple instances and load- > > balance them. All of which is heavily documented in the scalability > > section of the web2py book. > > > On Aug 1, 4:36 pm, Scott wrote: > > > Here are my thoughts, point by point: > > > > - web2py does support unit testing as it uses python code. I think > > > the article author means you cannot currently set up unit tests within > > > the administration console. You can configure tests as much or as > > > little as you like from the command line. > > > > - I think the article author should elaborate on the meaning of the > > > phrase “used in a twisted way to design the framework”. I don't see > > > anything twisted about the implementation; web2py is a WSGI > > > application. Personally, I think following Style Guide for Python > > > Code (PEP-8) is a good thing. Why is following the standard Style > > > Guide a bad thing? It promotes readability, consistency and > > > reusability. > > > > - I cannot disagree with the author more on his view of error > > > reporting. I prefer having the list of errors viewable from the > > > administration console so I can refer to previous errors without > > > grepping through logs. Not only that, but web2py built-in error > > > reporting gives you hyperlinks to the files so you can track down the > > > root cause. This is a Good Thing™! Furthermore, you could just > > > enable & tail the debug log if it bothers you that much. > > > > On Aug 1, 1:28 pm, David Marko wrote: > > > > >http://www.ahmedsoliman.com/2010/07/29/the-good-and-bad-about-web2py/
[web2py] Re: GAE precompilation
Richard, I've tested this with web2py and did notice a slight performance increase with the default welcome application and cube2py. I noticed a larger increase with math intensive routines. I've submitted a patch to Massimo so look for it soon in the web2py trunk on Google Code. Thanks! On Jun 30, 9:37 pm, Richard wrote: > http://googleappengine.blogspot.com/2010/06/app-engine-sdk-135-releas... > > """ > in this release we’ve also added support for precompilation of Python > source files to match the same feature we launched for Java last year. > For Python, you can now use precompilation to speed up application > loading time and to reduce CPU usage for new app instances. You can > enable precompilation by including the following lines in your > app.yaml file: > derived_file_type: > -python_precompiled > > This will start offline precompilation of Python modules used by your > app when you deploy your application. Currently precompliation is off > by default for Python applications, but it will be enabled by default > in some future release. (Java precompilation has been enabled by > default since the release of 1.3.1.) > > To give you a taste of what this feature is like, we tested this on a > modified version of Rietveld (which included a copy of Django 1.0.4 in > the app directory, and which did not use the datastore in its base > url). The latency and CPU usage results for the initial load of the > application, after uploading a new version of the app and requesting > the homepage, were: > Before precompilation enabled: > Test 1: 1450ms 1757cpu_ms > Test 2: 1298ms 1523cpu_ms > Test 3: 1539ms 1841cpu_ms > After precompilation enabled: > Test 1: 805ms 669cpu_ms > Test 2: 861ms 702cpu_ms > Test 3: 921ms 803cpu_ms > """ > > anyone tested this with web2py?
[web2py] Re: GAE precompilation
Also of note, since I saw a mention of this on other threads: If you are deploying to GAE, do *not* compile the application within the web2py admin console. Instead, rely on the GAE app.yaml python precompilation as mentioned above. On Aug 5, 9:06 pm, Scott wrote: > Richard, > > I've tested this with web2py and did notice a slight performance > increase with the default welcome application and cube2py. I noticed > a larger increase with math intensive routines. I've submitted a > patch to Massimo so look for it soon in the web2py trunk on Google > Code. Thanks! > > On Jun 30, 9:37 pm, Richard wrote: > > > > > > > > >http://googleappengine.blogspot.com/2010/06/app-engine-sdk-135-releas... > > > """ > > in this release we’ve also added support for precompilation of Python > > source files to match the same feature we launched for Java last year. > > For Python, you can now use precompilation to speed up application > > loading time and to reduce CPU usage for new app instances. You can > > enable precompilation by including the following lines in your > > app.yaml file: > > derived_file_type: > > -python_precompiled > > > This will start offline precompilation of Python modules used by your > > app when you deploy your application. Currently precompliation is off > > by default for Python applications, but it will be enabled by default > > in some future release. (Java precompilation has been enabled by > > default since the release of 1.3.1.) > > > To give you a taste of what this feature is like, we tested this on a > > modified version of Rietveld (which included a copy of Django 1.0.4 in > > the app directory, and which did not use the datastore in its base > > url). The latency and CPU usage results for the initial load of the > > application, after uploading a new version of the app and requesting > > the homepage, were: > > Before precompilation enabled: > > Test 1: 1450ms 1757cpu_ms > > Test 2: 1298ms 1523cpu_ms > > Test 3: 1539ms 1841cpu_ms > > After precompilation enabled: > > Test 1: 805ms 669cpu_ms > > Test 2: 861ms 702cpu_ms > > Test 3: 921ms 803cpu_ms > > """ > > > anyone tested this with web2py?
[web2py] Re: Will a compiled app run on GAE?
Cross post: https://groups.google.com/group/web2py/browse_thread/thread/d2b314ef36abda8c
[web2py] Re: login method mappings
Michele, When is get_user() called during the login or account creation process? Background: I use a custom login method which leverages a Web service to authenticate a user. The authentication Web service only returns a pass/fail value. I need to use a second Web service to pull user account information, such as first and last name. I'd like to set up a get_user method which would call this second Web service to populate the user name. To do that, I need to pull the 'username' variable, I suppose from the auth object? I appreciate your help. --Scott On Aug 10, 8:42 am, Michele Comitini wrote: > Just return a dictionary with the properties you defined in the auth > table in db.py. > > For instance to use facebook with oauth20_account you need to override > get_user() method in the OAuthAccount class as you need. > Below is how I implement it for the test application > onhttp://grafbook.appspot.com/helloFacebook > > You can find the code of the example > here:http://code.google.com/r/michelecomitini-facebookaccess/source/browse... > > the important parts in db.py: > > . > . > . > auth_table = db.define_table( > auth.settings.table_user_name, > Field('first_name', length=128, default=""), > Field('last_name', length=128, default=""), > Field('username', length=128, default="", unique=True), > Field('password', 'password', length=256, > readable=False, label='Password'), > Field('registration_key', length=128, default= "", > writable=False, readable=False)) > > auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username) > > auth.define_tables() # creates all needed tables > > . > . > . > > import sys, os > path = os.path.join(request.folder, 'modules') > if not path in sys.path: > sys.path.append(path) > from fbappauth import CLIENT_ID,CLIENT_SECRET > from facebook import GraphAPI > from gluon.contrib.login_methods.oauth20_account import OAuthAccount > > class FaceBookAccount(OAuthAccount): > """OAuth impl for FaceBook""" > AUTH_URL="https://graph.facebook.com/oauth/authorize"; > TOKEN_URL="https://graph.facebook.com/oauth/access_token"; > > def __init__(self, g): > OAuthAccount.__init__(self, g, CLIENT_ID, CLIENT_SECRET, > self.AUTH_URL, self.TOKEN_URL) > self.graph = None > > def get_user(self): > '''Returns the user using the Graph API. > ''' > > if not self.accessToken(): > return None > > if not self.graph: > self.graph = GraphAPI((self.accessToken())) > > user = None > try: > user = self.graph.get_object("me") > except GraphAPIError: > self.session.token = None > self.graph = None > > if user: > return dict(first_name = user['first_name'], > last_name = user['last_name'], > username = user['id']) > > auth.settings.login_form=FaceBookAccount(globals()) > > 2010/8/9 Matt : > > > > > I have acustomlogin method. I would like to set the group, and > > names etc. I noticed the mappings for facebook in the docs, but was a > > little confised about how to apply it. Can I apply a mapping from > > within the actuallogin_methodclass, and if so how? > > > Thanks.
[web2py] Re: login method mappings
Essentially I am looking to create a custom get_user method which will invoke the second Web service to retrieve to user's first name and last name, which in turn will populate the appropriate fields in the auth_user table. I've tried a few variations with no luck. The current iteration is below. Logins are successful, but I haven't been able to populate the auth_user table with the firstname and lastname... # ## Custom Web Service authentication # import os from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault def webservice_auth(): def webservice_login_aux(username, password): client = SoapClient(wsdl=os.path.abspath(os.path.join('applications/test/ private/UserAuthentication.wsdl'))) response = client.getUserAuthentication(UserID=username) try: result = str(response.message) if result == 'OK': return True except SoapFault: return False return webservice_login_aux def get_user(self): client = SoapClient(wsdl=os.path.abspath(os.path.join('applications/test/ private/UserProfile.wsdl'))) response = client.getUserProfile(Userid=auth.user.username) return dict(first_name = str(response.firstname), last_name = str(response.lastname)) On Sep 15, 2:30 pm, Scott wrote: > Michele, > > When is get_user() called during the login or account creation > process? > > Background: > I use a custom login method which leverages a Web service to > authenticate a user. The authentication Web service only returns a > pass/fail value. I need to use a second Web service to pull user > account information, such as first and last name. I'd like to set up > a get_user method which would call this second Web service to populate > the user name. To do that, I need to pull the 'username' variable, I > suppose from the auth object? > > I appreciate your help. > --Scott > > On Aug 10, 8:42 am, Michele Comitini > wrote: > > > > > Just return a dictionary with the properties you defined in the auth > > table in db.py. > > > For instance to use facebook with oauth20_account you need to override > > get_user() method in the OAuthAccount class as you need. > > Below is how I implement it for the test application > > onhttp://grafbook.appspot.com/helloFacebook > > > You can find the code of the example > > here:http://code.google.com/r/michelecomitini-facebookaccess/source/browse... > > > the important parts in db.py: > > > . > > . > > . > > auth_table = db.define_table( > > auth.settings.table_user_name, > > Field('first_name', length=128, default=""), > > Field('last_name', length=128, default=""), > > Field('username', length=128, default="", unique=True), > > Field('password', 'password', length=256, > > readable=False, label='Password'), > > Field('registration_key', length=128, default= "", > > writable=False, readable=False)) > > > auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username) > > > auth.define_tables() # creates all needed tables > > > . > > . > > . > > > import sys, os > > path = os.path.join(request.folder, 'modules') > > if not path in sys.path: > > sys.path.append(path) > > from fbappauth import CLIENT_ID,CLIENT_SECRET > > from facebook import GraphAPI > > from gluon.contrib.login_methods.oauth20_account import OAuthAccount > > > class FaceBookAccount(OAuthAccount): > > """OAuth impl for FaceBook""" > > AUTH_URL="https://graph.facebook.com/oauth/authorize"; > > TOKEN_URL="https://graph.facebook.com/oauth/access_token"; > > > def __init__(self, g): > > OAuthAccount.__init__(self, g, CLIENT_ID, CLIENT_SECRET, > > self.AUTH_URL, self.TOKEN_URL) > > self.graph = None > > > def get_user(self): > > '''Returns the user using the Graph API. > > ''' > > > if not self.accessToken(): > > return None > > > if not self.graph: > > self.graph = GraphAPI((self.accessToken())) > > > user = None > > try: > > user = self.graph.get_
[web2py] Re: gae memcace clear?
If you are interested in caching view or controller output, please check the examples section: http://web2py.com/examples/default/examples#cache_examples Notice the timers which indicate how long before the view or controller output is re-rendered. You can also check out appadmin.py included within your application; it shows you how to clear cached output, e.g.: if clear_ram: cache.ram.clear() session.flash += "Ram Cleared " if clear_disk: cache.disk.clear() session.flash += "Disk Cleared" On Sep 18, 6:45 pm, Jurgis Pralgauskis wrote: > would it be sound to use some cache_db instead of memcache in GAE > then? > For example if I render a CPU requiring view I want to cache, > but I could clear it anytime I like. > > hm, or could there be a recipy to abandon current memcached object. > this would need extra hash table: > > as if now probably is sth like > stuff_key <---cached---> stuff_value > > would become > stuff_key <---extra_hash---> stuff_key_timestamp <---cached---> > stuff_value > and on clear just delete the stuff_key from extra_hash > > On 2 Rugs, 00:25, mdipierro wrote:> no. sorry > > > On Sep 1, 3:49 pm,JurgisPralgauskis > > wrote: > > > > Hello, > > > > inhttp://www.web2py.com/book/default/chapter/04booksays > > > > The time_expire can be set to 0 to force a cache refresh and to None > > > to prevent the content from ever expiring. > > > You can clear one or more cache variables with > > > cache.ram.clear(regex='...') > > > > does this apply to gaememcache? > > > > ifmemcachedecorates some controller, > > > and I know its key, how can I force recache its new result?
[web2py] Re: Memory usage
Johann, We don't have a lot of information to work off of here; therefore the culprit could be a lot of things. Typically high memory usage is tied to how your application processes data. I've created applications serving 4 TPS against a 300MB database, with memory usage between 70-80MB and CPU usage around 15%. I segment the data and only pull what is needed. That is to say, I avoid transactions that touch the entire database for reads or writes with the exception of row counts. Here's a few things to think about in troubleshooting the issue: 1) What is your transaction volume and how large or complex is the database? 2) When you run your application locally under light load, how much memory is used? 3) Database efficiency does not translate to your application using less memory unless you are using an embedded database; and database tuning can be an arcane science 4) Database complexity does not automatically translate to your application using more memory (again, assuming you're not using an embedded database): Your application and your database are in separate processes. 5) Do you have an option to store most frequently accessed information in memcache? This would save on database reads/writes and offload some of your memory requirements. I know Webfaction supports memcached. Cheers, --Scott On Sep 21, 9:47 am, Johann Spies wrote: > Yesterday for the first time I deployed web2py on a commercial > platform (Webfaction) and today I received two messages from > Webfaction that I was using more memory (135Mb) than what the Shared 1 > option allowed for (80Mb). And that was before the application was in > full use! I have requested an upgrade to Shared 3. > > Now my question: How do I keep memory usage down on such a platform > when I have to serve 1. a fairly complex database and 2. a possibility > of a lot of data? I chose Postgresql as database thinking that with > the efficiency of Postgresql as backend I would avoid using too much > memory. > > Regards > Johann > > -- > "The fool hath said in his heart, There is no God..." > Psalm 14:1
[web2py] Re: GAE appstats problem in app.yaml
What version of the GAE development server are you using? On Sep 24, 5:55 am, mdmcginn wrote: > GAE appstats no longer works in app.yaml for 1.85.3 and some earlier > versions (at least using dev_appserver.py) > > This URL gets response code > 500:http://localhost:8080/_ah/login?continue=http://localhost:8080/_ah/st... > > It works if I remove "login: admin" (below) from app.yaml > - url: /_ah/stats.* > script: $PYTHON_LIB/google/appengine/ext/appstats/ui.py > login: admin > > This code causes no trouble, however: > - url: /_ah/admin/.* > script: $PYTHON_LIB/google/appengine/ext/admin > login: admin > > However, I can't get the custom admin console page to appear no matter > what I do. I have to go directly tohttp://localhost:8080/_ah/stats/I > can't remember if that ever worked.
[web2py:17496] pdf/doc attachments work in sqlite, not in GQL
Was reading through the forms. In previous posts, this was a t2 issue. I understand t2 has now been wrapped in elsewhere. I can get attachments (pdf/docs) to show using sqlite as a backend, but not GQL. Here is my code: model --- db.define_table('news', SQLField('author',db.person), SQLField('author_alias'), SQLField('title',length=128), SQLField('abstract','text'), SQLField('abstract_file','upload')) controller - def comments(): item=db(db.news.id==news).select()[0] return dict(item=item) def download(): import os path=os.path.join(request.folder,'uploads',request.args[0]) return response.stream(path) view --- {{if item.abstract:}} {{=WIKI(item.abstract.strip())}} {{elif item.abstract_file:}} {{type=item.abstract_file.split('.')[-1]}} {{=A('link to abstract ['+type+']',_href=URL (r=request,f='download',args=[item.abstract_file]))}} {{pass}} No errors, appears that the file is not being uploaded properly (the view returns None, indicating that neither an abstract(text) or abstract_file(link to doc/pdf) has been upload). This is an adaptation of the Reddish app. Thanks Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py] Editing the auth table schema
I'm trying to remove the fields 'first_name' and 'last_name' from the auth_user database, or at least stop them from showing up on the registration forms and such. I've tried the following in db.py: db.auth_user.first_name.readable = db.auth_user.first_name.writable = False I also placing the below code above the auth.define_tables() code. auth.settings.extra_fields['auth_user'] = Field('first_name', readable=False,writable=False Some help would be appreciated.
[web2py] webgrid- column width
Just started with web2py, and got the webgrid module running immediately. very impressive. How can I display the columns widths so they reflect the datatypes (and lengths) in the table. Currently, the default view is only about 3 columns across the screen
[web2py] Re: Consuming a web2py web service in C#?
This is what I have concluded... The problem is that many "Windows" based JSON-RPC serializers (Including jayrock) and proxy's append a 3 byte UTF-8 BOM (Byte Order Mark) to the beginning of the resulting encoded JSON text that is sent in the body of the HTML request. Note that this is not a "feature" added by jayrock or any other JSON-RPC library, it is a Windows OS specific encoding practice for UTF-8 strings. Python does not bother with this because UTF-8 is it's natural language encoding and assumes this without being told by use of the BOM. So, what should be sent as '{"params":"hello","id": 1,"method":"echo"}' for example is sent as '\xef\xbb \xbf{"params":"hello","id":1,"method":"echo"}' by jayrock. Neither simplejson or web2py's serve_jsonrpc function (in tools.py) check for this UTF-8 BOM when decoding the JSON string. I am not 100% sure where this problem should be fixed in the code, in simplejson's decode function or web2py's serve_jsonrpc function, but I made these changes to the code in web2py's serve_jsonrpc function: From: -- request = self.environment['request'] methods = self.jsonrpc_procedures data = simplejson.loads(request.body.read()) id, method, params = data['id'], data['method'], data.get('params','') To: (added: import codecsto the top of the file) -- request = self.environment['request'] methods = self.jsonrpc_procedures # added theBody = request.body.read() if theBody.startswith( codecs.BOM_UTF8 ): theBody = theBody[3:] #data = simplejson.loads(request.body.read()) data = simplejson.loads(theBody) id, method, params = data['id'], data['method'], data.get('params','') This strips out the 3 byte UTF-8 BOM at the beginning of the body of the HTML and calls from jayrock's JSON-RPC client's work just fine. This is something that needs to be fixed and included in web2py's source. Or perhaps the fix belongs in the simplejson library? On May 20, 4:23 pm, Matt wrote: > Anyone using web2py as the web service and then consuming the service > via json-rpc in C#? I imagine this is possible, but seem to have quite > some time trying to get this to work. > > I'm usingjayrockas my json-rpc C# parser and setting the url to the > service to be my exposed web2py service but can't seem to get the > data. > > I'd be interested to know if anyone is doing something similar. > > Thanks. > -m
[web2py] How to do 3 (hopefully not too weird) things w/ my DB definition in models
1) I want to let migration add a UNIQUE=true field to a table, which apparently isn't allowed. But what does seem to be allowed is having the field added w/ UNIQUE=false, and after restarting the server (now that the field exists), having UNIQUE=true. Is there a way to accomplish this w/ the restart? 2) Related to the above, is it possible to detect when this field will be added, so that I can initialize it? Unfortunately, it has to be computed, so unless default can be a function that gets called (it wouldn't need any arguments), I don't see how this could be done. 3) s there a way to tell when a define_table has to actually create the table, so I can stuff in an initial record? I suppose I could do a query after the definition, but then it will get done for every request. Thanks in advance, Scott Hunter P.S. I'm currently using v1.65.10; if a newer version would help address any of these, that'd bolster my argument to upgrade!
[web2py] Re: How to do 3 (hopefully not too weird) things w/ my DB definition in models
Thanks for the quick reply! The situation I'm interested in is where the field doesn't exist and I'm adding it as a UNIQUE field; v1.65.10 generates a ticket when the appliance starts up, saying it can't add a UNIQUE field, which seems odd, since field creation is pretty much the only time you're assured there would be no conflict. I may be mistaken about being able to add UNIQUE=true once the field already exists. I'll check out the latest version, and see if that addresses the issue. Any ideas about the initialization questions? - Scott On Oct 5, 5:45 pm, mdipierro wrote: > I believe something has changed about this since 1.65.10 so you may > want to look at a more recent version (1.86.2 has lots of bug fixes). > I do not remember exactly the details about what changed in this > respect. In general the problem is that if you make a field unique, > after there is data in it, web2py has no way of knowing if the data > already in was unique or not and there is no easy way of checking. > > On Oct 5, 4:13 pm, Scott Hunter wrote: > > > > > 1) I want to let migration add a UNIQUE=true field to a table, which > > apparently isn't allowed. But what does seem to be allowed is having > > the field added w/ UNIQUE=false, and after restarting the server (now > > that the field exists), having UNIQUE=true. Is there a way to > > accomplish this w/ the restart? > > > 2) Related to the above, is it possible to detect when this field will > > be added, so that I can initialize it? Unfortunately, it has to be > > computed, so unless default can be a function that gets called (it > > wouldn't need any arguments), I don't see how this could be done. > > > 3) s there a way to tell when a define_table has to actually create > > the table, so I can stuff in an initial record? I suppose I could do > > a query after the definition, but then it will get done for every > > request. > > > Thanks in advance, > > Scott Hunter > > > P.S. I'm currently using v1.65.10; if a newer version would help > > address any of these, that'd bolster my argument to upgrade!
[web2py] Re: How to do 3 (hopefully not too weird) things w/ my DB definition in models
My scenario is that I have version X of an appliance which is missing the field in question, and I add it to the model for version X+1. Currently, web2py will handle adding that field to the appropriate table when the new version of the appliance is run for the first time using the new model. So while I know when it is added to the model, I don't know when it is added to the DB without performing a query. I suppose I could add a statement to update this field whereever it is NULL, but I don't really want to execute this every time the model gets evaluated. If I knew when the field was actually added to the DB, then I could do this initialization at just that point. Similarly for adding a table: if I knew when the table in the DB actually gets created, then I could add my initial record at that point, and not do a query to see if this is necessary every time the model gets evaluated. - Scott On Oct 6, 9:36 am, mdipierro wrote: > Perhaps I do not understand the question. If you add a field you know > you are adding it. If you need to initialize it with a function then > you have to loop over all records and to an update_record. Are you > trying to prevent the update from accidentally happening twice? > > Massimo > > On Oct 5, 6:26 pm, Scott Hunter wrote: > > > > > Thanks for the quick reply! > > > The situation I'm interested in is where the field doesn't exist and > > I'm adding it as a UNIQUE field; v1.65.10 generates a ticket when the > > appliance starts up, saying it can't add a UNIQUE field, which seems > > odd, since field creation is pretty much the only time you're assured > > there would be no conflict. > > > I may be mistaken about being able to add UNIQUE=true once the field > > already exists. I'll check out the latest version, and see if that > > addresses the issue. > > > Any ideas about the initialization questions? > > > - Scott > > > On Oct 5, 5:45 pm, mdipierro wrote: > > > > I believe something has changed about this since 1.65.10 so you may > > > want to look at a more recent version (1.86.2 has lots of bug fixes). > > > I do not remember exactly the details about what changed in this > > > respect. In general the problem is that if you make a field unique, > > > after there is data in it, web2py has no way of knowing if the data > > > already in was unique or not and there is no easy way of checking. > > > > On Oct 5, 4:13 pm, Scott Hunter wrote: > > > > > 1) I want to let migration add a UNIQUE=true field to a table, which > > > > apparently isn't allowed. But what does seem to be allowed is having > > > > the field added w/ UNIQUE=false, and after restarting the server (now > > > > that the field exists), having UNIQUE=true. Is there a way to > > > > accomplish this w/ the restart? > > > > > 2) Related to the above, is it possible to detect when this field will > > > > be added, so that I can initialize it? Unfortunately, it has to be > > > > computed, so unless default can be a function that gets called (it > > > > wouldn't need any arguments), I don't see how this could be done. > > > > > 3) s there a way to tell when a define_table has to actually create > > > > the table, so I can stuff in an initial record? I suppose I could do > > > > a query after the definition, but then it will get done for every > > > > request. > > > > > Thanks in advance, > > > > Scott Hunter > > > > > P.S. I'm currently using v1.65.10; if a newer version would help > > > > address any of these, that'd bolster my argument to upgrade!
[web2py] Re: How to do 3 (hopefully not too weird) things w/ my DB definition in models
Perfect, and checking for "CREATE TABLE", I can address #3. Thanks, Scott On Oct 6, 10:00 am, mdipierro wrote: > Now I understand. There is not api exposed to do this but you can with > a trick > > if 'ADD fieldname' in db._lastsql: > do_whatever_you_need_to_do() > > On Oct 6, 8:48 am, Scott Hunter wrote: > > > > > My scenario is that I have version X of an appliance which is missing > > the field in question, and I add it to the model for version X+1. > > Currently, web2py will handle adding that field to the appropriate > > table when the new version of the appliance is run for the first time > > using the new model. So while I know when it is added to the model, I > > don't know when it is added to the DB without performing a query. I > > suppose I could add a statement to update this field whereever it is > > NULL, but I don't really want to execute this every time the model > > gets evaluated. If I knew when the field was actually added to the > > DB, then I could do this initialization at just that point. > > > Similarly for adding a table: if I knew when the table in the DB > > actually gets created, then I could add my initial record at that > > point, and not do a query to see if this is necessary every time the > > model gets evaluated. > > > - Scott > > > On Oct 6, 9:36 am, mdipierro wrote: > > > > Perhaps I do not understand the question. If you add a field you know > > > you are adding it. If you need to initialize it with a function then > > > you have to loop over all records and to an update_record. Are you > > > trying to prevent the update from accidentally happening twice? > > > > Massimo > > > > On Oct 5, 6:26 pm, Scott Hunter wrote: > > > > > Thanks for the quick reply! > > > > > The situation I'm interested in is where the field doesn't exist and > > > > I'm adding it as a UNIQUE field; v1.65.10 generates a ticket when the > > > > appliance starts up, saying it can't add a UNIQUE field, which seems > > > > odd, since field creation is pretty much the only time you're assured > > > > there would be no conflict. > > > > > I may be mistaken about being able to add UNIQUE=true once the field > > > > already exists. I'll check out the latest version, and see if that > > > > addresses the issue. > > > > > Any ideas about the initialization questions? > > > > > - Scott > > > > > On Oct 5, 5:45 pm, mdipierro wrote: > > > > > > I believe something has changed about this since 1.65.10 so you may > > > > > want to look at a more recent version (1.86.2 has lots of bug fixes). > > > > > I do not remember exactly the details about what changed in this > > > > > respect. In general the problem is that if you make a field unique, > > > > > after there is data in it, web2py has no way of knowing if the data > > > > > already in was unique or not and there is no easy way of checking. > > > > > > On Oct 5, 4:13 pm, Scott Hunter wrote: > > > > > > > 1) I want to let migration add a UNIQUE=true field to a table, which > > > > > > apparently isn't allowed. But what does seem to be allowed is > > > > > > having > > > > > > the field added w/ UNIQUE=false, and after restarting the server > > > > > > (now > > > > > > that the field exists), having UNIQUE=true. Is there a way to > > > > > > accomplish this w/ the restart? > > > > > > > 2) Related to the above, is it possible to detect when this field > > > > > > will > > > > > > be added, so that I can initialize it? Unfortunately, it has to be > > > > > > computed, so unless default can be a function that gets called (it > > > > > > wouldn't need any arguments), I don't see how this could be done. > > > > > > > 3) s there a way to tell when a define_table has to actually create > > > > > > the table, so I can stuff in an initial record? I suppose I could > > > > > > do > > > > > > a query after the definition, but then it will get done for every > > > > > > request. > > > > > > > Thanks in advance, > > > > > > Scott Hunter > > > > > > > P.S. I'm currently using v1.65.10; if a newer version would help > > > > > > address any of these, that'd bolster my argument to upgrade!
[web2py:23227] Re: Auth forwarding
I've just downloaded the MacOSX v 1.63.3, and its exhibiting this same problem. I had gotten an earlier copy through launchpad, and the problem was indeed fixed. Is it possible the pre-compiled version isn't up to date? I noticed that the web2py executable (in the MacOS directory) is dated 1/8/2009. Scott On May 13, 4:23 pm, mdipierro wrote: > Thanks Fran. This was your patch! > > On May 13, 3:22 pm, Fran wrote: > > > > > On May 13, 7:45 pm, ScottHunter wrote: > > > > Version 1.61.4 (2009-04-21 10:02:50) > > > Fixed on 2009-05-03 > > 05:43:55http://bazaar.launchpad.net/~mdipierro/web2py/devel/revision/723 > > > F --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:23228] Re: Auth forwarding
To be more specific: If I go to a protected page in my application, I go to the login page, but once I've successfully logged in , I do not get redirected to the page I originally requested. I am specifying that page by typing in the URL directly, or by clicking a link explicitly written in a view (like the links in the welcome application). I saw a suggestion in another thread that HOW I'm trying to get to the page in question may be the problem, but it still seems like a bug (auth is getting control in order to ask for the password, and knows what URL was originally requested, and is building the login page; why should it matter HOW it was requested?) Thanks for any help, Scott On Jun 3, 5:21 pm, Scott Hunter wrote: > I've just downloaded the MacOSX v 1.63.3, and its exhibiting this same > problem. I had gotten an earlier copy through launchpad, and the > problem was indeed fixed. Is it possible the pre-compiled version > isn't up to date? I noticed that the web2py executable (in the MacOS > directory) is dated 1/8/2009. > > Scott > > On May 13, 4:23 pm, mdipierro wrote: > > > > > Thanks Fran. This was your patch! > > > On May 13, 3:22 pm, Fran wrote: > > > > On May 13, 7:45 pm, ScottHunter wrote: > > > > > Version 1.61.4 (2009-04-21 10:02:50) > > > > Fixed on 2009-05-03 > > > 05:43:55http://bazaar.launchpad.net/~mdipierro/web2py/devel/revision/723 > > > > F --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:27983] Hacking the Windows version of web2py.py
In the source & Mac-standalone versions of web2py, one can (and I did :)) change/replace the file web2py.py in order to modify the server application. (In my case, I'm adding a list of server IPs to choose from and spawning an extra process; the latter could presumably be done elsewhere, but it is tied to the server running, so this way I can easily start/stop it when the server starts/stops.) But in the Windows-standalone version, this file is not present (presumably because it's functionality is baked into web2py.exe). So is there some way to make such modifications to the Windows- standalone version? Maybe some kind of hook(s) into web2py.exe? I'd even be willing to make a modified version of web2py.exe, but I don't see the source for it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:29630] web2py complaints & rebuttals
A colleague has lodged the following complaints about web2py, and I'd like to run my responses by this group in order to correct/strengthen those responses. Complaint #1: No real-time debugging (i.e. proper step-debugging in a real IDE) Response #1: web2py, being a framework, does not include a full-blown IDE, but it doesn't preclude your using your favorite IDE. Complaint #2: No proper logging mechanism for modules. (Related: web2py is pathetic at third-party module integration) Response #2: Again, nothing in web2py precludes using python's logging facility. (And I've had no problem getting it to play nice with PIL and some other modules, so I'm not sure what the complaint is here.) Complaint #3: Having to do strange things (like double-imports and reloads) to pick up run-time changes in my module. (This may be where the complaint about 3rd party modules comes from.) Response #3: I believe the issue here is that there is a module which is being developed/debugged, but changes to it aren't getting picked- up without re-starting the application (or doing "strange things"). Were the module being developed located inside web2py during development, then I believe edits would get picked up immediately. Complaint #4: web2py will not let me handle my own form, considering I don't want to use web2py's ORM to talk to my data Response #4: There is NOTHING in web2py the prevents you from using your own form. Complaint #5: It's not a real ORM, because there is entirely 'zero' configuration like a real ORM has. It's a database-to-HTML-form management system, not an object-relational management system. Response #5: White it has features to facilitate HTML form management, it certainly seems to map records to objects... Complant #6: web2py will only let you process a web2py form if it was created in the controller Response #6: while a from OBJECT must be created in the controller, the actual form need not be. Complaint #7: web2py won't let me loop over keys in their custom dict () structure (called Storage) in order to circumvent the FORM and SQLFORM issues in #5 above Response #7: ? Any help would be appreciated. - Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:29984] web2py testing example(s)
Could someone point me to good (however you define "good") example of test code for a web2py appliance? It looks like the "test" links in admin only refer to doctests, but I can't find examples of what these might look like for a web2py appliance. There is an entry in AlterEgo (#213) which sets things up using unittest, but I'm finding it hard to generalize from this one example. Thanks in advance, Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:33515] Problem w/ migration
I've added the following field to the table worksheet: SQLField('mysortkey', length = 40, default = 'something' ) I get a ticket reporting: Traceback (most recent call last): File "/home/scott/web2py_1_68_2/gluon/restricted.py", line 184, in restricted exec ccode in environment File "/home/scott/web2py_1_68_2/applications/Rover/models/db.py", line 165, in db.define_table(*([\'worksheet\'] + ws_fields) ) File "/home/scott/web2py_1_68_2/gluon/sql.py", line 1130, in define_table query = t._create(migrate=migrate) File "/home/scott/web2py_1_68_2/gluon/sql.py", line 1506, in _create sql_fields_aux, logfile) File "/home/scott/web2py_1_68_2/gluon/sql.py", line 1558, in _migrate self._db._execute(sub_query) File "/home/scott/web2py_1_68_2/gluon/sql.py", line 772, in self._execute = lambda *a, **b: self._cursor.execute(*a, **b) OperationalError: near "ADD": syntax error And the sql.log reports: timestamp: 2009-10-23T10:27:01.673960 ALTER TABLE worksheet ADD mysortkey CHAR(40); timestamp: 2009-10-23T10:30:40.842311 It doesn't seem to matter how I change the name, the type of the field, or use a different table; other examples from the sql.log, all of which had a similar ticket to the above: ALTER TABLE worksheet ADD silly CHAR(1); ALTER TABLE worksheet ADD when_rec CHAR(40); ALTER TABLE person ADD stupid INTEGER; This is running v 1.68.2 from source w/ an SQLlite DB --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:21475] Widget problem w/ duplication
Just downloaded v 1.61.4 (Mac), and I'm having a problem w/ widgets. For example: def ta_widget(field,value,nr): "Widget to allow size of textarea to be specified"" return TEXTAREA("xyz", _type="text", _class="text", _rows=nr, _cols=40, _name=field.name, _id=field._tablename+'_'+field.name) ... SQLField('textfield','text',widget=lambda a,b:ta_widget(a,b,1)), ... Yields the following HTML, which presents as a text area w/ a copy of the tag included in the content: xyz I have a similar problem w/ a widget that yields a SELECT producing one SELECT inside another (which the browser can handle). I'd used the ta_widget in earlier versions of web2py (01/09?). Thanks for the help, Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:21482] Re: Widget problem w/ duplication
That may have more of a symptom than the cause. The other widget I defined was: def choice_widget(field,value,labels,required): """ Widget to substitute a pup-up menu with a set of radio buttons """ id=field._tablename+'_'+field.name sro = [] i = 0 selected = False for x in labels: if str(value)==str(i): sro.append( OPTION(x,_value=i,_selected="selected") ) selected = True else: sro.append( OPTION(x,_value=i) ) i += 1 set = [x for x in range(len(labels))] if not selected: sro = [OPTION('', _value=-1)]+sro if not required: set = [-1]+set kw = {'_class':'integer', '_id':id, '_name':field.name, 'requires':IS_IN_SET(set, error_message='required information!')} return SELECT(*sro, **kw) And here's an example of its use: db.define_table('tbl', SQLField('field', 'integer', widget=lambda a,b:choice_widget(a,b,['a','b'],True))) When I bring up an insertion form (through appadmin or my own controller), all is well. But if I try to submit, and there is an error (as there will be if nothing is changed), the nesting originally described appears on the page w/ the error message (for a SELECT, you'd have to view the source to see the nesting). If I reload the form, the nesting appears (but the error messages do not). If I navigate away from and back to the insertion form, there's no nesting (and no error message). Thanks again, Scott On May 8, 10:46 am, mdipierro wrote: > I cannot reproduce the problem but there is a typo in your code > > "Widget to allow size of textarea to be specified"" > > should be > > "Widget to allow size of textarea to be specified" > > Massimo > > On May 8, 9:12 am, Scott Hunter wrote: > > > > > Just downloaded v 1.61.4 (Mac), and I'm having a problem w/ widgets. > > For example: > > > def ta_widget(field,value,nr): > > "Widget to allow size of textarea to be specified"" > > return TEXTAREA("xyz", _type="text", _class="text", _rows=nr, > > _cols=40, > > _name=field.name, > > _id=field._tablename+'_'+field.name) > > > ... > > SQLField('textfield','text',widget=lambda a,b:ta_widget(a,b,1)), > > ... > > > Yields the following HTML, which presents as a text area w/ a copy of > > the tag included in the content: > > > > name="heatdist_defects" rows="1" type="text"> > cols="40" id="worksheets_heatdist_defects" name="heatdist_defects" > > rows="1" type="text">xyz > > > I have a similar problem w/ a widget that yields a SELECT producing > > one SELECT inside another (which the browser can handle). > > > I'd used the ta_widget in earlier versions of web2py (01/09?). > > > Thanks for the help, > > Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:21500] Re: Widget problem w/ duplication
That seems to have done the truck; thanks. I tried to model the code I was replacing as much as possible (I'm just changing the # of rows in a TEXTAREA or adding an OPTION to a SELECT), so there shouldn't be any confusion -- and there doesn't seem to be. Again, thanks. Scott On May 8, 1:19 pm, mdipierro wrote: > On a second thought it is not too bad IF all widget have a _name > attribute in the outer html tag. > > On May 8, 12:08 pm, mdipierro wrote: > > > > > Yes there is a problem! > > > I fixed it for you in trunk (launchpad) but actually it is a bigger > > problem that it seems. With fix is that if the widget is too complex > > it may not display the error (because it is not obvious where the > > error should be displayed). > > I will keep working on this but let me know if this is fine for you > > for now. > > > Massimo > > > On May 8, 11:09 am, Scott Hunter wrote: > > > > That may have more of a symptom than the cause. The other widget I > > > defined was: > > > > def choice_widget(field,value,labels,required): > > > """ > > > Widget to substitute a pup-up menu with a set of radio buttons > > > """ > > > id=field._tablename+'_'+field.name > > > sro = [] > > > i = 0 > > > selected = False > > > for x in labels: > > > if str(value)==str(i): > > > sro.append( > > > OPTION(x,_value=i,_selected="selected") ) > > > selected = True > > > else: > > > sro.append( OPTION(x,_value=i) ) > > > i += 1 > > > set = [x for x in range(len(labels))] > > > if not selected: > > > sro = [OPTION('', _value=-1)]+sro > > > if not required: > > > set = [-1]+set > > > kw = {'_class':'integer', '_id':id, '_name':field.name, > > > 'requires':IS_IN_SET(set, error_message='required > > > information!')} > > > return SELECT(*sro, **kw) > > > > And here's an example of its use: > > > > db.define_table('tbl', SQLField('field', 'integer', widget=lambda > > > a,b:choice_widget(a,b,['a','b'],True))) > > > > When I bring up an insertion form (through appadmin or my own > > > controller), all is well. But if I try to submit, and there is an > > > error (as there will be if nothing is changed), the nesting originally > > > described appears on the page w/ the error message (for a SELECT, > > > you'd have to view the source to see the nesting). If I reload the > > > form, the nesting appears (but the error messages do not). If I > > > navigate away from and back to the insertion form, there's no nesting > > > (and no error message). > > > > Thanks again, > > > Scott > > > > On May 8, 10:46 am, mdipierro wrote: > > > > > I cannot reproduce the problem but there is a typo in your code > > > > > "Widget to allow size of textarea to be specified"" > > > > > should be > > > > > "Widget to allow size of textarea to be specified" > > > > > Massimo > > > > > On May 8, 9:12 am, Scott Hunter wrote: > > > > > > Just downloaded v 1.61.4 (Mac), and I'm having a problem w/ widgets. > > > > > For example: > > > > > > def ta_widget(field,value,nr): > > > > > "Widget to allow size of textarea to be specified"" > > > > > return TEXTAREA("xyz", _type="text", _class="text", _rows=nr, > > > > > _cols=40, > > > > > _name=field.name, > > > > > _id=field._tablename+'_'+field.name) > > > > > > ... > > > > > SQLField('textfield','text',widget=lambda a,b:ta_widget(a,b,1)), > > > > > ... > > > > > > Yields the following HTML, which presents as a text area w/ a copy of > > > > > the tag included in the content: > > > > > > > > > > name="heatdist_defects" rows="1" type="text"> > > > > cols="40" id="worksheets_heatdist_defects" name="heatdist_defects" > > > > > rows="1" type="text">xyz > > > > > > I have a similar problem w/ a widget that yields a SELECT producing > > > > > one SELECT inside another (which the browser can handle). > > > > > > I'd used the ta_widget in earlier versions of web2py (01/09?). > > > > > > Thanks for the help, > > > > > Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:21791] Auth forwarding
I'm trying out the Auth tool (very sweet!), and wondering if it can handle the following: I've decorated a controller/function to require a login, and auth dutifully redirects me to a login page, and properly processes the login. But when I've logged in, I'd like it to go to the page I originally requested, instead of default/index. So: is there machinery in auth to do this, or is it something I'll need to whip up myself? Thanks, Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:21799] Re: Auth forwarding
Version 1.61.4 (2009-04-21 10:02:50) I had to add auth.settings.login_url=URL(r=request,c='default',f='user',args= ['login']) in the model to get it to go to the right controller (before, I only had one controller :) ) But still, after logging in, I get sent to app/default/index, not the URL I originally requested. I put the following above the controller for the page I'm trying to go to: @auth.requires_login() And put this in default.py: def user(): return dict(form=auth()) Is there something I still need to do? Thanks, Scott On May 13, 1:00 pm, mdipierro wrote: > What you want is the default behavior of the web2py in trunk. > Are you using 1.61.4? > > Massimo > > On May 13, 11:17 am, Scott Hunter wrote: > > > > > I'm trying out the Auth tool (very sweet!), and wondering if it can > > handle the following: > > > I've decorated a controller/function to require a login, and auth > > dutifully redirects me to a login page, and properly processes the > > login. But when I've logged in, I'd like it to go to the page I > > originally requested, instead of default/index. > > > So: is there machinery in auth to do this, or is it something I'll > > need to whip up myself? > > > Thanks, > > Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:21925] Re: sqlite and threading
I hit this one a while back; its a limitation of SQLite. * You could create a new process to access the DB, but that's probably not very safe (they really mean the Lite part of the name!) * You could switch to a DB, like MySQL, which does support concurrent access * You could have your thread access your app as if it were on a different server, using (say) urllib; then your request would get processed by the thread that can access the DB. Which of these might solve your problem depends on the specifics of what your thread is trying to do. Good luck, Scott On May 15, 12:22 pm, Kacper Krupa wrote: > Hi, > > I've written application which creates another thread and do things > inside it. But why i can't use ORM in it? I'm using sqlite3 and i > always get: > > ProgrammingError: SQLite objects created in a thread can only be used > in that same thread.The object was created in thread id 28329984 and > this is thread id 28687360 > > Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:9917] Windows executable and command line options
Is it possible to supply command line options to the windows executable version (web2py.exe) of web2py, either explicitly or via a config file, and if so, how? (I see that I can specify a config file w/ a command line option - "that's some catch, that catch-22" :) Thanks in advance, Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:9982] Daemons as Threads
Using the shell command-line option of web2py, one can create a daemon with full access to the DB that the webserver has. Is it possible to do something similar w/ a thread created within web2py? When I tried, I got complaints that my db variable wasn't defined; then I tried to include my model file, but got a complaint that it isn't a module. Thanks, Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:10008] Re: Daemons as Threads
When I tried that, I got the following error when attempting a query: ProgrammingError: SQLite objects created in a thread can only be used in that same thread. But when I try to create an SQLDB object in my thread, I get: OperationalError: unable to open database file Maybe my thread didn't "instantiate its own connection to the database"; what does this involve? Thanks, Scott On Oct 8, 5:58 pm, mdipierro <[EMAIL PROTECTED]> wrote: > It depends on who starts the thread. The main problem is that the web > server monitors threads and kills them when they take long. > I principle a model, view controller can start its own thread but you > should pass a SQLDB object to it. It needs to instantiate its own > connection to the database and commit or rollback explicitly. > > Massimo > > On Oct 8, 4:42 pm, Scott Hunter <[EMAIL PROTECTED]> wrote: > > > Using the shell command-line option of web2py, one can create a daemon > > with full access to the DB that the webserver has. Is it possible to > > do something similar w/ a thread created within web2py? When I tried, > > I got complaints that my db variable wasn't defined; then I tried to > > include my model file, but got a complaint that it isn't a module. > > > Thanks, > > Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:10359] Re: Python 2.6 anyone?
When trying to run web2py off of Python 2.6, we got the following error from code that works fine under Python 2.5.x (note that the error trace never ventures out of the web2py code). Our immediate solution is to use the older Python, but thought I'd point it out (this is run on a Windows 2000 SP 4 machine, but got the same errors on Red Hat Enterprise Linux AS release 4 (Nahant Update 7) ) - sbh C:\Rover\RoverServer\Rover>python web2py.py -a xxx -p 8000 -i xxx.xxx.xxx.xxx C:\Rover\RoverServer\Rover\gluon\import_all.py:328: DeprecationWarning: the md5 module is deprecated; use hashlib instead try: import md5 C:\Python26\lib\mhlib.py:83: DeprecationWarning: the multifile module has been d eprecated since Python 2.5 import multifile C:\Rover\RoverServer\Rover\gluon\import_all.py:340: DeprecationWarning: the Mime Writer module is deprecated; use the email package instead try: import MimeWriter C:\Rover\RoverServer\Rover\gluon\import_all.py:343: DeprecationWarning: the mimi fy module is deprecated; use the email package instead try: import mimify C:\Rover\RoverServer\Rover\gluon\import_all.py:448: DeprecationWarning: the sets module is deprecated try: import sets C:\Rover\RoverServer\Rover\gluon\import_all.py:454: DeprecationWarning: the sha module is deprecated; use the hashlib module instead try: import sha Warning: web2py requires Python 2.5 but, instead, you are running: 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)]web2py Enterpr ise Web Framework Created by Massimo Di Pierro, Copyright 2007-2008 Version 1.42 (2008-09-12 11:33:40) WARNING:root:no file locking Traceback (most recent call last): File "web2py.py", line 4, in from gluon.widget import start File "C:\Rover\RoverServer\Rover\gluon\widget.py", line 35, in from gluon.main import HttpServer, save_password File "C:\Rover\RoverServer\Rover\gluon\main.py", line 16, in from globals import Request, Response, Session File "C:\Rover\RoverServer\Rover\gluon\globals.py", line 8, in from compileapp import run_view_in File "C:\Rover\RoverServer\Rover\gluon\compileapp.py", line 13, in from sql import SQLDB, SQLField File "C:\Rover\RoverServer\Rover\gluon\sql.py", line 551 def __init__(self,table,query,as=None): ^ SyntaxError: invalid syntax On Oct 14, 1:20 pm, "Phyo Arkar" <[EMAIL PROTECTED]> wrote: > Hi all; > > as Python 2.6 is backward compatible with 2.5 , have anyone used it as > Default python and , running Web2py ? > > Regards > > Phyo. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:10488] web2py on an iPhone?
The subject pretty much says it: will web2py run on an iPhone, and if not, what are (or might be) the obstacles that prevent it? - sbh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py] Insert works using SQLite, not GAE/Datastore
To elaborate on title: I have a simple web2py app, from which I can insert records into a particular table (using a smart grid, or from within a controller), but trying to do so with the app posted to GAE, it fails (for either method). Operations using other tables work fine. I believe it has to do with the table's schema having been modified from the original version posted to GAE; the field it is complaining about didn't used to exist. The table used to show up as one of the Entities, with the problematic field not showing as a Property; now the Entity doesn't even appear. I'm at a loss as to how to proceed. -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Insert works using SQLite, not GAE/Datastore
As requested, here is the traceback: In FILE: /base/data/home/apps/s~sbhweb2py/1.364873083036857122/applications/ppt_demo/controllers/default.py Traceback (most recent call last): File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/restricted.py", line 212, in restricted exec ccode in environment File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/applications/ppt_demo/controllers/default.py", line 57, in File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/globals.py", line 193, in self._caller = lambda f: f() File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/tools.py", line 2929, in f return action(*a, **b) File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/applications/ppt_demo/controllers/default.py", line 22, in trial_manage form = SQLFORM.smartgrid(db.t_trial,onupdate=auth.archive) File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/sqlhtml.py", line 2489, in smartgrid user_signature=user_signature, **kwargs) File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/sqlhtml.py", line 1881, in grid onsuccess=oncreate) File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/html.py", line 2179, in process self.validate(**kwargs) File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/html.py", line 2118, in validate if self.accepts(**kwargs): File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/sqlhtml.py", line 1486, in accepts self.vars.id = self.table.insert(**fields) File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/dal.py", line 7918, in insert ret = self._db._adapter.insert(self,self._listify(fields)) File "/base/data/home/apps/s~sbhweb2py/1.364873083036857122/gluon/dal.py", line 4671, in insert tmp = table._tableobj(**dfields) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 970, in __init__ prop.__set__(self, value) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 614, in __set__ value = self.validate(value) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 3286, in validate raise BadValueError('Property %s must be a float' % self.name) BadValueError: Property f_run_fee_2 must be a float Here is the controller: @auth.requires_login() def trial_manage(): form = SQLFORM.smartgrid(db.t_trial,onupdate=auth.archive) return locals() And here is the model: db.define_table('t_trial', Field('f_name', type='string', label=T('Name')), Field('f_club', type='string', label=T('Club')), Field('f_club_link', type='string', label=T('Club')), Field('f_when', type='date', label=T('When')), Field('f_days', type='integer', label=T('Days')), Field('f_open', type='date', label=T('Openning')), Field('f_close', type='date', label=T('Closing')), Field('f_location', type='string', label=T('Location')), Field('f_maplink', type='string', label=T('Map')), Field('f_maxruns', type='integer', label=T('Runs')), Field('f_run_fee_1', type='float', label=T('1st Run Fee')), Field('f_run_fee_2', type='float', label=T('2nd Run Fee')), Field('f_status', type='string', label=T('Status')), auth.signature, format='%(f_name)s', migrate=settings.migrate) (settings.migrate = True, from settings.py -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Insert works using SQLite, not GAE/Datastore
I entered 15.0 in the form, which sure looks like a float to me. If I had entered a non-float, automatic validation should have caught it before the appengine sdk was called to do a set. And when I used an insert statement myself using the DAL, I tried hard-coding a 10.0 for that field -- same error. I even tried explicitly casting it as a float -- exact same error. When I looked at the Datastore Statistics for that table/entity, it didn't show that field/property; in fact, none of the new fields appeared. - Scott On Monday, January 28, 2013 6:16:44 PM UTC-5, Alan Etkin wrote: > > As requested, here is the traceback: > > > Looks like a non-float value is sent to the GAE adapter for datatastore > insertion (without the proper type validation). otherwise the appengine sdk > should not raise that exception. Maybe you can debug the form values on > submission to check they are actual float objects. > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Insert works using SQLite, not GAE/Datastore
OK, it seems that GAE isn't fond of floats, but is quite happy with doubles -- its now happy with inserting both from a smartgrid-created form and from DAL calls. (I couldn't define any fields directly b/c the table/entity no longer appeared.) Thanks. On Monday, January 28, 2013 7:37:52 PM UTC-5, Alan Etkin wrote: > > I entered 15.0 in the form, which sure looks like a float to me. If I had >> entered a non-float, automatic validation should have > > > Not the best solution I guess, but, maybe you could try to define the > missing table/field objects in the datastore web interface to check if the > adapter is failing to update the definitions in the db > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Insert works using SQLite, not GAE/Datastore
Sorry - yes, I changed the model, replacing the floats with doubles. On Tuesday, January 29, 2013 4:33:12 AM UTC-5, Alan Etkin wrote: > > > OK, it seems that GAE isn't fond of floats, but is quite happy with > doubles > > Good to know, but, how did you fix GAE?. Have you changed your model? This > might be a bug in the DAL adapter > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] web2py under GAE: disabling indexes
As I understand it, the GAE datastore will automatically create an index for every field of every table (to facilitate queries using single fields); those requiring multiple fields also get generated, but will get added to index.yaml by the SDK when tested locally. Since these are created outside of the DAL, I wouldn't expect to be able to remove them using it. I also understand that there is a way, with the GAE SDK, to disable the index for any given field (by a parameter in the field definition); is there any way to accomplish this through the DAL, and if so, what is it? -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py under GAE: disabling indexes
According to https://developers.google.com/appengine/docs/python/datastore/indexes#Unindexed_Properties, "You declare a property unindexed by setting indexed=False in the property constructor". One incurs the cost of a write (or 2?) for every property of a record that gets written; so, for a table with about 25 fields (once you include all of the ones web2py adds), inserting 300 records incurs the cost of 14K+ writes; as the free account has a limit of 50K writes per day, that is rather limiting. It is easy to turn such indicies back on, but you have to re-write every record in order to repopulate them. - Scott On Thursday, February 21, 2013 4:51:59 PM UTC-5, howesc wrote: > > i'm being lazy heredo you have the instructions (or link to > instructions) from GAE for disabling indexes? i don't have it handy right > now > > we can check if the DAL has a secret way to handle it, and/or create a > patch to allow it. > > may i ask what advantage you are hoping to achieve by skipping those > indexes? i've left them on for fear of making a bad choice that i can't > revert. > > christian > > On Thursday, February 21, 2013 5:56:07 AM UTC-8, Scott Hunter wrote: >> >> As I understand it, the GAE datastore will automatically create an index >> for every field of every table (to facilitate queries using single fields); >> those requiring multiple fields also get generated, but will get added to >> index.yaml by the SDK when tested locally. Since these are created outside >> of the DAL, I wouldn't expect to be able to remove them using it. I also >> understand that there is a way, with the GAE SDK, to disable the index for >> any given field (by a parameter in the field definition); is there any way >> to accomplish this through the DAL, and if so, what is it? > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py under GAE: disabling indexes
If I had to guess, I'd say a patch is needed in the loop over the fields in create_table, that would add a new entry to the dict for the field definition based on a new attribute (which would be ignored for anything other than Google's Datastore) which gets added to sql_fields; then migrate_table, which seems to build the table building/altering commands would need to be made to recognize the new entry & add the disable index command. There's not a lot of comments in the code, and I'd be afraid to break something, but might give it a try. - Scott P.S. Not sure of the best way to handle this (what's describe above wouldn't handle it), but it would be nice to be able to turn off the indexes for the fields that don't get listed explicitly in models.db (things like created by & when, modified by & when). On Friday, February 22, 2013 6:14:28 PM UTC-5, howesc wrote: > > thanks for the link. i'll try and take a look this weekend and see if > there is a place for that in the DAL (feel free to open gluon/dal.py > yourself too). > > yup, i'm paying more for writes right now then i am for instance hours per > day on my largest paid application. :) > > cfh > > On Thursday, February 21, 2013 5:59:06 PM UTC-8, Scott Hunter wrote: >> >> According to >> https://developers.google.com/appengine/docs/python/datastore/indexes#Unindexed_Properties, >> >> "You declare a property unindexed by setting indexed=False in the property >> constructor". >> >> One incurs the cost of a write (or 2?) for every property of a record >> that gets written; so, for a table with about 25 fields (once you include >> all of the ones web2py adds), inserting 300 records incurs the cost of 14K+ >> writes; as the free account has a limit of 50K writes per day, that is >> rather limiting. It is easy to turn such indicies back on, but you have to >> re-write every record in order to repopulate them. >> >> - Scott >> >> On Thursday, February 21, 2013 4:51:59 PM UTC-5, howesc wrote: >>> >>> i'm being lazy heredo you have the instructions (or link to >>> instructions) from GAE for disabling indexes? i don't have it handy right >>> now >>> >>> we can check if the DAL has a secret way to handle it, and/or create a >>> patch to allow it. >>> >>> may i ask what advantage you are hoping to achieve by skipping those >>> indexes? i've left them on for fear of making a bad choice that i can't >>> revert. >>> >>> christian >>> >>> On Thursday, February 21, 2013 5:56:07 AM UTC-8, Scott Hunter wrote: >>>> >>>> As I understand it, the GAE datastore will automatically create an >>>> index for every field of every table (to facilitate queries using single >>>> fields); those requiring multiple fields also get generated, but will get >>>> added to index.yaml by the SDK when tested locally. Since these are >>>> created outside of the DAL, I wouldn't expect to be able to remove them >>>> using it. I also understand that there is a way, with the GAE SDK, to >>>> disable the index for any given field (by a parameter in the field >>>> definition); is there any way to accomplish this through the DAL, and if >>>> so, what is it? >>> >>> -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py under GAE: disabling indexes
I applied the patch, and added custom_qualifiers like so: Field('f_name', type='string',custom_qualifer={'indexed':False}, label=T('Name')), and this is the error I got: In FILE: /base/data/home/apps/s~sbhweb2py/1.365567821359373728/applications/ ppt_demo/models/db_wizard.py Traceback (most recent call last): File "/base/data/home/apps/s~sbhweb2py/1.365567821359373728/gluon/restricted.py",line 212, in restricted exec ccode in environment File "/base/data/home/apps/s~sbhweb2py/1.365567821359373728/applications/ppt_demo/models/db_wizard.py" , line 165, in label=T('Name')), TypeError: __init__() got an unexpected keyword argument 'custom_qualifer' On Saturday, February 23, 2013 12:30:48 PM UTC-5, howesc wrote: > > Scott, > > this is *completely* untested, but here's a proposal: > - use the (undocumented) field.custom_qualifier property in GAE field > definitions > - if you want a field to be unindexed set > custom_qualifier={'indexed':False} > - for "properties that don't get listed explicitly"override those > default properties with what you want (there are a few techniques for not > explicitly listing fields, depending on which technique you are using the > answer here is different. > > this patch against HG trunk this AM might work (i say might cause i have > not tested it). are you willing to experiment with it and let us know? > > thanks, > > christian > > On Friday, February 22, 2013 3:53:33 PM UTC-8, Scott Hunter wrote: >> >> If I had to guess, I'd say a patch is needed in the loop over the fields >> in create_table, that would add a new entry to the dict for the field >> definition based on a new attribute (which would be ignored for anything >> other than Google's Datastore) which gets added to sql_fields; then >> migrate_table, which seems to build the table building/altering commands >> would need to be made to recognize the new entry & add the disable index >> command. There's not a lot of comments in the code, and I'd be afraid to >> break something, but might give it a try. >> >> - Scott >> >> P.S. Not sure of the best way to handle this (what's describe above >> wouldn't handle it), but it would be nice to be able to turn off the >> indexes for the fields that don't get listed explicitly in models.db >> (things like created by & when, modified by & when). >> >> On Friday, February 22, 2013 6:14:28 PM UTC-5, howesc wrote: >>> >>> thanks for the link. i'll try and take a look this weekend and see if >>> there is a place for that in the DAL (feel free to open gluon/dal.py >>> yourself too). >>> >>> yup, i'm paying more for writes right now then i am for instance hours >>> per day on my largest paid application. :) >>> >>> cfh >>> >>> On Thursday, February 21, 2013 5:59:06 PM UTC-8, Scott Hunter wrote: >>>> >>>> According to >>>> https://developers.google.com/appengine/docs/python/datastore/indexes#Unindexed_Properties, >>>> >>>> "You declare a property unindexed by setting indexed=False in the property >>>> constructor". >>>> >>>> One incurs the cost of a write (or 2?) for every property of a record >>>> that gets written; so, for a table with about 25 fields (once you include >>>> all of the ones web2py adds), inserting 300 records incurs the cost of >>>> 14K+ >>>> writes; as the free account has a limit of 50K writes per day, that is >>>> rather limiting. It is easy to turn such indicies back on, but you have >>>> to >>>> re-write every record in order to repopulate them. >>>> >>>> - Scott >>>> >>>> On Thursday, February 21, 2013 4:51:59 PM UTC-5, howesc wrote: >>>>> >>>>> i'm being lazy heredo you have the instructions (or link to >>>>> instructions) from GAE for disabling indexes? i don't have it handy >>>>> right >>>>> now >>>>> >>>>> we can check if the DAL has a secret way to handle it, and/or create a >>>>> patch to allow it. >>>>> >>>>> may i ask what advantage you are hoping to achieve by skipping those >>>>> indexes? i've left them on for fear of making a bad choice that i can't >>>>> revert. >>>>> >>>&g
[web2py] Re: web2py under GAE: disabling indexes
Sorry about that. I've fixed it, and now I get the following: In FILE: /base/data/home/apps/s~sbhweb2py/1.365574604253984974/applications/ ppt_demo/models/db_wizard.py Traceback (most recent call last): File "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/restricted.py",line 212, in restricted exec ccode in environment File "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/applications/ppt_demo/models/db_wizard.py" , line 198, in migrate=settings.migrate) File "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/dal.py",line 7189, in define_table table = self.lazy_define_table(tablename,*fields,**args) File "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/dal.py",line 7225, in lazy_define_table polymodel=polymodel) File "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/dal.py",line 4368, in create_table ftype = self.types[field_type](**attr) TypeError: () takes no arguments (1 given) This only happens if one of the fields in question is a string; I get no error when the unindexed fields are all integer, boolean or double. - Scott On Tuesday, February 26, 2013 1:04:12 AM UTC-5, howesc wrote: > > it looks like you have a typo "custom_qualifer" vs "custom_qualifier" > > On Monday, February 25, 2013 6:44:14 PM UTC-8, Scott Hunter wrote: >> >> I applied the patch, and added custom_qualifiers like so: >> >> Field('f_name', type='string',custom_qualifer={'indexed':False}, >> label=T('Name')), >> >> >> >> and this is the error I got: >> >> In FILE: /base/data/home/apps/s~sbhweb2py/1.365567821359373728/ >> applications/ppt_demo/models/db_wizard.py >> >> >> Traceback (most recent call last): >> File >> "/base/data/home/apps/s~sbhweb2py/1.365567821359373728/gluon/restricted.py" >> , line 212, in restricted >> exec ccode in environment >> File >> "/base/data/home/apps/s~sbhweb2py/1.365567821359373728/applications/ppt_demo/models/db_wizard.py" >> , line 165, in >> label=T('Name')), >> TypeError: __init__() got an unexpected keyword argument >> 'custom_qualifer' >> >> >> >> >> On Saturday, February 23, 2013 12:30:48 PM UTC-5, howesc wrote: >>> >>> Scott, >>> >>> this is *completely* untested, but here's a proposal: >>> - use the (undocumented) field.custom_qualifier property in GAE field >>> definitions >>> - if you want a field to be unindexed set >>> custom_qualifier={'indexed':False} >>> - for "properties that don't get listed explicitly"....override those >>> default properties with what you want (there are a few techniques for not >>> explicitly listing fields, depending on which technique you are using the >>> answer here is different. >>> >>> this patch against HG trunk this AM might work (i say might cause i have >>> not tested it). are you willing to experiment with it and let us know? >>> >>> thanks, >>> >>> christian >>> >>> On Friday, February 22, 2013 3:53:33 PM UTC-8, Scott Hunter wrote: >>>> >>>> If I had to guess, I'd say a patch is needed in the loop over the >>>> fields in create_table, that would add a new entry to the dict for the >>>> field definition based on a new attribute (which would be ignored for >>>> anything other than Google's Datastore) which gets added to sql_fields; >>>> then migrate_table, which seems to build the table building/altering >>>> commands would need to be made to recognize the new entry & add the >>>> disable >>>> index command. There's not a lot of comments in the code, and I'd be >>>> afraid to break something, but might give it a try. >>>> >>>> - Scott >>>> >>>> P.S. Not sure of the best way to handle this (what's describe above >>>> wouldn't handle it), but it would be nice to be able to turn off the >>>> indexes for the fields that don't get listed explicitly in models.db >>>> (things like created by & when, modified by & when). >>>> >>>> On Friday, February 22, 2013 6:14:28 PM UTC-5, howesc wrote: >>>>> >>>>> thanks for the link. i'll try and take a look this weekend and see if >>>>> there is a place for that in the DAL (feel free to
[web2py] Re: web2py under GAE: disabling indexes
I'm working from Version 2.3.2 (2012-12-17 15:03:30) stable Here's the table in question (I've commented-out the custom_qualifier for the string fields): db.define_table('t_run', Field('f_trial', type='reference t_trial', label=T('Trial')), Field('f_when', type='date', label=T('When')), Field('f_dog', type='reference t_dog', label=T('Dog')), Field('f_name', type='string',#custom_qualifier={'indexed':False}, label=T('Name')), Field('f_breed', type='string',#custom_qualifier={'indexed':False}, label=T('Breed')), Field('f_jump_height', type='integer',custom_qualifier={'indexed':False }, label=T('Jump Height')), Field('f_level', type='string',#custom_qualifier={'indexed':False}, label=T('Level')), Field('f_class', type='string',#custom_qualifier={'indexed':False}, label=T('Class')), Field('f_pref', type='boolean',custom_qualifier={'indexed':False}, label=T('Preferred')), Field('f_armband', type='string',#custom_qualifier={'indexed':False}, label=T('Armband')), Field('f_yards', type='integer',custom_qualifier={'indexed':False}, label=T('Yards')), Field('f_sct', type='integer',custom_qualifier={'indexed':False}, label=T('SCT')), Field('f_judge', type='string',#custom_qualifier={'indexed':False}, label=T('Judge')), Field('f_score', type='integer',custom_qualifier={'indexed':False}, label=T('Score')), Field('f_time', type='double',custom_qualifier={'indexed':False}, label=T('Time')), Field('f_faults', type='string',#custom_qualifier={'indexed':False}, label=T('Faults')), Field('f_handler', type='string',#custom_qualifier={'indexed':False}, label=T('Handler')), Field('f_order', type='integer', label=T('Order')), auth.signature, format='%(f_key)s', migrate=settings.migrate) P.S. Turning off the indexes DOES make a difference; with the changes above, instead of using up over 30% of my quota, I'm "only" using 23%. If I can get the strings unindexed, and take out the web2py-supplied fields (created_by & _on, modified_by & _on, and maybe is_active), that should get it down to something manageable. (Not clear on how to handle the web2py-supplied fields, as I don't know what parameters were using in making them, making it difficult to know just how to "supply my own definitions".) On Tuesday, February 26, 2013 6:24:21 PM UTC-5, howesc wrote: > > your line numbers are off from mine so i'm having trouble making sense of > this. :( > > can you send your model definition so i can see what you are working > with? i think then i can line it up with the dal version i have here > (which was trunk from HG as of saturday AM PST) > > cfh > > On Tuesday, February 26, 2013 3:18:13 PM UTC-8, Scott Hunter wrote: >> >> Sorry about that. I've fixed it, and now I get the following: >> >> In FILE: /base/data/home/apps/s~sbhweb2py/1.365574604253984974/ >> applications/ppt_demo/models/db_wizard.py >> >> >> Traceback (most recent call last): >> File >> "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/restricted.py" >> , line 212, in restricted >> exec ccode in environment >> File >> "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/applications/ppt_demo/models/db_wizard.py" >> , line 198, in >> migrate=settings.migrate) >> File >> "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/dal.py",line >> 7189, in define_table >> table = self.lazy_define_table(tablename,*fields,**args) >> File >> "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/dal.py",line >> 7225, in lazy_define_table >> polymodel=polymodel) >> File >> "/base/data/home/apps/s~sbhweb2py/1.365574604253984974/gluon/dal.py",line >> 4368, in create_table >> ftype = self.types[field_type](**attr) >> TypeError: () takes no argumen
[web2py] Re: web2py under GAE: disabling indexes
With the latest patch, I was able to disable indices on the string fields I wanted to. Unfortunately (for me), I've just about used up my quota, so I'll have to wait until tomorrow to see how much doing so saves me. Thanks, Scott On Tuesday, February 26, 2013 8:50:29 PM UTC-5, howesc wrote: > > here's an updated DAL patch to try. > > thanks for trudging through this with us! > > cfh > > On Tuesday, February 26, 2013 3:36:30 PM UTC-8, Scott Hunter wrote: >> >> I'm working from Version 2.3.2 (2012-12-17 15:03:30) stable >> >> Here's the table in question (I've commented-out the custom_qualifier for >> the string fields): >> >> db.define_table('t_run', >> Field('f_trial', type='reference t_trial', >> label=T('Trial')), >> Field('f_when', type='date', >> label=T('When')), >> Field('f_dog', type='reference t_dog', >> label=T('Dog')), >> Field('f_name', type='string',#custom_qualifier={'indexed':False}, >> label=T('Name')), >> Field('f_breed', type='string',#custom_qualifier={'indexed':False}, >> label=T('Breed')), >> Field('f_jump_height', type='integer',custom_qualifier={'indexed': >> False}, >> label=T('Jump Height')), >> Field('f_level', type='string',#custom_qualifier={'indexed':False}, >> label=T('Level')), >> Field('f_class', type='string',#custom_qualifier={'indexed':False}, >> label=T('Class')), >> Field('f_pref', type='boolean',custom_qualifier={'indexed':False}, >> label=T('Preferred')), >> Field('f_armband', type='string',#custom_qualifier={'indexed':False}, >> label=T('Armband')), >> Field('f_yards', type='integer',custom_qualifier={'indexed':False}, >> label=T('Yards')), >> Field('f_sct', type='integer',custom_qualifier={'indexed':False}, >> label=T('SCT')), >> Field('f_judge', type='string',#custom_qualifier={'indexed':False}, >> label=T('Judge')), >> Field('f_score', type='integer',custom_qualifier={'indexed':False}, >> label=T('Score')), >> Field('f_time', type='double',custom_qualifier={'indexed':False}, >> label=T('Time')), >> Field('f_faults', type='string',#custom_qualifier={'indexed':False}, >> label=T('Faults')), >> Field('f_handler', type='string',#custom_qualifier={'indexed':False}, >> label=T('Handler')), >> Field('f_order', type='integer', >> label=T('Order')), >> auth.signature, >> format='%(f_key)s', >> migrate=settings.migrate) >> >> >> P.S. Turning off the indexes DOES make a difference; with the changes >> above, instead of using up over 30% of my quota, I'm "only" using 23%. If >> I can get the strings unindexed, and take out the web2py-supplied fields >> (created_by & _on, modified_by & _on, and maybe is_active), that should get >> it down to something manageable. (Not clear on how to handle the >> web2py-supplied fields, as I don't know what parameters were using in >> making them, making it difficult to know just how to "supply my own >> definitions".) >> >> On Tuesday, February 26, 2013 6:24:21 PM UTC-5, howesc wrote: >>> >>> your line numbers are off from mine so i'm having trouble making sense >>> of this. :( >>> >>> can you send your model definition so i can see what you are working >>> with? i think then i can line it up with the dal version i have here >>> (which was trunk from HG as of saturday AM PST) >>> >>> cfh >>> >>> On Tuesday, February 26, 2013 3:18:13 PM UTC-8, Scott Hunter wrote: >>>> >>>> Sorry about that. I've fixed it, and now I get the following: >>>> >>>> In FILE: /base/data/home/apps/s~sbhweb
[web2py] Re: web2py under GAE: disabling indexes
Sorry, I thought I had -- it works like a champ. Would be nice if there were a way to mark the signature fields as unindexed w/o having to recreate them (not as simple as cut and paste, as the table def uses a bunch of local definitions, but not hard), but definitely workable. And lowers the index overhead a LOT; in my case, from 15K to <3K. - Scott On Thursday, February 28, 2013 11:12:52 AM UTC-5, howesc wrote: > > can you let me know if it works as desired now? if so, i'll submit the > patch to massimo for review and possible inclusion in the next release of > web2py. > > thanks, > > cfh > > On Tuesday, February 26, 2013 6:31:52 PM UTC-8, Scott Hunter wrote: >> >> With the latest patch, I was able to disable indices on the string fields >> I wanted to. Unfortunately (for me), I've just about used up my quota, so >> I'll have to wait until tomorrow to see how much doing so saves me. >> >> Thanks, >> Scott >> >> On Tuesday, February 26, 2013 8:50:29 PM UTC-5, howesc wrote: >>> >>> here's an updated DAL patch to try. >>> >>> thanks for trudging through this with us! >>> >>> cfh >>> >>> On Tuesday, February 26, 2013 3:36:30 PM UTC-8, Scott Hunter wrote: >>>> >>>> I'm working from Version 2.3.2 (2012-12-17 15:03:30) stable >>>> >>>> Here's the table in question (I've commented-out the custom_qualifier >>>> for the string fields): >>>> >>>> db.define_table('t_run', >>>> Field('f_trial', type='reference t_trial', >>>> label=T('Trial')), >>>> Field('f_when', type='date', >>>> label=T('When')), >>>> Field('f_dog', type='reference t_dog', >>>> label=T('Dog')), >>>> Field('f_name', type='string',#custom_qualifier={'indexed':False}, >>>> label=T('Name')), >>>> Field('f_breed', type='string',#custom_qualifier={'indexed':False}, >>>> label=T('Breed')), >>>> Field('f_jump_height', type='integer',custom_qualifier={'indexed': >>>> False}, >>>> label=T('Jump Height')), >>>> Field('f_level', type='string',#custom_qualifier={'indexed':False}, >>>> label=T('Level')), >>>> Field('f_class', type='string',#custom_qualifier={'indexed':False}, >>>> label=T('Class')), >>>> Field('f_pref', type='boolean',custom_qualifier={'indexed':False}, >>>> label=T('Preferred')), >>>> Field('f_armband', type='string', >>>> #custom_qualifier={'indexed':False}, >>>> label=T('Armband')), >>>> Field('f_yards', type='integer',custom_qualifier={'indexed':False}, >>>> label=T('Yards')), >>>> Field('f_sct', type='integer',custom_qualifier={'indexed':False}, >>>> label=T('SCT')), >>>> Field('f_judge', type='string',#custom_qualifier={'indexed':False}, >>>> label=T('Judge')), >>>> Field('f_score', type='integer',custom_qualifier={'indexed':False}, >>>> label=T('Score')), >>>> Field('f_time', type='double',custom_qualifier={'indexed':False}, >>>> label=T('Time')), >>>> Field('f_faults', type='string', >>>> #custom_qualifier={'indexed':False}, >>>> label=T('Faults')), >>>> Field('f_handler', type='string', >>>> #custom_qualifier={'indexed':False}, >>>> label=T('Handler')), >>>> Field('f_order', type='integer', >>>> label=T('Order')), >>>> auth.signature, >>>> format='%(f_key)s', >>>> migrate=settings.migrate) >>>> >>>> >>>> P.S. Turning off the indexes DOES make a differ
[web2py] Thanks for the awesome framework/setting up PostgreSQL
Dear Massimo and the rest of the dev team, You and your team have assembled a wonderful framework here. Coming from a PHP/CakePHP background (non-professional other than some work as a web designer in the late 1990s), I decided to switch to a python- based framework and spent the past week carefully researching options. After seriously considering Django, I ended up deciding upon web2py, first and foremost because it's clear that you and your team very publically stand behind your "product". Thanks again for a wonderful tool -- it's much appreciated (and I just made a donation to the project to express my appreciation more concretely). I've started playing around with the framework on an EC2 instance, which is probably where I'll keep it for a small app I'm developing. I do have a question for the list: I'd like to set it up to work with PostgreSQL instead of SQlite. Is this the latest HOWTO on setting web2py up with PostgreSQL: http://www.web2pyslices.com/slices/take_slice/14 It looks like a very good HOWTO but I want to be sure it's current before I use it. I've got it set up on my virtual machine and I'm very familiar with SQL so it should not be too hard for me to set up the database; I just need recent documentation on setting web2py to work with it instead of sqlite. Thanks in advance for any input on guides to setting up PostgreSQL with web2py. Kind regards, Eric Eric Scott Bullington
[web2py] web2py and mercurial workflow question
I'm new to web2py but find it a vast improvement over the PHP-based web framework I was using before, and so I'm already using web2py to develop my next web app. At the same time, I find myself in a situation where I'm needing to use several different computers to do my work. See I need to find a way to keep up-to-date copies of my app on each computer (web-based admin is great for web2py but I would prefer to use an IDE). I've never used a DVCS before, but it's clear that Mercurial would be a good solution to my multi-computer problem. I'm also considering releasing the code as open source once I'm finished, so already having it on Mercurial would be an added benefit. I'm starting to play around with Mercurial and understand the basics, but I have a couple of questions about using Mercurial with web2py. 1) I've set up a system where I have a repository set up on each of my work computers, and one set up on Bitbucket to push to as the central repository. I intend to set a Mercurial repo up on my web server to pull from the bitbucket but I ran into several issues with www-data user and permissions while setting mercurial up on a server similar to what will eventually be my production server. Would using the built-in experimental mercurial feature of web2py offer a way around this problem? Or should I avoid setting up mercurial on a production server altogether? 2) I intend to use PostgreSQL for my app. Does that mean I will need to set up Postgres for each of my repos or can I just use SQLite with those? I assume this would involve appropriate use of .hgignore. Can anyone point me to a good tutorial on using Mercurial (or even Git or Bazaar) with database-driven websites? Just to be clear, I only want to use Mercurial for my own web app at the present time. I hope to contribute to web2py development in the future, once I have a better understanding of the framework and have fully transitioned from PHP to Python (which is happening much quicker than I expected). I know this is more of a Mercurial question than it is a web2py one, but given the project's use of Mercurial and its experimental integrated Mercurial feature, I thought it would not be entirely inappropriate to ask my question here. Thank you in advance. Eric
[web2py] Re: web2py and mercurial workflow question
Thank you Chris, Richard, and pbreit for your excellent input. Good to know I'm heading in the right direction. I'll definitely look into Fabric. Sounds like if I can gain some fluency in Fabric, it will allow me a lot more control over deployment. Thanks again, Eric On Aug 3, 5:40 pm, Christopher Steel wrote: > I really enjoy the mercurial / fabric combo as well and I agree with pbreit, > start with the basics and build on that over time. > > On my development system I clone Web2py itself and then in the applciations > directory I create clones of my projects as well. Makes for very fast setup. > You can save your database in a repository but things get messy really fast, > I would +1 .hgignore ing your database directory and use sqllite as well. > Sounds like you are picking up on things very quickly. Way more fun than php > and once you get past the initial curve mercurial is sweet... Use mercurial > tags to mark versions, very powerful stuff and well worth the effort. > > Have fun... > > Chris
[web2py] Follow-up on web2py, mercurial, and Fabric
Thanks again to pbreit, Chris, Richard, and any others I'm missing for answering my questions about web2py and mercurial. I'm rapidly getting used to mercurial with web2py and its working great for switching between computers. I do have a follow-up question about Fabric. Pbreit -- you're absolutely correct that Fabric is very straight-forward and easy to use. I just wanted to dig a little deeper on how you use it with Mercurial, web2py, and a central repo (like Bitbucket). Are you pulling from Bitbucket into a repo on the production server that is in a separate directory than the web directory, then using Fabric to deploy the necessary components to the web directory, minus the hg files and other unneeded stuff (e.g., /home/me/myrepo to /home/www- data/web2py/myapp)? I posted this same question to the list a few days ago, but it doesn't look like it went through (but apologies if it did). Thanks again for your input. Eric
[web2py] Problem with reference fields
I'm having problems getting tables linked in web2py using reference fields. For example, I have a model with table student and table contact. Table auth_user contains my app's users. In db.py, under db.define_table('auth_user') I have the following code to reference a one-to-many relationship between users:students and users:contacts: Field('student', db.student), Field('contact', db.contact), But I keep getting the following error: Traceback (most recent call last): File "/home/www-data/web2py/gluon/restricted.py", line 192, in restricted exec ccode in environment File "/home/www-data/web2py/applications/teachertext/models/db.py", line 61, in Field('student', db.student, File "/home/www-data/web2py/gluon/dal.py", line 4331, in __getattr__ return self[key] File "/home/www-data/web2py/gluon/dal.py", line 4325, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: 'student' I'm new to web2py (but not to frameworks) and this is my first time referencing foreign keys in a web2py app. I'm sure I'm missing something obvious but I'd be grateful if someone could point it out for me. Thank you, Eric
[web2py] Re: Problem with reference fields
Thanks for your response, Richard and Jim. Richard, the traceback is in my original message, as is the problematic part of the model code. The error occurs with any view/controller -- I can't access the app at all. The problem is definitely in the model and not the controller. The problem occurs when I insert any code into a model with the following syntax: field('fieldname", db.referenced_table) The error is revealed at the end of the traceback included in my original message: KeyError: 'student' One thing that confused me when reading the web2py book was the relatively brief time spend discussing foreign key relationships. Every other framework I've used (CakePHP and symfony) has spent at least a full chapter describing how to set up these relationships in the models. This makes me feel like I'm missing something really obvious. web2py has surprised me by letting me finish tasks that were very time consuming in other frameworks in a few lines of code, so I'm wondering if there's a really simple way to describe one-to-many and many-to-many relationships in web2py that I'm missing in the documentation. This is the syntax used for referencing many-to-one relationships in Chapter 7 of the latest web2py book, so I'm not entirely sure what I'm doing wrong. Jim, there is a many-to-one relationship between both students:users and contacts:users. I'm not sure if that's what you're asking. I've not seen the code you use anywhere in the web2py book (at least not that I recall), so I will give it a try to see if it works. Thanks again, Eric On Aug 8, 3:58 pm, Richard Vézina wrote: > If you send you controller and model code at least with trace back it could > help to troobleshoot... > > Richard > > > > > > > > On Mon, Aug 8, 2011 at 3:51 PM, Eric Scott wrote: > > I'm having problems getting tables linked in web2py using reference > > fields. For example, I have a model with table student and table > > contact. Table auth_user contains my app's users. In db.py, under > > db.define_table('auth_user') I have the following code to reference a > > one-to-many relationship between users:students and users:contacts: > > > Field('student', db.student), > > Field('contact', db.contact), > > > But I keep getting the following error: > > > Traceback (most recent call last): > > File "/home/www-data/web2py/gluon/restricted.py", line 192, in > > restricted > > exec ccode in environment > > File "/home/www-data/web2py/applications/teachertext/models/db.py", > > line 61, in > > Field('student', db.student, > > File "/home/www-data/web2py/gluon/dal.py", line 4331, in __getattr__ > > return self[key] > > File "/home/www-data/web2py/gluon/dal.py", line 4325, in __getitem__ > > return dict.__getitem__(self, str(key)) > > KeyError: 'student' > > > I'm new to web2py (but not to frameworks) and this is my first time > > referencing foreign keys in a web2py app. I'm sure I'm missing > > something obvious but I'd be grateful if someone could point it out > > for me. > > > Thank you, > > > Eric
[web2py] Re: Problem with reference fields
Thanks, Richard. Yes, I did make sure the custom auth_user was correct before I added the reference fields that caused the error. And I do have the student and contact tables defined. They were defined in the db_wizard.py file but I put all the model defs in the same db.py file, but still get the same error. I also tried changing the order of the table definitions, with student and contact coming before and after auth_user. I'm going to try a few more things and then I'll post the full model definition. Oh, and I'm using MySQL. I was trying PostgreSQL but being a long time MySQL user the change in syntax was too jarring in combination with all the other changes I've made recently (ie, PHP to python, CakePHP to web2py, etc.), so I switched back to MySQL for the time being. Thanks again for all your input. Eric On Aug 8, 4:46 pm, Richard Vézina wrote: > Without the whole model it is difficult to clearly understand what you are > trying to acheive... > > You add those line to auth_user that you have customized?? > > Field('student', db.student), # = one to many > Field('contact', db.contact), # idem > > It could depend of your backend database if it support FK... > > If you had customized the auth_user table... Before add you FK field (the > ones above), try to make sure your custom auth_user is correct then add your > custom field one after one... > > Richard > > > > > > > > On Mon, Aug 8, 2011 at 4:33 PM, Eric Scott wrote: > > Thanks for your response, Richard and Jim. Richard, the traceback is > > in my original message, as is the problematic part of the model code. > > The error occurs with any view/controller -- I can't access the app at > > all. The problem is definitely in the model and not the controller. > > The problem occurs when I insert any code into a model with the > > following syntax: > > > field('fieldname", db.referenced_table) > > > The error is revealed at the end of the traceback included in my > > original message: > > > KeyError: 'student' > > > One thing that confused me when reading the web2py book was the > > relatively brief time spend discussing foreign key relationships. > > Every other framework I've used (CakePHP and symfony) has spent at > > least a full chapter describing how to set up these relationships in > > the models. This makes me feel like I'm missing something really > > obvious. web2py has surprised me by letting me finish tasks that were > > very time consuming in other frameworks in a few lines of code, so I'm > > wondering if there's a really simple way to describe one-to-many and > > many-to-many relationships in web2py that I'm missing in the > > documentation. > > > This is the syntax used for referencing many-to-one relationships in > > Chapter 7 of the latest web2py book, so I'm not entirely sure what I'm > > doing wrong. > > > Jim, there is a many-to-one relationship between both students:users > > and contacts:users. I'm not sure if that's what you're asking. I've > > not seen the code you use anywhere in the web2py book (at least not > > that I recall), so I will give it a try to see if it works. > > > Thanks again, > > > Eric > > > On Aug 8, 3:58 pm, Richard Vézina wrote: > > > If you send you controller and model code at least with trace back it > > could > > > help to troobleshoot... > > > > Richard > > > > On Mon, Aug 8, 2011 at 3:51 PM, Eric Scott > > wrote: > > > > I'm having problems getting tables linked in web2py using reference > > > > fields. For example, I have a model with table student and table > > > > contact. Table auth_user contains my app's users. In db.py, under > > > > db.define_table('auth_user') I have the following code to reference a > > > > one-to-many relationship between users:students and users:contacts: > > > > > Field('student', db.student), > > > > Field('contact', db.contact), > > > > > But I keep getting the following error: > > > > > Traceback (most recent call last): > > > > File "/home/www-data/web2py/gluon/restricted.py", line 192, in > > > > restricted > > > > exec ccode in environment > > > > File "/home/www-data/web2py/applications/teachertext/models/db.py", > > > > line 61, in > > > > Field('student', db.student, > > > > File "/home/www-data/web2py/gluon/dal.py", line 4331, in __getattr__ > > > > return self[key] > > > > File "/home/www-data/web2py/gluon/dal.py", line 4325, in __getitem__ > > > > return dict.__getitem__(self, str(key)) > > > > KeyError: 'student' > > > > > I'm new to web2py (but not to frameworks) and this is my first time > > > > referencing foreign keys in a web2py app. I'm sure I'm missing > > > > something obvious but I'd be grateful if someone could point it out > > > > for me. > > > > > Thank you, > > > > > Eric
[web2py] Re: Follow-up on web2py, mercurial, and Fabric
Thanks Richard and pbreit for your input. pbreit -- what you describe is similar to what I was thinking of. And yes, it would be nice if there were a standardized way to do this. Richard, since Bitbucket is acting as my central repo, I'll need to pull from bitbucket to the production server. But you're correct that it doesn't need to be under VC on the server. Thanks again to both of you for your input. On Aug 8, 4:54 pm, pbreit wrote: > I actually just have a regular repo on the production server and do an "hg > pull; hg update". I'm not sure if that's the best approach but it has worked > so far on my low volume site. But I can see that there could be issues and I > suspect that is why many people update to other locations and then set sym > links (or whatever). > > I would be happy to hear suggestions for improvement.
[web2py] Form radio buttons from db with image - how to select "checked"?
I'm new to both Python and web2py and am having difficulty coding a web2py radio form where each input field displays a name and an image. One (and only one) of these images should be set as the user's default image. I'm having trouble figuring out how to do this in web2py. I was able to produce the dict and then loop through to list them accordingly: CONTROLLER: @auth.requires_login() def show_cards(): records = db((db.card.owner == session.auth.user.id) | (db.card.is_active == True)).select() user = db(db.auth_user.id == session.auth.user.id).select() return dict(records=records,user=user) VIEW (show_cards.html): {{for record in records:}} {{pass}} MODEL: db.define_table('auth_user', Field('id','id'), Field('username', type='string', label=T('Username')), Field('password', type='password', readable=False, label=T('Password')), Field('default_card', 'reference card') db.define_table('card', Field('id','id'), Field('image', 'upload', uploadfield='image_file',label=T('Image')), Field('image_file', 'blob'), Field('nick',label=T('Nickname')), Field('owner', db.auth_user), Field('is_active','boolean',default=False, label=T('Active')), The problem now is, I have no idea how to structure the view so that "checked=checked" is printed if the card value is equal to the owner's default value. I know it's going to involve a nested "if" clause, but I'm not sure how to do this in a view. Something like: "{{if record.id == user.auth_user.default_card: print 'checked="checked''}}" How should I include this in the code? I've not yet seen how to format nested logic in a view. I also think that I could do this with a widget, but the more I read on radio buttons and widgets, the more lost I become. I know there are probably much better ways to do this, but this is all I could hack together. Any guidance would be greatly appreciated, even if it's just a pointer in the right direction. Thanks in advance for your help. Eric
[web2py] Re: Janrain/site login
Thank you, Anthony. I've read the manual and looked for info before asking the question, but I obviously missed that. Thank you for pointing it out. Eric On Aug 22, 9:39 am, Anthony wrote: > See the Multiple Login Forms section at the end of this > section:http://web2py.com/book/default/chapter/08#Other-Login-Methods-and-Log > There's also this:http://www.web2pyslices.com/slices/take_slice/124. > > Anthony > > > > > > > > On Monday, August 22, 2011 8:30:18 AM UTC-4, Eric Scott wrote: > > Is there anyway to use both Janrain and give users to option to register > > for a local account using Auth? I've looked and looked and can't find > > anything. I can get my app to let users register for a local account, but > > then I can't find anyway to include that option on the login page in > > addition to the Janrain frame. > > > Also, does Janrain load very slow for others? I've not been impressed by > > their download speeds. When setting up Janrain, I just put in my Janrain > > domain name and API key in the appropriate place, and enabled Janrain. Am I > > missing something. Is there something else I need to do to make it run > > faster? Like cache the graphics on the user's machine? > > > Thank you, > > > Eric
[web2py] Problems running a module in web2py shell
I'm having trouble running a module in the web2py shell. It's having difficulty with a db query that I execute with no problems in any controller. Here's the traceback: Traceback (most recent call last): File "", line 1, in File "/home/www-data/web2py/gluon/custom_import.py", line 280, in __call__ fromlist, level) File "/home/www-data/web2py/gluon/custom_import.py", line 74, in __call__ level) File "applications/baristacode/modules/real_addcard.py", line 37, in rows = db(db.card.number==cardnum).select() File "/home/www-data/web2py/gluon/dal.py", line 4331, in __getattr__ return self[key] File "/home/www-data/web2py/gluon/dal.py", line 4325, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: 'card' >>> I use "python web2py.py -S app -M" and I always check to be sure the db is available in the shell, as well as the models. I'm also able to execute the query by itself in the shell, but when it's in a module, I get the KeyError above. I've tried importing the module and using execfile, and in both cases the script runs fine until the first db query. Any hints or suggestions? Thank you, Eric
[web2py] Re: Problems running a module in web2py shell
you mean include 'print db.tables' in the script? if you mean run 'print db.tables' in the shell to test my connection to the db, I've done that and it shows all my tables, until I run the script. At that point, I can no longer access the tables in the shell. I did read in an external site about web2py crontab that all cron scripts should have "db.commit()" at the end of each function with a query, so perhaps that's what's happening. On Aug 24, 12:33 pm, Massimo Di Pierro wrote: > try print db.tables > > On Aug 24, 10:55 am, Eric Scott wrote: > > > > > > > > > I'm having trouble running a module in the web2py shell. It's having > > difficulty with a db query that I execute with no problems in any > > controller. Here's the traceback: > > > Traceback (most recent call last): > > File "", line 1, in > > File "/home/www-data/web2py/gluon/custom_import.py", line 280, in > > __call__ > > fromlist, level) > > File "/home/www-data/web2py/gluon/custom_import.py", line 74, in > > __call__ > > level) > > File "applications/baristacode/modules/real_addcard.py", line 37, in > > > > rows = db(db.card.number==cardnum).select() > > File "/home/www-data/web2py/gluon/dal.py", line 4331, in __getattr__ > > return self[key] > > File "/home/www-data/web2py/gluon/dal.py", line 4325, in __getitem__ > > return dict.__getitem__(self, str(key)) > > KeyError: 'card' > > > I use "python web2py.py -S app -M" and I always check to be sure the > > db is available in the shell, as well as the models. I'm also able to > > execute the query by itself in the shell, but when it's in a module, I > > get the KeyError above. > > > I've tried importing the module and using execfile, and in both cases > > the script runs fine until the first db query. > > > Any hints or suggestions? > > > Thank you, > > > Eric
[web2py] Passing web2py command line parameters when using apache/mod_wsgi
How to I pass command line parameters to web2py when I'm not starting web2py from the command line. I'm using apache and mod_wsgi. I've looked closely at the documentation, and there's a section on how to pass parameters when it's running as a windows service, but the documentation is clear that this only works when it's running as a windows service. I've found an external site that mentions that it's possible to pass command line parameters when using mod_wsgi, but it doesn't explain how. Also, is there a way to check my web2py parameters when I'm running it on apache? Thank you in advance. Eric
[web2py] Changed field name in table def, database OK, but getting key error
I'm using postgresql. I had to change a field name in my table def, which are in the web2py models. The database changed accordingly, but now I get a key error when I try to insert a new record using appadmin. I made sure appadmin.py is the latest and greatest. Still getting key error. I don't dare drop the db since each time I've done that before I've not been able to get it running again, no matter how many variations of migrate and fake_migrate I tried. So end up having to re-create the app, and then copy in the files, which takes a long time. I love web2py but database issues are driving me nuts. Can someone please help me? My app is so close to finished. Here's the traceback Traceback (most recent call last): File "/home/www-data/web2py/gluon/restricted.py", line 192, in restricted exec ccode in environment File "/home/www-data/web2py/applications/baristacode/controllers/ appadmin.py", line 411, in File "/home/www-data/web2py/gluon/globals.py", line 145, in self._caller = lambda f: f() File "/home/www-data/web2py/applications/baristacode/controllers/ appadmin.py", line 126, in insert form = SQLFORM(db[table], ignore_rw=ignore_rw) File "/home/www-data/web2py/gluon/sqlhtml.py", line 830, in __init__ inp = self.widgets.options.widget(field, default) File "/home/www-data/web2py/gluon/sqlhtml.py", line 218, in widget options = requires[0].options() File "/home/www-data/web2py/gluon/validators.py", line 438, in options self.build_set() File "/home/www-data/web2py/gluon/validators.py", line 421, in build_set fields = [self.dbset.db[self.ktable][k] for k in self.fields] File "/home/www-data/web2py/gluon/dal.py", line 4675, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: 'name_string' By the way, I changed the field name from "name_string" to "name". Somewhere, "name_string" is still cached. I just can't figure out where. I've cleared the caches, restarted, etc etc. Thanks in advance for your help. Eric
[web2py] Re: Changed field name in table def, database OK, but getting key error [SOLVED]
Perfect! This thread solved at least one major headache, and perhaps another even greater headache. Massimo, I'm embarrassed I had not tried grep. It worked. I found the string in the db_wizard_populate.py file. I used the wizard to quickly recreate my app's database structure when I couldn't get the migrate to work. And speaking of problems migrating, Richard may have provided me with the missing info I needed for migration. I knew that it was the auth tables that were problematic, but I was so busy trying to mix up migrate and fake_migrate True settings that I never thought to set them to migrate=False. I'll try that next time and see if it works. If that is a known issue, it would be nice to mention it in the next ed. of the book, next to the mysql migrate issues. Thanks to both of you. Now if I could only figure out how to set web2py command line parameters when using apache/mod_wsgi... Eric On Aug 25, 3:03 pm, Richard Vézina wrote: > Hello Eric, > > I would help, but I have no clue... > > Do you alternate between SQLite and Postgres? If yes, web2py always try to > recreate the auth(s) tables that is a problem I often have... To solve it > you must define the auth(s) tables in the db.py and set them to > migrate=false... so web2py stop to trigger their creation each time... > > Richard > > On Thu, Aug 25, 2011 at 1:53 PM, Eric Scott wrote: > > > > > > > > > I'm using postgresql. I had to change a field name in my table def, > > which are in the web2py models. The database changed accordingly, but > > now I get a key error when I try to insert a new record using > > appadmin. I made sure appadmin.py is the latest and greatest. Still > > getting key error. I don't dare drop the db since each time I've done > > that before I've not been able to get it running again, no matter how > > many variations of migrate and fake_migrate I tried. So end up having > > to re-create the app, and then copy in the files, which takes a long > > time. > > > I love web2py but database issues are driving me nuts. Can someone > > please help me? My app is so close to finished. > > > Here's the traceback > > > Traceback (most recent call last): > > File "/home/www-data/web2py/gluon/restricted.py", line 192, in > > restricted > > exec ccode in environment > > File "/home/www-data/web2py/applications/baristacode/controllers/ > > appadmin.py", line 411, in > > File "/home/www-data/web2py/gluon/globals.py", line 145, in > > self._caller = lambda f: f() > > File "/home/www-data/web2py/applications/baristacode/controllers/ > > appadmin.py", line 126, in insert > > form = SQLFORM(db[table], ignore_rw=ignore_rw) > > File "/home/www-data/web2py/gluon/sqlhtml.py", line 830, in __init__ > > inp = self.widgets.options.widget(field, default) > > File "/home/www-data/web2py/gluon/sqlhtml.py", line 218, in widget > > options = requires[0].options() > > File "/home/www-data/web2py/gluon/validators.py", line 438, in > > options > > self.build_set() > > File "/home/www-data/web2py/gluon/validators.py", line 421, in > > build_set > > fields = [self.dbset.db[self.ktable][k] for k in self.fields] > > File "/home/www-data/web2py/gluon/dal.py", line 4675, in __getitem__ > > return dict.__getitem__(self, str(key)) > > KeyError: 'name_string' > > > By the way, I changed the field name from "name_string" to "name". > > Somewhere, "name_string" is still cached. I just can't figure out > > where. I've cleared the caches, restarted, etc etc. > > > Thanks in advance for your help. > > > Eric