[web2py] Re: web2py 3rd edition available in PDF from LULU.com
I bought the book too, it's great. Just wish comenting highlighting were enabled so that I could bookmark, highlight, fix typos ;-) as I go along -- but there must be a reason for locking this PDF feature? BR, Andre On 21 août, 15:31, ra3don ra3do...@gmail.com wrote: The 3rd edition was released on my birthday. Woohoo! It just wouldn't be right if i didn't buy it. On Aug 19, 5:04 pm, Christopher Steel chris.st...@gmail.com wrote: well worth the money! On Aug 19, 8:18 am, mdipierro mdipie...@cs.depaul.edu wrote: 3 months of work on the book it also cost money. ;-) On Aug 19, 1:37 am, Robby O'Connor robby.ocon...@gmail.com wrote: If I'm not out of line: Why not make the PDF available for free? Print costs money, i can understand charging for that... On 8/19/2010 1:44 AM, JorgeRpo wrote: BOUGHT!! ;) On Aug 13, 2:46 am, mdipierromdipie...@cs.depaul.edu wrote: http://www.lulu.com/product/ebook/official-web2py-manual/12196616 This is the same content as the online book but converted to PDF. There are significant additions and changes compared to the 2nd edition. - new chapter on components, plugins and plugin_wiki example - many new DAL features including list:reference, list:integer, list:string, belongs, contains, computed fields, virtual fields, shortcuts - new custom login methods (including openid, oauth, prx) - new validators - new helpers (including markmin) - application-level routes and other routes customizations - description of new Auth and Crud settings/messages. - description of new default layout and how to change it - {{blocks}} in template - examples are revised to account for new features - running background processes - sending signed and encrypted emails - more info on GAE deployment - new screenshots - may bug fixes. It contains 537 pages. Thanks to Alvaro, Bruno, Denes, Felipe, Graham, Jonathan, Hans, Kyle, Mark, Michele, Richard, Robin, Roman, Scott, Shane, Sharriff, Sriram, Sterling, Stuart, Thadeus for proofreading this and previous versions of the book. It costs one dollar more than 2nd edition, I guess it is because of the increased number of pages. I actually reduced my cut. Hopefully it will be available in print soon. I will take some help in converting to ePub. Massimo
[web2py] Re: Understanding SQLFORM
+1 for the latter, I totally forgot to point also the error on form.vars @david, try the last one by mdipierro and tell us if the problem of submitting the form goes away.. Niphlod On 23 Ago, 03:28, mdipierro mdipie...@cs.depaul.edu wrote: Your code can be simplified as follows: This is incorrect: form.vars.user.writable = False I assume you mean: db.services.user.writable = False It is not a good idea to define a form in a if block, i.e. in a different scope than the the form.accepts. Try this instead: @auth.requires_login() def services(): record = db.services(user=auth.user.id) # returns None if record not found db.services.user.writable = False db.services.user.default = auth.user.id form = SQLFORM(db.services, record, deletable=False) # update or create depending on record if form.accepts(request.vars, session): response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' return dict(form=form) On Aug 22, 3:48 pm, Niphlod niph...@gmail.com wrote: usually I'll do something like that: 1. @auth.requires_login() 2. def services(): 3. record = db(db.services.user==auth.user.id).select().first() 4. if record: 5. form = SQLFORM(db.services, record, deletable=False) 6. form.vars.user.writable = False 7. else: 8. form = SQLFORM(db.services) 9. form.vars.user.default = auth.user.id 10. form.vars.user.writable = False 11. if form.accepts(request.vars, session): 12. response.flash = 'form accepted' 13. elif form.errors: 14. response.flash = 'form has errors' 15. return dict(form=form) changes made to your implementation: a) request.args are needed to catch something after something/ default/services ... that line is copy/pasted from the book but in your context it doesn't mean anything...actually the URL with that is needed to be like something/default/services/xxx where xxx is an identifier of the record to edit. Since you want only one record per user, request.args use is meaningless. so, if len(request.args) is missing totally. b) if there's only one record per user, you can select directly the row with .first() , no need to retain the set (multiple rows object) if there aren't going to be multiple records per user. .first() return a row or None if non-existent, hence the if record: on line 4. c) if record exists, form will be editable of the row record (with records[1] you were doing quite a messactually selecting the 2nd row of your set, python enumeration starts from [0], not from [1]!!) . on line 6. and 10. form.vars.user.writable = False give yourself some protection actually if you don't do this you'll end up giving away the chance to your users to change the user field, assigning his services row to another user definitely not the way to go. I'll be happy to set also form.vars.user.readable = False to hide the field at all, but that's your choice. Feel free to ask more if you're concerned by something or if you didn't understand all. Niphlod- Nascondi testo citato - Mostra testo citato -
[web2py] Re: auth.settings.retrieve_password_next not being honoured
Help me please! :) On Aug 20, 6:38 pm, Adi aditya.sa...@gmail.com wrote: Tried both. No change. I think retrieve_password is the form where an email to reset password is sent. After sending the mail I want to go to my own controller function. On Aug 20, 4:26 pm, mdipierro mdipie...@cs.depaul.edu wrote: I think you want to set reset_password_next auth.settings.retrieve_password_next On Aug 20, 6:01 am, Adi aditya.sa...@gmail.com wrote: Hi, I'm setting auth.settings.retrieve_password_next= my_custom_url so that after sending out reset password mail, the my_custom_url page should open. However, web2py is taking user to default/index. Any help?
[web2py] Re: nice model, weird things
nice! It works perfectly. Sorry if that annoyed you, but I tend to implement functionality before nice representing, and the format parameter is quite always the last one in the development process. I'll try to push up that in the line of priorities ;-) Thanks again Niphlod On 23 Ago, 03:17, mdipierro mdipie...@cs.depaul.edu wrote: You did not set any validator.Validators will be set outomatically if you teach web2py how to represent records in the referenced tables: db.define_table('tablefoo', Field('foo', length=5), format='%(foo)s') db.define_table('tablebar', Field('bar', length=5), format='%(bar)s') db.define_table('tablefoobar', Field('foo_ref', db.tablefoo), Field('bar_ref', db.tablebar) ) On Aug 22, 4:11 pm, Niphlod niph...@gmail.com wrote: hello everybody.with this model I get some really strange behavioursis this a bug or a web2py limitation ? db.py --- db.define_table('tablefoo', Field('foo', length=5) ) db.define_table('tablebar', Field('bar', length=5) ) db.define_table('tablefoobar', Field('foo_ref', db.tablefoo), Field('bar_ref', db.tablebar) ) --- so, I have two tables, tablefoo and tablebar with some values in it and tablefoobar would have to store all the possible connections between tablefoo and tablebar. put 5 rows in tablefoo, 5 rows in tablebar and 1st weird thing: appadmin/insert/db/tablefoobar returns two text inputs: input type=text value= name=foo_ref id=tablefoobar_foo_ref class=reference tablefoo class is reference so there's clearly something wrong with that... 2nd weird thing: no costraint on insertion , form is always accepted (obviously if you try later to visualize the field in appadmin/update/ db/tablefoobar/1 a ticket is returned) 3rd weird thing: appadmin/update/db/tablefoobar/1 if you insert meaningful records (i.e. existing in tablefoo and tablebar, respectively) , it ends up having: input type=text value=1 name=bar_ref id=tablefoobar_bar_ref class=reference tablebar at least, it's coherent :-P I tried also creating a controller and enforcing IS_IN_DB(), then creating a form. I end up having the same bahaviour...- Nascondi testo citato - Mostra testo citato -
[web2py] link on browser-based editor: Bespin
Hello, have yoou heard about Bespin? https://bespin.mozillalabs.com/docs/userguide/index.html Maybe a good thing to add to the admin interface. What do you think? Regards.
Re: [web2py] link on browser-based editor: Bespin
seems very promising: +1 what everyone think? could be used for helping with this? http://groups.google.com/group/web2py/browse_thread/thread/cacb3553eea9f0a4/7bf34ec481232e8c?lnk=gstq=my+editor#7bf34ec481232e8c 2010/8/23 Timmie timmichel...@gmx-topmail.de: Hello, have yoou heard about Bespin? https://bespin.mozillalabs.com/docs/userguide/index.html Maybe a good thing to add to the admin interface. What do you think? Regards.
Re: [web2py] Re: Should we have a feature freeze and stability maintenance period in future?
Hi all, I do develomplent with many different things, different languages architectures and looking for tools for managing software projects is a must for me ;-) I think the problem here is that web2py has started to receive the deserved attention by the user and developer community. Prof. Massimo is doing his best to keep with the growing volume of request. The question is: design of new features is slowed by bugfixing? Well I red from Massimo 2 alerts similar to the following (Massimo feel free to correct me if I am wrong!!): 1. Please remind me of patches to be applied 2. I need to keep track of messages, so no IRC Due to web2py success things will get worse, then I would suggest to start focusing on 2 main points to see if we can find some ideas/solutions. 1) version control I perfectly understand Massimo position: dealing with mercurial (git,bzr) is a pain! Anyhow we must help Massimo delegate some dirty work to others, since we need Massimo to do the important stuff. I think that somehow Massimo's web2py problems resemble those that Linus' Linux faced at the end of '90s. I just remind that Linus to end the thing had written the git system! Please take time to read this chapter: http://hgbook.red-bean.com/read/collaborating-with-other-people.html and this: http://hgbook.red-bean.com/read/collaborating-with-other-people.html#id372519 The model for Linux development IMHO is too much at this time, but some ideas should be taken into consideration. 2) issue tracking We *must* setup a ticket system. Discussion on groups,IRC will eventually lead to a new ticket, but *only* tickets must be taken into account for bugfixing. Code snippets, error log, must be tracked there. ciao, mic 2010/8/23 mart msenecal...@gmail.com: Hi Again, So, spending the day with my 3 girls certainly does provide perspective on requirements and how well attached we can be to them sometimes ;). That in mind, I certainly do understand your personal requirements on keeping what you know and what works for you (I respect old fashion ;) ). We can work with that, while hopefully bringing something efficient, scalable and most certainly flexible, while remaining respectful of what is important to Mr Di Pierro who brought us all here. Although I haven't spent too much time with Mercurial, most concepts don't change, and implementation well... that's all it is really. I had look @ your src repository and I find it is very telling of how you do things and what is important. As I understand, the goal is to meet 2 separate requirements that inevitably impact one another with current structure. The desired outcome: no freeze of the code line while allowing for planned testing iterations to move forward (while enabling Mr Di Pierro to maintain those elements of the current model which are important to him). I think it's entirely doable and please don't hesitate to stop me if I get carried away... I would like to start, if there are no objections, by getting a high level understanding of current practices. So, I'll throw a few questions out there. (I will try t keep the number of questions short – although it may not appear that way). Perhaps, this could be taken to another area to minimize the ruckus? I like the idea of getting a group together and collaborate on developing a proposal. As the more input we have, the better we can serve this type of development model (the concept of contributors) in the web2py dev world in particular. I see that Mr Di Pierro commits all changes to the single branch (default). Here's are a few questions with that: Where do developers check-in or commit their changes while in development? Where does the src going to dev come from and at what frequency does it get synced with the reference code line (if at all) ? Is the reference code line stable (no changes) or is it in constant flux? Since Massimo, is doing the commits, I assume that everybody keeps a sandbox copy of the src? Is there a mechanism in place which makes sure that everyone is working off the same starting point? If not, how are merge conflicts handled presently? Does the code get reviewed before making its way to Massimo who will be committing the changes (or not committing)? As the “release guy”, my first and most important consumer of builds is QA - the testers usually get first dibs on my time ;) - as they are the ones blessing builds and enabling them to move to the next levels. I tend to want to have them in mind when writing automation and making sure they can interface as smoothly as possible to my automation with there own. When going to Test, what get's handed off (src or build)? Is there any regular automated/manual testing? Or is it the case where bigger testing efforts are done later in the release cycle? how are builds identified with those test results? Good release strategies do help, so here are just a few questions on that subject: Have you a
[web2py] filename length bug in sql.py under win32
Hi, I posted some time ago a problem related to uploading a file with a very long filename under window ( it crashes ). I have been able to spot that the issue is in sql.py around line 2799( function store ). So the pb is related to the python interpreter under win32 that doesn't allow the creation of a file descriptor when the path+filename is longer than 255 ( the ntfs filesystem does allow this but it seems to be related to the way python handle it) I don't really know what to do here but may i suggest to change the naming scheme so that generated filename is shorter ( something containing only a uuid and not the encoded part of the filename). Cheers,
Re: [web2py] link on browser-based editor: Bespin
@Michele Bespin is more an editor more web-oriented, the editor that you are linking (Stef Editor) is more Desktop oriented. @Timmie Bespin is a Mozilla Labs project, it is being developed for many time, maybe would be a great idea to integrate it in web2py. Bespin seems a new Vim , but web-oriented :D Regards. On Mon, Aug 23, 2010 at 10:32 AM, Michele Comitini michele.comit...@gmail.com wrote: seems very promising: +1 what everyone think? could be used for helping with this? http://groups.google.com/group/web2py/browse_thread/thread/cacb3553eea9f0a4/7bf34ec481232e8c?lnk=gstq=my+editor#7bf34ec481232e8c 2010/8/23 Timmie timmichel...@gmx-topmail.de: Hello, have yoou heard about Bespin? https://bespin.mozillalabs.com/docs/userguide/index.html Maybe a good thing to add to the admin interface. What do you think? Regards.
Re: [web2py] Re: Line continuation problem in new parser?
Probably didn't. I encountered it while trying to clean up some view code that was looking messy. I'm in favor of supporting line continuation if at all possible or, if not, at least issuing an error message to that effect. On Sun, Aug 22, 2010 at 9:14 PM, mdipierro mdipie...@cs.depaul.edu wrote: Did this work before? I do not think continuation was ever supported. Massimo On Aug 22, 2:13 pm, Michael Ellis michael.f.el...@gmail.com wrote: In Version 1.83.2 (2010-08-15 02:10:01) this works: {{ for r in rows: =DIV(SPAN(r[0]), SPAN(fcw[r[0]]), SPAN(fcw[r[1]])) pass }} but this raises a syntax error: {{ for r in rows: =DIV(SPAN(r[0]), SPAN(fcw[r[0]]), SPAN(fcw[r[1]])) pass }} Tried '\' continuations also. The parser thinks there are extra chars after the backslash even when there aren't. Apologies if this is a known issue or intentional limitation. Cheers, Mike
[web2py] Re: web2py 3rd edition available in PDF from LULU.com
It was not done on purpose. They processed the PDF I provided (which I believe is unlocked). On Aug 23, 1:55 am, dederocks dediro...@gmail.com wrote: I bought the book too, it's great. Just wish comenting highlighting were enabled so that I could bookmark, highlight, fix typos ;-) as I go along -- but there must be a reason for locking this PDF feature? BR, Andre On 21 août, 15:31, ra3don ra3do...@gmail.com wrote: The 3rd edition was released on my birthday. Woohoo! It just wouldn't be right if i didn't buy it. On Aug 19, 5:04 pm, Christopher Steel chris.st...@gmail.com wrote: well worth the money! On Aug 19, 8:18 am, mdipierro mdipie...@cs.depaul.edu wrote: 3 months of work on the book it also cost money. ;-) On Aug 19, 1:37 am, Robby O'Connor robby.ocon...@gmail.com wrote: If I'm not out of line: Why not make the PDF available for free? Print costs money, i can understand charging for that... On 8/19/2010 1:44 AM, JorgeRpo wrote: BOUGHT!! ;) On Aug 13, 2:46 am, mdipierromdipie...@cs.depaul.edu wrote: http://www.lulu.com/product/ebook/official-web2py-manual/12196616 This is the same content as the online book but converted to PDF. There are significant additions and changes compared to the 2nd edition. - new chapter on components, plugins and plugin_wiki example - many new DAL features including list:reference, list:integer, list:string, belongs, contains, computed fields, virtual fields, shortcuts - new custom login methods (including openid, oauth, prx) - new validators - new helpers (including markmin) - application-level routes and other routes customizations - description of new Auth and Crud settings/messages. - description of new default layout and how to change it - {{blocks}} in template - examples are revised to account for new features - running background processes - sending signed and encrypted emails - more info on GAE deployment - new screenshots - may bug fixes. It contains 537 pages. Thanks to Alvaro, Bruno, Denes, Felipe, Graham, Jonathan, Hans, Kyle, Mark, Michele, Richard, Robin, Roman, Scott, Shane, Sharriff, Sriram, Sterling, Stuart, Thadeus for proofreading this and previous versions of the book. It costs one dollar more than 2nd edition, I guess it is because of the increased number of pages. I actually reduced my cut. Hopefully it will be available in print soon. I will take some help in converting to ePub. Massimo
[web2py] Re: auth.settings.retrieve_password_next not being honoured
One more try please: auth.settings.request_reset_password_next On Aug 23, 2:32 am, Adi aditya.sa...@gmail.com wrote: Help me please! :) On Aug 20, 6:38 pm, Adi aditya.sa...@gmail.com wrote: Tried both. No change. I think retrieve_password is the form where an email to reset password is sent. After sending the mail I want to go to my own controller function. On Aug 20, 4:26 pm, mdipierro mdipie...@cs.depaul.edu wrote: I think you want to set reset_password_next auth.settings.retrieve_password_next On Aug 20, 6:01 am, Adi aditya.sa...@gmail.com wrote: Hi, I'm setting auth.settings.retrieve_password_next= my_custom_url so that after sending out reset password mail, the my_custom_url page should open. However, web2py is taking user to default/index. Any help?
[web2py] Re: Multiple submit not working on component
As an update, the issue remains with the following combinations: * if input type='submit' and different names * if input type='button', with or without different name attributes However, input type='text' are present in form.vars. For the interested a solution for usage in components is to use set a hidden input text field via the click event of each button. Miguel On Mon, Aug 23, 2010 at 3:54 AM, Miguel Lopes mig.e.lo...@gmail.com wrote: I'm using the same name to all input type submits technique. This is very nice because it avoids some js and works like a charm :-) In a regular controller the code works flawlessly. However when I try to put it in a controller, it fails: status_form = FORM(_id='status_form') for status in OPPTY_STATUS: btn = INPUT(_type='submit', _name='status', _value=status, _class='status_btn') status_form.append(btn) if status_form.accepts(request.vars, session, formname='status_form'): # status_form.vars.status is None in component # status_form.vars.status corresponds to whatever submit was pressed in regular controller ... It seems like the component mechanisms is ignoring the value of 'status'. Miguel
[web2py] Startup issues
Hello, I'm trying to run web2py, but as I go into 'the real stuff', problems start to arise. Just so you know, I'm running python 2.7 on a windows 7 OS, using the 1.83 source code. a) I get a warning that cron is disabled because there is no file locking. Starting the app with administrative rights doesn't change anything. b) I can't create a database: In[1]: db = DAL('sqlite://storage.db') Out[1]: In[2]: db.define_table('person',Field('name')) Out[2]: Traceback (most recent call last): File input, line 1, in module File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 1359, in define_table t._create(migrate=migrate, fake_migrate=fake_migrate) File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 1800, in _create self._db._execute(query) File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 947, in lambda self._execute = lambda *a, **b: self._cursor.execute(*a, **b) ProgrammingError: Cannot operate on a closed database. a) trying to experiment with the web2py shell, I found a surprising effect: the shell works if I call it from the 'welcome' application, but not from the 'examples' application. In the latter case, a ticket is raised, with sys.exit(1) highlighted: if import_models: try: run_models_in(environment) except RestrictedError, e: sys.stderr.write(e.traceback+'\n') sys.exit(1) return environment def exec_pythonrc(): any suggestions? Thxs BR, Andre
[web2py] RFC: validator IS_NOT_IN_SET
Hi all, I needed IS_NOT_IN_SET validator and added it in my custom validators.py, do you think it is useful? class IS_NOT_IN_SET(IS_IN_SET): example:: INPUT(_type='text', _name='name', requires=IS_NOT_IN_SET(['max', 'john'],zero='')) the argument of IS_NOT_IN_SET must be a list or set IS_NOT_IN_SET(['max', 'john'])('max') ('max', 'value not allowed') IS_NOT_IN_SET(['max', 'john'])('na') ('na', None) IS_NOT_IN_SET(('id1','id2'), ['first label','second label'])('id100') ('id100', None) IS_NOT_IN_SET(('id1','id2'), ['first label','second label'])('id1') ('id1', 'value not allowed') IS_NOT_IN_SET(('id1','id2'), ['first label','second label'])('id2') ('id2', 'value not allowed') IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) ('id100') ('id100', None) IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) ('id1') ('id1', 'value not allowed') IS_NOT_IN_SET({'id1':'first label', 'id2':'second label'}) ('id2') ('id2', 'value not allowed') import itertools IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('100') ('100', None) IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('1') ('1', 'value not allowed') IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('6') ('6', 'value not allowed') IS_NOT_IN_SET(itertools.chain(['1','3','5'],['2','4','6'])) ('7') ('7', None) def __init__(self, *a, **b): IS_IN_SET.__init__(self, *a, **b) def __call__(self, value): value, error = IS_IN_SET.__call__(self, value) if error == None: return (value, self.error_message) else: return (value, None)
[web2py] redirection question
I have a basic update form code that is called via a HREF form another view and form a menu. The problem is the redirect to the referrer is not working. I looked in the forums and have tried to debug. I understand the form is posting back to itself which is why the form is redirected to itself. The forums offer several solutions that depend on a hidden form element embedded in the calling view which are save as request.vars. I am not sure how to make this work with a menu. I hope there is a clean elegant way to accomplish this. Any help would be apprecaited.. @auth.requires_login() def editmeeting(): if not request.args: session.flash = 'Invalid parameter' redirect(URL(r=request, c='default', f='index')) meeting = db(db.meeting.id == request.args(0)).select() if len(meeting): meeting = meeting[0] else: session.flash = 'Invalid meeting' redirect(URL(r=request,c='default',f='index')) form=SQLFORM(db.meeting,meeting, submit_button='Update Meeting') if form.accepts(request.vars, session): redirect(request.env.http_referer) elif form.errors: response.flash = 'Invalid data.' return dict(form=form)
[web2py] Dropdown List with Select
This seems list a simple task but I can't figure out a way to do it with Web2Py I want to have a dropdown list of services that someone can select and then be taken to the correct profile page etc I want to build this list of names dynamically from my services model. How do I pull the different names from the model, with their ID and build a dropdown that auto selects to the next page?
[web2py] web2py minimalist version
I have hosting in webfaction and I am very satisfied with the service and support. Yesterday I was trying alwaysdata, which provides a free hosting alternative. The free option has some limitations, such as used disk space (10MB) and RAM (40MB). Following the tutorial [2], in a few minutes was running application welcome. I deleted the applications admin and examples, leaving only welcome, with that used disk space on my account is 6-7 MB. What else can be deleted, so as to leave the bare minimum in web2py? docs, scripts, etc? Jose [1] http://www.alwaysdata.com/ [2] http://wiki.alwaysdata.com/wiki/D% C3% A9ployer_une_application_web2py
[web2py] Re: Multiple submit not working on component
I think this is a bug in the web2py in the form processing system. I will fix it tonight. On Aug 22, 9:54 pm, Miguel Lopes mig.e.lo...@gmail.com wrote: I'm using the same name to all input type submits technique. This is very nice because it avoids some js and works like a charm :-) In a regular controller the code works flawlessly. However when I try to put it in a controller, it fails: status_form = FORM(_id='status_form') for status in OPPTY_STATUS: btn = INPUT(_type='submit', _name='status', _value=status, _class='status_btn') status_form.append(btn) if status_form.accepts(request.vars, session, formname='status_form'): # status_form.vars.status is None in component # status_form.vars.status corresponds to whatever submit was pressed in regular controller ... It seems like the component mechanisms is ignoring the value of 'status'. Miguel
[web2py] Re: Startup issues
there are two issues: 1) file locking. I assume you are using windows and running from source. You need to install the Mark Hammond win32 extensions. 2) shell error Cannot operate on a closed database.. This is a known problem. Do not use the web based shell to interact with the database. Use the normall shell python web2py.py -S yourapp -N -M On Aug 23, 9:18 am, dederocks dediro...@gmail.com wrote: Hello, I'm trying to run web2py, but as I go into 'the real stuff', problems start to arise. Just so you know, I'm running python 2.7 on a windows 7 OS, using the 1.83 source code. a) I get a warning that cron is disabled because there is no file locking. Starting the app with administrative rights doesn't change anything. b) I can't create a database: In[1]: db = DAL('sqlite://storage.db') Out[1]: In[2]: db.define_table('person',Field('name')) Out[2]: Traceback (most recent call last): File input, line 1, in module File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 1359, in define_table t._create(migrate=migrate, fake_migrate=fake_migrate) File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 1800, in _create self._db._execute(query) File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 947, in lambda self._execute = lambda *a, **b: self._cursor.execute(*a, **b) ProgrammingError: Cannot operate on a closed database. a) trying to experiment with the web2py shell, I found a surprising effect: the shell works if I call it from the 'welcome' application, but not from the 'examples' application. In the latter case, a ticket is raised, with sys.exit(1) highlighted: if import_models: try: run_models_in(environment) except RestrictedError, e: sys.stderr.write(e.traceback+'\n') sys.exit(1) return environment def exec_pythonrc(): any suggestions? Thxs BR, Andre
[web2py] Re: web2py and SEO
Sorry, but the first link don't work. Insteand, http://www.google.com/support/webmasters/ and, in help resources can found the google doc in search engine optimization. There are useful articles and videos SEO related too. Regards. On 22 ago, 14:53, puercoespin jzaragoza.puercoes...@gmail.com wrote: On 12 ago, 00:23, mdipierro mdipie...@cs.depaul.edu wrote: Could you provide a list of features you would like to see? Massimo On Aug 11, 4:52 pm, puercoespin jzaragoza.puercoes...@gmail.com wrote: First of all, I want to indicate that I am not an expert inSEO, not in Python not inWeb2py. In fact, I am not expert in anything :) I think that a good beginning to create a list of possible features that, in my opinion, it should haveWeb2pyin reference toSEO, would be the Google’s doc Google's Search Engine Optimization. Starter Guide , and it can be found in http: //www.google.com/webmasters/docs/search-engine-optimization-starter-gui... . It is a brief document, of only 22 pages, but very interesting and whose reading I recommend. In addition, it has links to go deeper into some treated topics, as well as to tools for webmaster related toSEO. What I am going to expose is a small summary of the document, as a list, of the elements that a web site must have in order that it could obtain a good positioning. I think that in some of them,web2pymight facilitate the fulfilment of these elements. 1.- Create unique, accurate page titles, Create unique title tags for each page, Make use of the 'description' meta tag, Use unique descriptions for each page, Improve the structure of your URLs. When Google presents us a list of webs as result of a search, he presents first the title of the web, a small text, which can - or not - match with the text of the meta tag description, and a url link to the web. So is very important put the major care in refilling this meta tags. So I think thatWeb2pymust to ask for title and description when created a new application. In order that every page has a title and a different description, depending on his content, maybe doing that the controller returning variables title and description?? URL’s must included words that can be found in a user search. And reflected the web’s structure, if possible, clean and ordered. Also, if a user “cuts” some parts of a url, (www.exemple.com/an/url/very/ large/ and user cuts /large, for example) the reply not would be an stranger message. About url’s, I thinkweb2pydoes a good job. 2.- Make your site easier to navigate Everything related to the user ease of navigation will be appreciated by the search engines. In fact, inSEO, accessibility and usability counts. So it's recommended a sitemap (lower case), that is a html file, generally located in the root, and with a hierarchy links of the pages of the site, maybe with its title and description. This file is aimed to human visitors. Also, it's recommended a Sitemap (upper case), That’s a xml file, aimed to search engines. With this file, the webmaster can inform to search engines about the frequency of changes of the web, or what are the most important pages of our sites. In both files, I think thatweb2pyhas job to do. Another interesting element would be a “breadcrumb”. That’s a row of internal links, located in top or/and bottom of the page as title.site title.page1 title.page2 title.page3. There a lot of snippets of code in Django that implements a breadcrumb. Also, there a project in google code in http://code.google.com/p/django-breadcrumbs/ ;. Whats aboutWeb2py?? And last, a 404 personalized page, that kindly redirects users to the root, or show a list of links of the most visited pages, its very appreciated. 3.- Offer quality content and services , Write better anchor text, “Use heading tags appropriately” “Optimize your use of images” Well, I think with that, any framework has nothing to do. :) 4.- “Make effective use of robots.txt”. Maybe allweb2pyapplication would be, by default, a robots.txt file with, at least, this content: User-agent: “ Disallow: /static/ A robots.txt is a good practice, simple to follow. 5. “Be aware of rel=nofollow for links”. As example of use, the google’s document example: a href=http://www.shadyseo.com/rel=”nofollow”Comment spammer/a Maybe interesting. As point the google doc: “Setting the value of the rel attribute of a link to nofollow will tell Google that certain links on your site shouldn't be followed or pass your page's reputation to the pages linked to. […]If your site has a blog with public commenting turned on, links within those comments could pass your reputation to pages that you may not be comfortable vouching for. Blog comment areas on pages are highly susceptible to comment spam. Nofollowing these user- added links ensures that you're not giving your page's hard-earned reputation to a spammy site. Many blogging software packages
[web2py] Re: SQLHTML is not defined - Autocomplete Widget
Changing SQLHTML to SQLFORM solved the SQLHTML not defined problem. SQLFORM, however, doesn't support limitby. SQLFORM.widgets.autocomplete(request,db.plaats.plaats,limitby=(0,10),min_length=2) I am working with web2py 1.83.2. Kind regards, Annet.
Re: [web2py] Re: How to start server from within a python file ?
thanks Massimo, but it doesn't work by me ... On 23-08-2010 04:33, mdipierro wrote: from gluon.main import HttpServer here the problem begin, Maybe I should start with a more basic question, what should I do with the sources ? I don't see a setup file, so I just dumped the source files in the python site-packages site-packages\web2py\... is that enough ? thanks, Stef
Re: [web2py] How to start server from within a python file ?
that's great Jason, On 23-08-2010 05:22, Jason Brower wrote: It's very nice to see you using linux. If you have any questions that are linux related please tell me and I can try to help you. :D ok here is the first problem What's the way to start the web2py server from a python script ? thanks, Stef BR, Jason Brower On Sun, 2010-08-22 at 22:03 +0200, Stef Mientki wrote: hello,
Re: [web2py] How to start server from within a python file ?
Hi Stef, you are using device names and backslashes (they are not understood by unix the same way windows does), could be that? http://en.wikipedia.org/wiki/Filename mic and gives the following error message: Traceback (most recent call last): File D:\Data_Python_25\support\test.py, line 21, in module execfile ( filename ) File P:/Web2Py/web2py_src/web2py/web2py.py, line 16, in module import gluon.import_all ImportError: No module named gluon.import_all 2010/8/23 Stef Mientki stef.mien...@gmail.com: that's great Jason, On 23-08-2010 05:22, Jason Brower wrote: It's very nice to see you using linux. If you have any questions that are linux related please tell me and I can try to help you. :D ok here is the first problem What's the way to start the web2py server from a python script ? thanks, Stef BR, Jason Brower On Sun, 2010-08-22 at 22:03 +0200, Stef Mientki wrote: hello,
Re: [web2py] How to start server from within a python file ?
thanks Mic, but that's not the problem ( I changed them in single forward slashes), the problem is the file structure of web2py, I'm definitely missing something there. cheers, Stef On 23-08-2010 21:46, Michele Comitini wrote: Hi Stef, you are using device names and backslashes (they are not understood by unix the same way windows does), could be that? http://en.wikipedia.org/wiki/Filename mic and gives the following error message: Traceback (most recent call last): File D:\Data_Python_25\support\test.py, line 21, in module execfile ( filename ) File P:/Web2Py/web2py_src/web2py/web2py.py, line 16, in module import gluon.import_all ImportError: No module named gluon.import_all 2010/8/23 Stef Mientki stef.mien...@gmail.com: that's great Jason, On 23-08-2010 05:22, Jason Brower wrote: It's very nice to see you using linux. If you have any questions that are linux related please tell me and I can try to help you. :D ok here is the first problem What's the way to start the web2py server from a python script ? thanks, Stef BR, Jason Brower On Sun, 2010-08-22 at 22:03 +0200, Stef Mientki wrote: hello,
[web2py] Re: Startup issues
Sorry for coming with old hats (to be included in the book?), and thanks for the quick help! On 23 août, 18:20, mdipierro mdipie...@cs.depaul.edu wrote: there are two issues: 1) file locking. I assume you are using windows and running from source. You need to install the Mark Hammond win32 extensions. 2) shell error Cannot operate on a closed database.. This is a known problem. Do not use the web based shell to interact with the database. Use the normall shell python web2py.py -S yourapp -N -M On Aug 23, 9:18 am, dederocks dediro...@gmail.com wrote: Hello, I'm trying to run web2py, but as I go into 'the real stuff', problems start to arise. Just so you know, I'm running python 2.7 on a windows 7 OS, using the 1.83 source code. a) I get a warning that cron is disabled because there is no file locking. Starting the app with administrative rights doesn't change anything. b) I can't create a database: In[1]: db = DAL('sqlite://storage.db') Out[1]: In[2]: db.define_table('person',Field('name')) Out[2]: Traceback (most recent call last): File input, line 1, in module File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 1359, in define_table t._create(migrate=migrate, fake_migrate=fake_migrate) File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 1800, in _create self._db._execute(query) File C:\Users\Andre\Documents\web2py\gluon\sql.py, line 947, in lambda self._execute = lambda *a, **b: self._cursor.execute(*a, **b) ProgrammingError: Cannot operate on a closed database. a) trying to experiment with the web2py shell, I found a surprising effect: the shell works if I call it from the 'welcome' application, but not from the 'examples' application. In the latter case, a ticket is raised, with sys.exit(1) highlighted: if import_models: try: run_models_in(environment) except RestrictedError, e: sys.stderr.write(e.traceback+'\n') sys.exit(1) return environment def exec_pythonrc(): any suggestions? Thxs BR, Andre
[web2py] Re: IS_IMAGE() broke?
I was also experiencing this issue, but found that rebuilding the database only worked until the first valid upload, after which it is broken again. In my case, I am using: Field('photo', 'upload', uploadfield='photo_data', requires=IS_IMAGE(extensions=('jpeg'))), Field('photo_data', 'blob', requires=IS_IMAGE(extensions=('jpeg'))), And was using SQLFORM to display the update form. When I first added this, it was accepting absolutely everything (pdf, odt, zip) as an upload. I deleted my database entirely, and had it rebuilt. I first noticed that it started rejecting non-image uploads. However, once I had uploaded an image, all subsequent uploads of non- image types were allowed again. A second database build showed the exact same behaviour; proper rejection until the first valid upload. I then made a backup of my web2py folder, and extracted today's nightly build over my folder. Rebuilding my database one last time, it shows the exact same behaviour. On Jul 11, 2:56 pm, Rob r...@rmdashr.com wrote: I just recently added: db.Item.image.requires =IS_IMAGE() The records that existed prior to adding this line does not obey theIS_IMAGE() (ie: they still allow me to upload a PDF). All new records created DO work - they force me to select an image or else they show an error. steps to reproduce (untested) 1) create DB db.define_table('Item', Field('description'), Field('need', 'boolean'), Field('image', 'upload')) 2) add rows to the table 3) add rules: db.Item.category.requires = IS_IN_DB(db, db.Category.id,'%(name)s') db.Item.description.requires = IS_NOT_EMPTY() db.Item.image.requires =IS_IMAGE() 4) go back to the rows you added to the Item table and add non-image files - notice it works Does that help? On Jul 11, 11:42 am, mdipierro mdipie...@cs.depaul.edu wrote: Please tell us more. When do you get an error? What is the error? On 11 Lug, 11:57, Rob r...@rmdashr.com wrote: This issue only happens for records that were created before I added the .requires fields. Error handling on new records works as expected... so... is it still a bug? On Jul 11, 9:15 am, Rob r...@rmdashr.com wrote: db.define_table('Category', Field('name')) db.define_table('Item', Field('category', db.Category), Field('description'), Field('need', 'boolean'), Field('image', 'upload')) db.Item.category.requires = IS_IN_DB(db, db.Category.id) db.Item.description.requires = IS_NOT_EMPTY() db.Item.image.requires =IS_IMAGE() def details(): item = request.args(0) form = crud.update(db.Item, item, next=URL(r=request, args=item)) return dict(form=form) It allows me to upload PDFs and flashes 'record updated'
Re: [web2py] Re: nice model, weird things
On 08/22/2010 06:17 PM, mdipierro wrote: You did not set any validator.Validators will be set outomatically if you teach web2py how to represent records in the referenced tables: db.define_table('tablefoo', Field('foo', length=5), format='%(foo)s') db.define_table('tablebar', Field('bar', length=5), format='%(bar)s') db.define_table('tablefoobar', Field('foo_ref', db.tablefoo), Field('bar_ref', db.tablebar) ) I have been following along and I wonder is this documented somewhere? I never would have made the connection between an optional format representation and validation :) -- Adrian Klaver adrian.kla...@gmail.com
[web2py] Re: How to start server from within a python file ?
No. you either dubmp the gluon folder in site-packages site-packages/gluon or better import sys sys.path.append('location/to/web2py/') On Aug 23, 2:16 pm, Stef Mientki stef.mien...@gmail.com wrote: thanks Massimo, but it doesn't work by me ... On 23-08-2010 04:33, mdipierro wrote: from gluon.main import HttpServer here the problem begin, Maybe I should start with a more basic question, what should I do with the sources ? I don't see a setup file, so I just dumped the source files in the python site-packages site-packages\web2py\... is that enough ? thanks, Stef
[web2py] Re: nice model, weird things
http://web2py.com/book/default/chapter/03?search=would+be+automatic On Aug 23, 1:30 pm, Adrian Klaver adrian.kla...@gmail.com wrote: On 08/22/2010 06:17 PM, mdipierro wrote: You did not set any validator.Validators will be set outomatically if you teach web2py how to represent records in the referenced tables: db.define_table('tablefoo', Field('foo', length=5), format='%(foo)s') db.define_table('tablebar', Field('bar', length=5), format='%(bar)s') db.define_table('tablefoobar', Field('foo_ref', db.tablefoo), Field('bar_ref', db.tablebar) ) I have been following along and I wonder is this documented somewhere? I never would have made the connection between an optional format representation and validation :) -- Adrian Klaver adrian.kla...@gmail.com
[web2py] Re: IS_IMAGE() broke?
Something is wrong here IS_IMAGE(extensions=('jpeg')) should be IS_IMAGE(extensions=('jpeg',)) A tuple of one element must contain a comma. Not sure if that may be the cause of your problem. On Aug 23, 3:16 pm, Joe Wakefield coffeeburr...@gmail.com wrote: I was also experiencing this issue, but found that rebuilding the database only worked until the first valid upload, after which it is broken again. In my case, I am using: Field('photo', 'upload', uploadfield='photo_data', requires=IS_IMAGE(extensions=('jpeg'))), Field('photo_data', 'blob', requires=IS_IMAGE(extensions=('jpeg'))), And was using SQLFORM to display the update form. When I first added this, it was accepting absolutely everything (pdf, odt, zip) as an upload. I deleted my database entirely, and had it rebuilt. I first noticed that it started rejecting non-image uploads. However, once I had uploaded an image, all subsequent uploads of non- image types were allowed again. A second database build showed the exact same behaviour; proper rejection until the first valid upload. I then made a backup of my web2py folder, and extracted today's nightly build over my folder. Rebuilding my database one last time, it shows the exact same behaviour. On Jul 11, 2:56 pm, Rob r...@rmdashr.com wrote: I just recently added: db.Item.image.requires =IS_IMAGE() The records that existed prior to adding this line does not obey theIS_IMAGE() (ie: they still allow me to upload a PDF). All new records created DO work - they force me to select an image or else they show an error. steps to reproduce (untested) 1) create DB db.define_table('Item', Field('description'), Field('need', 'boolean'), Field('image', 'upload')) 2) add rows to the table 3) add rules: db.Item.category.requires = IS_IN_DB(db, db.Category.id,'%(name)s') db.Item.description.requires = IS_NOT_EMPTY() db.Item.image.requires =IS_IMAGE() 4) go back to the rows you added to the Item table and add non-image files - notice it works Does that help? On Jul 11, 11:42 am, mdipierro mdipie...@cs.depaul.edu wrote: Please tell us more. When do you get an error? What is the error? On 11 Lug, 11:57, Rob r...@rmdashr.com wrote: This issue only happens for records that were created before I added the .requires fields. Error handling on new records works as expected... so... is it still a bug? On Jul 11, 9:15 am, Rob r...@rmdashr.com wrote: db.define_table('Category', Field('name')) db.define_table('Item', Field('category', db.Category), Field('description'), Field('need', 'boolean'), Field('image', 'upload')) db.Item.category.requires = IS_IN_DB(db, db.Category.id) db.Item.description.requires = IS_NOT_EMPTY() db.Item.image.requires =IS_IMAGE() def details(): item = request.args(0) form = crud.update(db.Item, item, next=URL(r=request, args=item)) return dict(form=form) It allows me to upload PDFs and flashes 'record updated'
[web2py] Model with many to many defined across multiple database instances
I have a model which has sites and servers with a many-to-many relation described by site_servers as follows: # Global table of known sites db.define_table('sites', Field('uuid', 'string', length=64, default=str(uuid.uuid4()), writable=False), Field('last_modified', 'datetime', default=request.now, update=request.now, writable=False, readable=False), Field('name', 'string', length=16, required=True, notnull=True, unique=True, label='Site name'), Field('long_name', 'string', length=64, unique=True, label='Site full name'), format='%(name)s' ) # Global table of known servers db.define_table('servers', Field('uuid', 'string', length=64, default=str(uuid.uuid4()), writable=False), Field('last_modified', 'datetime', default=request.now, update=request.now, writable=False, readable=False), Field('hostname', 'string', length=64, required=True, notnull=True, unique=True, label='Hostname:'), format='%(hostname)s' ) # Global table showing which servers perform known functions for which sites. # The default is a server provides all services. db.define_table('site_servers', Field('uuid', 'string', length=64, default=str(uuid.uuid4()), writable=False), Field('last_modified', 'datetime', default=request.now, update=request.now, writable=False, readable=False), Field('site_uuid', 'string', length=64), Field('server_uuid', 'string', length=64), Field('web_server', 'boolean', default=True), Field('archiver', 'boolean', default=True) ) db.site_servers.site_uuid.requires = IS_IN_DB(db, 'sites.uuid', '% (name)s') db.site_servers.server_uuid.requires = IS_IN_DB(db, 'servers.uuid', '% (hostname)s') sites_and_servers = db((db.sites.uuid==db.site_servers.site_uuid) (db.servers.uuid==db.site_servers.server_uuid)) The problem is this line that should be used to test for uniqueness of the site_servers rows so I don't get duplicate entries in the join table causes the server line of the site_servers insert form to change from a drop down selecting from existing servers to a text input line. # Test for uniqueness across site_uuid and server_uuid db.site_servers.server_uuid.requires = IS_NOT_IN_DB(db (db.site_servers.site_uuid==request.vars.site_uuid),db.site_servers.server_uuid) I took thie problem line from several other posts, however they were not involving uuid and timestamp tables meant for global use across multiple installations of the database. I have trimmed some fields from the model to simplify the definition. Also the example in the DAL chapter third edition of the book under the heading CSV and Remote Database Synchronization shows the 'modified_on' field setting of default=now which results in undefined variable now. I believe that should be default=request.now Thanks for any advice Ron
Re: [web2py] Re: nice model, weird things
On Monday 23 August 2010 2:02:53 pm mdipierro wrote: http://web2py.com/book/default/chapter/03?search=would+be+automatic Thanks. I was looking in the wrong place, DAL and Form sections. -- Adrian Klaver adrian.kla...@gmail.com
[web2py] Re: build a row base questionnaire
A much more sophisticated solution Massimo! I completely missed the orderby='random' functionality. Going back to the original question, the point here is that when you have a 'normalised' table of question/answers, you need to decouple from SQLFORM (with SQLFORM.factory) and handle the db interactions more explicitly. On Aug 23, 2:31 pm, mdipierro mdipie...@cs.depaul.edu wrote: We need to clarify the goal. The goal is not to propose questions to the user. the goal is to check if he answers correctly. Should each correct answer be recorded for each user? should incorrect answers be recorded? Should the list of proposed questions be recored? Should a score be computed? What is the answer is Darwin and he answers darwin or Charles Darwin? Anyway, the above code can be simplified in: db.define_table('q_and_a', Field('question'), Field('answer')) def check(correct_answer,answer): if correct_answer.lower() in answer.lower(): return 1 return 0 def ask(): asked = db(db.q_and_a.id0).select(orderby='random',limitby=(0,3)) form=SQLFORM.factory(*[Field('a%s'%i, label = a.question) for i,a in enumerate(asked)]) if form.accepts(request.vars,session): score = sum((check(a.answer,request.vars.get('a%s'%i,'')) for i,a in enumerate(asked)) # do something with score return dict(form=form) On Aug 22, 6:04 pm, Russell russell.mcmur...@gmail.com wrote: In my experience, it is a bit awkward to do this using SQLFORM. You could try something like this: db.define_table('q_and_a', Field('question'), Field('answer')) rows = db(db.q_and_a.id0).select() import random random.seed() asked = random.sample(rows, 3)) form=SQLFORM.factory( Field('asked_0', label = asked [0]['question']), Field('asked_1 ', label = asked [1]['question']), Field('asked_2 ', label = asked [2]['question'])) But this can create more problems than it solves. Ultimately it might be easier to put your questions in a wide table and use something like Massimo proposed here: http://groups.google.com/group/web2py/browse_thread/thread/d0093fa190... On Aug 20, 1:10 pm, dlin dlin...@gmail.com wrote: Tks, Bruno. I seems haven't describe the 'row base' questionaire. That is: I've already a table like: Question Answer Q1... A1 Q2... A2 Q3... A3 ... Q13... A1 Then, I'll random choose three(or by customized) questions to ask. Question Answer Q3. Q8. Q9. [submit] sometimes, it Question Answer Q7. Q9. Q13. [submit] I think it is not proper to save it fixed on 3 field on table. I'm thinking should I use following steps: 1. SQLTABLE to select some random rows from my question and answer . 2. try to form a FORM() (I haven't idea now) 3. when user submit form, then try to compare the answer and store the scores of user in another table. On Aug 19, 7:54 am, Bruno Rocha rochacbr...@gmail.com wrote: You can use FORM(), and also use the table configuration to define questions, you can use the arguments label and comment on field definition. After that, you can use CSS to improve the form layout. You can't create a new field to store the login info and putting by default the auth.user value? 2010/8/18 dlin dlin...@gmail.com I want a form like: Question Answer Q1. Q2. Q3. [submit] Q1,Q2,Q3 and correct answer is stored in a table. But the 'Answer' field should combined with login user's answer. What's the best way to display the form to user? Do you suggest use FORM() in control or use form in view? -- http://rochacbruno.com.br
Re: [web2py] Re: How to start server from within a python file ?
hi Massimo, On 23-08-2010 22:56, mdipierro wrote: No. you either dubmp the gluon folder in site-packages site-packages/gluon then it crashes on not having a version number or better import sys sys.path.append('location/to/web2py/') the program just hangs completely: import os, sys filepath = r'P:/Web2Py/web2py_src/web2py' sys.path.append ( filepath ) os.chdir ( filepath ) ## == absolutely necessary to get the version number !!! from gluon.main import HttpServer server = HttpServer ( password='xxx' ) #ip,port,admin_password) server.start() print 'piep' and never says 'piep' :-( cheers, Stef On Aug 23, 2:16 pm, Stef Mientki stef.mien...@gmail.com wrote: thanks Massimo, but it doesn't work by me ... On 23-08-2010 04:33, mdipierro wrote: from gluon.main import HttpServer here the problem begin, Maybe I should start with a more basic question, what should I do with the sources ? I don't see a setup file, so I just dumped the source files in the python site-packages site-packages\web2py\... is that enough ? thanks, Stef
[web2py] Re: Model with many to many defined across multiple database instances
To simplify I just used standard id fields, copied the scaffold (welcome) application with create new application in admin and then in db.py changed the db line to match MySQL and created the database else: # else use a normal relational database # db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB db = DAL('mysql://xxx:y...@localhost/testing') # testing then added the following to the bottom of the model file db.py # Global table of known sites db.define_table('sites', Field('name', 'string', length=16, required=True, notnull=True, unique=True, label='Site name'), Field('long_name', 'string', length=64, unique=True, label='Site full name'), format='%(name)s' ) # Global table of known servers db.define_table('servers', Field('hostname', 'string', length=64, required=True, notnull=True, unique=True, label='Hostname:'), format='%(hostname)s' ) # Global table showing which servers perform known functions for which sites. # The default is a server provides all services. db.define_table('site_servers', Field('site_id', db.sites), Field('server_id', db.servers), Field('web_server', 'boolean', default=True), Field('archiver', 'boolean', default=True) ) db.site_servers.site_id.requires = IS_IN_DB(db, 'sites.id', '% (name)s') db.site_servers.server_id.requires = IS_IN_DB(db, 'servers.id', '% (hostname)s') sites_and_servers = db((db.sites.id==db.site_servers.site_id) (db.servers.id==db.site_servers.server_id)) Commenting out the following lines shows servers as a drop down list on the insert site_servers form, leaving the line active causes the servers line to be a text input field. # Test for uniqueness across site_id and server_id db.site_servers.server_id.requires = IS_NOT_IN_DB(db (db.site_servers.site_id==request.vars.site_id),db.site_servers.server_id)
[web2py] Re: integrate editarea in application
I checked the manual and didn't see anything regarding TEXTAREA. Is there a way to enable the editarea editor on TEXTAREA fields? On Aug 21, 1:41 am, KMax mkostri...@gmail.com wrote: What does mean 'without going through the admin interface' ? Try search TEXTAREA in book?
[web2py] Re: ajax post before ajax reload
This is link to example http://web2py.ru/test Click on 'show me' then on any in link of list and update. Second update will reflect changes in first time On 23 авг, 11:52, KMax mkostri...@gmail.com wrote: ## to db.py added db.define_table('mytable',Field('myfield','string')) ## controllers/default.py def index(): example action using the internationalization operator T and flash rendered by views/default/index.html or views/generic.html onclick = XML( ajax('+str(URL(r=request,f='loadlist.load',args=[]))+', ['test'], 'content');return false; ) linkdiv=DIV(DIV(A('show me',_href='#', _onclick=onclick)),DIV(_id='content')) return dict(linkdiv=linkdiv) def loadlist(): return dict() def list(): result = [] for i in db(db.mytable.id 0).select(): onclick=XML( jQuery('#form+str(i.id) +').slideToggle();return false; ) form=crud.update(db.mytable,i.id,onaccept=crud.archive,deletable=False) result.append(DIV(DIV(A(XML(i.myfield),_href='#',_onclick=onclick)), DIV(form,_id = 'form'+str(i.id),_class = 'hidden'))) return dict(results=result) ## views/default/list.load {{response.headers['Content-Type']='text/ html';response.headers['web2py-response-flash']=response.flash}} table {{for result in results:}}{{ =TR(TD(result))}}{{pass}} /table ## views/default/loadlist.load {{response.headers['Content-Type']='text/ html';response.headers['web2py-response-flash']=response.flash}} {{=LOAD ('default','list.load',args=[],ajax=True)}} - Adding to mytables some strings to see the list of them in example code. Clicking on 'show me' give a list of table rows. Clicking on any of row shows form for string update. But if you submit changes, they does not reflect in list of items (but the same time db table row was updated) Next time submit updates the list of items was made last time. Question: how to make update of db table before updating list of item of the same table? On 23 авг, 08:19, mdipierro mdipie...@cs.depaul.edu wrote: I think I need more explanation, a practical example of usage and an example of code. I do not understand.
[web2py] Re: integrate editarea in application
Perhaps you are looking for widgets in controls, to extend textarea as editor. Check similar example at http://www.web2pyslices.com/main/slices/take_slice/18 On 23 ago, 20:01, Cory Coager ccoa...@gmail.com wrote: I checked the manual and didn't see anything regarding TEXTAREA. Is there a way to enable the editarea editor on TEXTAREA fields? On Aug 21, 1:41 am, KMax mkostri...@gmail.com wrote: What does mean 'without going through the admin interface' ? Try search TEXTAREA in book?
[web2py] Re: How to start server from within a python file ?
It does not hang. It starts the server. The server blocks. If you want to start the server is a new thread: import os, sys, thread, time filepath = r'P:/Web2Py/web2py_src/web2py' sys.path.append ( filepath ) os.chdir ( filepath ) ## == absolutely necessary to get the version number !!! from gluon.main import HttpServer server = HttpServer ( password='xxx' ) #ip,port,admin_password) thread.start_new_thread(server.start,(,)) print 'piep' time.sleep(1) will print piep but will only live for 1. It is up to you to handle concurrency. On Aug 23, 5:07 pm, Stef Mientki stef.mien...@gmail.com wrote: hi Massimo, On 23-08-2010 22:56, mdipierro wrote: No. you either dubmp the gluon folder in site-packages site-packages/gluon then it crashes on not having a version number or better import sys sys.path.append('location/to/web2py/') the program just hangs completely: import os, sys filepath = r'P:/Web2Py/web2py_src/web2py' sys.path.append ( filepath ) os.chdir ( filepath ) ## == absolutely necessary to get the version number !!! from gluon.main import HttpServer server = HttpServer ( password='xxx' ) #ip,port,admin_password) server.start() print 'piep' and never says 'piep' :-( cheers, Stef On Aug 23, 2:16 pm, Stef Mientki stef.mien...@gmail.com wrote: thanks Massimo, but it doesn't work by me ... On 23-08-2010 04:33, mdipierro wrote: from gluon.main import HttpServer here the problem begin, Maybe I should start with a more basic question, what should I do with the sources ? I don't see a setup file, so I just dumped the source files in the python site-packages site-packages\web2py\... is that enough ? thanks, Stef
[web2py] Re: filename length bug in sql.py under win32
This is a complex issue. The length of a filename is limited to 200 chars + extension. There is no way to limit the length of path+filename since the path depends on where web2py is installed and it outside web2py control. Even we were to limit len(filename) to 1 character, this function may still fail if len(path+filename)255. I say this is a major windows bug. Massimo On Aug 23, 5:11 am, Sw1 swel...@gmail.com wrote: Hi, I posted some time ago a problem related to uploading a file with a very long filename under window ( it crashes ). I have been able to spot that the issue is in sql.py around line 2799( function store ). So the pb is related to the python interpreter under win32 that doesn't allow the creation of a file descriptor when the path+filename is longer than 255 ( the ntfs filesystem does allow this but it seems to be related to the way python handle it) I don't really know what to do here but may i suggest to change the naming scheme so that generated filename is shorter ( something containing only a uuid and not the encoded part of the filename). Cheers,
[web2py] Re: Multiple submit not working on component
well... it is a bug not not in web2py, in jQuery: http://www.johnnycode.com/blog/2010/04/08/jquery-form-serialize-doesnt-post-submit-and-button-values-duh/ We cannot fork jQuery to fix this. Eventually they will fix it. Massimo On Aug 23, 8:46 am, Miguel Lopes mig.e.lo...@gmail.com wrote: As an update, the issue remains with the following combinations: * if input type='submit' and different names * if input type='button', with or without different name attributes However, input type='text' are present in form.vars. For the interested a solution for usage in components is to use set a hidden input text field via the click event of each button. Miguel On Mon, Aug 23, 2010 at 3:54 AM, Miguel Lopes mig.e.lo...@gmail.com wrote: I'm using the same name to all input type submits technique. This is very nice because it avoids some js and works like a charm :-) In a regular controller the code works flawlessly. However when I try to put it in a controller, it fails: status_form = FORM(_id='status_form') for status in OPPTY_STATUS: btn = INPUT(_type='submit', _name='status', _value=status, _class='status_btn') status_form.append(btn) if status_form.accepts(request.vars, session, formname='status_form'): # status_form.vars.status is None in component # status_form.vars.status corresponds to whatever submit was pressed in regular controller ... It seems like the component mechanisms is ignoring the value of 'status'. Miguel
[web2py] crud.archive issue with unique
Hello, if I have unique field in mytable. How should crud.archive deal with it? I tried setting it after mytable and mytable_archive declaration, but then it doesn't apply it to mytable... db.mytable.name.unique=True ps.: in http://web2py.com/book/default/chapter/07#Record-Versioning and in docstrings there is said, thtat crud.archive creates mytable_history, but it creates mytable_archive ..
[web2py] Re: crud.archive issue with unique
you cannot set the unique attribute after the table definition. Moreover it would be a problem with archive unless you make the archive table manually with fields that corrspond to the table to be archived but with unique=False. Massimo On Aug 23, 10:14 pm, Jurgis Pralgauskis jurgis.pralgaus...@gmail.com wrote: Hello, if I have unique field in mytable. How should crud.archive deal with it? I tried setting it after mytable and mytable_archive declaration, but then it doesn't apply it to mytable... db.mytable.name.unique=True ps.: inhttp://web2py.com/book/default/chapter/07#Record-Versioning and in docstrings there is said, thtat crud.archive creates mytable_history, but it creates mytable_archive ..
[web2py] Web2py and threads
Hello, I would like to know how Web2py is managing threads. Is it like Java servlets where requests are mapped to servlets while one servlet object can be used by multiple threads at the same time to serve many requests? Are some users here using Jython with Web2py to get around the ugly Pyhton GIL? I would to know about your experience. -- Pierre
[web2py] Re: My editor ...
Is it possible to post a free version of this _as it is_ ? Some of us my find it very useful. Or even, a version without the wysiwyg, if that's the problem.
[web2py] Re: Web2py and threads
In Java a serverlet, as far as I understand, is a class which conforms to some API that allows it to serve one http request. Each instance is executed in its own thread. The Python equivalent of the serverlet API is a WSGI application and web2py is based on WSGI, therefore the parallelization mechanism is equivalent to Java serverlets. In web2py (the same in Django, Pylons, any any WSGI app) each http request is executed in its own thread. Threads are recycled to server non-concurrent requests and reuse database connections (pooling) without need to close and reopen them. The web server can be configured for a min number and a max number of threads. I think the GIL in this context is a false problem. In fact in production you can use Apache and run as many processes as the number of cores that you have. Each process will create as many threads as it needs to server multiple requests. The GIL is a problems only if one process runs multiple threads on multiple cores. It is possible there are some caveats with many cores but I have not really played with apache configurations and benchmarks. I do not think using Jython helps anything. According to these tests: http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/ http://pyevolve.sourceforge.net/wordpress/?p=1189 Jython is 2x-3x slower than cpython. So you may get better scaling with multiple cores but you pay huge perfomance hit. Web2py runs on Jython but there is a known bug in Java regular expressions that Sun marked as won'tfix that can cause runaway problems when parsing complex templates. This is not a web2py specific problem but we have seen effects of the bug in some web2py apps. Massimo On Aug 23, 11:29 pm, pierreth pierre.thibau...@gmail.com wrote: Hello, I would like to know how Web2py is managing threads. Is it like Java servlets where requests are mapped to servlets while one servlet object can be used by multiple threads at the same time to serve many requests? Are some users here using Jython with Web2py to get around the ugly Pyhton GIL? I would to know about your experience. -- Pierre
[web2py] Re: Web2py and threads
P.S. In the end the bottle neck is ALWAYS database access. On Aug 24, 12:20 am, mdipierro mdipie...@cs.depaul.edu wrote: In Java a serverlet, as far as I understand, is a class which conforms to some API that allows it to serve one http request. Each instance is executed in its own thread. The Python equivalent of the serverlet API is a WSGI application and web2py is based on WSGI, therefore the parallelization mechanism is equivalent to Java serverlets. In web2py (the same in Django, Pylons, any any WSGI app) each http request is executed in its own thread. Threads are recycled to server non-concurrent requests and reuse database connections (pooling) without need to close and reopen them. The web server can be configured for a min number and a max number of threads. I think the GIL in this context is a false problem. In fact in production you can use Apache and run as many processes as the number of cores that you have. Each process will create as many threads as it needs to server multiple requests. The GIL is a problems only if one process runs multiple threads on multiple cores. It is possible there are some caveats with many cores but I have not really played with apache configurations and benchmarks. I do not think using Jython helps anything. According to these tests: http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-p... http://pyevolve.sourceforge.net/wordpress/?p=1189 Jython is 2x-3x slower than cpython. So you may get better scaling with multiple cores but you pay huge perfomance hit. Web2py runs on Jython but there is a known bug in Java regular expressions that Sun marked as won'tfix that can cause runaway problems when parsing complex templates. This is not a web2py specific problem but we have seen effects of the bug in some web2py apps. Massimo On Aug 23, 11:29 pm, pierreth pierre.thibau...@gmail.com wrote: Hello, I would like to know how Web2py is managing threads. Is it like Java servlets where requests are mapped to servlets while one servlet object can be used by multiple threads at the same time to serve many requests? Are some users here using Jython with Web2py to get around the ugly Pyhton GIL? I would to know about your experience. -- Pierre