Re: [web2py] Re: Hide Error on SQLFORM
There is no possible way it can. Looking through the source code, it never passes along the extra attributes to anything. The current way the widgets are implemented never use attributes passed to them. -- Thadeus On Tue, Jul 27, 2010 at 4:13 AM, mdipierro mdipie...@cs.depaul.edu wrote: I am surprised it does not. can you help debug. Try form.errors.clear() On Jul 27, 2:29 am, Thadeus Burgess thade...@thadeusb.com wrote: I don't get it SQLFORM.factory(Field., hideerror=True). It doesn't do what its supposed to. How can I make sure that none of my widgets render errors alongside their own INPUT elements without rewriting everything in sqlhtml? -- Thadeus
Re: [web2py] Re: Hide Error on SQLFORM
This has been a problem for quite some time, I just did not get around to complaining about it again until now =) If I am to use a custom form (which I almost always do). Then I can't have my form elements going off and rendering their own errors now can I? Not very enterprisey of SQLFORM to just assume I want to always display errors automatically. -- Thadeus On Tue, Jul 27, 2010 at 5:04 AM, mdipierro mdipie...@cs.depaul.edu wrote: It is the INPUT widget that upon serialization displays the errors. I can see it may be a problem with custom widgets. On Jul 27, 4:42 am, Thadeus Burgess thade...@thadeusb.com wrote: There is no possible way it can. Looking through the source code, it never passes along the extra attributes to anything. The current way the widgets are implemented never use attributes passed to them. -- Thadeus On Tue, Jul 27, 2010 at 4:13 AM, mdipierro mdipie...@cs.depaul.edu wrote: I am surprised it does not. can you help debug. Try form.errors.clear() On Jul 27, 2:29 am, Thadeus Burgess thade...@thadeusb.com wrote: I don't get it SQLFORM.factory(Field., hideerror=True). It doesn't do what its supposed to. How can I make sure that none of my widgets render errors alongside their own INPUT elements without rewriting everything in sqlhtml? -- Thadeus
Re: [web2py] Re: Hide Error on SQLFORM
perfect. Thanks Massimo! I owe you one. -- Thadeus On Tue, Jul 27, 2010 at 7:32 AM, mdipierro mdipie...@cs.depaul.edu wrote: I looked into it. What you are trying to do was never supported. hideerror was a machanism for allowing certain custom widgets to explicitly hide error or decide where to display them. I say was because I just implemented it the way *I think* you expect it to work. Works with custom forms as well. if form.accepts(,hideerror=True): On Jul 27, 6:50 am, mdipierro mdipie...@cs.depaul.edu wrote: Until this is resolved this is how I usually handle the situation. form=SQLFORM() if form.accepts() errors,form.errors=form.errors,{} return dict(form=form,errors=form) Unless you do this the philosophy is that widgets handle their own errors and they can be customized by overriding .xml(). On Jul 27, 6:00 am, Thadeus Burgess thade...@thadeusb.com wrote: This has been a problem for quite some time, I just did not get around to complaining about it again until now =) If I am to use a custom form (which I almost always do). Then I can't have my form elements going off and rendering their own errors now can I? Not very enterprisey of SQLFORM to just assume I want to always display errors automatically. -- Thadeus On Tue, Jul 27, 2010 at 5:04 AM, mdipierro mdipie...@cs.depaul.edu wrote: It is the INPUT widget that upon serialization displays the errors. I can see it may be a problem with custom widgets. On Jul 27, 4:42 am, Thadeus Burgess thade...@thadeusb.com wrote: There is no possible way it can. Looking through the source code, it never passes along the extra attributes to anything. The current way the widgets are implemented never use attributes passed to them. -- Thadeus On Tue, Jul 27, 2010 at 4:13 AM, mdipierro mdipie...@cs.depaul.edu wrote: I am surprised it does not. can you help debug. Try form.errors.clear() On Jul 27, 2:29 am, Thadeus Burgess thade...@thadeusb.com wrote: I don't get it SQLFORM.factory(Field., hideerror=True). It doesn't do what its supposed to. How can I make sure that none of my widgets render errors alongside their own INPUT elements without rewriting everything in sqlhtml? -- Thadeus
Re: [web2py] Re: Hide Error on SQLFORM
If I need to use a workaround to perform the most basic needs of a system, then that system is flawed to begin with. A form system, by its very nature of what it is, should require 100% customization ability without ugly, undocumented hacks. -- Thadeus On Tue, Jul 27, 2010 at 9:53 PM, Iceberg iceb...@21cn.com wrote: nk the former is straightforward. form=SQLFOR
[web2py] table migration metadata storage location
When migrate = False and fake_migrate = False the .table files are not even read from the filesystem, meaning they do not technically *need* to exist to run your application. Running code on production always uses migrate = False except for when I run migration scripts which allow the DAL to perform table updates. Only the migration script needs access to the .table files. The question is then, should the .table files used for the production server be version controlled? If so, should it be in the same repository as the code, or in its own repository just storing the migration data? Where is the proper location for these .table files be stored. I have multiple web2py apps that use the same database, and therefore share .table files, so they need to exist in a app-agnostic location. Is the project folder the proper place for this, or something like /metadata/pms/migration/ ? The DAL instance exist in a module, therefore any request contexts will not be available. I'm just curious on what others thoughts are on this. -- Thadeus
Re: [web2py] IS_IN_SET syntax
db.candidate.for_language.requires = IS_IN_SET(['english', 'french', 'german'], zero=None) If you notice how web2py will put a blank option in the drop down? the zero attribute of IS_IN_SET or IS_IN_DB will control the value of that first dropdown option. To completely rid yourself of the bank option, you set zero to null, making the first value of the dropdown the default selected. -- Thadeus On Mon, Jul 26, 2010 at 3:36 PM, sarsar sarsara...@gmail.com wrote: Hi all, Please help me with the syntax of dropdown selection , because i' ve read a lot of answers and sugestions, AND the book , and i cant find how to do this simple thing . db.candidate.for_language.requires=IS_IN_SET(['english','french','german']),default='english' using crud to update the form , i expect that there is no blanc at selection and having english as default even if the user doesnot choose any selection . I have read a lot of questions , a lot of sugestions , from a lot of people , i think i checked inside the online book, but there is no clear syntax explanation about this iam asking , specially about the default value , even if the user does not make a choise . Please forgive me if it is something obvious . Sarados
Re: [web2py] Re: book revision
IS_IN_SET zero changes and how they work and why it is that way now. -- Thadeus On Mon, Jul 26, 2010 at 11:20 PM, Iceberg iceb...@21cn.com wrote: On Jul 24, 5:53am, mdipierro mdipie...@cs.depaul.edu wrote: I am revising the book. Please list what features are not mentioned in the book or deserve more space they correctly get. You suggestions will be appreciated. Massimo Not sure whether is already mentioned in this 30-post thread, anyway please include the parse html feature. Currently a post is available here. http://web2py.com/AlterEgo/default/show/266 Iceberg
Re: [web2py] dynamic urls or catch-all controllers
I would use a routes_in that would redirect to a single function which would then look at the arguments of the path to determine what to do =/ -- Thadeus On Sun, Jul 25, 2010 at 2:47 PM, Andrew Thompson andre...@aktzero.com wrote: If I wanted to create pages like /about /contact /asdf1 /asdf2 /asdf3, how's the best way to have web2py capture and process them without building controllers for each page? I'd prefer to capture the urls early and internally redirect them to /content/about or wherever my database tells me the url really lives. I'd rather not create routes_in entries for them all(I'm still not reliable at making routes_* work). Am I going about this the wrong way? I'm capable of searching, if I know what feature/function/module I should be looking for, so any pointers happily accepted. Thanks. -- Andrew Thompson http://aktzero.com/
Re: [web2py] Re: book revision
Update the deployment section. I never got the instructions in the book to work without tweaking, so I think it needs some fine tuning and references to web2pyslices slice 14, 29, 33, 36, 57, 64 -- Thadeus On Sun, Jul 25, 2010 at 5:27 PM, howesc how...@umich.edu wrote: I use google app engine a lot, and would love to have mention in the main content of the book when features won't work on GAE. some are now, and others are only in the GAE section at the end. also not everything in http://groups.google.com/group/web2py/browse_thread/thread/cd89f11de4d23b53/f67faac66a695ca2?lnk=gstq=google+app+engine+production#f67faac66a695ca2 has made it to the code, so those tips would be nice in the book (especially the caching of wsgihandler.py - it saves 90% of the execution time for a simple page). http://www.web2py.com/AlterEgo/default/show/248 would be great in the book as well. thanks! cfh
Re: [web2py] advice on ListProperty
Yes. Just go the extra half a mile and add it for every database that will use a table behind the scenes. -- Thadeus On Sun, Jul 25, 2010 at 6:17 PM, mdipierro mdipie...@cs.depaul.edu wrote: GAE has a ListPropery and IS_IN_DB(...,multiple=True) does not use it but uses '|2|34|45|' instead for portability over relational databases and GAE. Should there be a web2py type 'list' that hides all of this and uses ListProperty on GAE and provides simpler query syntax in this case? Massimo
Re: [web2py] Re: Recent change to string escaping breaks dynamic javascript
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 mdipie...@cs.depaul.edu 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. script type=text/javascript /* ![CDATA[ */ $(#{{=ks+kc}}).sparkline(data.wsc.{{=ks}}.{{=kc}}, {{=XML(schartoptions)}} /script If not, what are chartmin and chartmax, are they themselves helpers? On Jul 24, 7:28 am, Michael Ellis michael.f.el...@gmail.com 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 mdipie...@cs.depaul.edu 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 michael.f.el...@gmail.com 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 make the rendering code smart enough to always distinguish js from html strings. Just a thought, Mike On Sat, Jul 24, 2010 at 4:02 AM, mdipierro mdipie...@cs.depaul.edu wrote: Thadeus, This was a security fix. We had a a security review and this was determined to be a weakness. The code by Mike Ellis broke not because of the fix but because it incorrectly implicitly assumed that the strings were HTML/XML and therefore needed escaping when, in reality, they were JS strings. If we had a review board, would you have opposed to this change? Massimo On Jul 23, 5:28 pm, Thadeus Burgess thade...@thadeusb.com wrote: I also agree that this is a break in backwards compatibility. It is also a change that was never considered for longer than 15 minutes before the decision to make the change was implemented. I really wish we would put certain things such as this under a review board so they don't get into web2py and break things! -- Thadeus On Fri, Jul 23, 2010 at 2:33 PM, MikeEllis michael.f.el...@gmail.com wrote: Typo: 2 sentence in prior message should read ... after XML() supplies the unescaped string. On Jul 23, 3:28 pm, Michael Ellis michael.f.el...@gmail.com wrote: Urgh! FWIW, putting XML() around the strings doesn't seem to work. Looks like the escaping is applied after XML() supplies the unquoted string. I tried {{ for optstring in (schartoptions, countpieoptions, cchartoptions): optstring = XML(optstring) debug(opstring=%s%optstring) pass}} after assigning the strings and before they are used in inside the script tags. The debug() calls show the strings with the single quotes unescaped, but they still end up being escaped in what gets sent to browser. On Fri, Jul 23, 2010 at 2:16 PM, Michael Ellis michael.f.el...@gmail.comwrote: Thanks, Nathan. That's certainly a possibility. It's just that I'm not sure what security issue this change actually fixes. There are no user-supplied strings in what I'm using to generate ... read more »
Re: [web2py] Re: global name 'MySQLdb' is not define d
Perhaps WSGI is configured to use python 2.4 and the libraries are not linked correctly. -- Thadeus On Sat, Jul 24, 2010 at 10:58 AM, oktay onur.ok...@gmail.com wrote: Yes, it works with import MySQLdb at the top of web2py.py: web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2010 Version 1.81.5 (2010-07-22 23:56:21) Database drivers available: MySQL Starting hardcron... WARNING:root:GUI not available because Tk library is not installed On 24 Temmuz, 18:52, mdipierro mdipie...@cs.depaul.edu wrote: As a test, can you try add import MySQLdb at the top of web2py.py and run python2.6 web2py.py Massimo On Jul 24, 10:46 am, oktay onur.ok...@gmail.com wrote: Hello, I am trying to install web2py with apache mysql. I checked all the scenarios with the global name 'MySQLdb' is not defined subject, but they didn't solve my problem. I am using: CentOS 5.5 httpd-2.2.3 mysql 5.0.77 Python26 MySQL-python-1.2.3c1 web2py Version 1.81.5 Default CentOS 5 python version is 2.4, I installed 2.6. I can both import MySQLdb from python24 python26 from console. When I run web2py from source like python ./web2py.py or with python26 ./web2py.py I can see Database drivers available: MySQL I think there is a configuration problem with the python libraries I installed. Do you have any idea? Here is the trace: --- Traceback (most recent call last): File gluon/restricted.py, line 178, in restricted exec ccode in environment File /var/www/web2py/applications/welcome/models/db.py, line 1, in module db=SQLDB('mysql://xxx:y...@zzz:3306/aaa') File gluon/sql.py, line 921, in __init__ self._pool_connection(lambda : MySQLdb.Connection( File gluon/sql.py, line 828, in _pool_connection self._connection = f() File gluon/sql.py, line 921, in lambda self._pool_connection(lambda : MySQLdb.Connection( NameError: global name 'MySQLdb' is not defined
Re: [web2py] Re: Recent change to string escaping breaks dynamic javascript
I don't know enough about the problem to say if I would support or oppose this change. I also agree that a template symbol is easier than having to wrap the entirety around a function. -- Thadeus On Sat, Jul 24, 2010 at 3:02 AM, mdipierro mdipie...@cs.depaul.edu wrote: ad a review board, would you have opp
Re: [web2py] Re: Recent change to string escaping breaks dynamic javascript
I also agree that this is a break in backwards compatibility. It is also a change that was never considered for longer than 15 minutes before the decision to make the change was implemented. I really wish we would put certain things such as this under a review board so they don't get into web2py and break things! -- Thadeus On Fri, Jul 23, 2010 at 2:33 PM, MikeEllis michael.f.el...@gmail.comwrote: Typo: 2 sentence in prior message should read ... after XML() supplies the unescaped string. On Jul 23, 3:28 pm, Michael Ellis michael.f.el...@gmail.com wrote: Urgh! FWIW, putting XML() around the strings doesn't seem to work. Looks like the escaping is applied after XML() supplies the unquoted string. I tried {{ for optstring in (schartoptions, countpieoptions, cchartoptions): optstring = XML(optstring) debug(opstring=%s%optstring) pass}} after assigning the strings and before they are used in inside the script tags. The debug() calls show the strings with the single quotes unescaped, but they still end up being escaped in what gets sent to browser. On Fri, Jul 23, 2010 at 2:16 PM, Michael Ellis michael.f.el...@gmail.comwrote: Thanks, Nathan. That's certainly a possibility. It's just that I'm not sure what security issue this change actually fixes. There are no user-supplied strings in what I'm using to generate the jQuery calls. If that were the case, then yes it would definitely be my responsibility to properly sanitize it. Have to say this feels like a loss of backward compatibility to me. I've got a fair amount of code in this app that uses that technique; it's already inherently messy because of the indirection involved in code generation. Wrapping it all in XML calls just adds to the mess. Hope there's a way to refine the security fix so that it's confined to the areas that matter. Cheers, Mike On Fri, Jul 23, 2010 at 1:56 PM, mr.freeze nat...@freezable.com wrote: It was probably introduced as a security fix. You can do: {{ schartoptions = XML({ type: 'bar', barColor: 'green', chartRangeMin: '%d', chartRangeMax: '%d' } %(chartmin,chartmax)) }} and it won't be escaped. On Jul 23, 12:39 pm, Michael Ellis michael.f.el...@gmail.com wrote: I've got an app with views that generate jQuery code on the fly. This was all working fine until recently, i.e. sometime after 1.92. With more recent builds, single and double quotes in strings are now escaped and it breaks the javascript. Here's an example The view has (with much snipped out): {{ schartoptions = { type: 'bar', barColor: 'green', chartRangeMin: '%d', chartRangeMax: '%d' } %(chartmin,chartmax) }} and later on I use the variables within a script tag, e.g. script type=text/javascript /* ![CDATA[ */ $(#{{=ks+kc}}).sparkline(data.wsc.{{=ks}}.{{=kc}}, {{=schartoptions}} /script With an earlier web2py, it produces the desired result, $(#solution0).sparkline(data.s.solution0, { type: 'bar', barColor: 'green', chartRangeMin: '0', chartRangeMax: '1' } ); but now (at tip) I get $(#solution0).sparkline(data.s.solution0, { type: #x27;bar#x27;, barColor: #x27;green#x27;, chartRangeMin: #x27;0#x27;, chartRangeMax: #x27;1#x27; } ); Was this change intentional? If so, what's the recommended workaround? Thanks, Mike
Re: [web2py] Re: Recent change to string escaping breaks dynamic javascript
Also, I don't have time to read every google group posting anymore. This may have been suggested in a thread that was buried from those who just scan the post titles. Changes like this need to be called out, we need some way of being able to review and vote for certain changes something like uservoice but for bugfixes. -- Thadeus On Fri, Jul 23, 2010 at 5:31 PM, mr.freeze nat...@freezable.com wrote: There was talk of a week long RC period for all releases unless there was an important bug fix but we seem to have reverted to old habits. On Jul 23, 5:28 pm, Thadeus Burgess thade...@thadeusb.com wrote: I also agree that this is a break in backwards compatibility. It is also a change that was never considered for longer than 15 minutes before the decision to make the change was implemented. I really wish we would put certain things such as this under a review board so they don't get into web2py and break things! -- Thadeus On Fri, Jul 23, 2010 at 2:33 PM, MikeEllis michael.f.el...@gmail.com wrote: Typo: 2 sentence in prior message should read ... after XML() supplies the unescaped string. On Jul 23, 3:28 pm, Michael Ellis michael.f.el...@gmail.com wrote: Urgh! FWIW, putting XML() around the strings doesn't seem to work. Looks like the escaping is applied after XML() supplies the unquoted string. I tried {{ for optstring in (schartoptions, countpieoptions, cchartoptions): optstring = XML(optstring) debug(opstring=%s%optstring) pass}} after assigning the strings and before they are used in inside the script tags. The debug() calls show the strings with the single quotes unescaped, but they still end up being escaped in what gets sent to browser. On Fri, Jul 23, 2010 at 2:16 PM, Michael Ellis michael.f.el...@gmail.comwrote: Thanks, Nathan. That's certainly a possibility. It's just that I'm not sure what security issue this change actually fixes. There are no user-supplied strings in what I'm using to generate the jQuery calls. If that were the case, then yes it would definitely be my responsibility to properly sanitize it. Have to say this feels like a loss of backward compatibility to me. I've got a fair amount of code in this app that uses that technique; it's already inherently messy because of the indirection involved in code generation. Wrapping it all in XML calls just adds to the mess. Hope there's a way to refine the security fix so that it's confined to the areas that matter. Cheers, Mike On Fri, Jul 23, 2010 at 1:56 PM, mr.freeze nat...@freezable.com wrote: It was probably introduced as a security fix. You can do: {{ schartoptions = XML({ type: 'bar', barColor: 'green', chartRangeMin: '%d', chartRangeMax: '%d' } %(chartmin,chartmax)) }} and it won't be escaped. On Jul 23, 12:39 pm, Michael Ellis michael.f.el...@gmail.com wrote: I've got an app with views that generate jQuery code on the fly. This was all working fine until recently, i.e. sometime after 1.92. With more recent builds, single and double quotes in strings are now escaped and it breaks the javascript. Here's an example The view has (with much snipped out): {{ schartoptions = { type: 'bar', barColor: 'green', chartRangeMin: '%d', chartRangeMax: '%d' } %(chartmin,chartmax) }} and later on I use the variables within a script tag, e.g. script type=text/javascript /* ![CDATA[ */ $(#{{=ks+kc}}).sparkline(data.wsc.{{=ks}}.{{=kc}}, {{=schartoptions}} /script With an earlier web2py, it produces the desired result, $(#solution0).sparkline(data.s.solution0, { type: 'bar', barColor: 'green', chartRangeMin: '0', chartRangeMax: '1' } ); but now (at tip) I get $(#solution0).sparkline(data.s.solution0, { type: #x27;bar#x27;, barColor: #x27;green#x27;, chartRangeMin: #x27;0#x27;, chartRangeMax: #x27;1#x27; } ); Was this change intentional? If so, what's the recommended workaround? Thanks, Mike
Re: [web2py] Sorting alphanumeric data
It is possible to create SQL functions that will represent your natural sort. You can use db.executesql() to call the function. Read the following comments in the below link for examples on performing this with postgresql. http://www.postgresql.org/docs/8.0/interactive/queries-order.html -- Thadeus On Fri, Jul 23, 2010 at 8:01 PM, Jonathan Lundell jlund...@pobox.com wrote: On Jul 23, 2010, at 5:39 PM, DJ wrote: I have sorting problem with a column in the database (string) that stores alphanumeric data. The data is A1, A2, A3..A10, A11, A12. When I sort by column type, I get A1, A10, A11, A12 but I would like to get A1, A2, A3...A10, A11, A12. Is there anything I can try with orderby=columntype? What other kind of operations does orderby allow? (I saw field.upper and field.month). What you're looking for is a natural (as opposed to lexical) sort, which most (all?) databases lack. A common solution is to create another column to serve as a sort key. In your example, it might be A01, A02, ... A10. Or two columns, one with the leading alpha, sorted lexically, and the other with the number, sorted numerically (and a two-column major-minor sort).
Re: [web2py] Re: LEFT JOIN query as object?
It is kinda possible. Save both queries as objects. Left is just a query that tells web2py which fields in the tables should be linked together. For example, lefton = (db.friend.dog_id == db.dog.id) where = db(db.friend.name == fred) ... continue and do some stuff with the where query object results = where.select(db.friend.ALL, left = lefton) -- Thadeus On Thu, Jul 22, 2010 at 4:10 PM, mwolfe02 michael.joseph.wo...@gmail.comwrote: It turns out the error I got it was for a different syntactical mistake I'd made. The relevant error is slightly different: TypeError: 'Rows' object is not callable I assume this is because the .select() method returns a 'Rows' object? On Jul 22, 4:09 pm, Michael Wolfe michael.joseph.wo...@gmail.com wrote: I'm still learning web2py, so bear with me. I am trying to write a somewhat complex query and would like to build it as a series of smaller, easier to understand queries. web2py seems to support this beautifully for INNER JOINs and WHERE clauses as explained here: http://www.thadeusb.com/weblog/2010/3/19/increase_productivity_by_usi... However, it appears that LEFT JOINs are not supported in the same way, because they are only available from within the .select() method. I tried doing this and received the following error: TypeError: 'SQLJoin' object is not callable Is there any sort of workaround or am I stuck creating my left joins when I call .select()? Thanks, Mike
Re: [web2py] Re: web2py performance issue or rather my fault?
I will make said changes, and add my Flask-DAL extension to the flask app, so at least the database layer will be the exact same. Flask handles sessions too. I shouldn't disable web2py sessions while letting flask use sessions, that would be an unfair test too. The good news is, that even with migrate=True the DAL still outperforms sqlalchemy (yay). So using sqlalchemy would result in a slightly slower flask. -- Thadeus On Wed, Jul 21, 2010 at 9:02 AM, mdipierro mdipie...@cs.depaul.edu wrote: I agree with your assessment. The problem you, Iceberg, Rahul, and MikeEllis are having with Rocket appears distinct from the problem Thadeus is having uwsgi+cherokee. In my previous email I tried to suggest changes in Thadeus code to isolate the cause of his problem. Going back to your problem. I am still suspicious that this is a cron issue. Can you try change cron=True into cron=False in web2py.py? Massimo On Jul 21, 8:41 am, Kuba Kucharski kuba.kuchar...@gmail.com wrote: You said: I moved to apache/WSGI from Rocket. For me the problem disappears. therefore your problem is not the same that some other problems experienced with apache/WSGI. look at Iceberg, Rahul, MikeEllis in this thread You also said you cache.ram all requests. Can you try remove the caching? Any improvement? I think there are two or more problems. One is Thadeus having. The second was described by me. They can be the same but they seem not to be. As I investigated in this thread people talking about my kind of the problem report using rocket/cherrypy. Removing caching gives no improvement.
Re: [web2py] Re: Error in wsgi/apache
For the record, I never really had any issues with web2py filling up my RAM, mostly just crashing while processing a certain number of requests. Even after the ab tests, when looking at RAM usage, it would only spike to maybe 150MB for all apache+mod_wsgi+web2py processes, and then go back down to the normal 36MB load after the ab test finished. What else do you have installed on the server? Is it really web2py that is causing the memory usage, or a rouge daemon running in the background? I have not seen any of my web2py processes ever make it over 150MB usage unless I did some massive caching. -- Thadeus On Wed, Jul 21, 2010 at 1:09 PM, Michael Toomim too...@gmail.com wrote: Great! I want to understand it too! Your breakdown helps me think about how to look into this. I will do some more analysis, but for now: - I'm not using forms - I had migrate=True and the app was not compiled earlier. now it's compiled and migrate=False and I have a bigger machine, things are running ok, but I changed quite a few variables. Would migrate=True create locking issues? The problems seemed similar to locking issues. - My machine's ram slowly filled up from ~700mb/1500mb to 1400mb/ 1500mb over 5 hours. But I haven't looked to see which process grew yet, I will investigate. On Jul 21, 1:13 am, mdipierro mdipie...@cs.depaul.edu wrote: I still want to understand why you are having this problem. I see the following possibility: 1) There is a threshold in requests/seconds that depends on memory available and it is different for different frameworks. web2py does more than Flask (which is a microframework by definitions) and this threshold may be lower. If this is the case the problem should go away with more ram. 2) There is a bug in web2py or one of its modules that causes a memory leak (did you experience a memory leak?) or a locking issues (for example a process crashes before a locked resource is released). I remember you mentioning have this problem exclusively with actions using SQLFORM under heavy load. Is that correct? This could help us narrow down the problem. Massimo On Jul 20, 7:17 pm, Thadeus Burgess thade...@thadeusb.com wrote: The solution: I switched to Flask. And the problems dissipated completely, without modifying any configuration of the web server. I would not, and will not use web2py for any application that is mission critical. For personal sites, or quick projects that I know won't receive that much attention, web2py is fine. For quickly prototyping something, web2py excels. For stability, reliability, and scalability, use Flask or Django. The DAL is great though, nothing quite like it, thats why I am working on a Flask-DAL extension, and I am working to re-write parts of the DAL and strip out the web2py cohesion (such as SQLFORM validators). Using the DAL inside of flask works fine, and I do not run into these errors. This means that the DAL is not the cause of these errors, but web2py core code. Most likely in dealing with pages that have forms is where these errors arise. Web2py core is messy, and it ignores the wsgi specification for the most part. I am sure that these errors arise from the fact that web2py uses execfile in many places over and over again, which is a discouraged practice among the python community, and you see why now. -- Thadeus On Tue, Jul 20, 2010 at 4:17 PM, Michael Toomim too...@gmail.com wrote: Thank you for the clarification. My wsgi.conf has default values, so I have not set maximum-requests. Perhaps there are settings there I should look into? I still have free memory, so perhaps there is not a memory leak issue. I'm also not sure how one would get memory leaks in web2py, since isn't the environment wiped clean with each request? This looks similar to the issue here: http://groups.google.com/group/web2py/browse_thread/thread/49a7ecabf4... Was there any resolution? I use logging by having the following file in models/0_log.py: import logging def get_log(): try: f = open(logging.handlers[0].baseFilename, 'r') c = f.readlines() f.close() return {'log':TABLE(*[TR(str(item)) for item in c])} except: return () # This model file defines some magic to implement app_wide_log. def _init_log(): # Does not work on GAE import os,logging,logging.handlers logger = logging.getLogger(request.application) logger.setLevel(logging.DEBUG) handler = logging.handlers.RotatingFileHandler( os.path.join( # so that it can be served as http:// .../yourapp/static/applog.txt request.folder,'static','applog.txt'),'a',1024*1024,1) handler.setLevel(logging.DEBUG) handler.setFormatter(logging.Formatter(%(asctime)s %(levelname)s % (filename)s
Re: [web2py] Re: web2py performance issue or rather my fault?
I try. I have several copies of web2py core that I have modified in attempt to fix these issues, attempting to narrow down the cause, to no avail yet. I want to do two more tests. The first one, make flask use the web2py DAL so we can compare core to core. Make sure web2py has all of the fancy optimizations in place. The second thing I want to do is develop a very minimalistic WSGI application that is not based on any framework. I want to execute the controllers in two different ways, I want to test a import based controller, and then an execfile based controller. Very simple, no templates, no database. This small test will verify if it is an issue that can be fixed (such as too much overhead processing the request), or if it is an issue that cannot be fixed (ie: a design flaw in using execfile). Once the question of execfile vs import on performance is answered will depend on what should be tested next to figure out what is causing these issues. -- Thadeus On Wed, Jul 21, 2010 at 9:59 AM, mdipierro mdipie...@cs.depaul.edu wrote: Thank you Thadeus for your help with these tests. I did not see a open_session(request) in your Flask code. Where does Flask save sessions? filesystem or client? If they are saved on the client that is closer to session.forget() in web2py since filling the filesystem with one question file for every http request when running ab may cause problems. Massimo On Jul 21, 9:44 am, Thadeus Burgess thade...@thadeusb.com wrote: I will make said changes, and add my Flask-DAL extension to the flask app, so at least the database layer will be the exact same. Flask handles sessions too. I shouldn't disable web2py sessions while letting flask use sessions, that would be an unfair test too. The good news is, that even with migrate=True the DAL still outperforms sqlalchemy (yay). So using sqlalchemy would result in a slightly slower flask. -- Thadeus On Wed, Jul 21, 2010 at 9:02 AM, mdipierro mdipie...@cs.depaul.edu wrote: I agree with your assessment. The problem you, Iceberg, Rahul, and MikeEllis are having with Rocket appears distinct from the problem Thadeus is having uwsgi+cherokee. In my previous email I tried to suggest changes in Thadeus code to isolate the cause of his problem. Going back to your problem. I am still suspicious that this is a cron issue. Can you try change cron=True into cron=False in web2py.py? Massimo On Jul 21, 8:41 am, Kuba Kucharski kuba.kuchar...@gmail.com wrote: You said: I moved to apache/WSGI from Rocket. For me the problem disappears. therefore your problem is not the same that some other problems experienced with apache/WSGI. look at Iceberg, Rahul, MikeEllis in this thread You also said you cache.ram all requests. Can you try remove the caching? Any improvement? I think there are two or more problems. One is Thadeus having. The second was described by me. They can be the same but they seem not to be. As I investigated in this thread people talking about my kind of the problem report using rocket/cherrypy. Removing caching gives no improvement.
Re: [web2py] Re: The one video you should watch
Web2py is now in a league of its own. This is the vision of web2py that has been in mind since the begininning, all of the other stuff (DAL, templateing etc) is just the means to this end. -- Thadeus On Tue, Jul 20, 2010 at 10:40 AM, MikeEllis michael.f.el...@gmail.comwrote: Massimo, I'm impressed!!! I've followed the discussions about the markmin syntax but didn't quite understand how it was meant to fit in the overall scheme of web2py development. It looks like you've taken web2py up to whole new level. Congrats! Now I need to watch the video again, download the latest, and start trying to grok the implications... Cheers, Mike On Jul 20, 10:22 am, mdipierro mdipie...@cs.depaul.edu wrote: If you have not followed closes the latest developments, you should watch this video: http://www.vimeo.com/13485916
Re: [web2py] Re: Error in wsgi/apache
The solution: I switched to Flask. And the problems dissipated completely, without modifying any configuration of the web server. I would not, and will not use web2py for any application that is mission critical. For personal sites, or quick projects that I know won't receive that much attention, web2py is fine. For quickly prototyping something, web2py excels. For stability, reliability, and scalability, use Flask or Django. The DAL is great though, nothing quite like it, thats why I am working on a Flask-DAL extension, and I am working to re-write parts of the DAL and strip out the web2py cohesion (such as SQLFORM validators). Using the DAL inside of flask works fine, and I do not run into these errors. This means that the DAL is not the cause of these errors, but web2py core code. Most likely in dealing with pages that have forms is where these errors arise. Web2py core is messy, and it ignores the wsgi specification for the most part. I am sure that these errors arise from the fact that web2py uses execfile in many places over and over again, which is a discouraged practice among the python community, and you see why now. -- Thadeus On Tue, Jul 20, 2010 at 4:17 PM, Michael Toomim too...@gmail.com wrote: Thank you for the clarification. My wsgi.conf has default values, so I have not set maximum-requests. Perhaps there are settings there I should look into? I still have free memory, so perhaps there is not a memory leak issue. I'm also not sure how one would get memory leaks in web2py, since isn't the environment wiped clean with each request? This looks similar to the issue here: http://groups.google.com/group/web2py/browse_thread/thread/49a7ecabf4910bcc/b6fac1806ffebcd1?lnk=gstq=ioerror#b6fac1806ffebcd1 Was there any resolution? I use logging by having the following file in models/0_log.py: import logging def get_log(): try: f = open(logging.handlers[0].baseFilename, 'r') c = f.readlines() f.close() return {'log':TABLE(*[TR(str(item)) for item in c])} except: return () # This model file defines some magic to implement app_wide_log. def _init_log(): # Does not work on GAE import os,logging,logging.handlers logger = logging.getLogger(request.application) logger.setLevel(logging.DEBUG) handler = logging.handlers.RotatingFileHandler( os.path.join( # so that it can be served as http:// .../yourapp/static/applog.txt request.folder,'static','applog.txt'),'a',1024*1024,1) handler.setLevel(logging.DEBUG) handler.setFormatter(logging.Formatter(%(asctime)s %(levelname)s % (filename)s:%(lineno)d %(funcName)s(): %(message)s)) logger.addHandler(handler) return logger logging = cache.ram('app_wide_log',lambda:_init_log(),time_expire=None) On Jul 20, 2:03 am, mdipierro mdipie...@cs.depaul.edu wrote: Thanks for the clarification. @Michael, do you use the logging module? How? On Jul 20, 4:00 am, Graham Dumpleton graham.dumple...@gmail.com wrote: On Jul 20, 5:17 pm, mdipierro mdipie...@cs.depaul.edu wrote: The problem with IOError, I can understand. As Graham says, if the client closes the connection before the server responds or if the server timesout the socket is closed and apache logs the IOError. That isn't what I said. If you see that message when using daemon mode, the Apache server process that is proxying to the daemon process is crashing. This is different to the HTTP client closing the connection. You would only see that message if HTTP client closed connection if using embedded mode. I know they are using daemon mode as that is the only situation where they could also see the message about premature end of script headers. What I really do not understand is why some requests are handled by multiple threads. web2py is agnostic to this (unless you use Rocket which you do not). web2py only provides a wsgi application which is executed - per thread - by the web server. It is the web server (in your case apache) that spans the thread, maps requests to threads, calls the web2py wsgi application for each of them. If this is happening it is a problem with apache or with mod_wsgi. More likely the problem is that they are registering the logging module from multiple places and that is why logging is displayed more than once. They should log the thread ID as well as that would confirm whether actually from the same thread where logging module handler has been registered multiple times. Multiple registrations of logging handler could occur if it isn't done in a thread safe why, ie., so as to avoid multiple threads doing it at the same time. Graham Can you tell us more about the version of ubuntu, apache and mod_wsgi that you are using? Any additional information will be very useful. Massimo On Jul 19, 9:01 pm, Michael Toomim
Re: [web2py] Re: The one video you should watch
Odd. I do not hear any when I watched it. -- Thadeus On Tue, Jul 20, 2010 at 5:08 PM, mdipierro mdipie...@cs.depaul.edu wrote: I wish I knew how. I do not know where the z comes from. On Jul 20, 4:07 pm, Mengu whalb...@gmail.com wrote: great screencast but you should really stop that zz. :) On 20 Temmuz, 17:22, mdipierro mdipie...@cs.depaul.edu wrote: If you have not followed closes the latest developments, you should watch this video: http://www.vimeo.com/13485916
Re: [web2py] Re: The one video you should watch
I just realized why I did not hear it, I was listening on one of those headsets that have a built-in inline audio card, so it was performing a filter and it took that noise out. Playing through my PC speakers and the noise is there -- Thadeus On Tue, Jul 20, 2010 at 9:59 PM, weheh richard_gor...@verizon.net wrote: Very interesting demo. Lots to absorb. Unfortunately, I hear the audio buzz, too, and agree that it's distracting.
Re: [web2py] Re: web2py performance issue or rather my fault?
I am taking http://techspot.zzzeek.org/?p=17 and making a benchmark_dal.py and testing the results vs sqlalchemy. So far it looks promising, the DAL seems to be much more efficient than SQLAlchemy, and brick tons faster too. This is good news for me, as it proves that the DAL is valuable... if only we could make it its own package instead of apart of web2py... that will be my next project. Here I have attached to aggregate screenshots, and the file used to test DAL. I compared both SQLAlchemy and the DAL on my VPS server, each got their own postgresql database. I am using a slightly modified DAL (I removed validators completely). However, after I ran the tests I realized migrate was still set to True so If I were to re-run the tests I expect the DAL to outperform SQLAlchemy even more. Refer to the link at techspot.zzzeeek for more information about the tests. http://static.thadeusb.com/total_time.jpg http://static.thadeusb.com/call_count.jpg http://static.thadeusb.com/benchmark_dal.py I think it is safe to say that the DAL is not what is causing these 500 server errors. I think David is on to something. On my production sites, I always get errors related to the pages with SQLFORM on them, never on regular pages that just render a template. -- Thadeus On Mon, Jul 19, 2010 at 1:27 AM, David Marko dma...@tiscali.cz wrote: I can see the same problems with failed requests on many my machines. (WinXP, Debian 5) . The simple test using default web2py examples shows me, that template rendering is OK e.g. http://localhost:8000/examples/template_examples/test_for but when using form example like in http://localhost:8000/examples/form_examples/form causes request failures. Constantly, when I did test repeatedly, template rendering example caused no problem, but form based example claimed 13-15% of failed requests for me. I have use apache ab. As stated above, I could see the same results despite of platform. I tested today on latest version 1.81.4 with default Rocket web server. (I remember I could see the same issues with CherryPy as well) David On 19 čnc, 06:22, Thadeus Burgess thade...@thadeusb.com wrote: I am wondering if this is a web2py issue or a DAL issue. I would like to re-run my tests just rendering a simple template with no dbio and see if I still get the same results. I love the DAL and there is nothing else quite like it, and would hate for it to be the cause. I would like to compare the DAL standalone, without web2py to determine it is not the cause. -- Thadeus On Sun, Jul 18, 2010 at 6:10 PM, MikeEllis michael.f.el...@gmail.com wrote: I was just about to create new topic, but thought I'd start by reporting here since it could be related. The short description is: 1. Serve web2py (rocket.py, sqlite3, etc) over a lan connection from a laptop 2. Open a page from my app on another laptop. 3. Also open the same page on the server laptop. 4. Start clicking reload alternately between the two laptops at about 1Hz 5. All goes well for an indeterminate period of time, typically about 1 minute. 6. Occasionally a reload will take about 20 seconds. Can happen on either box. Other Info * db is very small - only 2 tables with only a few entries each. * App is not doing anything intensive and the pages are relatively simple. * web2py 1.92 * OS X 10.6 on both laptops * Browser = Chrome Observations * No evidence of high CPU usage. * Happens even with pages that don't write to the db. * I even managed once to produce the problem with an unmodified Welcome app, but it took a really long time to make it happen and the latency wasn't as bad. When I reproduce the problem with Chrome DevTools open, the delay corresponds to an incredibly long latency, ie 20 seconds, fetching one or more .js or .css modules. Usually it's jquery.timers-1.2.js or base.css but can occur with other modules. It's never the page html, that always arrives in milliseconds. Here's the Header info from the long fetch on base.css: Request URL:http://192.168.253.105:8000/init/static/base.css Request Method:GET Status Code:304 Not Modified Request Headers Accept:text/css,*/*;q=0.1 Cache-Control:max-age=0 If-Modified-Since:Mon, 14 Jun 2010 23:30:00 GMT Referer:http://192.168.253.105:8000/init/editproblem/index User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4 Response Headers Connection:keep-alive Content-Type:text/html; charset=UTF-8 Date:Sun, 18 Jul 2010 22:32:09 GMT Server:Rocket 1.0.5 Python/2.6.1 One other oddity: I've been seeing (and ignoring) the following warning from DevTools when js/css files are loaded: Resource interpreted as stylesheet but transferred with MIME type text/html. Someone on stackoverflow.com
Re: [web2py] Re: web2py performance issue or rather my fault?
Now the question is why? I don't see how it can just be the generation of the form, I am willing to bet it is the session and CSRF tokens. If someone has time, we need to test a couple of scenarios. A) display a simple FORM B) display a simple FORM, but do NOT include a form.accepts in the controller C,D) Repeat a and b but with SQLFORM E) Move sessions to database and repeat C,D I still expect that even with sessions in the database you will still run into issues, as I do run into these on one of my production sites that does have session in the database. I would like to see if a implementation of a SecureSignedCookie for storing the session would solve the issue (this is what flask uses). Also, large sites such as twitter, facebook, google, etc all use SecureCookies to store session, since storing as many sessions as they use in a database would overtax their resources. -- Thadeus On Mon, Jul 19, 2010 at 3:28 AM, David Marko dma...@tiscali.cz wrote: One can even user examples hosted on web2py.com with same results as I tested on my local machines. simple temple rendering - no failed requests ## c:\apache\binab -n 100 -c 5 http://web2py.com/examples/template_examples/test_def This is ApacheBench, Version 2.3 $Revision: 655654 $ Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking web2py.com (be patient).done Server Software:Apache/2.2.8 Server Hostname:web2py.com Server Port:80 Document Path: /examples/template_examples/test_def Document Length:7311 bytes Concurrency Level: 5 Time taken for tests: 18.656 seconds Complete requests: 100 Failed requests:0 Write errors: 0 Total transferred: 775042 bytes HTML transferred: 731100 bytes Requests per second:5.36 [#/sec] (mean) Time per request: 932.813 [ms] (mean) Time per request: 186.563 [ms] (mean, across all concurrent requests) Transfer rate: 40.57 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 172 179 9.3172 203 Processing: 391 721 64.0734 781 Waiting: 188 436 111.7391 703 Total:563 901 64.6906 953 rendering form example - many failed requests apears constantly ## c:\apache\binab -n 100 -c 5 http://web2py.com/examples/form_examples/form This is ApacheBench, Version 2.3 $Revision: 655654 $ Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking web2py.com (be patient).done Server Software:Apache/2.2.8 Server Hostname:web2py.com Server Port:80 Document Path: /examples/form_examples/form Document Length:23849 bytes Concurrency Level: 5 Time taken for tests: 23.203 seconds Complete requests: 100 Failed requests:95 (Connect: 0, Receive: 0, Length: 95, Exceptions: 0) Write errors: 0 Total transferred: 2427908 bytes HTML transferred: 2383978 bytes Requests per second:4.31 [#/sec] (mean) Time per request: 1160.156 [ms] (mean) Time per request: 232.031 [ms] (mean, across all concurrent requests) Transfer rate: 102.18 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 156 174 7.2172 203 Processing: 859 947 84.99221375 Waiting: 203 284 100.0234 703 Total: 1031 1121 85.6 10941547
Re: [web2py] How to handle jaywalking - parsing a comma-delimited value in field and do lookups (1,4,5,6...)
Web2py is actually guilty of performing this same operation, however instead of commas, we use the pipe char '|' The theory works like this If you have the following |1|23|4|55|15| You can perform the following query to find the record with group id of 55 db(db.groups.like(%|55|%)).select() This works as expected. However, in your case you have a problem. The fact that the beginning and end of your records don't wrap with a comma! So if you wanted to look for the group 1 in your dataset... well it just wouldn't work. You can't do a like query on %1% either, because that would also match if you have group 15. Dope. Is it possible for you to run an update query on the table, and wrap every record with a beginning and ending comma? If so, you can just use the simple trick we use in web2py but use a comma instead of a pipe. Otherwise, you might be better off attempting to re-design the system (you should at some point anyways) Hope that helps. -- Thadeus On Mon, Jul 19, 2010 at 5:16 AM, Snaky Love snakyl...@googlemail.comwrote: any-to-many relation. For anybody interested: there is a book by Bill Karwin called SQL Antipatterns - he names the described design Jaywalking and it is the first antipattern in the book. I was surprised to find it in rea
Re: [web2py] Re: How to handle jaywalking - parsing a comma-delimited value in field and do lookups (1,4,5,6...)
where does this kind of thing happen with web2py? Could you please specify what exactly are you writing about here? Does this mean the web2py database abstraction layer produces this kind of hackery instead of intersection tables on a many-2-many relation? Consider the following schema. db.define_table('groups', Field('name')) db.define_table('accounts', Field('name'), Field('group_id', db.groups, requires=IS_IN_DB(db, 'groups.id', ' groups.name', multiple=True) ) In this case, what web2py actually does is create a string field (because you specified multiple = True), and then when you insert a record using SQLFORM, it will automatically parse the multiple checkboxes into the jaywalking trick. Its stupid, thats another reason to add to my very long list of dislikes for SQLFORM and how web2py couples these things together. I would much rather a Field('group_id', db.groups, manytomany=True) type that the DAL would handle automatically for me... but that is getting into ORM space, so the right thing to do is to handle many to many relationships manually. That is all fine and dandy, back to the problem at hand. I'm afraid though that anything will be hacky because of the design flaw. Hopefully there are no spaces in the data? You might have to do something such as I want record 5 out of the following set 5,55,32,12,16,15 Well, I need to look for a single 5 that could appear at the beginning of the string, the end of the string, or somewhere in the middle of the comma separated values... nasty, but it might look something like this: db((db.groups.like('5,%')) | (db.groups.like(',5%') | (db.groups.like('%,5,%')).select() This won't be fast though. You won't be happy with the performance in speed. BUT it will work. -- Thadeus On Mon, Jul 19, 2010 at 6:45 AM, Snaky Love snakyl...@googlemail.comwrote: where does this kind of thing happen with web2py? Could you please specify what exactly are you writing about here? Does this mean the web2py database abstraction layer produces this kind of hackery instead of intersection tables on a many-2-many relation?
Re: [web2py] Re: web2py performance issue or rather my fault?
I am wondering if this is a web2py issue or a DAL issue. I would like to re-run my tests just rendering a simple template with no dbio and see if I still get the same results. I love the DAL and there is nothing else quite like it, and would hate for it to be the cause. I would like to compare the DAL standalone, without web2py to determine it is not the cause. -- Thadeus On Sun, Jul 18, 2010 at 6:10 PM, MikeEllis michael.f.el...@gmail.comwrote: I was just about to create new topic, but thought I'd start by reporting here since it could be related. The short description is: 1. Serve web2py (rocket.py, sqlite3, etc) over a lan connection from a laptop 2. Open a page from my app on another laptop. 3. Also open the same page on the server laptop. 4. Start clicking reload alternately between the two laptops at about 1Hz 5. All goes well for an indeterminate period of time, typically about 1 minute. 6. Occasionally a reload will take about 20 seconds. Can happen on either box. Other Info * db is very small - only 2 tables with only a few entries each. * App is not doing anything intensive and the pages are relatively simple. * web2py 1.92 * OS X 10.6 on both laptops * Browser = Chrome Observations * No evidence of high CPU usage. * Happens even with pages that don't write to the db. * I even managed once to produce the problem with an unmodified Welcome app, but it took a really long time to make it happen and the latency wasn't as bad. When I reproduce the problem with Chrome DevTools open, the delay corresponds to an incredibly long latency, ie 20 seconds, fetching one or more .js or .css modules. Usually it's jquery.timers-1.2.js or base.css but can occur with other modules. It's never the page html, that always arrives in milliseconds. Here's the Header info from the long fetch on base.css: Request URL:http://192.168.253.105:8000/init/static/base.css Request Method:GET Status Code:304 Not Modified Request Headers Accept:text/css,*/*;q=0.1 Cache-Control:max-age=0 If-Modified-Since:Mon, 14 Jun 2010 23:30:00 GMT Referer:http://192.168.253.105:8000/init/editproblem/index User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4 Response Headers Connection:keep-alive Content-Type:text/html; charset=UTF-8 Date:Sun, 18 Jul 2010 22:32:09 GMT Server:Rocket 1.0.5 Python/2.6.1 One other oddity: I've been seeing (and ignoring) the following warning from DevTools when js/css files are loaded: Resource interpreted as stylesheet but transferred with MIME type text/html. Someone on stackoverflow.com suggested putting meta http-equiv=content-script-type content=text/javascript into the head of the document. I tried that (in layout.html) but it had no effect on the warnings. Anyone seen similar problems or have an idea what could be causing the long fetch times? Thanks, Mike On Jul 18, 1:20 pm, Thadeus Burgess thade...@thadeusb.com wrote: Massimo, web2py.com is not a valid application to be testing this on. Most of what web2py.com does is just render a template and display it, it hardly does any kind of strenuous dbio. As you know I have a few separate servers running different configurations. I mainly decided to do this testing as to the problems I have had with my application at work (which runs apache + mod_wsgi). I wondered if my blog had the same issue (which when I ran ab tests on it and spiked its usage, it did). Interesting thing is my blog ran on cherokee + uwsgi. I doubt it is a configuration issue since I still have the same problem on two completely different apps running completely different setups all different except web2py. They both use postgres as well. I am attaching the two apps that I tested, as well as a text file that contains the raw ab tests that I collected to run -- Thadeus On Sun, Jul 18, 2010 at 4:39 AM, mdipierro mdipie...@cs.depaul.edu wrote: Last week I run some tests. I can confirm I have NO dropped requests on web2py.com running with the recommended configuration (apache +mod_wsgi 3.1). Here is the httpserver.log for 3 days of running (I removed the IPs from the logs and requests for static files served directly by apache). http://www.web2py.com/examples/static/logs.txt You can see that most pages are served in about 50 millisecond and all of them return a 200 OK. At 2010-07-08 16:58:22 I also run a test and you can see the logs for that. No propped request from ab. Clearly something is wrong with Thadues setup. I cannot help debug this if I cannot reproduce the problem. As soon as I have some time I will install uwsgi and try it. @Thadeus. Can you post the application you used for testing? Massimo AB_WEB2PY_FLASK.tar.lzma 1011KViewDownload
Re: [web2py] Re: web2py 1.81.1 is OUT
One thing Ive learned. NEVER update your production code to the latest version. ALWAYS find a stable release, and stick to it until you can test another stable release 100%. Honestly I would stay away from upgrading at all unless you are needing a new feature. Typically new features in web2py don't become *stable* until a few releases later. I'm currently still running 1.68 codebase (with a couple of the security patches manually applied) on one of my sites, and 1.7* on another. -- Thadeus On Fri, Jul 16, 2010 at 3:39 PM, Phyo Arkar phyo.arkarl...@gmail.comwrote: same to mee too.. i updated on my production site and screwed :(.. On Fri, Jul 16, 2010 at 3:43 PM, VP vtp2...@gmail.com wrote: well, i should have read this thread before upgrading. Hope to see 1.81.2 soon. On Jul 16, 8:53 am, mr.freeze nat...@freezable.com wrote: You can just change line 1401 of tools.py to 'else:' and it should work. On Jul 16, 8:48 am, Narendran gunanar...@gmail.com wrote: Looks like there is no get_user method in default Auth. I find a get_or_create_user. May be the name was modified in the recent checkins. On Jul 16, 6:34 pm, mr.freeze nat...@freezable.com wrote: Line 1401 of tools.py needs to be changed (back) from... if self.settings.login_form: to... else: It didn't affect my test app because it already used CAS. On Jul 16, 3:44 am, David Marko dma...@tiscali.cz wrote: The same problem is on all apps I have. David On 16 čnc, 10:21, David Marko dma...@tiscali.cz wrote: I updated web2py but it breaks my app. This is what I got for standard login dialog. (no rpx_account login used, app remained unchanged) Traceback (most recent call last): File c:\java\google_appengine\web2py\gluon\restricted.py, line 178, in restricted exec ccode in environment File c:/java/google_appengine/web2py/applications/tp/controllers/ default.py, line 300, in module File c:\java\google_appengine\web2py\gluon\globals.py, line 96, in lambda self._caller = lambda f: f() File c:/java/google_appengine/web2py/applications/tp/controllers/ default.py, line 277, in user return dict(form=auth()) File c:\java\google_appengine\web2py\gluon\tools.py, line 967, in __call__ return self.login() File c:\java\google_appengine\web2py\gluon\tools.py, line 1404, in login cas_user = cas.get_user() AttributeError: 'Auth' object has no attribute 'get_user'
Re: [web2py] Re: storing hierarchical data in web2py database
I have this code implemented in plugin_category.py let me just find it =/ Ah yes, here it is http://code.google.com/p/blogitizor/source/browse/src/modules/plugin_category.py You can see example usage in blogitizor. -- Thadeus On Tue, Jul 13, 2010 at 4:19 PM, sociotech cfassna...@gmail.com wrote: You might want to check out Massimo's code for Modified Preorder Tree Traversal, which is an extremely efficient way of storing tree structures in a database: http://groups.google.com/group/web2py/browse_thread/thread/70efddab62dfe73 On Jul 13, 11:59 am, topher.baron topher.ba...@gmail.com wrote: I'm looking forward to it. On Jul 13, 1:12 pm, Vasile Ermicioi elff...@gmail.com wrote: I am developing a solution for my needs, something similar to nested sets, if you could wait a few days I think I will be able to share it
Re: [web2py] Re: Commenting system - Disqus/IntenseDebate
Pros: * Disqus is really easy to use and setup and include on your site. * Automatically emails you with comments, that you can respond to from your email client * You don't have to do anything but include the javascript on your page and include a page ID. Cons: * Reliant on disqus, their export feature is weak and a manual process. If they go down or decide to start charging for the service, your SOL. * If for some reason disqus servers go offline, like what happens with the fail whale, then so does your sites commenting system. * Because your comments are javascript, they are NOT included in search results. Comments can be a decent source of SEO to the page. -- Thadeus On Tue, Jul 13, 2010 at 3:25 AM, mdipierro mdipie...@cs.depaul.edu wrote: I do not know about them but I have these http://web2py.com/plugins/default/comments http://web2py.com/plugins/default/simple_comments Other users have other systems On 13 Lug, 03:11, Narendran gunanar...@gmail.com wrote: Hi, I'm about to add commenting system to my site I've developed using web2py. I'd like to hear opinions regarding integrating Disqus, or IntenseDebate, if someone has already done this. If there is some native web2py widget, I'd like to try that as well. I could not hit any on googling for one. -- Thanks Narendran
Re: [web2py] Re: T2, T3, Cube2py ...
easier programming without coding. LOL =) Best un-intentional oxy-moron I have read in a while -- Thadeus On Tue, Jul 13, 2010 at 4:53 PM, mdipierro mdipie...@cs.depaul.edu wrote: This video is already obsolete: http://www.vimeo.com/13154869 The goal is to build an additional layer on top of web2py that would allow: - easier programming without coding - integrate some content management functionality - could potentially become a new welcome (scaffolding) app T2,T3,Cube2py are all experiments. Cube2py is the latest. I still do not promise backward compatibility because it is an app. On 13 Lug, 14:49, Jeff S jf_sic...@hotmail.com wrote: Hi, I'm not sure I understand all of this T2 T3 and Cube2py stuff. I have recently installed web2py(1.76.3) on my computer and I read somewhere that T2, T3 are deprecated and Cube2py would be the new stuff. But what is T2 and T3 anyway? Is it like project code names that were included in web2py as upgrades like CRUD got included some time ago? What is the direction of web2py with cube2py? As far as I understand it, T3 is part of web2py, no? Cube2py only looks like another application like anyone that can be installed on web2py, or is it more than that? Actually Cube2py does not seem to work with my 1.76.3. I guess I'll have to upgrade to the latest revision in order to use Cube2py. Thanks,
Re: [web2py] State of the DAL rewrite
The DAL is an sql abstraction layer. NoSQL is just that, no sql needed, since its a document store... I think its silly to try and put relational mindsets into something that is designed to not be relational or ACID/ATOMIC. -- Thadeus On Sun, Jul 11, 2010 at 5:12 AM, Pystar aitoehi...@gmail.com wrote: I would like to know the status of the DAL rewrite in respect to NoSQL support. How can I help in the work being done?
Re: [web2py] new welcome (scaffolding) app
[x] new layout [x] less on the views/layout is more, unless you just want to ship a tutorial with web2py instead, good for newbies, not so good for those who have done a few apps [x] id rather a tutorial series written instead of being shipped with web2py [ ] no plugin_wiki, let me install it if I want to, just make some documentation on how to use it. [ ] jquery.ui is nice, but not needed for everyone or everything. -- Thadeus On Fri, Jul 9, 2010 at 8:34 AM, mdipierro mdipie...@cs.depaul.edu wrote: let's consider a new scaffolding app. What should be in it? What should not be in it? possible suggestions: [ ] js menu [ ] new layout (suggestions?) [ ] more complex views/layout? [ ] simpler views/layout.html [ ] example plugins [ ] plugin_wiki from cube2py? [ ] jquery.ui Massimo
Re: [web2py] Re: web2py performance issue or rather my fault?
Setup: Two applications that perform a simple db insert, db select, render a template and return it. All in all this is a very small application. The application has two views, one insert/select view and one select view. Each of these views are tested separately using apache ab test. The insert view, will insert a random 6 letter name into the database, and return a select of the last 10 records inserted. The ab test compose of several of the recommended tests that can easily be found in a google search. Different tests compose of concurrency, number of connections, etc etc. Each tested individually. The web server was restarted and the database reset in between each ab test to prove that everything is starting with a fresh slate. The db is in postgresql, and uses the following schema: TABLE friends COL id COL name Each application has their own blank database in postgres to start. Web Server: Cherokee with uwsgi running on a 256MB VPS with slicehost. During the testing, all other virtual servers were DISABLED except for the one being tested. This was to ensure that nothing would interfere with the application. First framework tested: Name: web2py Configuration --- db: DAL cron: disabled app: compiled cache: none pool_size: 10 The end result was about 68% throughput. There were 32% 500 internal server errors. Error logs reveal IOErrors and the such as has been duly noted in my previous google group posts. Second framework: name: Flask / werkzeug Configuration db: sqlalchemy cron: n/a app: python source cache: none pool_size: 10 The end result was 100% throughput, no 500 internal server errors, no error logs. -- Thadeus On Thu, Jul 8, 2010 at 7:56 AM, Kuba Kucharski kuba.kuchar...@gmail.com wrote: What could it be? let's rule things out - cron when it runs spikes CPU usage. DO NOT USE. In production run not the case. no cron, no cpu spikes - web2py session lock (the the same user can only access one page at I have session.forget.. - sqlite lock (depending on the query and the complexity of not the case, I use mysql now - db connection pooling locks (when look up for open connection) how to check this? I even did pool_size=10 but I never have more than 3 users at once I think it does not help - cache locks (it is a global lock, to ensure data integrity) how to debug this? - cache.ram can cause memory leaks if the key depends on variables no memory leaks noticed - problem with web server (Rocket or the apache or mod_wsgi, etc.) I use Rocket now, I don't know when I will be able to migrate to wsgi, probably soon
Re: [web2py] Re: web2py performance issue or rather my fault?
I get similar results with httperf. Web2py has over 15% 500 internal server errors, flask has none. -- Thadeus On Thu, Jul 8, 2010 at 10:17 AM, Kuba Kucharski kuba.kuchar...@gmail.com wrote: The web server was restarted and the database reset in between each ab test but AFAIK ab tends to be unreliable.. it is also my conclusion from benchmarking rocket vs cherrypy try httperf?
Re: [web2py] Re: markmin, t2, t3, cube9 etc. (important update)
This looks really awesome! Name suggestion: Cube^2 -- Thadeus On Wed, Jul 7, 2010 at 10:18 AM, Jonathan Lundell jlund...@pobox.com wrote: On Jul 7, 2010, at 5:42 AM, mdipierro wrote: The philosophy is the same as T3. Every URL is a wiki. Would you elaborate a little on that statement, please?
Re: [web2py] Re: markmin
I wish web2py was modular, so that this could be a separate project, and you can ``easy_install markmin`` and then web2py will pick up the existance or non-existance of the package and use or not use it automatically. This way we don't have to install markmin if we don't want to, but it is only one command away. I know this makes it harder to maintain when you have multiple packages, however allows for people who use other web frameworks to take advantage of it! -- Thadeus On Wed, Jul 7, 2010 at 9:45 AM, Álvaro Justen alv...@justen.eng.br wrote: On Wed, Jul 7, 2010 at 02:15, mdmcginn michael.d.mcgin...@gmail.com wrote: Massimo also announced this at http://groups.google.com/group/comp.lang.python.announce/browse_thread/thread/216e52e03e1a0120/4e9404e70bdeed0e#4e9404e70bdeed0e but didn't include a link to http://www.web2py.com/examples/static/markmin.html. No comments yet. No. New project, new repository. On Jul 6, 11:47 pm, Jason Brower encomp...@gmail.com wrote: Markdown has no classes and it's annoying. I have been hoping for something like this. And didn't they say it was faster? Why do we need Python when we can do everything in C? Then again, I am no expert. And about the seporate project. It kind of is now, but it is just included with the web2py package. It can be removed if needed. (Hence another reason to have a plugin like manager. We could install stuff for that web2py install and manage it as well. All from the admin pages.) --Jason On Tue, 2010-07-06 at 23:34 -0300, Álvaro Justen wrote: Another thoughts: *why* do we need another markup language? Markdown is not enough? It is so boring to learn a lot of languages (rest, markdown, markmin...). On Tue, Jul 6, 2010 at 23:32, Álvaro Justen alv...@justen.eng.br wrote: On Mon, Jul 5, 2010 at 19:42, mdipierro mdipie...@cs.depaul.edu wrote: http://www.web2py.com/examples/static/markmin.html As you created it, it is in contrib, it doesn't depend on web2py and maybe useful to other people, I think we should create another project to maintain markmin. Other ideia is to integrate the template system with markmin. For example: create a applications/myapp/views/default/somepage.markmin if somepage.html does not exist, web2py should use markmin to generate HTML instead. We have tests! Great! \o/ :-) -- Álvaro Justen - @turicas http://blog.justen.eng.br/ 21 9898-0141 -- Álvaro Justen - @turicas http://blog.justen.eng.br/ 21 9898-0141
Re: [web2py] web2py performance issue or rather my fault?
I have experienced this under high capacity on my web2py sites. I have not found a solution to the issue as of yet. All I can say is I have done AB testing comparing different python web frameworks with a basic database IO, web2py just doesn't perform under high load. Perhaps it is a coding issue with *how* you are caching your queries. When caching in ram, *each* web2py process has to cache its own version of the select. So if you reload a couple of times, apache( or your web server ) might determine it needs to spawn another process, which then in turn needs to cache all of the queries again. Solution: A) Use memcached B) or cache on disk AND ram, so if a new process starts, doesn't have it cached in ram, it will pull from the disk much quicker than re-executing the query. A is better. -- Thadeus On Wed, Jul 7, 2010 at 3:04 PM, Kuba Kucharski kuba.kuchar...@gmail.com wrote: I had prepared some mini-portal, I have 1000 unique visits a day but there is a performance issue bandwidth is ok memory is ok processor load is ok cache.ram is set for almost all of the queries, and is set for 1 hour but sometimes, once every few hits, it loads signifacantly slower weirdest thing is when you re-click the link it loads instantly, when you left it working to load on itself, it is slow.. like 4 to 8 seconds what could it be? where to look for an answer? I think some of you had to see this before.. -- Kuba
Re: [web2py] Anybody having trouble accessing web2py google group on mozilla firefox 3.6.6?
try logging completely out of your google account, clearing firefox cookies, closing firefox, then start again. -- Thadeus On Mon, Jun 28, 2010 at 10:32 AM, weheh richard_gor...@verizon.net wrote: I'm able to access the web2py group no problem on IE (ugh). But starting just recently, on Mozilla, I'm getting stuck in an infinite loop. The tab displays, Redirecting constantly. The URL is: https://www.google.com/accounts/ServiceLogin?service=groups2passive=1209600continue=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fweb2py%3Fhl%3Den%26pli%3D1followup=http%3A%2F%2Fgroups.google.com%2Fgroup%2Fweb2py%3Fhl%3Den%26pli%3D1hl=en Anybody else run into this problem?
Re: [web2py] Is there a more efficient way to do this?
ids = [] names = [] for r in rows: ids.append(r.id) names.append(r.name) db.table.multilist_field.requires=IS_IN_SET(ids, names) -- Thadeus On Mon, Jun 28, 2010 at 10:49 AM, weheh richard_gor...@verizon.net wrote: I have a multilist that I want to populate from db.table: rows=db(query).select(db.table.id,db.table.name) db.table.multilist_field.requires=IS_IN_SET( [r.id for r in rows], labels=[r.name for r in rows], ) Is there a better, more efficient way to do this rather than having to run through the rows list twice?
Re: [web2py] Is there a more efficient way to do this?
IS_IN_DB(rows, '%(id)s', '%(name)s') -- Thadeus On Mon, Jun 28, 2010 at 11:35 AM, Thadeus Burgess thade...@thadeusb.com wrote: ids = [] names = [] for r in rows: ids.append(r.id) names.append(r.name) db.table.multilist_field.requires=IS_IN_SET(ids, names) -- Thadeus On Mon, Jun 28, 2010 at 10:49 AM, weheh richard_gor...@verizon.net wrote: I have a multilist that I want to populate from db.table: rows=db(query).select(db.table.id,db.table.name) db.table.multilist_field.requires=IS_IN_SET( [r.id for r in rows], labels=[r.name for r in rows], ) Is there a better, more efficient way to do this rather than having to run through the rows list twice?
Re: [web2py] Re: web2py suggestions
I agree with most of these points. http://packages.python.org/web2py_utils/test_runner.html That is about as far as you will get with testing on web2py. You need very hacky code just to run your tests properly. Web2py was just not designed with testing in mind, and due to backwards compatibility never can be. One of the things I dislike about web2py are the conventions! I am tired of software assuming what I want it to do (grrr microsoft paperclip), half the time I have to hack around things the framework assumes I want to get it to do what I really want. -- Thadeus On Sun, Jun 20, 2010 at 2:26 AM, Giuseppe Luca Scrofani glsdes...@gmail.com wrote: I am a totally noob so I am not the best person to tell this, however, I think web2py is the best python software I ever tried, after python itself. I tried only django in this field before, my experience in limited, but I just can't imagine something better for the development of web application. Maybe Ruby On Rails, in the scene from a long time, can be more mature. But I think with some exposition web2py can grow to be the industry standard, now it seems to be in a niche waiting to explode. You Bihn made some good service to address weakness and propose improvements, so thanks. When I've had enough experience and skill to contribute to this project Im surely will and if this gaps arent yet solved (very improbable) I will try to solve the most easy :D For the point 3 I can say conventions dont'have to be this rigid, I create always css, img, swf ecc. folders on static. I think it is automatic to do this, but if dont want to do this for any reason I dont like to be forced. Maybe I'm wrong, maybe without all present conventions learning will be much difficult and web2py would be more like cherrypy where you can do all what you want how you want (if you know your stuff) with a higher learning curve. What I think is another area, in my humble opinion, of improvement is the manual, it is very good, but more example, a clearer API and a better search function can make my searches for information more easy. Please excuse me for my bad english.
Re: [web2py] Best practise to render tables
Isn't this what SQLTABLE and crud.select is for? -- Thadeus On Sat, Jun 19, 2010 at 8:06 AM, baloan balo...@googlemail.com wrote: Since my web application needs to render more than two tables I was too lazy to write/copy/paste table html code over and over again. Instead I implemented render_table which does the job nicely. Everything starts out with one or more database query result sets. Columns are reordered and reassigned to a new target table that shall be rendered. Is there a better built-in web2py-ish way to achieve the same? Regards, Andreas balo...@gmail.com -- views/render_table.html -- {{def render_table(table): # render table with header and attributes # string table.colnames[] # string table.colattrs[] # string table.rows[][] }} table thead {{for cn in table.colnames:}} th{{=cn}}/th {{pass}} /thead {{for n, row in enumerate(table.rows):}} tr{{if n % 2 == 0:}} class='even'{{else:}} class='odd'{{pass}} {{for cn, col in zip(table.colnames, row):}} td{{if cn in table.colattrs:}} {{=table.colattrs[cn]}} {{elif isinstance(col, float) or isinstance(col, int):}} align='right' {{pass}}{{=col}}/td {{pass}} /tr {{pass}} /table{{pass}} -
Re: [web2py] Re: my app instead of welcome app???
bah, whats the use. -- Thadeus On Tue, Jun 15, 2010 at 10:14 AM, Jean-Guy jean...@gmail.com wrote: On 2010-06-15 02:45, mdipierro wrote: se you do not have too, you can use ruotes already for this purpose. Here : http://www.web2py.com/AlterEgo/default/show/42
Re: [web2py] Re: my app instead of welcome app???
I ment... whats the use attempting to convince Massimo that this is a good idea although many community members want it. He has been against this suggestion for the last year that I have been using web2py and this has been brought up many times, and he probably won't ever change his mind, so we should just stop arguing the topic. -- Thadeus On Tue, Jun 15, 2010 at 12:05 PM, Jean-Guy jean...@gmail.com wrote: On 2010-06-15 11:47, Thadeus Burgess wrote: bah, whats the use. -- Thadeus On Tue, Jun 15, 2010 at 10:14 AM, Jean-Guyjean...@gmail.com wrote: On 2010-06-15 02:45, mdipierro wrote: se you do not have too, you can use ruotes already for this purpose. Here : http://www.web2py.com/AlterEgo/default/show/42 Just specify the app to load by default... Jonhy
Re: [web2py] Re: Documentation on moving common code into modules?
web2py does NOT follow normal python conventions. You are writing web2py code not python code =) -- Thadeus On Tue, Jun 15, 2010 at 4:41 PM, David Mitchell monch1...@gmail.com wrote: Thanks everyone, Didn't work for me for a while, then I rewired my brain from Ruby-mode to Python-mode and was off and running! Dave M. On 15 June 2010 10:48, weheh richard_gor...@verizon.net wrote: +1 regarding Yarko's suggestion. Putting common code into modules is probably the easiest way to have it visible to all controllers. It seems a little kludgy at first, but you get used to it. The one thing to be aware of is that models get executed in alphabetic order. So you may want to stick a number or letter at the beginning of the model name, like A_, B_, C_, etc. to control order of execution. Like I said, a little kludgy, but you get used to it. You will not have this issue if you use the modules approach.
Re: [web2py] upload bug in filename
how long is the filename? Isn't there like a 255 char limit to filenames? -- Thadeus On Mon, Jun 14, 2010 at 4:58 PM, Swell swel...@googlemail.com wrote: Hi , I tried to send a file with a form containing a upload field( actually it is a SQLFORM). When i try to add a new record with the administrative db interface , it breaks if the filename if very long ( not sure where it comes from ). Any idea? Thx
Re: [web2py] Re: my app instead of welcome app???
Why can't we configure the default name of 'init' ? -- Thadeus On Mon, Jun 14, 2010 at 7:33 AM, mdipierro mdipie...@cs.depaul.edu wrote: or simply call your app init On Jun 14, 7:19 am, Vasile Ermicioi elff...@gmail.com wrote: create routes.py (or rename routes.example.py) from web2py folder routes_in = ( ('/', '/yourappname/'), ) and restart web2py
Re: [web2py] Re: simplejson -- wasn't this resolved?
Sure. Worked. Installed simplejson with sudo easy_install simplejson Then get this traceback It seems that the version in contrib is importing from simplejson expecting its local version of the files, but instead it is pulling it down from the site-packages. -- Thadeus On Fri, Jun 11, 2010 at 12:55 AM, mdipierro mdipie...@cs.depaul.edu wrote: it is not the same problem. Can you help debug? On Jun 11, 12:38 am, Thadeus Burgess thade...@thadeusb.com wrote: Traceback (most recent call last): File /home/thadeusb/sites/thadeusb.com/subdomains/odyssey/wsgihandler.py, line 27, in module import gluon.main File gluon/main.py, line 34, in module from globals import Request, Response, Session File gluon/globals.py, line 18, in module from compileapp import run_view_in File gluon/compileapp.py, line 28, in module from sql import SQLDB, SQLField, DAL, Field File gluon/sql.py, line 43, in module from serializers import json File gluon/serializers.py, line 9, in module import contrib.simplejson as simplejson File gluon/contrib/simplejson/__init__.py, line 238, in module _default_decoder = JSONDecoder(encoding=None, object_hook=None) File gluon/contrib/simplejson/decoder.py, line 322, in __init__ self.scan_once = make_scanner(self) AttributeError: 'JSONDecoder' object has no attribute 'object_pairs_hook' I have to have simplejson installed in the system wide site-packages. -- Thadeus
Re: [web2py] Re: upload file -- lot of file in one directory
@auth.requires_login() def download(): problem solved. -- Thadeus On Fri, Jun 11, 2010 at 2:11 PM, weheh richard_gor...@verizon.net wrote: Once assigned, the user_id that my app creates is never changed. I would use the auth.user.id field, but I don't like the fact that it's sequential and therefore, easily guessed. I doubt that uploads can be hacked easily since you did such a good job with security. Nevertheless, I prefer to have an additional layer of obfuscation by having an encrypted user_id. On Jun 10, 11:32 pm, mdipierro mdipie...@cs.depaul.edu wrote: The problem with this is that the, I assume, tha database links the uploaded filename to the user_id and therefore you need to access the database to locate the file. That is ok until the database changes and somebody edits the user_id. Than you can no longer locate the file. On Jun 10, 7:36 am, weheh richard_gor...@verizon.net wrote: I think I'm dealing with the same situation, however, I'm going about it a little differently. I'm storing files in uploads/users/user_id/filename My user_id is a cypher of characters [A-Z][a-z][0-9] with a length anywhere from 8 to 12 characters or so. The filename is another cypher created automatically by web2py, following the table.field approach. One thing I'm thinking about is taking the user/user_id/filename structure entirely outside of web2py. The reason is that my server has 2 disk partitions and I might want to have these files resident under C:/ or D:/ Another reason is that I might want to gradually move these files to the cloud or another server. I'm wondering whether this is reasonable and even possible to do from within a web2py app working around the web2py way.- Hide quoted text - - Show quoted text -
Re: [web2py] Re: Separating models into their own files
I like the idea of an execmodels.py file, it could create a list of model names to execute.. Not yaml or cfg because that means web2py would require yet another library Massimo, tell me where this code *should* go and I will work on it since this is a very important feature to me. Lets draft up a specification and design first... I will make a public google doc located here https://docs.google.com/Doc?docid=0ActNNXQhkjU-ZGMyajJnbTdfOGZ3Z2IzOHQ2hl=en everyone can edit this doc What about requiring models from other apps? (i know apps arn't supposed to depend on each other, but it might be a good option to add so you *can* do it). -- Thadeus On Wed, Jun 9, 2010 at 11:42 PM, mdipierro mdipie...@cs.depaul.edu wrote: They both make a lot of sense. The former would be much easier to implement and would result in faster code. What do other people think? On Jun 9, 11:32 pm, Salvor Hardin salvor.pub...@gmail.com wrote: I'm new to python and web2py, so this might sound crazy but...here goes. Noob idea #1 Why not provide an optional exec_models.cfg file? If it doesn't exist, execute *.py files in alphabetical order found in the models folder. This will maintain backward compatibility and give web2py more flexibility. If exec_models.cfg exists, then exec the files in the order specified inside exec_models.cfg. If you want to get fancy, allow wildcards, etc. Even better, you can also use exec_models.py or exec_models.yaml instead of simple config. Noob idea #2 Provide web2py's version of python's import function. Call it require(somefile.py) and provide some web2py convention for somefile.py to follow. That way, you can have require() detect and decide what to do if somefile.py was already executed. Ruby has require and rubygems added their own require_gem() function which might provide useful ideas so you don't have to reinvent the wheel. It is late, and these are ideas that surfaced in the mind of a python and web2py noob. If you must laugh, do so with compassion. In the meantime, I'll try to read at least one python book by next Monday. Think Python is free online and looks like a quick one. On Jun 9, 9:32 pm, mdipierro mdipie...@cs.depaul.edu wrote: My approach is to use db_blablabla1.py db_blablabla2.py db_blablabla3.py where db_blablabla.py defiles all tables that link each other for a specific purpose. The different files are independent and therefore the order of execution is not important. On Jun 9, 9:20 pm, Thadeus Burgess thade...@thadeusb.com wrote: There are some things you can do to alleviate the situation. First, you can name you models so that they execute in the correct order. A_db.py B_user.py C_post.py E_tag.py That said, I usually try to keep all related models in the same file. In your case you might have B_user.py C_weblog.py Since post and tag both belong to the same logical set of tables, stick them together in one file. For objects, I also might subset it simpler such as C_weblog.py C_weblog_objects.py # contains virtualfield definitions. -- Thadeus On Wed, Jun 9, 2010 at 4:42 PM, mdipierro mdipie...@cs.depaul.edu wrote: No. This the main issue with web2py design. This is the price we pay for not having imports of models. On Jun 9, 4:21 pm, Binh btbinht...@gmail.com wrote: Hi, I am trying to create an orm setup like in ruby on rails with the DAL. I have a user, post, and tag model. A user has many posts. A tag belongs to a user. A post has and belongs to many tags. A tag has and belongs to many posts. I have 4 separate files in my models folder: db.py, user.py, post.py, and tag.py db.py contains the db connection and mail configurations. The respective model files define the table structure and have a class named after the model to implement virtual fields. I noticed that defining the tables with relationships in the separate files does not work properly. The model files would load which appears to be in alphabetical order. So, my db.py would load first and then post.py which fails. post.py fails to recognize the table definition in user.py, so it cannot define the belongs to relationship. Is their anyway to setup a model file to import all the other models without the hassle of file load order and possibly import order which rails does implicitly?
Re: [web2py] Re: web2pyslices update
I will have to point out. You can resize slices at anytime you want with no downtime to your server. You can clone any slice as many times as you want to any size of disk you want without taking down the original slice You get automated backups from daily, weekly, to monthly that are exact images of your slice. You can create a slice based from a backup image I have never had any of my slices go down or the network become unresponsive other than programming errors on my part You get a web console into the system, I have used several web based consoles before and this is absolutely the best I have used. Slicehost support has always gotten back to me with a response within 5 minutes of sending an email. During the middle of the day or the middle of the night! Slicehost has an API in python so theoretically you can have web2py control your slice if you so desired. There is something to say about the simplicity of the slicehost management, no fancy graphics making the navigation of the dashboard complex, it just has what you need and its perfect. -- Thadeus On Wed, Jun 9, 2010 at 10:31 PM, Salvor Hardin salvor.pub...@gmail.com wrote: FWIW, I've had 600+ days of uptime running Debian + Apache + qmail at www.linode.com. It was rebooted recently to switch from uml to xen. I have two nodes there, one Debian (sarge) in Texas and one Ubuntu 10.04 in New Jersey. Linode's web-based interface is amazing (I love being able to resize my ext3 disks without losing data, or cloning them or creating as many disks as I'd like. And being able to have multiple distros available to boot. And rebooting as frequently as I'd like.) And get this: you can get remote console access (LISH) even when your own SSH server is misconfigured or not running (so you can see your Linux startup/boot messages in real time when you reboot your vps even while your own ssh server hasn't started yet.) I'm just a very happy customer/fan. Not affiliated with them in any way. On Jun 9, 6:01 pm, mr.freeze nat...@freezable.com wrote: VPS provider fail. I'm on the hunt for a new provider. I hope to have it back up tomorrow.
Re: [web2py] Re: Separating models into their own files
What if I needed two controllers to share the same model? Would I then place two definitions in request.models? Not 0.py that is not a valid python filename. Python modules/variables cannot start with numbers. how about just a simple exec.py that gets loaded before everything? -- Thadeus On Thu, Jun 10, 2010 at 11:22 AM, mdipierro mdipie...@cs.depaul.edu wrote: one we agree with the syntax, this is easy. The main issue is making sure it works with bytecode compiled models. On Jun 10, 11:20 am, mdipierro mdipie...@cs.depaul.edu wrote: Here is my proposal: define the following: request.models=( ('*','db.py'), ('*','model1.py'), ('*','model2.py'), ('default','model3.py'), ('default/a,default/b','model4.py'), ) it specifies the order in which models should be executed. For each row, the first item specifies whether the model should be executed for all actions (*) for all actions in a controller (default) or only for specific actions (default/a, default/b). The second item in the model name. All models not listed would be executed in alphabetical order after those listed explicitly (backward compatibility). request.models would default to []. there would be a special model (execmodels.py? 0.py?) that would always be executed before every other model and it may override the value of request.models. all required code should go in a single place run_models_in() in gluon/ compileapp.py Massimo On Jun 10, 10:56 am, Thadeus Burgess thade...@thadeusb.com wrote: I like the idea of an execmodels.py file, it could create a list of model names to execute.. Not yaml or cfg because that means web2py would require yet another library Massimo, tell me where this code *should* go and I will work on it since this is a very important feature to me. Lets draft up a specification and design first... I will make a public google doc located here https://docs.google.com/Doc?docid=0ActNNXQhkjU-ZGMyajJnbTdfOGZ3Z2IzOH... everyone can edit this doc What about requiring models from other apps? (i know apps arn't supposed to depend on each other, but it might be a good option to add so you *can* do it). -- Thadeus On Wed, Jun 9, 2010 at 11:42 PM, mdipierro mdipie...@cs.depaul.edu wrote: They both make a lot of sense. The former would be much easier to implement and would result in faster code. What do other people think? On Jun 9, 11:32 pm, Salvor Hardin salvor.pub...@gmail.com wrote: I'm new to python and web2py, so this might sound crazy but...here goes. Noob idea #1 Why not provide an optional exec_models.cfg file? If it doesn't exist, execute *.py files in alphabetical order found in the models folder. This will maintain backward compatibility and give web2py more flexibility. If exec_models.cfg exists, then exec the files in the order specified inside exec_models.cfg. If you want to get fancy, allow wildcards, etc. Even better, you can also use exec_models.py or exec_models.yaml instead of simple config. Noob idea #2 Provide web2py's version of python's import function. Call it require(somefile.py) and provide some web2py convention for somefile.py to follow. That way, you can have require() detect and decide what to do if somefile.py was already executed. Ruby has require and rubygems added their own require_gem() function which might provide useful ideas so you don't have to reinvent the wheel. It is late, and these are ideas that surfaced in the mind of a python and web2py noob. If you must laugh, do so with compassion. In the meantime, I'll try to read at least one python book by next Monday. Think Python is free online and looks like a quick one. On Jun 9, 9:32 pm, mdipierro mdipie...@cs.depaul.edu wrote: My approach is to use db_blablabla1.py db_blablabla2.py db_blablabla3.py where db_blablabla.py defiles all tables that link each other for a specific purpose. The different files are independent and therefore the order of execution is not important. On Jun 9, 9:20 pm, Thadeus Burgess thade...@thadeusb.com wrote: There are some things you can do to alleviate the situation. First, you can name you models so that they execute in the correct order. A_db.py B_user.py C_post.py E_tag.py That said, I usually try to keep all related models in the same file. In your case you might have B_user.py C_weblog.py Since post and tag both belong to the same logical set of tables, stick them together in one file. For objects, I also might subset it simpler such as C_weblog.py C_weblog_objects.py # contains virtualfield definitions. -- Thadeus On Wed, Jun 9, 2010 at 4:42 PM, mdipierro mdipie...@cs.depaul.edu wrote: No. This the main issue with web2py design. This is the price we pay
Re: [web2py] Re: best list of jquery plugins I found so far
I think just... http://www.jqueryplugins.com/ -- Thadeus On Thu, Jun 10, 2010 at 12:02 PM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: that comes up as a bad link for me... www.jquery.com/plugins redirects to http://plugins.jquery.com -- is this the one you meant? On Jun 10, 11:04 am, mdipierro mdipie...@cs.depaul.edu wrote: http://www.jqueryplugins.com/plugins/
Re: [web2py] Re: Separating models into their own files
How will the exec_models.py be formatted Could it potentially be executed in an environment given a list, and append or overwrite this list with the model definitions exec_models = [ 'settings.py', 'db.py', 'auth.py', 'tag.py', 'post.py', 'comments.py', 'menu.py', 'other.py', ] Wildcards You should be able to specify a wildcard that would execute every remaining models in alpha order. exec_models = ['settings.py', 'db.py', '*'] The default exec_models.py file would contain a simple ['*'] from now on. Models from other applications It would be nice if you could execute models from another application. This leads to some issues such as 1) What if the other apps models overwrite some settings? Think of a situation you could have two sites, one public signup site, and a backend dashboard. You could do the following exec_models = ['backend.settings.py', 'backend.db.py', 'pages.py'] It will execute settings.py existing in the backend application, say this settings.py declares a DAL instance that then the rest of the current app will use. This way if two apps use the same database connection this theoretically allows a KISS principle by only having to write the database settings once, and the common tables once. -- Thadeus On Thu, Jun 10, 2010 at 12:17 PM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: On Jun 10, 11:20 am, mdipierro mdipie...@cs.depaul.edu wrote: Here is my proposal: define the following: request.models=( ('*','db.py'), ('*','model1.py'), ('*','model2.py'), ('default','model3.py'), ('default/a,default/b','model4.py'), ) it specifies the order in which models should be executed. For each row, the first item specifies whether the model should be executed for all actions (*) for all actions in a controller (default) or only for specific actions (default/a, default/b). The second item in the model name. All models not listed would be executed in alphabetical order after those listed explicitly (backward compatibility). == Why? Your reason for adding this requirement here is not evident. I thought the original suggestion: that backward compatibility is accomplished, and current order of exectution actuated in the _absence_ of an exec.py (or whateve the name ends up being). request.models would default to []. there would be a special model (execmodels.py? 0.py?) that would always be executed before every other model and it may override the value of request.models. all required code should go in a single place run_models_in() in gluon/ compileapp.py Massimo On Jun 10, 10:56 am, Thadeus Burgess thade...@thadeusb.com wrote: I like the idea of an execmodels.py file, it could create a list of model names to execute.. Not yaml or cfg because that means web2py would require yet another library Massimo, tell me where this code *should* go and I will work on it since this is a very important feature to me. Lets draft up a specification and design first... I will make a public google doc located here https://docs.google.com/Doc?docid=0ActNNXQhkjU-ZGMyajJnbTdfOGZ3Z2IzOH... everyone can edit this doc What about requiring models from other apps? (i know apps arn't supposed to depend on each other, but it might be a good option to add so you *can* do it). -- Thadeus On Wed, Jun 9, 2010 at 11:42 PM, mdipierro mdipie...@cs.depaul.edu wrote: They both make a lot of sense. The former would be much easier to implement and would result in faster code. What do other people think? On Jun 9, 11:32 pm, Salvor Hardin salvor.pub...@gmail.com wrote: I'm new to python and web2py, so this might sound crazy but...here goes. Noob idea #1 Why not provide an optional exec_models.cfg file? If it doesn't exist, execute *.py files in alphabetical order found in the models folder. This will maintain backward compatibility and give web2py more flexibility. If exec_models.cfg exists, then exec the files in the order specified inside exec_models.cfg. If you want to get fancy, allow wildcards, etc. Even better, you can also use exec_models.py or exec_models.yaml instead of simple config. Noob idea #2 Provide web2py's version of python's import function. Call it require(somefile.py) and provide some web2py convention for somefile.py to follow. That way, you can have require() detect and decide what to do if somefile.py was already executed. Ruby has require and rubygems added their own require_gem() function which might provide useful ideas so you don't have to reinvent the wheel. It is late, and these are ideas that surfaced in the mind of a python and web2py noob. If you must laugh, do so with compassion. In the meantime, I'll try to read at least one python book by next Monday. Think Python is free online and looks like a quick one. On Jun 9, 9:32 pm, mdipierro mdipie...@cs.depaul.edu wrote: My approach is to use
Re: [web2py] Re: Hardening web2py on Linux and Windows servers
www-data needs write access to databases/cache/sessions etc. IF a hacker were able to gain access *somehow* and alter the databases files, they can kill your entire system by forcing fake migrations or other issues. Just make sure you have migrate=False and fake_migrate=False and everything *should* be just fine. -- Thadeus On Thu, Jun 10, 2010 at 2:01 PM, mdipierro mdipie...@cs.depaul.edu wrote: None of these should be a problem. Mind that you will not be able to edit/install/uninstall apps using the web interface. On Jun 10, 1:45 pm, Salvor Hardin salvor.pub...@gmail.com wrote: We selected web2py over django and pylons to replace RoR. Luckily, that project doesn't require paranoid security (hence our ability to use RoR in the past.) But we're evaluating web2py to replace a Win32 GUI intranet app, and preventing hacks on the server side, is pretty high on the priority for that project. For example, we want to prevent user from modifying web2py's .py files, etc. by exploiting security flaws in Python or python modules. What are some ways to improve the security of web2py apps on production servers? * Use mod_security and its Core Rule Set (no web2py compatibility issues?) * Prevent Apache2 user (www-data) having write access or chmod rights to web2py application files? * chown/chmod web2py files to require root access to upgrade to newer web2py? I'm not asking for changes to web2py. I'm just looking for best practices on projects that value security over certain features like web-based upgrades or web-based deployment, etc. For example, requiring root access to upgrade web2py would be seen as a benefit on at least one project.
Re: [web2py] Re: Separating models into their own files
This is what I desire from this Web2py applications to be importable python modules Along with [A] your models immediately become python modules that you can import. This solves my need to share models between web2py apps.' Web2py has a Top down approach, where other frameworks use a down-up approach. Meaning, web2py executes the models THEN looks at the request, determines the controller and executes it, then executes the view. Everyone else does the down-top approach, where the request comes in, it goes to the controller, the controller decides what models to IMPORT and then executes itself and even decides what view to return if any! This is what the discussion has turned into, a design pattern, web2py can never satisfy the down-top approach because of backwards compatibility. Perhaps web3py. -- Thadeus On Thu, Jun 10, 2010 at 3:24 PM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: On Jun 10, 1:17 pm, mdipierro mdipie...@cs.depaul.edu wrote: If we are going to work on this we may as well solve a different problem. Executing models take time. If you have 500 tables each defined it its own file, it takes lots of time. Yet not all actions need all tables so we may want to implement a dependency not just among models but among actions and models so that not-needed models are not executed. If the dependencies are expressed in the model files themselves they ... I assume you meant to say ...in controller files... still needs to be executed (or at least bytceode compiled) to be resolved and that defies the purpose. Moreover this would be similar to the python import mechanism (from a user prospective) and thus an example of reinventing the wheel. ... if I am following you, then why do we not just import the needed models? I mean, really, seriously - why the need to exec? It seems like that is a question on the table. Having a centralized place where these dependencies are expressed has advantages: - sets us a apart from everybody and we do not need to reinvent the wheel Global variables in FORTRAN had proponents too - but the need to manage complexity drove a different structure in programming. (That is to say, I am not seeing, am challenging that there are _any_ REAL advantages to centralized dependency management;) == set us apart is not any kind of advantage, if it does not provide tangible benefit. (that is, benefit may drive what sets web2py apart, but making set apart a motive is not beneficial in and of itself - this should be very clear). If there is a current wheel that is useful, use it. $ python import this one way is better; if there is something that currently solves the problem, use it (don't 'reinvent the wheel'; _and_ don't look for problems as an excuse to invent a wheel) - it will make the structure of the application easier to read in a single place ... I don't agree, don't see this as beneficial; harder to maintain; related information scattered; - it will make the app faster ... this is not a benefit - it is a goal; you are implying that centralized models are the only way to make an app faster; I'm not buying; I don't think that's true at all. - it will be easier to implement without breaking backward compatibility (and there it will get done) simplicity of implementation is a benefit to _you_; but (while that may be important to you), simplicity to implement applications (since it happens more frequently) is first in line; _then_ simplicity of implementation, practicality; I don't see this as a benefit of central place; - it will open the possibility for dependencies to be auto-discovered and therefore the config-file auto-generated ... actually, you could generate (if that were the most practical way) a central dependency list from local declarations (which is how Windows Registry works); I don't see this is a benefit of central place, rather a practical consideration. ... this is beginning to feel like an old tet-a-tet. ...
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Idea: Theoretically speaking of course if I were to create a virtual machine loaded with an apache instance and web2py on mod_wsgi. Using the various methods of *faking* an autonumber field on different virtual machines, for the sake of scientific research. Using the apache AB testing upon a page of web2py that performs an insert into the database it could be potential to determine any errors with the *faked* autonumber system. In this case, the original method of using a query for last_mem_id *should* fail under an extensive AB test. This would be determined since the AB tests keep track of how many 500 server errors are returned... in the web2py case, this would be the ``IntegrityError`` issued from the database complaining about a duplicate value. So... using this same logic we can implement the other method of *faking* autonumber by creating a secondary table sequence manually in web2py. Using this same test we can verify if the server fails under high insertion load, or if it handles things correctly. This would look like Massimo's suggestion earlier. Also, the new autonumber support could be testing the exact same way. Does this way of testing make logical sense? Do you think it would work? What I am getting at is that if Massimo's suggestion of using a secondary table and compute to calculate will hold up to the AB testing then that would be the way to do things on a cross-database level. When you use SERIAL in postgres, it is effectively creating a secondary table to use as a sequence value that can correctly handle race-time conditions. -- Thadeus On Wed, Jun 9, 2010 at 11:05 AM, mdipierro mdipie...@cs.depaul.edu wrote: This is not going to stay, it is just for you to look at. Consider defining the field as integer and create a trigger using SQL to autofill this field. On Jun 9, 10:52 am, mdipierro mdipie...@cs.depaul.edu wrote: well, I am posting in trunk a modifiled sql.py that allows Field('name','autoincrement') and generates the following code for postgresql (only postgresql). Give it a try. Massimo On Jun 9, 10:38 am, Thadeus Burgess thade...@thadeusb.com wrote: Postgres CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT SERIAL); Or... CREATE SEQUENCE seq_foo_did START 2; CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT nextval('seq_foo_did')); SQLite however does not support multiple auto-increment fields unfortunately, so on sqlite it must be done the way of creating another table with a blank field and use its id as a sequence (basically like how postgres does behind the scenes). MySQL also supports multiple autonumber fields. Having two autonumber fields is an absolute requirement of the system and there is no way around this. Unfortunately I don't have time to work on implementing this in web2py, and I could probably re-write my app in something else faster than it would take me to implement this in the DAL since I am not familiar enough with the DALs internal quirks. I can't do anything for at least 3 weeks programming wise, so I won't even be getting around to fixing this issue until then. -- Thadeus On Wed, Jun 9, 2010 at 9:26 AM, mdipierro mdipie...@cs.depaul.edu wrote: I am not sure about the postgresql solution. Tell me how you do it in SQL and i tell you how to do in web2pyese. On Jun 9, 9:01 am, Thadeus Burgess thade...@thadeusb.com wrote: Great. What about sqlite? -- Thadeus On Wed, Jun 9, 2010 at 8:41 AM, mdipierro mdipie...@cs.depaul.edu wrote: In postgresql you get it native: Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) On Jun 9, 5:28 am, Thadeus Burgess thade...@thadeusb.com wrote: That is the thing, its *almost* the same, but its not a true postgres sequence. Postgres already has many years of development making sure their auto number works, why can't I just use that instead of trying to hack around the limitations of a system? I don't have a choice. I *must* have native support for autonumber, or I have to use another system that already allows me to. -- Thadeus On Tue, Jun 8, 2010 at 10:22 PM, mdipierro mdipie...@cs.depaul.edu wrote: If it were possible to do a SQL insert without the dummy filed this almost the same as creating a sequence. web2py can create a table without any field but the id, but I do not do not how to do an insert without any field value. On Jun 8, 8:12 pm, Thadeus Burgess thade...@thadeusb.com wrote: This *might* work. You are right, it is still horrible... It might be *effectively* accomplishing the same thing that sequences do on PostgreSQL, however I still wouldn't use it in production as it feels hacky. I already have to re-design this table, so I might as well do
Re: [web2py] Re: Separating models into their own files
This code MUST be executed. There is no way to import it because request.client only exist when the request arrives and we do not want to re import modules on every request. Flask accomplishes this perfectly by placing the request in a context thread local. It only exists the the thread local when a request actually arrives. So from flask import request will fail if there is actually no request! I am learning more about thread locals at the moment, but it seems reasonable enough and it works. -- Thadeus On Thu, Jun 10, 2010 at 4:53 PM, mdipierro mdipie...@cs.depaul.edu wrote: The conclusion is right but it is more complicated than that. This is not a syntactical issue. Let' say in a model we have: db.define_table('a',Field('b',default=request.client)) This code MUST be executed. There is no way to import it because request.client only exist when the request arrives and we do not want to re import modules on every request. The easiness comes from the fact that you can code assuming there is a client while in other frameworks you need to be careful and wrap everything into functions that eventually will be called when the request arrives and the request is passed around explicitly. In all other frameworks, the imports are resolved before an http request arrives, not after. This is why for example, they have issue with multiple database connections, client dependent database connections, real time migrations, etc. Moreover, as a result they need to monitor py files for changes are reload them when changes occur. This mechanism works ONLY for pure-python web servers and not with apache for example. Moreover this is subject to all the reload caveats http://docs.python.org/library/functions.html about old global variables being retained on reload in the module __dict__ (this may cause memory leaks and data leaking from one session to another thus causing security issues). We make a clean exec for every request and we have no memory leaks and no data pollution as well a clean syntax. There will be no import of models in web2py or it will not be web2py any more. This can be reassessed in web3py but as I stated before: IF there is a web3py for me to be interesting it has to be completely different. It may not even be in Python. Perhaps we should look into Cobra (http:// cobra-language.com/). Massimo On Jun 10, 3:44 pm, Thadeus Burgess thade...@thadeusb.com wrote: This is what I desire from this Web2py applications to be importable python modules Along with [A] your models immediately become python modules that you can import. This solves my need to share models between web2py apps.' Web2py has a Top down approach, where other frameworks use a down-up approach. Meaning, web2py executes the models THEN looks at the request, determines the controller and executes it, then executes the view. Everyone else does the down-top approach, where the request comes in, it goes to the controller, the controller decides what models to IMPORT and then executes itself and even decides what view to return if any! This is what the discussion has turned into, a design pattern, web2py can never satisfy the down-top approach because of backwards compatibility. Perhaps web3py. -- Thadeus On Thu, Jun 10, 2010 at 3:24 PM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: On Jun 10, 1:17 pm, mdipierro mdipie...@cs.depaul.edu wrote: If we are going to work on this we may as well solve a different problem. Executing models take time. If you have 500 tables each defined it its own file, it takes lots of time. Yet not all actions need all tables so we may want to implement a dependency not just among models but among actions and models so that not-needed models are not executed. If the dependencies are expressed in the model files themselves they ... I assume you meant to say ...in controller files... still needs to be executed (or at least bytceode compiled) to be resolved and that defies the purpose. Moreover this would be similar to the python import mechanism (from a user prospective) and thus an example of reinventing the wheel. ... if I am following you, then why do we not just import the needed models? I mean, really, seriously - why the need to exec? It seems like that is a question on the table. Having a centralized place where these dependencies are expressed has advantages: - sets us a apart from everybody and we do not need to reinvent the wheel Global variables in FORTRAN had proponents too - but the need to manage complexity drove a different structure in programming. (That is to say, I am not seeing, am challenging that there are _any_ REAL advantages to centralized dependency management;) == set us apart is not any kind of advantage, if it does not provide tangible benefit. (that is, benefit may drive what sets web2py apart, but making set apart a motive is not beneficial
Re: [web2py] Re: web2pyslices update
Is it running slow for you or is it just me? -- Thadeus On Thu, Jun 10, 2010 at 1:34 PM, mr.freeze nat...@freezable.com wrote: We're back! Sorry about the extended downtime. I ended up going with FiveBean since their VPS's were more in my price range (promo code UBUNTU gives you 50% off!). http://fivebean.com/account/aff.php?aff=161 Now get to slicin'! On Jun 10, 11:26 am, Thadeus Burgess thade...@thadeusb.com wrote: I will have to point out. You can resize slices at anytime you want with no downtime to your server. You can clone any slice as many times as you want to any size of disk you want without taking down the original slice You get automated backups from daily, weekly, to monthly that are exact images of your slice. You can create a slice based from a backup image I have never had any of my slices go down or the network become unresponsive other than programming errors on my part You get a web console into the system, I have used several web based consoles before and this is absolutely the best I have used. Slicehost support has always gotten back to me with a response within 5 minutes of sending an email. During the middle of the day or the middle of the night! Slicehost has an API in python so theoretically you can have web2py control your slice if you so desired. There is something to say about the simplicity of the slicehost management, no fancy graphics making the navigation of the dashboard complex, it just has what you need and its perfect. -- Thadeus On Wed, Jun 9, 2010 at 10:31 PM, Salvor Hardin salvor.pub...@gmail.com wrote: FWIW, I've had 600+ days of uptime running Debian + Apache + qmail at www.linode.com. It was rebooted recently to switch from uml to xen. I have two nodes there, one Debian (sarge) in Texas and one Ubuntu 10.04 in New Jersey. Linode's web-based interface is amazing (I love being able to resize my ext3 disks without losing data, or cloning them or creating as many disks as I'd like. And being able to have multiple distros available to boot. And rebooting as frequently as I'd like.) And get this: you can get remote console access (LISH) even when your own SSH server is misconfigured or not running (so you can see your Linux startup/boot messages in real time when you reboot your vps even while your own ssh server hasn't started yet.) I'm just a very happy customer/fan. Not affiliated with them in any way. On Jun 9, 6:01 pm, mr.freeze nat...@freezable.com wrote: VPS provider fail. I'm on the hunt for a new provider. I hope to have it back up tomorrow.
Re: [web2py] Re: Support for conversation?
That is where the hidden input field with a custom hash comes into play I think? -- Thadeus On Fri, Jun 11, 2010 at 12:00 AM, mdipierro mdipie...@cs.depaul.edu wrote: The only issue is that if you have two browser windows open I do not know of a mechanism to identify from which of the two windows a request arrives since the cookies are the same. On Jun 10, 11:39 pm, pierreth pierre.thibau...@gmail.com wrote: On 10 juin, 19:14, mdipierro mdipie...@cs.depaul.edu wrote: Interesting. How do you think this can be implemented? Well, before thinking about the implementation, we must understand the concepts involved. So let's start with the idea of scope. The scope defines the time a peace of information is kept. Information in application memory is present a certain scope. From the shortest to the longest, scopes form a hierarchy. One scope is included in the life time of another. We may have: - Request scope (exists the time it takes to process the request) - Conversation scope (the time of a conservation) - Session scope (as we already know) - Application scope (from the server start up to its shutdown) - Business process scope (scope usually involving many actors and that can last for many months, this state has to be saved and restored between server shutdowns) The conversation scope deserves more explanation. This is the scope to use for example when a user wants to reserve a hotel room. The user goes through a set of pages to do its reservation (he can also use the back button if he change his mind). He can open a new window and do another reservation in parallel. The application keep a different state for each window. This is what we call a conversation. In the application, we need an object to read and write in these scopes. Let's called it the 'scope resolver' or 'resolver' for short. Instead of using the session, we use the resolver. The resolver looks for a property in the shortest long living scope to find the value of a property. If it does not find the value at one scope, it looks at the next longer living scope. It continues like that up the longest scope. If nothing is found in the whole lookup process, it returns 'None'. To begin and end scoping processes, I think we can use decorators just like Java uses annotations. We also have to find a way to add a hidden field in the forms to identify them with a specific conversation. All of this was implemented in Java using the interceptor pattern. I know that Web2py has the concept of plug-in (I am new to Web2py). Is it possible to implement all this without modifying Web2py? It could a great occasion to improve the design of the framework if it is not the case. We have a great example with JBoss Seam. Spring Webflow could be inspiring too. So before going in the details, what do think about this idea?
[web2py] simplejson -- wasn't this resolved?
Traceback (most recent call last): File /home/thadeusb/sites/thadeusb.com/subdomains/odyssey/wsgihandler.py, line 27, in module import gluon.main File gluon/main.py, line 34, in module from globals import Request, Response, Session File gluon/globals.py, line 18, in module from compileapp import run_view_in File gluon/compileapp.py, line 28, in module from sql import SQLDB, SQLField, DAL, Field File gluon/sql.py, line 43, in module from serializers import json File gluon/serializers.py, line 9, in module import contrib.simplejson as simplejson File gluon/contrib/simplejson/__init__.py, line 238, in module _default_decoder = JSONDecoder(encoding=None, object_hook=None) File gluon/contrib/simplejson/decoder.py, line 322, in __init__ self.scan_once = make_scanner(self) AttributeError: 'JSONDecoder' object has no attribute 'object_pairs_hook' I have to have simplejson installed in the system wide site-packages. -- Thadeus
Re: [web2py] Re: Support for conversation?
javascript? -- Thadeus On Fri, Jun 11, 2010 at 12:14 AM, mdipierro mdipie...@cs.depaul.edu wrote: yes but people don't just navigate by submitting forms. they also navigate by clicking links. The only way to keep a conversation would be to store a token in request.args(0) and keep it there in all links. Still the conversation is fragile and ends if the user types in a url without the token. On Jun 11, 12:04 am, Thadeus Burgess thade...@thadeusb.com wrote: That is where the hidden input field with a custom hash comes into play I think? -- Thadeus On Fri, Jun 11, 2010 at 12:00 AM, mdipierro mdipie...@cs.depaul.edu wrote: The only issue is that if you have two browser windows open I do not know of a mechanism to identify from which of the two windows a request arrives since the cookies are the same. On Jun 10, 11:39 pm, pierreth pierre.thibau...@gmail.com wrote: On 10 juin, 19:14, mdipierro mdipie...@cs.depaul.edu wrote: Interesting. How do you think this can be implemented? Well, before thinking about the implementation, we must understand the concepts involved. So let's start with the idea of scope. The scope defines the time a peace of information is kept. Information in application memory is present a certain scope. From the shortest to the longest, scopes form a hierarchy. One scope is included in the life time of another. We may have: - Request scope (exists the time it takes to process the request) - Conversation scope (the time of a conservation) - Session scope (as we already know) - Application scope (from the server start up to its shutdown) - Business process scope (scope usually involving many actors and that can last for many months, this state has to be saved and restored between server shutdowns) The conversation scope deserves more explanation. This is the scope to use for example when a user wants to reserve a hotel room. The user goes through a set of pages to do its reservation (he can also use the back button if he change his mind). He can open a new window and do another reservation in parallel. The application keep a different state for each window. This is what we call a conversation. In the application, we need an object to read and write in these scopes. Let's called it the 'scope resolver' or 'resolver' for short. Instead of using the session, we use the resolver. The resolver looks for a property in the shortest long living scope to find the value of a property. If it does not find the value at one scope, it looks at the next longer living scope. It continues like that up the longest scope. If nothing is found in the whole lookup process, it returns 'None'. To begin and end scoping processes, I think we can use decorators just like Java uses annotations. We also have to find a way to add a hidden field in the forms to identify them with a specific conversation. All of this was implemented in Java using the interceptor pattern. I know that Web2py has the concept of plug-in (I am new to Web2py). Is it possible to implement all this without modifying Web2py? It could a great occasion to improve the design of the framework if it is not the case. We have a great example with JBoss Seam. Spring Webflow could be inspiring too. So before going in the details, what do think about this idea?
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
That is the thing, its *almost* the same, but its not a true postgres sequence. Postgres already has many years of development making sure their auto number works, why can't I just use that instead of trying to hack around the limitations of a system? I don't have a choice. I *must* have native support for autonumber, or I have to use another system that already allows me to. -- Thadeus On Tue, Jun 8, 2010 at 10:22 PM, mdipierro mdipie...@cs.depaul.edu wrote: If it were possible to do a SQL insert without the dummy filed this almost the same as creating a sequence. web2py can create a table without any field but the id, but I do not do not how to do an insert without any field value. On Jun 8, 8:12 pm, Thadeus Burgess thade...@thadeusb.com wrote: This *might* work. You are right, it is still horrible... It might be *effectively* accomplishing the same thing that sequences do on PostgreSQL, however I still wouldn't use it in production as it feels hacky. I already have to re-design this table, so I might as well do it 100% right. I never expected the scale of inserts that happened yesterday and today, nor had any proper benchmarking been done previously if it could handle this kind of sudden rush of traffic. -- Thadeus On Tue, Jun 8, 2010 at 4:36 PM, mdipierro mdipie...@cs.depaul.edu wrote: I know this horrible but it does solve some of the problems... db.define_table('whopper_seq',Field('dummy')) db.define_table('yourtable',... Field(whopper_id, integer,compute=lambda r: db.whopper_seq.insert(dummy=None)) ...) On Jun 7, 8:29 pm, Thadeus Burgess thade...@thadeusb.com wrote: I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests come in to create a record within miliseconds of each other. Here is where I need some help please. I need to convert this entire field, into an autoincrementing integer performed by the database, however ALL current whopper_ids must stay EXACTLY the same. I don't know how to accomplish this with web2py. I know what I want... Field(whopper_id, integer, unique=True, autoincrement=True) But how do I convert all existing whopper_ids over and keep them the exact same? Is this even possible with web2py and the DAL? -- Thadeus
Re: [web2py] Re: PluginManager?
We have not fully agreed on the spec of PluginManager, it has been added as a proof of concept, however no plugins to date have been implemented with it. There are hundreds of posts debated what it should do. Currently the spec for plugins is you can do anything you want as long as it has the word plugin_ in front of it. PluginManager is an attempt to clean up the global namespace, so you don't have tons of plugins littering with their own variables and such. Not sure if you have seen this... http://static.thadeusb.com/Web2py%20Plugin%20Specification.pdf -- Thadeus On Wed, Jun 9, 2010 at 5:08 AM, AsmanCom d.as...@web.de wrote: env(a, import_models=False, c=1, f=1, dir='', extra_request={}) Return web2py execution environment for application (a), controller (c), function (f). If import_models is True the exec all application models into the environment. extra_request allows you to pass along any extra variables to the request object before your models get executed. This was mainly done to support web2py_utils.test_runner, however you can use it with any wrapper scripts that need access to the web2py environment. On 8 Jun., 05:42, Doug Warren doug.war...@gmail.com wrote: So I'm writing a plugin to handle scheduling of tasks with a dynamic granularity of a second or less, and I went to use PluginManger per it's definition in tools.py: class PluginManager(dict): This object stored parameters to configure plugins (if they need configuration) In models/db.py instantiate the PluginManager plugins=PluginManager() then set the parameters required plugins, for example plugins.comments.db=db (each plugin should have a documented set of required parameters) My code: plugins = PluginManager() db = plugins.plugin_scheduler.db or None if db is not None: db.define_table(plugins.plugin_scheduler.table_name or 'plugin_scheduler_table', db.Field('execution_time', 'datetime', default=request.now), db.Field('controller', 'string'), db.Field('function', 'string') ) Only problem... def __init__(self,env): self['globals'] = env What's that env? Has anyone written a plugin that uses PluginManager? I checked on the official site and none seem to be using it... If it's request.env shouldn't it have a default arg of None? Am I using it as it was expected to be used?
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Great. What about sqlite? -- Thadeus On Wed, Jun 9, 2010 at 8:41 AM, mdipierro mdipie...@cs.depaul.edu wrote: In postgresql you get it native: Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) On Jun 9, 5:28 am, Thadeus Burgess thade...@thadeusb.com wrote: That is the thing, its *almost* the same, but its not a true postgres sequence. Postgres already has many years of development making sure their auto number works, why can't I just use that instead of trying to hack around the limitations of a system? I don't have a choice. I *must* have native support for autonumber, or I have to use another system that already allows me to. -- Thadeus On Tue, Jun 8, 2010 at 10:22 PM, mdipierro mdipie...@cs.depaul.edu wrote: If it were possible to do a SQL insert without the dummy filed this almost the same as creating a sequence. web2py can create a table without any field but the id, but I do not do not how to do an insert without any field value. On Jun 8, 8:12 pm, Thadeus Burgess thade...@thadeusb.com wrote: This *might* work. You are right, it is still horrible... It might be *effectively* accomplishing the same thing that sequences do on PostgreSQL, however I still wouldn't use it in production as it feels hacky. I already have to re-design this table, so I might as well do it 100% right. I never expected the scale of inserts that happened yesterday and today, nor had any proper benchmarking been done previously if it could handle this kind of sudden rush of traffic. -- Thadeus On Tue, Jun 8, 2010 at 4:36 PM, mdipierro mdipie...@cs.depaul.edu wrote: I know this horrible but it does solve some of the problems... db.define_table('whopper_seq',Field('dummy')) db.define_table('yourtable',... Field(whopper_id, integer,compute=lambda r: db.whopper_seq.insert(dummy=None)) ...) On Jun 7, 8:29 pm, Thadeus Burgess thade...@thadeusb.com wrote: I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests come in to create a record within miliseconds of each other. Here is where I need some help please. I need to convert this entire field, into an autoincrementing integer performed by the database, however ALL current whopper_ids must stay EXACTLY the same. I don't know how to accomplish this with web2py. I know what I want... Field(whopper_id, integer, unique=True, autoincrement=True) But how do I convert all existing whopper_ids over and keep them the exact same? Is this even possible with web2py and the DAL? -- Thadeus
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Postgres CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT SERIAL); Or... CREATE SEQUENCE seq_foo_did START 2; CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT nextval('seq_foo_did')); SQLite however does not support multiple auto-increment fields unfortunately, so on sqlite it must be done the way of creating another table with a blank field and use its id as a sequence (basically like how postgres does behind the scenes). MySQL also supports multiple autonumber fields. Having two autonumber fields is an absolute requirement of the system and there is no way around this. Unfortunately I don't have time to work on implementing this in web2py, and I could probably re-write my app in something else faster than it would take me to implement this in the DAL since I am not familiar enough with the DALs internal quirks. I can't do anything for at least 3 weeks programming wise, so I won't even be getting around to fixing this issue until then. -- Thadeus On Wed, Jun 9, 2010 at 9:26 AM, mdipierro mdipie...@cs.depaul.edu wrote: I am not sure about the postgresql solution. Tell me how you do it in SQL and i tell you how to do in web2pyese. On Jun 9, 9:01 am, Thadeus Burgess thade...@thadeusb.com wrote: Great. What about sqlite? -- Thadeus On Wed, Jun 9, 2010 at 8:41 AM, mdipierro mdipie...@cs.depaul.edu wrote: In postgresql you get it native: Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) On Jun 9, 5:28 am, Thadeus Burgess thade...@thadeusb.com wrote: That is the thing, its *almost* the same, but its not a true postgres sequence. Postgres already has many years of development making sure their auto number works, why can't I just use that instead of trying to hack around the limitations of a system? I don't have a choice. I *must* have native support for autonumber, or I have to use another system that already allows me to. -- Thadeus On Tue, Jun 8, 2010 at 10:22 PM, mdipierro mdipie...@cs.depaul.edu wrote: If it were possible to do a SQL insert without the dummy filed this almost the same as creating a sequence. web2py can create a table without any field but the id, but I do not do not how to do an insert without any field value. On Jun 8, 8:12 pm, Thadeus Burgess thade...@thadeusb.com wrote: This *might* work. You are right, it is still horrible... It might be *effectively* accomplishing the same thing that sequences do on PostgreSQL, however I still wouldn't use it in production as it feels hacky. I already have to re-design this table, so I might as well do it 100% right. I never expected the scale of inserts that happened yesterday and today, nor had any proper benchmarking been done previously if it could handle this kind of sudden rush of traffic. -- Thadeus On Tue, Jun 8, 2010 at 4:36 PM, mdipierro mdipie...@cs.depaul.edu wrote: I know this horrible but it does solve some of the problems... db.define_table('whopper_seq',Field('dummy')) db.define_table('yourtable',... Field(whopper_id, integer,compute=lambda r: db.whopper_seq.insert(dummy=None)) ...) On Jun 7, 8:29 pm, Thadeus Burgess thade...@thadeusb.com wrote: I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests come in to create a record within miliseconds of each other. Here is where I need some help please. I need to convert this entire field, into an autoincrementing integer performed by the database, however ALL current whopper_ids must stay EXACTLY the same. I don't know how to accomplish this with web2py. I know what I want... Field(whopper_id, integer, unique=True, autoincrement=True) But how do I convert all existing whopper_ids over and keep them the exact same? Is this even possible with web2py and the DAL? -- Thadeus
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Understood. I will test this ASAP. -- Thadeus On Wed, Jun 9, 2010 at 11:05 AM, mdipierro mdipie...@cs.depaul.edu wrote: This is not going to stay, it is just for you to look at. Consider defining the field as integer and create a trigger using SQL to autofill this field. On Jun 9, 10:52 am, mdipierro mdipie...@cs.depaul.edu wrote: well, I am posting in trunk a modifiled sql.py that allows Field('name','autoincrement') and generates the following code for postgresql (only postgresql). Give it a try. Massimo On Jun 9, 10:38 am, Thadeus Burgess thade...@thadeusb.com wrote: Postgres CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT SERIAL); Or... CREATE SEQUENCE seq_foo_did START 2; CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT nextval('seq_foo_did')); SQLite however does not support multiple auto-increment fields unfortunately, so on sqlite it must be done the way of creating another table with a blank field and use its id as a sequence (basically like how postgres does behind the scenes). MySQL also supports multiple autonumber fields. Having two autonumber fields is an absolute requirement of the system and there is no way around this. Unfortunately I don't have time to work on implementing this in web2py, and I could probably re-write my app in something else faster than it would take me to implement this in the DAL since I am not familiar enough with the DALs internal quirks. I can't do anything for at least 3 weeks programming wise, so I won't even be getting around to fixing this issue until then. -- Thadeus On Wed, Jun 9, 2010 at 9:26 AM, mdipierro mdipie...@cs.depaul.edu wrote: I am not sure about the postgresql solution. Tell me how you do it in SQL and i tell you how to do in web2pyese. On Jun 9, 9:01 am, Thadeus Burgess thade...@thadeusb.com wrote: Great. What about sqlite? -- Thadeus On Wed, Jun 9, 2010 at 8:41 AM, mdipierro mdipie...@cs.depaul.edu wrote: In postgresql you get it native: Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) On Jun 9, 5:28 am, Thadeus Burgess thade...@thadeusb.com wrote: That is the thing, its *almost* the same, but its not a true postgres sequence. Postgres already has many years of development making sure their auto number works, why can't I just use that instead of trying to hack around the limitations of a system? I don't have a choice. I *must* have native support for autonumber, or I have to use another system that already allows me to. -- Thadeus On Tue, Jun 8, 2010 at 10:22 PM, mdipierro mdipie...@cs.depaul.edu wrote: If it were possible to do a SQL insert without the dummy filed this almost the same as creating a sequence. web2py can create a table without any field but the id, but I do not do not how to do an insert without any field value. On Jun 8, 8:12 pm, Thadeus Burgess thade...@thadeusb.com wrote: This *might* work. You are right, it is still horrible... It might be *effectively* accomplishing the same thing that sequences do on PostgreSQL, however I still wouldn't use it in production as it feels hacky. I already have to re-design this table, so I might as well do it 100% right. I never expected the scale of inserts that happened yesterday and today, nor had any proper benchmarking been done previously if it could handle this kind of sudden rush of traffic. -- Thadeus On Tue, Jun 8, 2010 at 4:36 PM, mdipierro mdipie...@cs.depaul.edu wrote: I know this horrible but it does solve some of the problems... db.define_table('whopper_seq',Field('dummy')) db.define_table('yourtable',... Field(whopper_id, integer,compute=lambda r: db.whopper_seq.insert(dummy=None)) ...) On Jun 7, 8:29 pm, Thadeus Burgess thade...@thadeusb.com wrote: I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests
Re: [web2py] web2pyslices update
slicehost! =) -- Thadeus On Wed, Jun 9, 2010 at 6:01 PM, mr.freeze nat...@freezable.com wrote: VPS provider fail. I'm on the hunt for a new provider. I hope to have it back up tomorrow.
Re: [web2py] Re: Separating models into their own files
There are some things you can do to alleviate the situation. First, you can name you models so that they execute in the correct order. A_db.py B_user.py C_post.py E_tag.py That said, I usually try to keep all related models in the same file. In your case you might have B_user.py C_weblog.py Since post and tag both belong to the same logical set of tables, stick them together in one file. For objects, I also might subset it simpler such as C_weblog.py C_weblog_objects.py # contains virtualfield definitions. -- Thadeus On Wed, Jun 9, 2010 at 4:42 PM, mdipierro mdipie...@cs.depaul.edu wrote: No. This the main issue with web2py design. This is the price we pay for not having imports of models. On Jun 9, 4:21 pm, Binh btbinht...@gmail.com wrote: Hi, I am trying to create an orm setup like in ruby on rails with the DAL. I have a user, post, and tag model. A user has many posts. A tag belongs to a user. A post has and belongs to many tags. A tag has and belongs to many posts. I have 4 separate files in my models folder: db.py, user.py, post.py, and tag.py db.py contains the db connection and mail configurations. The respective model files define the table structure and have a class named after the model to implement virtual fields. I noticed that defining the tables with relationships in the separate files does not work properly. The model files would load which appears to be in alphabetical order. So, my db.py would load first and then post.py which fails. post.py fails to recognize the table definition in user.py, so it cannot define the belongs to relationship. Is their anyway to setup a model file to import all the other models without the hassle of file load order and possibly import order which rails does implicitly?
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
By the way, this is for PostgreSQL that I need this. I think that autoincrement needs to be implemented for each database type natively. The *other* guys have autoincrement already... curious as to why it is left out of web2py. As always, the sooner the better . -- Thadeus On Mon, Jun 7, 2010 at 11:39 PM, Thadeus Burgess thade...@thadeusb.com wrote: Legacy systems =) The database was already in place as this, unfortunately when I migrated from access to postgres I kept the same schema as I was under a time crunch to get *something* running And now it bites me in the butt. The thing is... I cannot do this ``db(db.table.id==3).update(db.table.field=db.table.field+1) ``. It is not ATOMIC and crashes the application underneath a certain load. Why does web2py NOT have an autoincrement attribute? Databases are kinda designed for this thing =) Massimo, what reasons do you justify for not having one? -- Thadeus On Mon, Jun 7, 2010 at 9:56 PM, mr.freeze nat...@freezable.com wrote: I'm not even going to ask how you got in this situation :) Could you?: 0) Create a patch to Field for an autoincrement field type 1) Create a new table (whopper_temp) on your database with an id field that is NOT set to auto-increment (yet) 2) Copy all records from the table in question to whopper_temp, casting whopper_id to an integer as you go. 3) Rename your source table 4) Rename whopper_temp to the source tables original name 5) Change Field type for whopper_id to your new autoincrement type On Jun 7, 8:29 pm, Thadeus Burgess thade...@thadeusb.com wrote: I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests come in to create a record within miliseconds of each other. Here is where I need some help please. I need to convert this entire field, into an autoincrementing integer performed by the database, however ALL current whopper_ids must stay EXACTLY the same. I don't know how to accomplish this with web2py. I know what I want... Field(whopper_id, integer, unique=True, autoincrement=True) But how do I convert all existing whopper_ids over and keep them the exact same? Is this even possible with web2py and the DAL? -- Thadeus
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
This *might* work. You are right, it is still horrible... It might be *effectively* accomplishing the same thing that sequences do on PostgreSQL, however I still wouldn't use it in production as it feels hacky. I already have to re-design this table, so I might as well do it 100% right. I never expected the scale of inserts that happened yesterday and today, nor had any proper benchmarking been done previously if it could handle this kind of sudden rush of traffic. -- Thadeus On Tue, Jun 8, 2010 at 4:36 PM, mdipierro mdipie...@cs.depaul.edu wrote: I know this horrible but it does solve some of the problems... db.define_table('whopper_seq',Field('dummy')) db.define_table('yourtable',... Field(whopper_id, integer,compute=lambda r: db.whopper_seq.insert(dummy=None)) ...) On Jun 7, 8:29 pm, Thadeus Burgess thade...@thadeusb.com wrote: I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests come in to create a record within miliseconds of each other. Here is where I need some help please. I need to convert this entire field, into an autoincrementing integer performed by the database, however ALL current whopper_ids must stay EXACTLY the same. I don't know how to accomplish this with web2py. I know what I want... Field(whopper_id, integer, unique=True, autoincrement=True) But how do I convert all existing whopper_ids over and keep them the exact same? Is this even possible with web2py and the DAL? -- Thadeus
Re: [web2py] Re: Last Saved On field displays communication error using HTTPS on Apache2, OpenSSL 0.98k, mod_wsgi, python 2.6.5
*leaves gedit / netbeans world to test said bug* It does not work for me either. No tickets are generated however a 500 internal server error is caused when looking at firebug. Ubuntu 10.4, firefox 3.6.3 or Epiphany Quite strange, I can't figure out what is causing the error =/ *goes back to gedit / netbeans world* -- Thadeus On Mon, Jun 7, 2010 at 2:05 PM, Salvor Hardin salvor.pub...@gmail.com wrote: I just tried web2py 1.78.3 on Ubuntu Server 10.04 using Rocket and there is no communication error message. This problem appears to be introduced in 1.79.1 for some operating systems. It works fine in Windows, but not in Ubuntu Server 10.04 for me, and Ubuntu 9.10 for Lisandro. On Jun 7, 1:41 pm, Lisandro Rostagno rostagnolisan...@gmail.com wrote: Hi. First, sorry about my english, I'm from Argentina. I'm a user from the group of spanish users. I've written in that group, but I did't get any answer. My problem is exactly the same that the one reported by Salvor Hardin. I'm using Ubuntu 9.10, with the last version of web2py (Version 1.79.1 (2010-06-05 19:48:42)). I've downloaded web2py, unzip, run development server, create application, edit file, there I receive the communication error. The changes that were made before de first error, are saved correctly, but any changes I do after that it's not saved. I tried with Firefox and Chrome, and the same thing happens in both cases. I'm working with the user I always worked in ubuntu, and I unzipped web2py in my home folder. No directory permission conflict. In fact, the error started to appear (i don't know how to say that) just after the installation of the last stable version of web2py. I also tried to delete all app/errors/ files, but no error file is generated. ¿Could someone help me? ¿Or at least guide me in the look of a solution? Thanks very much! On 7 jun, 15:19, Salvor Hardin salvor.pub...@gmail.com wrote: I'm sorry, there are no error tickets generated from this. And I didn't see any errors in javascript consoles in Chrome and Firefox +Firebug. I only got 1 ticket yesterday while setting up apache due to file permission error. Deleted that ticket. No errors today at all. When using Apache 2 with Python 2.6.5, I also checked /var/log/apache2/ error.log which only had one harmless error (which I'm told to ignore based on Googling) [Mon Jun 07 12:47:45 2010] [error] Exception KeyError: KeyError(-1216764160,) in module 'threading' from '/usr/lib/python2.6/ threading.pyc' ignored Other than that, no web2py error tickets and no Apache2 errors logged. I'm new to Rocket, so I'll see if I can find the log file(s) for that. On Jun 7, 1:04 pm, mdipierro mdipie...@cs.depaul.edu wrote: try the following. delete all your tickets app/errors/* reproduce the problem and see if you find a new ticket file. If so, please email it to me. On Jun 7, 12:43 pm, Salvor Hardin salvor.pub...@gmail.com wrote: Here's what I tried: * I setup SSH tunnel from my Vista desktop's localhost:8080 to ubuntu.private.lan:80. * I modified Apache2's virtualhost *:80 to enable access to /admin The new non-HTTPS, ssh-tunneled, remote URL to ubuntu.private.lan is: http://localhost:8080/admin/default/edit/myblog/views/default/index.html I got same problem again on Firefox and Chrome. Files get saved successfully, but Last Saved On field shows communication error in red background color every time I click Save button. Next, I'll try using Rocket on Ubuntu, just for debugging this problem. Rocket won't be approved for production servers here (this summer), so I hope we can find a solution using Apache 2.2.14. On Jun 7, 11:58 am, mdipierro mdipie...@cs.depaul.edu wrote: Does it work without ssl? Which browser are you using? Have you tried other browsers? Massimo On Jun 7, 11:47 am, Salvor Hardin salvor.pub...@gmail.com wrote: I'm new to web2py and python (currently evaluating python frameworks to replace Ruby on Rails on production servers by July 4th weekend.) PROBLEM: * Saving a file using the admin interface displays a red communication error in the Last Saved On field. However, when I click Reload in the browser, a new date and time appears correctly so the file is successfully saved. I'm using HTTPS (web2py is not running on 127.0.0.1.) SYSTEM: * Software: web2py 1.79.1, Python 2.6.5, Apache 2.2.14, mod_wsgi 2.8, OpenSSL 0.98k, sqlite 3.6.22 * Browsers: Latest stable versions of Chrome and Firefox on Vista 32- bit * OS: Ubuntu Server 10.04 LTS guest running in Virtual PC 2007 SP1 on Vista 32-bit host (because Virtual PC 2007 only uses ~16 (sixteen) MB RAM for actively used Ubuntu Server 10.04 guest setup with 512 MB RAM,
Re: [web2py] DAL crossdatabase reference
Technically speaking, you cannot do it, and *should* not do it. However you can hack around this by using a integer type instead of a FK relationship. Basically store your integer without FK status, and then you manually handle all of the relationships. -- Thadeus On Mon, Jun 7, 2010 at 2:38 PM, kachna petr.marti...@gmail.com wrote: Hi, I am trying to define table with foreign key to the table stored in different database on same server (MySQL). db_sys # db_sys on localhost mysql db_cs # db_cs on localhost mysql db_sys.define_table('item', Field('id_producer', db_sys.producer, requires=IS_IN_DB(db_sys, 'producer.id', '%(name)s (%(id)s)', error_message=T('Vyrobce neni v databazi'))), Field('catalogue_no', 'string', label=T('Katalogove cislo'), notnull=True), Field('name', 'string', label=T('Polozka (interne)')) ) db_cs.define_table('item', Field('title', 'string', label=T('Nazev')), Field('description', 'text', label=T('Popis')) ) after execution I get: sql.py, line 1576, in _create_references SyntaxError: Table: table item does not exist I quick-check sources and I thing that there is not too much work to make it work fine. Am I wrong? Is there different way? thx
[web2py] Advice, convert from string storing numbers to autoincrement integer
I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests come in to create a record within miliseconds of each other. Here is where I need some help please. I need to convert this entire field, into an autoincrementing integer performed by the database, however ALL current whopper_ids must stay EXACTLY the same. I don't know how to accomplish this with web2py. I know what I want... Field(whopper_id, integer, unique=True, autoincrement=True) But how do I convert all existing whopper_ids over and keep them the exact same? Is this even possible with web2py and the DAL? -- Thadeus
Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer
Legacy systems =) The database was already in place as this, unfortunately when I migrated from access to postgres I kept the same schema as I was under a time crunch to get *something* running And now it bites me in the butt. The thing is... I cannot do this ``db(db.table.id==3).update(db.table.field=db.table.field+1) ``. It is not ATOMIC and crashes the application underneath a certain load. Why does web2py NOT have an autoincrement attribute? Databases are kinda designed for this thing =) Massimo, what reasons do you justify for not having one? -- Thadeus On Mon, Jun 7, 2010 at 9:56 PM, mr.freeze nat...@freezable.com wrote: I'm not even going to ask how you got in this situation :) Could you?: 0) Create a patch to Field for an autoincrement field type 1) Create a new table (whopper_temp) on your database with an id field that is NOT set to auto-increment (yet) 2) Copy all records from the table in question to whopper_temp, casting whopper_id to an integer as you go. 3) Rename your source table 4) Rename whopper_temp to the source tables original name 5) Change Field type for whopper_id to your new autoincrement type On Jun 7, 8:29 pm, Thadeus Burgess thade...@thadeusb.com wrote: I have a problem. I have this in the database Field(whopper_id, string, default=None, unique=True), The thing with whopper_id is it always stores numbers. Said numbers are anywhere from 2 to 6. Also upon entering a new entry, I do the following last_whopper_id = db(db.table.id 0).select(db.table.whopper_id, orderby=~db.table.whopper_id, limit=(0,1)).first().whopper_id db.insert(whopper_id = (int(last_whopper_id) + 1)) So I do all this juju just to get the number to autoincrement. The problem is, this structure is bad... first I'm storing integers in a string field, and then manually incrementing them I get errors like... IntegrityError: duplicate key value violates unique constraint table_whopper_id_key... when two requests come in to create a record within miliseconds of each other. Here is where I need some help please. I need to convert this entire field, into an autoincrementing integer performed by the database, however ALL current whopper_ids must stay EXACTLY the same. I don't know how to accomplish this with web2py. I know what I want... Field(whopper_id, integer, unique=True, autoincrement=True) But how do I convert all existing whopper_ids over and keep them the exact same? Is this even possible with web2py and the DAL? -- Thadeus
Re: [web2py] Web2py naming bug
Yes, starting with a number is NOT valid python... This is why I use A_py B_py C_py instead of 0_...py 1_...py 2_...py -- Thadeus On Mon, Jun 7, 2010 at 11:08 PM, Doug Warren doug.war...@gmail.com wrote: I think I was just bitten by a naming bug... I named my application starting with a number and for a few days everything worked fine until that fateful night when i tried to local_import something... Traceback (most recent call last): File C:\4x2-server\web2py\gluon\restricted.py, line 178, in restricted exec ccode in environment File C:/4x2-server/web2py/applications/4x2/models/plugin_scheduler.py, line 30, in module scheduler_module = local_import('scheduler') File C:\4x2-server\web2py\gluon\compileapp.py, line 227, in lambda local_import_aux(name,reload,app) File C:\4x2-server\web2py\gluon\compileapp.py, line 165, in local_import_aux exec(import %s as mymodule % name) in env File string, line 1 import applications.4x2.modules.scheduler as mymodule ^ SyntaxError: invalid syntax (The carrot is over the 4 if it isn't obvious from a fixed width font) I assume that Python doesn't allow module to start with a number? If this is the case and I created the application through the web interface, it should probably check at the create application step, and now I need to think of a way to change my directory structure in my source control as I rename the project :)
Re: [web2py] Is there a default file upload when filling forms?
thats why you have a VirtualField called get_image_url() that does that and everywhere you need it you go record.get_image_url() More on virtualfields here: http://thadeusb.com/weblog/archive/2009/12/31/web2py_virtualfields_as_an_orm_an_sqlalchemy_approach/27 -- Thadeus On Sun, Jun 6, 2010 at 3:57 AM, Jason Brower encomp...@gmail.com wrote: Yes. But i end up having to do that about 15 times in my document. And we all know programs creat ways to do everything once. - Original message - Sounds like you got it. if not record.image: if record.sex == male: return male.jpg else: return female.jpg else: return record.image -- Thadeus On Sat, Jun 5, 2010 at 12:22 PM, Jason Brower encomp...@gmail.com wrote: I need the avatar (IS_IMAGE) in my authentication table to have a default if nothing is entered. Is this easily possible? I was thinking of having it controller side and just check if it was blank... if so, default it. The image would be based on the auth_user tables .sex value. Any ideas how to accomplish this? Best Regards, Jason Brower
Re: [web2py] Keep the instance of a class during the session
cache the object. -- Thadeus On Sun, Jun 6, 2010 at 7:23 PM, Jose jjac...@gmail.com wrote: I have a module (in my_app / modules) that defines a class MyClass. This class operates with model data. In the __init__ there is a heavy workload, and data are available for other minor calculations. What I want is to create an instance of MyClass [my_object = MyClass (...)] a function of my controller and can use this instance from other functions, to avoid re-do the calculations again. I analyzed the alternatives are: 1) Save my_object in session. This is discarded because session only supports saving simple objects. 2) Save my_object with pickle and load it to the other functions. 3) Save the state of the object in the database. I do not like. 4) ¿? How do you see this approach? What other alternative can be proposed? Regards Jose
Re: [web2py] stumped on a regex
http://hg.thadeusb.com/Web/web2py_utils/file/697470f78d16/web2py_utils/output.py Line 20 - 48 could possibly be adapted. Basicly use a DOTALL regex to find \n (what about \r too, if your on windows), you might want to use os.newline, and then a dotall regex for the pre code blockqoute etc. Then doing the regex match, you look and see if the line starts with something you don't want to alter, if it does then don't do anything, otherwise return '', or in your case br / This should do it Just remove the regex looking for multiple spaces, and set to return br / def compress_output(response, 21 startswith = [ 22 'pre', 23 'textarea', 24 'blockquote', 25 ], 26 funcs=[], 27 debug=False,): 28 29 def save_pre(match): 30 s = match.group() 31 for sw in startswith: 32 if s.startswith(sw): 33 return s 34 return 'br /' # this turns whitespace into nothing 35 36 def compress_response(d): 37 if callable(d): 38 d = d() 39 if isinstance(d, dict): 40 cpat = re.compile(r'[\n\t\r\f\v]|(?s)pre(.*?)/pre|(?s)blockquote(.*?)/blockquote|(?s)textarea(.*?)/textarea') 41 d = cpat.sub(save_pre, response.render(d)) 42 for f in funcs: 43 if callable(f): 44 f(d) 45 return d 46 47 if not debug: 48 response._caller = compress_response -- Thadeus On Sat, Jun 5, 2010 at 12:14 PM, mr.freeze nat...@freezable.com wrote: I'm trying to replace all newline characters in a chunk of text with BRs except for those inside PRE tags. I can't seem to make it work. Any regex gurus out there?
Re: [web2py] Is there a default file upload when filling forms?
Sounds like you got it. if not record.image: if record.sex == male: return male.jpg else: return female.jpg else: return record.image -- Thadeus On Sat, Jun 5, 2010 at 12:22 PM, Jason Brower encomp...@gmail.com wrote: I need the avatar (IS_IMAGE) in my authentication table to have a default if nothing is entered. Is this easily possible? I was thinking of having it controller side and just check if it was blank... if so, default it. The image would be based on the auth_user tables .sex value. Any ideas how to accomplish this? Best Regards, Jason Brower
Re: [web2py] Re: html text editor selection shift position
I don't use the web based editor, but it h as to do with the syntax highlighting, turn that off and it should be fine. -- Thadeus On Sat, Jun 5, 2010 at 6:43 PM, mdipierro mdipie...@cs.depaul.edu wrote: hmm. I use a Firefox and never seen this. Massimo On Jun 5, 6:17 pm, MikeEllis michael.f.el...@gmail.com wrote: Yes! I see similar issues all the time on my Mac in Firefox. Most often, things get confused when I break a line with a carriage return. Seems to happen less when working in Chrome. Mike On Jun 4, 11:45 am, Jean Guy jean...@gmail.com wrote: Hi, I would like to know there is other web2py user that are experimenting a shift in selection highlight in html text editor built in web2py dev environnement? There is a way to fix that easily? I attached a sceenshot... Windows current version OK Linux src current version NOT OK Thanks. Jonhy windows_w2p_editor.png 49KViewDownload linux_w2p_src_editor.png 63KViewDownload
Re: [web2py] Mustache.js and web2py
Unfortunately not at the moment. This is something we have been discussing for the last week however it does not seem web2py templates will ever get this. Just as a note, you would have this problem whether you were using jinja, or django templates as well. -- Thadeus On Fri, Jun 4, 2010 at 6:50 AM, PanosJee panos...@gmail.com wrote: Hello everyone i am trying to use Mustache.js along with web2py Mustache is a cross language rendering mechanism. We use it both server side and client side. What i want to do is to have a hidden div with the mustache template but i have the following problem. Mustache uses {{ }} as web2py does so if i place my mustache templates in the html code web2py dies. Is there anyway to bypass the web2py rendering for a given partial so i do not have to do any changes to mustache?
Re: [web2py] Re: Layout of functions with the MVC environment
All functions defined in models are available to controllers and views as anything you put in the models becomes part of the global namespace that the controllers/views are executed in. This leads to potential problems of namespace collision. Make sure you do not overwrite the function elsewhere, as this could be causing issues. Why are you calling db.create_object? This isn't a class of the DAL, refer to Yarko's explanation, the DAL is not an ORM. You probably mean. if form.accepts(request.vars, session): foo = create_object(owner_id=auth.auth_id, # NOT db.create_object, just call your function like regular template_name=form.vars.template) -- Thadeus On Fri, Jun 4, 2010 at 11:39 AM, Doug Warren doug.war...@gmail.com wrote: On Fri, Jun 4, 2010 at 9:11 AM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: On Jun 4, 10:58 am, Doug Warren doug.war...@gmail.com wrote: I don't believe I want to local_import my db.py file as it's already set up by the environment correct? Correct - you do not want / need to import your db.py. As long as it is in your models folder (by default it is), it's already in your request context before your controller is called. Yes but as I mentioned in my original E-Mail, I was unable to get a function defined in the model file to be visible to the controller hence the original question. :) I thought about it a bit during my drive and think I will try (using the below example) something like: def create_object... ... co = create_object controller.py co( template_id ...) What I'm asking for is a way to keep all of the code that relates to the model in one place and to invoke it from controllers. That is if I define 5 tables for the model I'd expect to write helper functions to manipulate all 5 tables and not to have the controller know the intimate details of the model. That's the concept behind Object Orientated programming isn't it? Objects are black boxes to other objects other than their public facing interface. Right - but DAL is just a Data abstraction layer (i.e. an SQL adapter, if you will), not an ORM (i.e. there's not the level of object- oriented abstraction that you would expect w/ an orm - it's lower level) So in web2py, with DAL you have knowledge of your table layout (without direct knowledge / need for the specific back ends SQL). You'll also find that forms, and validators are coupled to table structure, so if / as you try to abstract away from table definitions, you will run into this. I'm sure others will add more comments... On Fri, Jun 4, 2010 at 8:56 AM, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: On Jun 4, 10:43 am, Doug Warren doug.war...@gmail.com wrote: Traditionally when I've written MVC style applications, the model would contain not only the data representing the objects but also the data for manipulating the objects. I'm not sure how that same relation applies to web2py. If I have a model that defines 4-5 tables, 2 of them are just foreign key lookups, and creating a new object involves inserting data into 3 of the tables, it seems that I would want a create_object method in my model file. So I write something like: def create_object(owner_id=None, template=None): # Some sanity checking on the above new_object = db.objects.insert(template_id=template.id, person_id=owner_id) widgets = db.template_widget(db.template_widget.thingy_template_id == template.id).select() for widget in widgets: db.thingy_widget.insert(widget_id = widget.id, thingy_id = new_object) whatchymacallits = db.template_whatchymacallit(db.template_whatchymacallit.thingy_template_id == template.id).select() for whatchymacallit in whatchymacallits: db.thingy_whatchymacallit.insert(whatchymacallit_id = whatchymacallit.id, thingy_id = new_object) return new_object and place that into my db.py. Now the controller has a function like: def create(): form = SQLFORM.factory( Field('template', requires=IS_IN_SET(__get_templates( if form.accepts(request.vars, session): foo = db.create_object(owner_id=auth.auth_id, template_name=form.vars.template) response.flash = Created elif form.errors: response.flash = Error (hacker) Well db is referring to the DAL db not the db.py, from db import create_object gives a name not found error, so I'm at a loss as to how to define functions that work upon the model and can be invoked from one or more controllers. I'm not sure what exactly you are saying here - but to import, use local_import() (seehttp://www.web2py.com/book/default/section/4/18?search=local_import) BUT before you do, here is some background: When a request comes into web2py, here's what happens (roughly): web2py parses the request url, and sets up an environment to call the appropriate application / controller / function; Part of that
Re: [web2py] [proposition] Need date calculations in a query
http://thadeusb.com/weblog/archive/2010/1/5/query_between_dates/30 http://thadeusb.com/weblog/archive/2010/3/19/increase_productivity_by_using_parameterized_queries_with_web2py/33 If you have any questions please feel free to ask. -- Thadeus On Fri, Jun 4, 2010 at 5:42 AM, Sverre sverreodeg...@gmail.com wrote: I need some like query(startdate+timedelta(days) endtime) In PostgreSQL and other databases that not a problem. The alternative is only filtering on client side.
Re: [web2py] Re: Multiple instances of same application
I agree with Massimo, the NOT packing facility could be handled by .hgignore. As for configuration, I have used 0_config.py in blogitizor so that I can run two versions, my personal version and the one that is open source, this way my database and email information doesn't get leaked out into the internetz. I use the following, http://code.google.com/p/blogitizor/source/browse/src/models/A_config.example And then rename it to A_config.py and it won't get committed since src/models/A_config.py is placed in my .hgignore file. However this isn't a web2py mechanism just a personal one, I don't like the idea of making web2py in charge of this because then I the developer lose control and can't change the way it works without forking web2py. -- Thadeus On Fri, Jun 4, 2010 at 3:28 AM, Iceberg iceb...@21cn.com wrote: Aside from the config issue, a flag when packaging that does not package the database/ folder, would be the long missing piece. And when this flag is available, I think I can have my own databases/ my_config.py to solve the local config problem in my style. :-) So +1 for the flag when packaging that does not package the database/ folder. On Jun4, 2:20pm, mdipierro mdipie...@cs.depaul.edu wrote: I normally use #in models/0.py from gluon.storage import Storage settings=Storage() settings.development=True settings.email_sender=...@example.com' ... Anyway, this does not address Iceberg's problem of packing some config files and not others. I am not convinced this scenario should be handled at the web2py level. This is better handled using .hgignore and mercurial or other version control system. I am thinking anyway, to allow a flag when packaging that does not package the database/ folder. So in principle one could create function that updates parameters from a DAL('sqlite://settings.db') On Jun 4, 1:10 am, Iceberg iceb...@21cn.com wrote: IMHO, flask and my lightweight proposal try to solve same problem. Both can load configuration for sure. My proposal's loading ability relies only on python's built-in import (via web2py's model mechanism), therefore no need to introducing extra module. Isn't it clean? The basic challenge is how to separate and manage local setting from default setting, and how to prevent the local setting being distributed via app.w2p or Mercurial. Flask uses environment variable YOURAPPLICATION_SETTINGS=/path/to/settings.cfg, to specify a local setting. I like that too, but it can not be done via pure web2py admin interface, so administrator need to ssh into their production machine and make adjustments, and perhaps a kill-and-restart is needed. On the contrary, in my proposal, although I did not emphasis this in earlier post, administrator only need to visit standard web2py admin interface and setup a new 0_local_setting.py. No ssh nor restart is needed, again I rely on web2py's native behavior. Isn't it lightweight? Of course, I don't like the 0_local_config_pls_dont_pack_dont_commit.py naming convention neither, but I just did not come up with another descriptive name. The point here, is we need a config file which can be used by a web2py app, but not packed with the app. Well, if we really just don't like the long and clumsy name convention, then we can do it in a decent way: 1. introduce a applications/myapp/local_config directory, local settings go into there. 2. adjust web2py to NOT pack, and NOT commit local_config directory 3. but we need more work for web2py's admin UI, to support add/edit/ view/delete setting file. We can choose. On Jun4, 3:26am, Thadeus Burgess thade...@thadeusb.com wrote: Or... we can copy flask and integrate a configuration module.. God I pray we never use something like `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and its naming conventions . -- Thadeus On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote: I think Doug's puzzle deserves a more general solution. The requirement and challenge is: R1. The app's central source code should contain default setting. R2. The app's multiple deployment instances should be allowed to contain its local setting. R3. And after the next hg update, the default setting in (R1) should not override the local setting in (R2). My solution contains two steps: Step1: Use myapp/models/0_config.py to store default setting, such as: MY_HOST = 'http://localhost' MY_EMAIL = '@bar.com' MY_PASSWORD = 'blah' MY_DB = 'sqlite://storage.sqlite' Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to store instance-wide local setting, such as: MY_HOST = 'http://myaccount.my_vps_provider.com' MY_EMAIL = 'my_real_acco...@for_example_hotmail.com' MY_PASSWORD = 'i_will_never_share_it' MY_DB = 'mysql://10.1.1.1.' To reach this goal, two things need
Re: [web2py] Re: Multiple instances of same application
Or... we can copy flask and integrate a configuration module.. God I pray we never use something like `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and its naming conventions . -- Thadeus On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote: I think Doug's puzzle deserves a more general solution. The requirement and challenge is: R1. The app's central source code should contain default setting. R2. The app's multiple deployment instances should be allowed to contain its local setting. R3. And after the next hg update, the default setting in (R1) should not override the local setting in (R2). My solution contains two steps: Step1: Use myapp/models/0_config.py to store default setting, such as: MY_HOST = 'http://localhost' MY_EMAIL = 'f...@bar.com' MY_PASSWORD = 'blah' MY_DB = 'sqlite://storage.sqlite' Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to store instance-wide local setting, such as: MY_HOST = 'http://myaccount.my_vps_provider.com' MY_EMAIL = 'my_real_acco...@for_example_hotmail.com' MY_PASSWORD = 'i_will_never_share_it' MY_DB = 'mysql://10.1.1.1.' To reach this goal, two things need to be adjusted in web2py source code: Thing1: add 0_local_config_pls_dont_pack_dont_commit.py into / web2py/.hgignore Thing2: adjust the admin's pack code, to NOT pack the new 0_local_config_pls_dont_pack_dont_commit.py On Jun3, 10:23pm, mdipierro mdipie...@cs.depaul.edu wrote: they can see request.env.host_name and you can use hostnames like bla bla bla.yourdomain.com you can symlink different apps to the same one so you have one but it will see different request.application depending on the request On Jun 3, 8:50 am, Doug Warren doug.war...@gmail.com wrote: Is there a preferred way to handle multiple instances of the same application installed on the same machine? Say for instance is there's 3 dev environments and 2 staging environments on one server pointing at different databases? Is there a preferred way of getting the configuration to each unique app? IE: Can a view/db/controller see a parameter placed in either options_std or parameters_PORTNO? I guess what I'm really after is a way to specify at a minimum the database that an application can point at but have it contained outside the application itself. IE: foo.w2p is uploaded foo.w2p is installed as foo foo.w2p is installed as foo-dev foo.w2p is installed as foo-dev2 foo.w2p is installed as foo-stag Without having to edit db.py in each of those environments I'd like to have a way of saying foo-stag should use this connect string, and have it survive the next time I upload a new foo.w2p and overwrite the one that's there.
Re: [web2py] Re: Multiple instances of same application
Exactly, We can copy flask and add the same configuration module which implements everything and more of what you just described. -- Thadeus On Thu, Jun 3, 2010 at 4:33 PM, Doug Warren doug.war...@gmail.com wrote: What I was thinking was something we use in the gaming world, called a console variable, you can specify their values in code, in a config file, through an in app interface, or through the command line. In web2py terms, I was thinking to make a global singleton that when first instantiated would scan sys.argv for things that looked like command arguments in the form of +Key Value or +Key=Value and then parse that to a global vs appliation level dict IE: +welcome.banner=Hello vs +admin.banner Hola vs banner=hi when an application queries the system, it would exec request.env.web2py_path + appliation which would look like: convars = ConVars() convars.database_string = sqlite://file.sql convars.debug = 1 convars.arbitrarysettinghere = 2 further dragging in new variables and overriding those that are on the command line. (This last distinction is open to debate as it could be considered easier to change a file than to change the command line.) There would also be a global level file to be read that can just define all known variables and their defaults. Finally a database table could be defined and a controller set that would represent the final most dynamic version of the config that can be updated in real time. A db or controller could then invoke it like convars = ConVars(request) if convars.debug: # Handle debug case On Thu, Jun 3, 2010 at 12:26 PM, Thadeus Burgess thade...@thadeusb.com wrote: Or... we can copy flask and integrate a configuration module.. God I pray we never use something like `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and its naming conventions . -- Thadeus On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote: I think Doug's puzzle deserves a more general solution. The requirement and challenge is: R1. The app's central source code should contain default setting. R2. The app's multiple deployment instances should be allowed to contain its local setting. R3. And after the next hg update, the default setting in (R1) should not override the local setting in (R2). My solution contains two steps: Step1: Use myapp/models/0_config.py to store default setting, such as: MY_HOST = 'http://localhost' MY_EMAIL = 'f...@bar.com' MY_PASSWORD = 'blah' MY_DB = 'sqlite://storage.sqlite' Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to store instance-wide local setting, such as: MY_HOST = 'http://myaccount.my_vps_provider.com' MY_EMAIL = 'my_real_acco...@for_example_hotmail.com' MY_PASSWORD = 'i_will_never_share_it' MY_DB = 'mysql://10.1.1.1.' To reach this goal, two things need to be adjusted in web2py source code: Thing1: add 0_local_config_pls_dont_pack_dont_commit.py into / web2py/.hgignore Thing2: adjust the admin's pack code, to NOT pack the new 0_local_config_pls_dont_pack_dont_commit.py On Jun3, 10:23pm, mdipierro mdipie...@cs.depaul.edu wrote: they can see request.env.host_name and you can use hostnames like bla bla bla.yourdomain.com you can symlink different apps to the same one so you have one but it will see different request.application depending on the request On Jun 3, 8:50 am, Doug Warren doug.war...@gmail.com wrote: Is there a preferred way to handle multiple instances of the same application installed on the same machine? Say for instance is there's 3 dev environments and 2 staging environments on one server pointing at different databases? Is there a preferred way of getting the configuration to each unique app? IE: Can a view/db/controller see a parameter placed in either options_std or parameters_PORTNO? I guess what I'm really after is a way to specify at a minimum the database that an application can point at but have it contained outside the application itself. IE: foo.w2p is uploaded foo.w2p is installed as foo foo.w2p is installed as foo-dev foo.w2p is installed as foo-dev2 foo.w2p is installed as foo-stag Without having to edit db.py in each of those environments I'd like to have a way of saying foo-stag should use this connect string, and have it survive the next time I upload a new foo.w2p and overwrite the one that's there.
Re: [web2py] Re: Multiple instances of same application
For context, please see http://flask.pocoo.org/docs/config/ http://flask.pocoo.org/docs/api/#configuration -- Thadeus On Thu, Jun 3, 2010 at 4:55 PM, Thadeus Burgess thade...@thadeusb.com wrote: Exactly, We can copy flask and add the same configuration module which implements everything and more of what you just described. -- Thadeus On Thu, Jun 3, 2010 at 4:33 PM, Doug Warren doug.war...@gmail.com wrote: What I was thinking was something we use in the gaming world, called a console variable, you can specify their values in code, in a config file, through an in app interface, or through the command line. In web2py terms, I was thinking to make a global singleton that when first instantiated would scan sys.argv for things that looked like command arguments in the form of +Key Value or +Key=Value and then parse that to a global vs appliation level dict IE: +welcome.banner=Hello vs +admin.banner Hola vs banner=hi when an application queries the system, it would exec request.env.web2py_path + appliation which would look like: convars = ConVars() convars.database_string = sqlite://file.sql convars.debug = 1 convars.arbitrarysettinghere = 2 further dragging in new variables and overriding those that are on the command line. (This last distinction is open to debate as it could be considered easier to change a file than to change the command line.) There would also be a global level file to be read that can just define all known variables and their defaults. Finally a database table could be defined and a controller set that would represent the final most dynamic version of the config that can be updated in real time. A db or controller could then invoke it like convars = ConVars(request) if convars.debug: # Handle debug case On Thu, Jun 3, 2010 at 12:26 PM, Thadeus Burgess thade...@thadeusb.com wrote: Or... we can copy flask and integrate a configuration module.. God I pray we never use something like `0_local_config_pls_dont_pack_dont_commit.py` INTO web2py. web2py and its naming conventions . -- Thadeus On Thu, Jun 3, 2010 at 10:22 AM, Iceberg iceb...@21cn.com wrote: I think Doug's puzzle deserves a more general solution. The requirement and challenge is: R1. The app's central source code should contain default setting. R2. The app's multiple deployment instances should be allowed to contain its local setting. R3. And after the next hg update, the default setting in (R1) should not override the local setting in (R2). My solution contains two steps: Step1: Use myapp/models/0_config.py to store default setting, such as: MY_HOST = 'http://localhost' MY_EMAIL = 'f...@bar.com' MY_PASSWORD = 'blah' MY_DB = 'sqlite://storage.sqlite' Step2: Use myapp/models/0_local_config_pls_dont_pack_dont_commit.py to store instance-wide local setting, such as: MY_HOST = 'http://myaccount.my_vps_provider.com' MY_EMAIL = 'my_real_acco...@for_example_hotmail.com' MY_PASSWORD = 'i_will_never_share_it' MY_DB = 'mysql://10.1.1.1.' To reach this goal, two things need to be adjusted in web2py source code: Thing1: add 0_local_config_pls_dont_pack_dont_commit.py into / web2py/.hgignore Thing2: adjust the admin's pack code, to NOT pack the new 0_local_config_pls_dont_pack_dont_commit.py On Jun3, 10:23pm, mdipierro mdipie...@cs.depaul.edu wrote: they can see request.env.host_name and you can use hostnames like bla bla bla.yourdomain.com you can symlink different apps to the same one so you have one but it will see different request.application depending on the request On Jun 3, 8:50 am, Doug Warren doug.war...@gmail.com wrote: Is there a preferred way to handle multiple instances of the same application installed on the same machine? Say for instance is there's 3 dev environments and 2 staging environments on one server pointing at different databases? Is there a preferred way of getting the configuration to each unique app? IE: Can a view/db/controller see a parameter placed in either options_std or parameters_PORTNO? I guess what I'm really after is a way to specify at a minimum the database that an application can point at but have it contained outside the application itself. IE: foo.w2p is uploaded foo.w2p is installed as foo foo.w2p is installed as foo-dev foo.w2p is installed as foo-dev2 foo.w2p is installed as foo-stag Without having to edit db.py in each of those environments I'd like to have a way of saying foo-stag should use this connect string, and have it survive the next time I upload a new foo.w2p and overwrite the one that's there.
Re: [web2py] How to get the filename from an upload field?
Taken from http://web2py.com/book/default/section/7/2?search=original+filename Occasionally you may want to store the original filename in a database field. In this case, you need to modify the model and add a field to store it in: db.define_table('person', Field('name', requires=IS_NOT_EMPTY()), Field('image_filename'), Field('image', 'upload')) def display_form(): if len(request.args): records = db(db.person.id==request.args[0]).select() if len(request.args) and len(records): url = URL(r=request, f='download') form = SQLFORM(db.person, records[0], deletable=True, upload=url, fields=['name', 'image']) else: form = SQLFORM(db.person, fields=['name', 'image']) if request.vars.image: form.vars.image_filename = request.vars.image.filename if form.accepts(request.vars, session): response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' return dict(form=form) -- Thadeus On Wed, Jun 2, 2010 at 3:18 AM, Sverre sverreodeg...@gmail.com wrote: I have an upload field in the DB an want to display the original filename in a view. How can I do that?
Re: [web2py] Clearing Database Tables
db.table.truncate() -- Thadeus On Wed, Jun 2, 2010 at 1:05 PM, Vasile Ermicioi elff...@gmail.com wrote: db(db.table.id 0).delete() no sure what you mean by entries in a given field
Re: [web2py] Clearing Database Tables
And for a given field... db(db.table.id 0).update(field = None) -- Thadeus On Wed, Jun 2, 2010 at 2:04 PM, Thadeus Burgess thade...@thadeusb.com wrote: db.table.truncate() -- Thadeus On Wed, Jun 2, 2010 at 1:05 PM, Vasile Ermicioi elff...@gmail.com wrote: db(db.table.id 0).delete() no sure what you mean by entries in a given field
Re: [web2py] calling a fuction from javascript (jquery)
Add the variable to the data declaration of the jquery.ajax method. This will be passed along as a POST or GET and then your function just looks at request.vars.naotext. -- Thadeus On Tue, Jun 1, 2010 at 10:30 AM, pk peter.kirch...@youngdesigners.de wrote: hi i need help, how can i call a function from jquery with parameters for example: $('nao_speak').click(function(event){ event.preventDefault(); var naotext = $('naospeak').val(); $.ajax({ url: {{=URL(r=request,c='speak',f='NaoSpeak')}}, naotext}); console.log('Nao is speaking'); }); i want to call the function NaoSpeak and the variable naotext should be given to this function. how can i solve this problem? thanks. peter
Re: [web2py] Problem with document uploading (not with common processing)
Add a third table named something like doc_links. So you have activity -- id name docpool --- id name data doc_links - id activity_id docpool_id Now in your form, you insert both (you will need a custom SQLFORM.factory for this). Submit each record, then create a doc_links with the ids of the two new records. -- Thadeus On Tue, Jun 1, 2010 at 8:31 AM, Sverre sverreodeg...@gmail.com wrote: The problem is I have 5 tables and each can have many documents per entity. I solved this with a table docpool. For every new entity in one of the 5 tables I generate a docpool entity (only the ID) and put the docpool.id into the entity. Each document is linked by the docpool.id But now I have a problem with this: I made a table to log activities. You can store values and documents. But I have to store the activity before I can upload any document. So is there a solution without making a 2nd document table?
Re: [web2py] Re: how to generate barcode label ?
jquery one froze my firefox too =( -- Thadeus On Tue, Jun 1, 2010 at 12:34 PM, Richard Shebora sheb...@gmail.com wrote: This works fine for me offline... http://zbar.sourceforge.net/ Thanks, Richard Shebora On Tue, Jun 1, 2010 at 1:18 PM, ceriox cer...@gmail.com wrote: i generate barcode with this workaround 1) i install the barcode font 2) i generate the code and with the view i show the code with barcode font On 1 Giu, 19:04, ceriox cer...@gmail.com wrote: thanks for the help but i need to generate a barcode not a qr code and without internet connection :( On 1 Giu, 15:32, Jason Brower encomp...@gmail.com wrote: That's the one. :D But it doesn't work without an internet connection. I needed it without internet. (Or a big brother.:P) On Tue, 2010-06-01 at 03:24 -0700, kuba wrote: http://www.web2py.com/appliances/default/show/51
Re: [web2py] Re: 1.79.0rc1 please check it out
I think that the .hgtags need to be updated. the 1.79.0rc1 tag refers to an earlier commit than the commit with the message 1.79.0rc1 The tag refers to c29660517c When I think it needs to refer to 075c967337 -- Thadeus On Sun, May 30, 2010 at 3:52 AM, mdipierro mdipie...@cs.depaul.edu wrote: That should be fixed in 1.79.0rc1 On May 30, 2:05 am, Iceberg iceb...@21cn.com wrote: On May30, 1:17pm, mdipierro mdipie...@cs.depaul.edu wrote: http://web2py.com/examples/static/nightly/web2py_src.ziphttp://web2py... x509 emails, thanks Gyuris attachment and html in Mail on GAE, thanks PanosJee fixed docstring in SQLTABLE, thanks aabelyakov TAG(html) parese html into helpers (experimental, still some problems with unicode, , th\ anks RobertVa for unicode help) DIV.elements(find=re.compile()) DIV.flatten() DIV.elements('') supports jQuery syntax in '' better it-it.py and it.py, thanks Marcello Della Longa Many Bug fixes: improved support for DAL and joins in postgresql/oracle, thanks Nico de Groot bux fixex in html.py, thanks Ian fixed an issue with registration_key==None, thanks Jay Kelkar fixed bug in gql.py, thanks NoNoNo fixed problem with multiple and checkboxes, thanks MIchael Howden fixed bug in gae, thanks NoNoNo restored 2.4 compatibility, thanks Paolo Gasparello auth.update() when pictures in profile Revision: c29660517c with log message fixed problem with multiple and checkboxes, thanks MIchael Howden causes my current app fails. Did not take careful look yet, but it seems changing html.py's line 2154 from: value, _value = self['value'] = self['_value'] # Is it a typo anyway? to: value, _value = self['value'], self['_value'] can fix the problem. Check it out please. The error trace, if needed. File C:/DOWNLOAD/google_appengine/web2py/applications/test/ controllers/default.py, line 34, in index Field('bar', requires=IS_IN_SET(range(5),multiple=True), widget=CheckboxesWidget.widget), File C:\DOWNLOAD\google_appengine\web2py\gluon\sqlhtml.py, line 1033, in factory **attributes) File C:\DOWNLOAD\google_appengine\web2py\gluon\sqlhtml.py, line 689, in __init__ inp = self.widgets.boolean.widget(field, default) File C:\DOWNLOAD\google_appengine\web2py\gluon\sqlhtml.py, line 153, in widget return INPUT(**attr) File C:\DOWNLOAD\google_appengine\web2py\gluon\html.py, line 327, in __init__ self._postprocessing() File C:\DOWNLOAD\google_appengine\web2py\gluon\html.py, line 1254, in _postprocessing value, _value = self['value'] = self['_value'] TypeError: 'NoneType' object is not iterable
Re: [web2py] Re: Non-Breaking Space Helper
Also, you can use the css rules to accomplish the same. text-align: center; width: 150px; height: 100px; padding-top: 40px; -- Thadeus On May 30, 11:32 am, NetAdmin mr.netad...@gmail.com wrote: It would be nice to have a non-breaking space html-helper that uses the following syntax... NBSP(), or NBSP(5) Any Takers? center2.png 2KViewDownload
Re: [web2py] Corrupted db?
Try wiping both databases and sessions and cache. Somehow it seems a record got inserted without an id ?? -- Thadeus On Sun, May 30, 2010 at 4:44 PM, weheh richard_gor...@verizon.net wrote: Things were going great with my new app, but then I seem to have corrupted something and now I can't get my app running again. I'm hitting this error: Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 178, in restricted exec ccode in environment File C:/web2py/applications/YAKiToMe/models/A_db.py, line 16, in module auth=Auth(globals(),db) File C:\web2py\gluon\tools.py, line 533, in __init__ self.user_id = self.user.id AttributeError: 'int' object has no attribute 'id' I wiped the database clean out of the databases folder, but I still get the above error message. Anybody have a clue?