Re: [web2py] How to update web app on server without change the data already in database
On 21 January 2013 04:46, animnook animn...@yahoo.com wrote: I have a web app on server and I use web2py web interface to update the project file. But the users wants to add data in db while I am still working on other part of the app. as right now I just copy and paste everything in controller file local to server. and upload whatever new pages I create. Is there a easy way to update everything and not change the data inside the database?? Uploading a new controller or views will in itself not change anything in the database. It is the use of the controller functions that may do that. Changes to model files (table definitions) will change the database when you upload them into the server. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) --
Re: [web2py] Re: PowerFormWizard 0.1.4 - Bug Fixes and auto_validation (+ a new plugin for grids)
Your powerformwizard is layed out horizontally. For large number of steps i think it would be better vertically like an accordion .Also better for printing Also instead of blocking users from going to next step without filling fields in current step it would be nicer just to block editing next steps fields. Best regards António 2013/1/20 Bruno Rocha rochacbr...@gmail.com Ok, problem fixed Updated here: https://bitbucket.org/rochacbruno/powerformwizard/downloads Live example here: http://www.web2pyslices.com/formwizard -- --
Re: [web2py] Problem: SQLFORM.grid and setting a value for a field when a new dataset is created
On 18 January 2013 15:05, Sverre sverreodeg...@gmail.com wrote: I have a contact table that includes our employees too. To make a difference I have a cclass field to make the difference. When I want to create an employee the user should not have a choice to set the cclass field, but when he is creating a customer or supplier. So I tried in SQLFORM.grid the oncreate callback with this function: def setEmployeeClass(form): form.vars.cclass = 2 But this doesn't work. Has someone a tip? Try using 'default = 2' in your model and writable = False in your form definition. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) --
Re: [web2py] Re: Book in epub format?
On 18 January 2013 17:38, Massimo Di Pierro massimo.dipie...@gmail.comwrote: Can you help us make the epub? On Thursday, 17 January 2013 04:59:59 UTC-6, Johann Spies wrote: Is there any chance to get the book in epub-format? I think it should be possible using markmin - xhtml epub (via calibre)? I can try if I understand the working of the book app. At the moment my understanding of how the book app works is very limited. Is there somewhere documentation on the process? Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) --
[web2py] Re: looking for volunteers to help proof-read book 5th ed.
The attached file contains the changes between the 4th edition and 5th edition (only the new text). The imap adapter has two new features that could be updated in the email section (faster queries by field and override mailbox name mapping). --
[web2py] Re: Exposing validators as JSON?
For me, a 'json:reference attributes' field would basically be like a list: string field but with only one string holding a json object of a variable list of attributes with their value and unit. Then you can do simply: db.define_table(... Field(a_list_of_json_objects, json)) When you get the db record, it is represented as Python object for server-side processing. If you stored a json object, then you get a Python dict For explicit json export do rows/row object.as_json() So the enhancement would: use a select widget ... It seems to me that you could build a custom widget and assign it to the json field. have the ability to assign a grid object for viewing rows where the column names match the fields in the referenced table Also consider using contrib.spreadsheet and the data argument (for editing a db) --
[web2py] scientific reference for migrations
As I am currently writing my phD thesis i wonder if there is a proper reference to the migrations technique used in web2py. I cannot even find a proper Wikipedia article for that (not that this would be a reference I would like to use). the closest I found so far is http://guides.rubyonrails.org/migrations.html anyone anything better? --
Re: [web2py] How to update web app on server without change the data already in database
as Johann already mentioned overwriting all your .py files will not change you database so you should be fine doing that if you do not wan to do this manually you can e.g. use a version control system and exclude the content of the databases directory then on the client side all you have to do is svn up or hg pull; hg update I have worked with that for a couple of years and it works fine, but there are some small issues that you have to take into account. similar should works with sync tools if they work with ignore patterns or create you own update mechanism. this is what i ended up doing since i do not want extra software on the locations where my client apps run. so I created plugin_release for pyMantis https://sourceforge.net/scm/?type=hggroup_id=304012source=navbar which is similar to the web2py packaging mechanism (I copied some code) but it does not include the contents of the databases, sessions, and erros directories. Next to the packaging mechanism it also has mechanisms to download and install (unpack, overwrite) these packages based on version numbers. I have used the plugin in several projects over the last year and found it to be quite stable. On Monday, January 21, 2013 10:24:19 AM UTC+1, Johann Spies wrote: On 21 January 2013 04:46, animnook anim...@yahoo.com javascript:wrote: I have a web app on server and I use web2py web interface to update the project file. But the users wants to add data in db while I am still working on other part of the app. as right now I just copy and paste everything in controller file local to server. and upload whatever new pages I create. Is there a easy way to update everything and not change the data inside the database?? Uploading a new controller or views will in itself not change anything in the database. It is the use of the controller functions that may do that. Changes to model files (table definitions) will change the database when you upload them into the server. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) --
[web2py] looking for volunteers to help proof-read book 5th ed.
Signed, I hope! I just downloaded diff and am looking forward to the task. --
[web2py] How to automatically send emails to users if they perform an action like sign up...
I want to know how to send emails to users automatically based on their actions... specifically things like an email verification (for validation), notifications for updates and similar actions... --
Re: [web2py] How to automatically send emails to users if they perform an action like sign up...
in your models. mail = auth.settings.mailer mail.settings.server = your_smtp_server_and:port mail.settings.sender = y...@you.com mail.settings.login = y...@you.com:password # sends an verification e-mail upon registration auth.settings.registration_requires_verification = True def send_email(user, subject): message = Multi line string for %(first_name)s.. message = open(somefile.html, r).read() # you also have the option to include everyone in bcc=[...] mail.send(to=user.email, subject=subject, message=message % user) Now in any place like controllers or scripts users = db(db.auth_user).select() for user in users: send_email(user, some subject) Dont forget to keep track of sent emails, use try: except... try to not use gmail for more than 500 recipients. If you want an email to be send everytime a user login in your page auth.settings.login_onaccept = lambda form: mail.send(to=form.vars.email, subject=%(first_name)s logged in % form.vars, message=User logged in %s % str(form.vars)) --
[web2py] Scheduler ignoring period/repeat setting.
I have created a *scheduler.py *in /models/ which looks something like this: def my_function(): ### function body ### scheduler = Scheduler(db) scheduler.queue_task( function='my_function', task_name = 'my_function', repeats = 0, # unlimited runs period = 300 # every 5 minutes ) The problem I'm seeing is that multiple tasks are being created in the database for this one function at totally incorrect *next_run_time* with respect to *start_time* and *period*. The multiple tasks created in the db are also not at the correct time interval apart. In addition, changing the repeat value to something other than zero has not effect, tasks continue to be created and executed unrelentingly according to what I see in the database. I am very keen to use the Scheduler, it seems like an elegant solution to what I'm trying to do but with all these tasks sprouting and executing at (what appears to be) random it is basically broken. Apologies if I misunderstood the usage of the scheduler, I was proceeding as close as I could to what I deciphered from the book. Thanks in advance for the help! --
[web2py] is bug? sqlform.factory
when implemented the following code, I notice that the system does not respect the length of the field in the database. if the user enters a name of more than one (1) character the system stores .. wonder: is this a bug? to the following model: auth_user_id = (auth.user and auth.user.id) or None db.define_table('table_x', Field('name', 'string', length=1, requires= IS_UPPER()), Field('auth_user', db.auth_user, default=auth_user_id, writable=False, Readable=False), ) using the controller: def index (): form = SQLFORM.factory( Field('name', 'string', length=3, requires=IS_UPPER()), ) if form.accepts (request.vars): db(db.table_x.auth_user==auth_user_id).update(name=request.vars.name) return dict (form = form) --
Re: [web2py] is bug? sqlform.factory
IS it SQLITE? Sqlite dos not implements ALTER TABLE for column properties, if you created the model with n length and so changed it later, sqlite does not respect this. It is a sqlite problem. *if another database, so can be a dal problem On Mon, Jan 21, 2013 at 11:43 AM, www.diazluis.com diazluis2...@gmail.comwrote: when implemented the following code, I notice that the system does not respect the length of the field in the database. if the user enters a name of more than one (1) character the system stores .. wonder: is this a bug? to the following model: auth_user_id = (auth.user and auth.user.id) or None db.define_table('table_x', Field('name', 'string', length=1, requires= IS_UPPER()), Field('auth_user', db.auth_user, default=auth_user_id, writable=False, Readable=False), ) using the controller: def index (): form = SQLFORM.factory( Field('name', 'string', length=3, requires=IS_UPPER()), ) if form.accepts (request.vars): db(db.table_x.auth_user==auth_user_id).update(name= request.vars.name) return dict (form = form) -- --
[web2py] Re: is bug? sqlform.factory
You can use the IS_LENGTH validator: requires = IS_LENGTH(1, 0) # The max length is the first argument, don't ask why --
Re: [web2py] Re: is bug? sqlform.factory
I think the max is the first because you can ommit the second. IS_LENGTH(10) will allow max 10. No need to inform the second. But I agree this is odd. --
Re: [web2py] Re: is bug? sqlform.factory
But I agree this is odd. My bad, I thought the two args were mandatory (sorry Bruno for re-posting, I sent a reply to author by mistake) --
Re: [web2py] Re: Book in epub format?
I can try if I understand the working of the book app. At the moment my understanding of how the book app works is very limited. When you go to book app/default/chapter/book id/chapter id the app creates .html files stored in book app/static_chaps For more information try sending a Bat-Signal to Niphlod --
Re: [web2py] Re: Custom form delete Crud checkbox
On Wed, Dec 26, 2012 at 5:55 AM, Alan Etkin spame...@gmail.com wrote: form.custom.deletable In this case there is an error in book : {{=form.custom.delete}} At the end of the section custom form : http://web2py.com/books/default/chapter/29/07#Custom-forms Just above CSS Conventions. Richard --
[web2py] book typo
Hello, There is a typo in the book : {{=form.custom.delete}} At the end of the section custom form : http://web2py.com/books/default/chapter/29/07#Custom-forms Just above CSS Conventions. Should be : {{=form.custom.deletable}} Richard --
[web2py] 'list:reference', contains, Mysql, instr
Hello: I was getting incorrect SQL from statements like: db(db.paper.authors.contains(person.id)).select() where db.define_table('paper', Field('title'), Field('authors', 'list:reference person'), ) so I rewrote dal.MySQLAdapter.CONTAINS from: def CONTAINS(self, first, second): if first.type in ('string', 'text'): key = '%'+str(second).replace('%','%%')+'%' elif first.type.startswith('list:'): key = '%|'+str(second).replace('|','||').replace('%','%%')+'|%' return '(%s LIKE %s)' % (self.expand(first),self.expand(key,'string')) into: def CONTAINS(self, first, second): if first.type in ('string', 'text'): key = '%'+str(second).replace('%','%%')+'%' elif first.type.startswith('list:reference'): return 'INSTR(%s, %s)'%(first, str(second)) elif first.type.startswith('list:'): key = '%|'+str(second).replace('|','||').replace('%','%%')+'|%' return '(%s LIKE %s)' % (self.expand(first),self.expand(key,'string')) now the above query works, but that's in MySQL, not SQLite, which apparently does not have a INSTR operation, despite the fact that it is advertised! https://www.sqlite.org/lang_corefunc.html Can anybody think of a solution that works in more databases --
Re: [web2py] Redmine beside web2py with Nginx deployment script
On Tue, Jan 15, 2013 at 10:31 AM, Arnon Marcus a.m.mar...@gmail.com wrote: and postgres, each are owned by a different use, each of which is different from my user - so I don't have permission to edit them... What should I do? sudo YOUR COMMAND Richard --
Re: [web2py] Re: onvalidation form.vars empty
can onvalidation be used with sqlform.factory ? i´m getting error Errors in Form. Please check it out!!! Thank you António 2013/1/17 Massimo Di Pierro massimo.dipie...@gmail.com *You are storing the image twice:* * * *if trabalhador_form.process(onvalidation=attach_image_to_record).accepted: # here after validation * *def attach_image_to_record(form):* ... photo=db.trabalhador.foto.**store(temp,'foto.jpg') # here on validation *... * form.vars.photo=photo *# here is where someting goes wrong* * * *The problem is that you altering the form on validation.* * * * * *This this:* * * ** *def attach_image_to_record(form):* import cgi response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) photo = cgi.FieldStorage() photo.file = open('foto1231.jpg','rb') photo.filename = 'foto.jpg' form.vars.photo=photo # not this on, you let process do upload ** This is very important for me , * * * * On Wednesday, 16 January 2013 07:49:30 UTC-6, Ramos wrote: I just noticed one image created in upload folder and one txt file. Inside the txt file i see the name of jpg file created above. why is that? help please :) António 2013/1/16 António Ramos ramst...@gmail.com can onvalidation set upload file field? i was complaining that form.vars was empty. It is if the controller does not return the form to the view So i return the form and away with my quest. Now, in onvalidation i set the field with the upload file. I have to becaue i have a different upload button that goes online to get a file. Its working but the image file i set goes as a txt file to the database, why here my code: (I use PIL module) *if trabalhador_form.process(onvalidation=attach_image_to_ record).accepted:* *def attach_image_to_record(form):* response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) temp=open('foto1231.jpg','rb') photo=db.trabalhador.foto.**store(temp,'foto.jpg') *print photo # echoes something like trabalhador.foto. 989708787087078.9823492034.jpg* form.vars.photo=photo *# here is where someting goes wrong* This is very important for me , can anyone explain why a jpg is inserted as a txt? how to force jpg ? Thank you António 2013/1/15 António Ramos ramst...@gmail.com I´m testing this book example http://web2py.com/books/**default/chapter/29/07#**onvalidationhttp://web2py.com/books/default/chapter/29/07#onvalidation I get error on field named 'a' Traceback (most recent call last): File C:\web2pyGit\web2py\gluon\**restricted.py, line 212, in restricted exec ccode in environment File C:/web2pyGit/web2py/**applications/teste1/models/db.**py http://127.0.0.1:8000/admin/default/edit/teste1/models/db.py, line 91, in module Field('c', 'integer', readable=False, writable=False)) File C:\web2pyGit\web2py\gluon\**dal.py, line 7189, in define_table table = self.lazy_define_table(tablena**me,*fields,**args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7206, in lazy_define_table table = table_class(self, tablename, *fields, **args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7612, in __init__ db.check_reserved_keyword(fiel**d_name) File C:\web2pyGit\web2py\gluon\**dal.py, line 6933, in check_reserved_keyword 'invalid table/column name %s is a %s reserved SQL keyword' % (name, backend.upper())) SyntaxError: invalid table/column name a is a ALL reserved SQL keyword So i renamed all to a1,b1,c1 and it works ! Now my initial complain is still not working. I will test tomorrow and post some code. Meanwhile please check why a is not a valid field name and update the book if necessary. thank you 2013/1/15 Anthony abas...@gmail.com form.vars should work. Can you show more code? Note, form.request_vars is simply a copy of the original request.post_vars, so not equivalent to form.vars. Anthony On Tuesday, January 15, 2013 10:17:08 AM UTC-5, Ramos wrote: hello reading the book online i tried the code def my_form_processing(form): c = form.vars.a form.vars.b if c 0: form.errors.b = 'a' else: form.vars.c = c but form.vars was empty to access my form vars i changed to form.request_vars *Is the book wrong?* Thank you António -- -- --
Re: [web2py] Re: problems with wiki create
... In the meanwhile I have opened a issue for having the render option at page ... Perhaps it's possible to add a .render record field and have the wiki collect the option from the record on document reads. When calling auth.wiki(render=...) the wiki object should set the .render field default attribute to the value passed (unless the page was retrieved from a query, in which case the record render has precedence). This would require adding a render field to the insert/update page form --
[web2py] Form with fields collected from javascript
Hello!! I have a Form for this table, but I'm only want to get the 'name' field from the user input. the other fields I need fill them from javascript vars... Model: db.define_table('fences', Field('customer', db.customer, label='Cliente', notnull=True), Field('name', length=160, label='Nombre', notnull=True), Field('type', length=12, label='Tipo', notnull=True), Field('definition', length=120, notnull=True), signature ) Controller: def fences(): return(form=SQLFORM(db.fences).process()) View: script var get_type; var definition = []; /script {{=form.custom.begin}} Name: {{=form.custom.widget.name}} {{=form.custom.submit}} {{=form.custom.end}} The customer field I need collect from my function: get_customer_id(auth.user.id) Thanks in advance. Christian. --
[web2py] Re: 'list:reference', contains, Mysql, instr
Before we attempt to fix this. It works for me as it is with sqlite. Why does doesn't it wirk with mysql? MySQL has a LIKE operator. Wat error do you get? I can see why using the INSTR operator on MySQL may be better but do we know it is faster? Massimo On Monday, 21 January 2013 08:55:40 UTC-6, pablo@uam.es wrote: Hello: I was getting incorrect SQL from statements like: db(db.paper.authors.contains(person.id)).select() where db.define_table('paper', Field('title'), Field('authors', 'list:reference person'), ) so I rewrote dal.MySQLAdapter.CONTAINS from: def CONTAINS(self, first, second): if first.type in ('string', 'text'): key = '%'+str(second).replace('%','%%')+'%' elif first.type.startswith('list:'): key = '%|'+str(second).replace('|','||').replace('%','%%')+'|%' return '(%s LIKE %s)' % (self.expand(first),self.expand(key,'string')) into: def CONTAINS(self, first, second): if first.type in ('string', 'text'): key = '%'+str(second).replace('%','%%')+'%' elif first.type.startswith('list:reference'): return 'INSTR(%s, %s)'%(first, str(second)) elif first.type.startswith('list:'): key = '%|'+str(second).replace('|','||').replace('%','%%')+'|%' return '(%s LIKE %s)' % (self.expand(first),self.expand(key,'string')) now the above query works, but that's in MySQL, not SQLite, which apparently does not have a INSTR operation, despite the fact that it is advertised! https://www.sqlite.org/lang_corefunc.html Can anybody think of a solution that works in more databases --
Re: [web2py] Re: Custom form delete Crud checkbox
this was fixed in trunk some time ago: self.custom.delete = self.custom.deletable = '' On Monday, 21 January 2013 09:55:09 UTC-6, Richard wrote: On Wed, Dec 26, 2012 at 5:55 AM, Alan Etkin spam...@gmail.comjavascript: wrote: form.custom.deletable In this case there is an error in book : {{=form.custom.delete}} At the end of the section custom form : http://web2py.com/books/default/chapter/29/07#Custom-forms Just above CSS Conventions. Richard --
Re: [web2py] book typo
Both work with trunk code. On Monday, 21 January 2013 09:56:43 UTC-6, Richard wrote: Hello, There is a typo in the book : {{=form.custom.delete}} At the end of the section custom form : http://web2py.com/books/default/chapter/29/07#Custom-forms Just above CSS Conventions. Should be : {{=form.custom.deletable}} Richard --
Re: [web2py] Re: onvalidation form.vars empty
yes. On Monday, 21 January 2013 11:35:00 UTC-6, Ramos wrote: can onvalidation be used with sqlform.factory ? i´m getting error Errors in Form. Please check it out!!! Thank you António 2013/1/17 Massimo Di Pierro massimo@gmail.com javascript: *You are storing the image twice:* * * *if trabalhador_form.process(onvalidation=attach_image_to_record).accepted: # here after validation * *def attach_image_to_record(form):* ... photo=db.trabalhador.foto.**store(temp,'foto.jpg') # here on validation *... * form.vars.photo=photo *# here is where someting goes wrong* * * *The problem is that you altering the form on validation.* * * * * *This this:* * * ** *def attach_image_to_record(form):* import cgi response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) photo = cgi.FieldStorage() photo.file = open('foto1231.jpg','rb') photo.filename = 'foto.jpg' form.vars.photo=photo # not this on, you let process do upload ** This is very important for me , * * * * On Wednesday, 16 January 2013 07:49:30 UTC-6, Ramos wrote: I just noticed one image created in upload folder and one txt file. Inside the txt file i see the name of jpg file created above. why is that? help please :) António 2013/1/16 António Ramos ramst...@gmail.com can onvalidation set upload file field? i was complaining that form.vars was empty. It is if the controller does not return the form to the view So i return the form and away with my quest. Now, in onvalidation i set the field with the upload file. I have to becaue i have a different upload button that goes online to get a file. Its working but the image file i set goes as a txt file to the database, why here my code: (I use PIL module) *if trabalhador_form.process(onvalidation=attach_image_to_ record).accepted:* *def attach_image_to_record(form):* response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) temp=open('foto1231.jpg','rb') photo=db.trabalhador.foto.**store(temp,'foto.jpg') *print photo # echoes something like trabalhador.foto. 989708787087078.9823492034.jpg* form.vars.photo=photo *# here is where someting goes wrong* This is very important for me , can anyone explain why a jpg is inserted as a txt? how to force jpg ? Thank you António 2013/1/15 António Ramos ramst...@gmail.com I´m testing this book example http://web2py.com/books/**default/chapter/29/07#**onvalidationhttp://web2py.com/books/default/chapter/29/07#onvalidation I get error on field named 'a' Traceback (most recent call last): File C:\web2pyGit\web2py\gluon\**restricted.py, line 212, in restricted exec ccode in environment File C:/web2pyGit/web2py/**applications/teste1/models/db.**py http://127.0.0.1:8000/admin/default/edit/teste1/models/db.py, line 91, in module Field('c', 'integer', readable=False, writable=False)) File C:\web2pyGit\web2py\gluon\**dal.py, line 7189, in define_table table = self.lazy_define_table(tablena**me,*fields,**args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7206, in lazy_define_table table = table_class(self, tablename, *fields, **args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7612, in __init__ db.check_reserved_keyword(fiel**d_name) File C:\web2pyGit\web2py\gluon\**dal.py, line 6933, in check_reserved_keyword 'invalid table/column name %s is a %s reserved SQL keyword' % (name, backend.upper())) SyntaxError: invalid table/column name a is a ALL reserved SQL keyword So i renamed all to a1,b1,c1 and it works ! Now my initial complain is still not working. I will test tomorrow and post some code. Meanwhile please check why a is not a valid field name and update the book if necessary. thank you 2013/1/15 Anthony abas...@gmail.com form.vars should work. Can you show more code? Note, form.request_vars is simply a copy of the original request.post_vars, so not equivalent to form.vars. Anthony On Tuesday, January 15, 2013 10:17:08 AM UTC-5, Ramos wrote: hello reading the book online i tried the code def my_form_processing(form): c = form.vars.a form.vars.b if c 0: form.errors.b = 'a' else: form.vars.c = c but form.vars was empty to access my form vars i changed to form.request_vars *Is the book wrong?* Thank you António -- -- --
Re: [web2py] Re: onvalidation form.vars empty
Sorry for insisting, I ´m using onvalidation in sqlform but if i use it in sqlform.factory i get a flash message Errors in Form. Please check it out!!! *Secondly* as i am using sqlform.factory to add records how to use it also to update or delete? Thank you António 2013/1/21 Massimo Di Pierro massimo.dipie...@gmail.com yes. On Monday, 21 January 2013 11:35:00 UTC-6, Ramos wrote: can onvalidation be used with sqlform.factory ? i´m getting error Errors in Form. Please check it out!!! Thank you António 2013/1/17 Massimo Di Pierro massimo@gmail.com *You are storing the image twice:* * * *if trabalhador_form.process(onvalidation=attach_image_to_record).accepted: # here after validation * *def attach_image_to_record(form):* ... photo=db.trabalhador.foto.**stor**e(temp,'foto.jpg') # here on validation *... * form.vars.photo=photo *# here is where someting goes wrong* * * *The problem is that you altering the form on validation.* * * * * *This this:* * * ** *def attach_image_to_record(form):* import cgi response=requests.get(form.**var**s.fp_url) img=Image.open(StringIO(**respon**se.content)) img.save('foto1231.jpg','JPEG') photo = cgi.FieldStorage() photo.file = open('foto1231.jpg','rb') photo.filename = 'foto.jpg' form.vars.photo=photo # not this on, you let process do upload ** This is very important for me , * * * * On Wednesday, 16 January 2013 07:49:30 UTC-6, Ramos wrote: I just noticed one image created in upload folder and one txt file. Inside the txt file i see the name of jpg file created above. why is that? help please :) António 2013/1/16 António Ramos ramst...@gmail.com can onvalidation set upload file field? i was complaining that form.vars was empty. It is if the controller does not return the form to the view So i return the form and away with my quest. Now, in onvalidation i set the field with the upload file. I have to becaue i have a different upload button that goes online to get a file. Its working but the image file i set goes as a txt file to the database, why here my code: (I use PIL module) *if trabalhador_form.process(onvalidation=attach_image_to_record ).accepted:* *def attach_image_to_record(form):* response=requests.get(form.**var**s.fp_url) img=Image.open(StringIO(**respon**se.content)) img.save('foto1231.jpg','JPEG') temp=open('foto1231.jpg','rb') photo=db.trabalhador.foto.**stor**e(temp,'foto.jpg') *print photo # echoes something like trabalhador.foto. 989708787087078.9823492034.jpg* form.vars.photo=photo *# here is where someting goes wrong* This is very important for me , can anyone explain why a jpg is inserted as a txt? how to force jpg ? Thank you António 2013/1/15 António Ramos ramst...@gmail.com I´m testing this book example http://web2py.com/books/**defaul**t/chapter/29/07#**onvalidationhttp://web2py.com/books/default/chapter/29/07#onvalidation I get error on field named 'a' Traceback (most recent call last): File C:\web2pyGit\web2py\gluon\**res**tricted.py, line 212, in restricted exec ccode in environment File C:/web2pyGit/web2py/**applicati**ons/teste1/models/db.**py http://127.0.0.1:8000/admin/default/edit/teste1/models/db.py, line 91, in module Field('c', 'integer', readable=False, writable=False)) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7189, in define_table table = self.lazy_define_table(tablename,*fields,**args) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7206, in lazy_define_table table = table_class(self, tablename, *fields, **args) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7612, in __init__ db.check_reserved_keyword(field_name) File C:\web2pyGit\web2py\gluon\**dal**.py, line 6933, in check_reserved_keyword 'invalid table/column name %s is a %s reserved SQL keyword' % (name, backend.upper())) SyntaxError: invalid table/column name a is a ALL reserved SQL keyword So i renamed all to a1,b1,c1 and it works ! Now my initial complain is still not working. I will test tomorrow and post some code. Meanwhile please check why a is not a valid field name and update the book if necessary. thank you 2013/1/15 Anthony abas...@gmail.com form.vars should work. Can you show more code? Note, form.request_vars is simply a copy of the original request.post_vars, so not equivalent to form.vars. Anthony On Tuesday, January 15, 2013 10:17:08 AM UTC-5, Ramos wrote: hello reading the book online i tried the code def my_form_processing(form): c = form.vars.a form.vars.b if c 0: form.errors.b = 'a' else: form.vars.c = c but form.vars was empty to access my form vars i changed to form.request_vars *Is the book wrong?* Thank you
Re: [web2py] Form with fields collected from javascript
include hidden fields hidden id=customer name=customer the use Javascript to populate $('#customer').val(something) --
[web2py] Re-enable admin interface
Hello, Trying to upload my web2py project to the server I failed to enter the admin password (4 times :-S) so the admin interface was automatically disabled. Since I have no access to my server and I have to request all things to the server administrators I asked them to re-enable the admin interface. But they have answer me that they don't know how to do it, so...what should they do to re-enable the admin interface? The server is a typical Apache. Kind regards and thank you very much! --
Re: [web2py] Re: problems with wiki create
Hi Alan, good catch, I don't know how wiki works but if it is only to add a field to the table and handle it during insert/update it is worth to do that. isn't it? When a user is editing a page he/she can choose from a dropdow list the render engine to use. Paolo 2013/1/21 Alan Etkin spame...@gmail.com ... In the meanwhile I have opened a issue for having the render option at page ... Perhaps it's possible to add a .render record field and have the wiki collect the option from the record on document reads. When calling auth.wiki(render=...) the wiki object should set the .render field default attribute to the value passed (unless the page was retrieved from a query, in which case the record render has precedence). This would require adding a render field to the insert/update page form -- -- Paolo --
[web2py] How to redirect within a method that was invoked via Ajax?! Problem with wrong method being called.
Hi everyone, Could someone please help me with a problem I'm having with the *amazing*web2py framework? This is hard to explain, so please bear with me, I'm still new to web development :) I seem to have a problem with using redirect in a function that is called via ajax. I thought I could use web2py_component method to call a method that returns a form (using SQLFORM or CRUD) and when the form is processed OK I could redirect to another method and have the content of that method returned instead. Everything is OK if I just add records, or edit records or delete records BUT when I edit or delete a record and then try to add a record something odd happens. Basically, when I delete a record I redirect back to the index page (to reload the grid). The grid is rendered OK BUT when a add a new record (using the form included in the index page) the WRONG METHOD is called. I can see from the debug that the delete method is called. I presume its all to do with me doing a redirect from within a .load file that has been rendered via web2py_component. I have page that I load a tabbed display into using ajax (web2py_component). The tabs are labelled Contacts, Documents, Widgets etc. When I click on the Contacts tab I use ajax to call contacts/index and display the what is returned into the tab-content div. Everything is OK at this point. @auth.requires_login() def index(): company_id = request.args[0] crud.settings.hideerror=True db.contact.company.default = company_id grid = create_grid(db.contact.company == company_id, company_id) form = crud.create(db.contact, next=URL('contacts', 'index', args=company_id, user_signature=True)) submit_btn = form.element(_type='submit') submit_btn['_class']='btn btn-small btn-success' submit_btn['_value']='Save' return locals() The create_grid function returns a grid and the links are like this: links = [ lambda row: A('', _onclick=web2py_component(' + URL(contacts, edit, args=[row.id, company_id], user_signature=True) + ', 'tabContent');, _class='icon-pencil'), lambda row: A('', _onclick=web2py_component(' + URL(contacts, delete, args=[row.id, company_id], user_signature=True) + ', 'tabContent');, _class='icon-trash') ] If a click on a Delete link within the grid, this is what is called: @auth.requires_login() def delete(): contact_id = request.args[0] company_id = request.args[1] crud.settings.hideerror=True contact = db.contact[contact_id] or redirect(error_page) crud.delete(db.contact, contact.id, next=URL('contacts', 'index', args=company_id, user_signature=True)) The record is deleted OK and the index method is called OK and the grid is re-appears. When I try to add a new record then the delete method is called AGAIN rather than the index method. There is no problem adding records if I don't do a delete first! I don't understand what where I'm going wrong :( I suspect its to with using web2py_component method within a partial (.load) file that was also loaded via ajax and then trying to do a redirect from a method that was invoked via ajax. Kind Regards, Chris --
Re: [web2py] Re: onvalidation form.vars empty
Here is my test. $ python web2py.py -S welcome (InteractiveConsole) import sys form = SQLFORM.factory(Field('name')) form.process(onvalidation=lambda form:sys.stdout.write('check!\n'),formname=None,session=None) check! It works. Something else is wrong in your code. If you could post a complete example we can try help you debug it. Massimo On Monday, 21 January 2013 12:03:11 UTC-6, Ramos wrote: Sorry for insisting, I ´m using onvalidation in sqlform but if i use it in sqlform.factory i get a flash message Errors in Form. Please check it out!!! *Secondly* as i am using sqlform.factory to add records how to use it also to update or delete? Thank you António 2013/1/21 Massimo Di Pierro massimo@gmail.com javascript: yes. On Monday, 21 January 2013 11:35:00 UTC-6, Ramos wrote: can onvalidation be used with sqlform.factory ? i´m getting error Errors in Form. Please check it out!!! Thank you António 2013/1/17 Massimo Di Pierro massimo@gmail.com *You are storing the image twice:* * * *if trabalhador_form.process(onvalidation=attach_image_to_record).accepted: # here after validation * *def attach_image_to_record(form):* ... photo=db.trabalhador.foto.**stor**e(temp,'foto.jpg') # here on validation *... * form.vars.photo=photo *# here is where someting goes wrong* * * *The problem is that you altering the form on validation.* * * * * *This this:* * * ** *def attach_image_to_record(form):* import cgi response=requests.get(form.**var**s.fp_url) img=Image.open(StringIO(**respon**se.content)) img.save('foto1231.jpg','JPEG') photo = cgi.FieldStorage() photo.file = open('foto1231.jpg','rb') photo.filename = 'foto.jpg' form.vars.photo=photo # not this on, you let process do upload ** This is very important for me , * * * * On Wednesday, 16 January 2013 07:49:30 UTC-6, Ramos wrote: I just noticed one image created in upload folder and one txt file. Inside the txt file i see the name of jpg file created above. why is that? help please :) António 2013/1/16 António Ramos ramst...@gmail.com can onvalidation set upload file field? i was complaining that form.vars was empty. It is if the controller does not return the form to the view So i return the form and away with my quest. Now, in onvalidation i set the field with the upload file. I have to becaue i have a different upload button that goes online to get a file. Its working but the image file i set goes as a txt file to the database, why here my code: (I use PIL module) *if trabalhador_form.process(onvalidation=attach_image_to_record ).accepted:* *def attach_image_to_record(form):* response=requests.get(form.**var**s.fp_url) img=Image.open(StringIO(**respon**se.content)) img.save('foto1231.jpg','JPEG') temp=open('foto1231.jpg','rb') photo=db.trabalhador.foto.**stor**e(temp,'foto.jpg') *print photo # echoes something like trabalhador.foto. 989708787087078.9823492034.jpg* form.vars.photo=photo *# here is where someting goes wrong* This is very important for me , can anyone explain why a jpg is inserted as a txt? how to force jpg ? Thank you António 2013/1/15 António Ramos ramst...@gmail.com I´m testing this book example http://web2py.com/books/**defaul**t/chapter/29/07#**onvalidationhttp://web2py.com/books/default/chapter/29/07#onvalidation I get error on field named 'a' Traceback (most recent call last): File C:\web2pyGit\web2py\gluon\**res**tricted.py, line 212, in restricted exec ccode in environment File C:/web2pyGit/web2py/**applicati**ons/teste1/models/db.**py http://127.0.0.1:8000/admin/default/edit/teste1/models/db.py, line 91, in module Field('c', 'integer', readable=False, writable=False)) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7189, in define_table table = self.lazy_define_table(tablename,*fields,**args) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7206, in lazy_define_table table = table_class(self, tablename, *fields, **args) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7612, in __init__ db.check_reserved_keyword(field_name) File C:\web2pyGit\web2py\gluon\**dal**.py, line 6933, in check_reserved_keyword 'invalid table/column name %s is a %s reserved SQL keyword' % (name, backend.upper())) SyntaxError: invalid table/column name a is a ALL reserved SQL keyword So i renamed all to a1,b1,c1 and it works ! Now my initial complain is still not working. I will test tomorrow and post some code. Meanwhile please check why a is not a valid field name and update the book if necessary. thank you 2013/1/15 Anthony abas...@gmail.com form.vars should work. Can you show more code? Note, form.request_vars is simply a copy of
Re: [web2py] book typo
Ok, nevermind then... I was with 2.3.2. Richard On Mon, Jan 21, 2013 at 12:57 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Both work with trunk code. On Monday, 21 January 2013 09:56:43 UTC-6, Richard wrote: Hello, There is a typo in the book : {{=form.custom.delete}} At the end of the section custom form : http://web2py.com/books/** default/chapter/29/07#Custom-**formshttp://web2py.com/books/default/chapter/29/07#Custom-forms Just above CSS Conventions. Should be : {{=form.custom.deletable}} Richard -- --
[web2py] Re: How to redirect within a method that was invoked via Ajax?! Problem with wrong method being called.
Assuming your ajax callback function is correctly called you just need to do: redirect(location, client_side=True) instead of redirect(location) With client_side = True you are handling the redirect client-side and not server side. This is designed to work over ajax requests. On Monday, 21 January 2013 12:58:03 UTC-6, c0nstin3 wrote: Hi everyone, Could someone please help me with a problem I'm having with the *amazing*web2py framework? This is hard to explain, so please bear with me, I'm still new to web development :) I seem to have a problem with using redirect in a function that is called via ajax. I thought I could use web2py_component method to call a method that returns a form (using SQLFORM or CRUD) and when the form is processed OK I could redirect to another method and have the content of that method returned instead. Everything is OK if I just add records, or edit records or delete records BUT when I edit or delete a record and then try to add a record something odd happens. Basically, when I delete a record I redirect back to the index page (to reload the grid). The grid is rendered OK BUT when a add a new record (using the form included in the index page) the WRONG METHOD is called. I can see from the debug that the delete method is called. I presume its all to do with me doing a redirect from within a .load file that has been rendered via web2py_component. I have page that I load a tabbed display into using ajax (web2py_component). The tabs are labelled Contacts, Documents, Widgets etc. When I click on the Contacts tab I use ajax to call contacts/index and display the what is returned into the tab-content div. Everything is OK at this point. @auth.requires_login() def index(): company_id = request.args[0] crud.settings.hideerror=True db.contact.company.default = company_id grid = create_grid(db.contact.company == company_id, company_id) form = crud.create(db.contact, next=URL('contacts', 'index', args=company_id, user_signature=True)) submit_btn = form.element(_type='submit') submit_btn['_class']='btn btn-small btn-success' submit_btn['_value']='Save' return locals() The create_grid function returns a grid and the links are like this: links = [ lambda row: A('', _onclick=web2py_component(' + URL(contacts, edit, args=[row.id, company_id], user_signature=True) + ', 'tabContent');, _class='icon-pencil'), lambda row: A('', _onclick=web2py_component(' + URL(contacts, delete, args=[row.id, company_id], user_signature=True) + ', 'tabContent');, _class='icon-trash') ] If a click on a Delete link within the grid, this is what is called: @auth.requires_login() def delete(): contact_id = request.args[0] company_id = request.args[1] crud.settings.hideerror=True contact = db.contact[contact_id] or redirect(error_page) crud.delete(db.contact, contact.id, next=URL('contacts', 'index', args=company_id, user_signature=True)) The record is deleted OK and the index method is called OK and the grid is re-appears. When I try to add a new record then the delete method is called AGAIN rather than the index method. There is no problem adding records if I don't do a delete first! I don't understand what where I'm going wrong :( I suspect its to with using web2py_component method within a partial (.load) file that was also loaded via ajax and then trying to do a redirect from a method that was invoked via ajax. Kind Regards, Chris --
Re: [web2py] Form with fields collected from javascript
Hi Bruno I have on this way the code now at the view: {{=form.custom.begin}} Name: {{=form.custom.widget.name}} input type='hidden' id=type name=type input type='hidden' id=definition name=definition input type='hidden' id=customer name=customer {{=form.custom.submit}} {{=form.custom.end}} and I getting the values for every input ok, but SQLForm doesn't store nothing at the db... Thanks Christian. El lunes, 21 de enero de 2013 15:03:55 UTC-3, rochacbruno escribió: include hidden fields hidden id=customer name=customer the use Javascript to populate $('#customer').val(something) --
Re: [web2py] Form with fields collected from javascript
SQLFORM expects a field named fences_customer the pattern is tablename_fieldname --
Re: [web2py] Form with fields collected from javascript
Weird, because I'm noted that the first save process doesn't work, but from the second all work fine :-/ and I'm have the same code without changes... I'm have the trunk version.. El lunes, 21 de enero de 2013 17:12:38 UTC-3, rochacbruno escribió: SQLFORM expects a field named fences_customer the pattern is tablename_fieldname --
Re: [web2py] Re: Book in epub format?
rotfl. always available, but I don't know a single thing about the epub format. did anyone tried just converting the pdf to epub using calibre ? On Monday, January 21, 2013 4:11:14 PM UTC+1, Alan Etkin wrote: I can try if I understand the working of the book app. At the moment my understanding of how the book app works is very limited. When you go to book app/default/chapter/book id/chapter id the app creates .html files stored in book app/static_chaps For more information try sending a Bat-Signal to Niphlod --
[web2py] Re: Exposing validators as JSON?
Nice! Looking for loads_json in serializers.py; Found custom_json instead that takes an object, checks it for a custom attribute and a callable. then returns the objects custom_json() method...[I call it a method but in Python I guess it's an attribute?]...Basically, before calling json() I need to decide if I want to override the .default() call or subclass JSONEncoder and set session.vars._default_encoder to my subclass. I'll give the spreadsheet a try as well. So I can avoid the gluon xml code being displayed. Thank you.. Reading the docs and taking notes left them here for searchable reference: custom_json is a parameter to json() that calls json_parser.dumps...where json_parser is either json or simplejson imported custom_json gets assigned to the defualt parameter in dumps dumps is found in __init__.py (nice documnetation) and returns the JSONEncoder that calls dumps() notes say;``default(obj)`` is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError. So dumps takes several arguments that are not available if you use the On Monday, January 21, 2013 5:20:33 AM UTC-6, Alan Etkin wrote: For me, a 'json:reference attributes' field would basically be like a list: string field but with only one string holding a json object of a variable list of attributes with their value and unit. Then you can do simply: db.define_table(... Field(a_list_of_json_objects, json)) When you get the db record, it is represented as Python object for server-side processing. If you stored a json object, then you get a Python dict For explicit json export do Rows/Row object.as_json() So the enhancement would: use a select widget ... It seems to me that you could build a custom widget and assign it to the json field. have the ability to assign a grid object for viewing rows where the column names match the fields in the referenced table Also consider using contrib.spreadsheet and the data argument (for editing a db) BTW, if you need to do custom deserialize/serialize of json, you can do: from serializers import loads_json, json --
[web2py] Re: Scheduler ignoring period/repeat setting.
scheduler support coming . I think you didn't understand how models works / the scheduler works. Sorry for probably being redundant/naive, but just to check. in models belong: def myfunction(): whatever from gluon.scheduler import Scheduler myscheduler = Scheduler(db) This line basically give you access to the scheduler api and the underlying tables. Now, the following line myscheduler.queue_task( function='my_function', task_name = 'my_function', repeats = 0, # unlimited runs period = 300 # every 5 minutes) that can be shortened as well as myscheduler.queue_task( my_function, repeats = 0, # unlimited runs period = 300 # every 5 minutes) does an actual insert on the scheduler_task table. That should be used whenever you need to queue a NEW task. For repeating task, executing that line *one time only* it's all it's needed. So, if that's your only function, you can either use that line in a controller, or just use the appadmin inserting a *single* row on the scheduler_task table. Repeating functions will be repeated with just ONE row in the scheduler task (where the repeats column != 1) and they'll honour period. status, next_run_time, last_run_time, times_run, times_failed will be updated accordingly to executions on that *single* row. NB: If the function returns something (and doesn't raise an exception), every execution will create a row in the *scheduler_run* table. I think that you have myscheduler.queue_task() in your models, and basically myfunction gets queued every time over and over (because models are executed at every request). That's why you have multiple records in the scheduler_task table and observing strange behaviours. Please let me know if this explanation made sense and if not, feel free to ask for further details. On Monday, January 21, 2013 2:31:48 PM UTC+1, Stormcrow wrote: I have created a *scheduler.py *in /models/ which looks something like this: def my_function(): ### function body ### scheduler = Scheduler(db) scheduler.queue_task( function='my_function', task_name = 'my_function', repeats = 0, # unlimited runs period = 300 # every 5 minutes ) The problem I'm seeing is that multiple tasks are being created in the database for this one function at totally incorrect *next_run_time* with respect to *start_time* and *period*. The multiple tasks created in the db are also not at the correct time interval apart. In addition, changing the repeat value to something other than zero has not effect, tasks continue to be created and executed unrelentingly according to what I see in the database. I am very keen to use the Scheduler, it seems like an elegant solution to what I'm trying to do but with all these tasks sprouting and executing at (what appears to be) random it is basically broken. Apologies if I misunderstood the usage of the scheduler, I was proceeding as close as I could to what I deciphered from the book. Thanks in advance for the help! --
Re: [web2py] Re: onvalidation form.vars empty
Thank you Massimo, you are always available to help. Where is Bill Gates when we need it right? I restarted web2py and it works Strange Second question. as i am using sqlform.factory to add records how to use it also to update or delete? Thank YOU again! António 2013/1/21 Massimo Di Pierro massimo.dipie...@gmail.com Here is my test. $ python web2py.py -S welcome (InteractiveConsole) import sys form = SQLFORM.factory(Field('name')) form.process(onvalidation=lambda form:sys.stdout.write('check!\n'),formname=None,session=None) check! It works. Something else is wrong in your code. If you could post a complete example we can try help you debug it. Massimo On Monday, 21 January 2013 12:03:11 UTC-6, Ramos wrote: Sorry for insisting, I ´m using onvalidation in sqlform but if i use it in sqlform.factory i get a flash message Errors in Form. Please check it out!!! *Secondly* as i am using sqlform.factory to add records how to use it also to update or delete? Thank you António 2013/1/21 Massimo Di Pierro massimo@gmail.com yes. On Monday, 21 January 2013 11:35:00 UTC-6, Ramos wrote: can onvalidation be used with sqlform.factory ? i´m getting error Errors in Form. Please check it out!!! Thank you António 2013/1/17 Massimo Di Pierro massimo@gmail.com *You are storing the image twice:* * * *if trabalhador_form.process(onvalidation=attach_image_to_record).accepted: # here after validation * *def attach_image_to_record(form):* ... photo=db.trabalhador.foto.**store(temp,'foto.jpg') # here on validation *... * form.vars.photo=photo *# here is where someting goes wrong* * * *The problem is that you altering the form on validation.* * * * * *This this:* * * ** *def attach_image_to_record(form):* import cgi response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) photo = cgi.FieldStorage() photo.file = open('foto1231.jpg','rb') photo.filename = 'foto.jpg' form.vars.photo=photo # not this on, you let process do upload ** This is very important for me , * * * * On Wednesday, 16 January 2013 07:49:30 UTC-6, Ramos wrote: I just noticed one image created in upload folder and one txt file. Inside the txt file i see the name of jpg file created above. why is that? help please :) António 2013/1/16 António Ramos ramst...@gmail.com can onvalidation set upload file field? i was complaining that form.vars was empty. It is if the controller does not return the form to the view So i return the form and away with my quest. Now, in onvalidation i set the field with the upload file. I have to becaue i have a different upload button that goes online to get a file. Its working but the image file i set goes as a txt file to the database, why here my code: (I use PIL module) *if trabalhador_form.process(onvalidation=attach_image_to_record ).accepted:* *def attach_image_to_record(form):* response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) temp=open('foto1231.jpg','rb') photo=db.trabalhador.foto.**store(temp,'foto.jpg') *print photo # echoes something like trabalhador.foto. 989708787087078.9823492034.jpg* form.vars.photo=photo *# here is where someting goes wrong * This is very important for me , can anyone explain why a jpg is inserted as a txt? how to force jpg ? Thank you António 2013/1/15 António Ramos ramst...@gmail.com I´m testing this book example http://web2py.com/books/**default/chapter/29/07#**onvalidationhttp://web2py.com/books/default/chapter/29/07#onvalidation I get error on field named 'a' Traceback (most recent call last): File C:\web2pyGit\web2py\gluon\**restricted.py, line 212, in restricted exec ccode in environment File C:/web2pyGit/web2py/**applications/teste1/models/db.**py http://127.0.0.1:8000/admin/default/edit/teste1/models/db.py, line 91, in module Field('c', 'integer', readable=False, writable=False)) File C:\web2pyGit\web2py\gluon\**dal.py, line 7189, in define_table table = self.lazy_define_table(tablena**me,*fields,**args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7206, in lazy_define_table table = table_class(self, tablename, *fields, **args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7612, in __init__ db.check_reserved_keyword(fiel**d_name) File C:\web2pyGit\web2py\gluon\**dal.py, line 6933, in check_reserved_keyword 'invalid table/column name %s is a %s reserved SQL keyword' % (name, backend.upper())) SyntaxError: invalid table/column name a is a ALL reserved SQL keyword
[web2py] Re: Re-enable admin interface
admin works on sessions like any other app. I think your problem will be easily fixed by just deleting the applications/admin/sessions/* files. On Monday, January 21, 2013 7:18:01 PM UTC+1, Wonton wrote: Hello, Trying to upload my web2py project to the server I failed to enter the admin password (4 times :-S) so the admin interface was automatically disabled. Since I have no access to my server and I have to request all things to the server administrators I asked them to re-enable the admin interface. But they have answer me that they don't know how to do it, so...what should they do to re-enable the admin interface? The server is a typical Apache. Kind regards and thank you very much! --
Re: [web2py] Redmine beside web2py with Nginx deployment script
I just publish the script last version of the script on Bitbucket : https://bitbucket.org/richardv/setup-ubuntu-redmine-unicorn-web2py-uwsgi-nginx/src/4383ed417c128f7d4e46a42c708fe9ff78bec169/setup-ubuntu-redmine-unicorn-web2py-uwsgi-nginx.sh?at=default I plan to publish it on GitHub too in the coming days as soon as I install and test the HG Git Plugin for Mercurial. :) Richard On Mon, Jan 21, 2013 at 12:14 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: On Tue, Jan 15, 2013 at 10:31 AM, Arnon Marcus a.m.mar...@gmail.comwrote: and postgres, each are owned by a different use, each of which is different from my user - so I don't have permission to edit them... What should I do? sudo YOUR COMMAND Richard --
[web2py] Re: 'list:reference', contains, Mysql, instr
Now I understand the problem. You want to pass an expression where a value is expected. I do not believe we can support this. INSTR does not solve the problem because it would not be correct to looks for substrings. In fact paper.authors may contain '|12|13|' and it would incorrectly return that author '2' is one of authors because it is a substring. You have to do it in two steps: person = db(db.person.name='').select().first() papers = db.paper.authors.contains(person.id).select() Massimo On Jan 21, 2013, at 3:33 PM, pablo.ang...@uam.es wrote: El lunes, 21 de enero de 2013 18:56:07 UTC+1, Massimo Di Pierro escribió: Before we attempt to fix this. It works for me as it is with sqlite. Why does doesn't it wirk with mysql? MySQL has a LIKE operator. Wat error do you get? execution of: db(db.paper.authors.contains(person.id))._select() gives: SELECT person.id, paper.id, paper.title, paper.authors FROM person, paper WHERE (paper.authors LIKE '%|person.id|%'); which I think tries to find those papers whose authors field contains the literal person.id, instead of the pairs (paper,person) such that the person is one of the authors of the paper. With the modification I wrote before, it gets converted into: 'SELECT person.id, paper.id, paper.title, paper.authors FROM person, paper WHERE INSTR(paper.authors, person.id);' with a different meaning. I can see why using the INSTR operator on MySQL may be better but do we know it is faster? I haven't made any speed test, I'd go for anything that works in sqlite and mysql/mariadb. Thanks for your attention! Massimo On Monday, 21 January 2013 08:55:40 UTC-6, pablo@uam.es wrote: Hello: I was getting incorrect SQL from statements like: db(db.paper.authors.contains(person.id)).select() where db.define_table('paper', Field('title'), Field('authors', 'list:reference person'), ) so I rewrote dal.MySQLAdapter.CONTAINS from: def CONTAINS(self, first, second): if first.type in ('string', 'text'): key = '%'+str(second).replace('%','%%')+'%' elif first.type.startswith('list:'): key = '%|'+str(second).replace('|','||').replace('%','%%')+'|%' return '(%s LIKE %s)' % (self.expand(first),self.expand(key,'string')) into: def CONTAINS(self, first, second): if first.type in ('string', 'text'): key = '%'+str(second).replace('%','%%')+'%' elif first.type.startswith('list:reference'): return 'INSTR(%s, %s)'%(first, str(second)) elif first.type.startswith('list:'): key = '%|'+str(second).replace('|','||').replace('%','%%')+'|%' return '(%s LIKE %s)' % (self.expand(first),self.expand(key,'string')) now the above query works, but that's in MySQL, not SQLite, which apparently does not have a INSTR operation, despite the fact that it is advertised! https://www.sqlite.org/lang_corefunc.html Can anybody think of a solution that works in more databases --
Re: [web2py] Re: onvalidation form.vars empty
If you want want to interact with a database table why use SQLFORM.factory and not simply SQLFORM? On Monday, 21 January 2013 15:25:07 UTC-6, Ramos wrote: Thank you Massimo, you are always available to help. Where is Bill Gates when we need it right? I restarted web2py and it works Strange Second question. as i am using sqlform.factory to add records how to use it also to update or delete? Thank YOU again! António 2013/1/21 Massimo Di Pierro massimo@gmail.com javascript: Here is my test. $ python web2py.py -S welcome (InteractiveConsole) import sys form = SQLFORM.factory(Field('name')) form.process(onvalidation=lambda form:sys.stdout.write('check!\n'),formname=None,session=None) check! It works. Something else is wrong in your code. If you could post a complete example we can try help you debug it. Massimo On Monday, 21 January 2013 12:03:11 UTC-6, Ramos wrote: Sorry for insisting, I ´m using onvalidation in sqlform but if i use it in sqlform.factory i get a flash message Errors in Form. Please check it out!!! *Secondly* as i am using sqlform.factory to add records how to use it also to update or delete? Thank you António 2013/1/21 Massimo Di Pierro massimo@gmail.com yes. On Monday, 21 January 2013 11:35:00 UTC-6, Ramos wrote: can onvalidation be used with sqlform.factory ? i´m getting error Errors in Form. Please check it out!!! Thank you António 2013/1/17 Massimo Di Pierro massimo@gmail.com *You are storing the image twice:* * * *if trabalhador_form.process(onvalidation=attach_image_to_record).accepted: # here after validation * *def attach_image_to_record(form):* ... photo=db.trabalhador.foto.**store(temp,'foto.jpg') # here on validation *... * form.vars.photo=photo *# here is where someting goes wrong* * * *The problem is that you altering the form on validation.* * * * * *This this:* * * ** *def attach_image_to_record(form):* import cgi response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) photo = cgi.FieldStorage() photo.file = open('foto1231.jpg','rb') photo.filename = 'foto.jpg' form.vars.photo=photo # not this on, you let process do upload ** This is very important for me , * * * * On Wednesday, 16 January 2013 07:49:30 UTC-6, Ramos wrote: I just noticed one image created in upload folder and one txt file. Inside the txt file i see the name of jpg file created above. why is that? help please :) António 2013/1/16 António Ramos ramst...@gmail.com can onvalidation set upload file field? i was complaining that form.vars was empty. It is if the controller does not return the form to the view So i return the form and away with my quest. Now, in onvalidation i set the field with the upload file. I have to becaue i have a different upload button that goes online to get a file. Its working but the image file i set goes as a txt file to the database, why here my code: (I use PIL module) *if trabalhador_form.process(onvalidation=attach_image_to_record ).accepted:* *def attach_image_to_record(form):* response=requests.get(form.**vars.fp_url) img=Image.open(StringIO(**response.content)) img.save('foto1231.jpg','JPEG'**) temp=open('foto1231.jpg','rb') photo=db.trabalhador.foto.**store(temp,'foto.jpg') *print photo # echoes something like trabalhador.foto. 989708787087078.9823492034.jpg* form.vars.photo=photo *# here is where someting goes wrong* This is very important for me , can anyone explain why a jpg is inserted as a txt? how to force jpg ? Thank you António 2013/1/15 António Ramos ramst...@gmail.com I´m testing this book example http://web2py.com/books/**default/chapter/29/07#**onvalidationhttp://web2py.com/books/default/chapter/29/07#onvalidation I get error on field named 'a' Traceback (most recent call last): File C:\web2pyGit\web2py\gluon\**restricted.py, line 212, in restricted exec ccode in environment File C:/web2pyGit/web2py/**applications/teste1/models/db.**py http://127.0.0.1:8000/admin/default/edit/teste1/models/db.py, line 91, in module Field('c', 'integer', readable=False, writable=False)) File C:\web2pyGit\web2py\gluon\**dal.py, line 7189, in define_table table = self.lazy_define_table(tablena**me,*fields,**args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7206, in lazy_define_table table = table_class(self, tablename, *fields, **args) File C:\web2pyGit\web2py\gluon\**dal.py, line 7612, in __init__ db.check_reserved_keyword(fiel**d_name) File C:\web2pyGit\web2py\gluon\**dal.py, line 6933, in
Re: [web2py] Redmine beside web2py with Nginx deployment script
I actually ended up choosing CentOS over Ubuntu, as I'm going for a multi-VM array over Windows 2008R2 Hyper-V, and it has better support for CentOS/RHEL then for Ubuntu (something relating to virtualization acceleration...) Will the already-existing script for CentOS work for 6.3 86_64 ? How difficult would it be to mix up your script with that one, to make a CentOS-6.3+NginX+uwsgi+Redmine+Web2py configuration? On Mon, Jan 21, 2013 at 1:29 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: I just publish the script last version of the script on Bitbucket : https://bitbucket.org/richardv/setup-ubuntu-redmine-unicorn-web2py-uwsgi-nginx/src/4383ed417c128f7d4e46a42c708fe9ff78bec169/setup-ubuntu-redmine-unicorn-web2py-uwsgi-nginx.sh?at=default I plan to publish it on GitHub too in the coming days as soon as I install and test the HG Git Plugin for Mercurial. :) Richard On Mon, Jan 21, 2013 at 12:14 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: On Tue, Jan 15, 2013 at 10:31 AM, Arnon Marcus a.m.mar...@gmail.comwrote: and postgres, each are owned by a different use, each of which is different from my user - so I don't have permission to edit them... What should I do? sudo YOUR COMMAND Richard -- --
Re: [web2py] Re: onvalidation form.vars empty
I need a multi file uploader. Web2py does not have it yet. I saw an example using another table for the files. I dont know how to sqlform 2 tables. The book showed me how to do it with sqlform.factory Thank you António 2013/1/21 Massimo Di Pierro massimo.dipie...@gmail.com If you want want to interact with a database table why use SQLFORM.factory and not simply SQLFORM? On Monday, 21 January 2013 15:25:07 UTC-6, Ramos wrote: Thank you Massimo, you are always available to help. Where is Bill Gates when we need it right? I restarted web2py and it works Strange Second question. as i am using sqlform.factory to add records how to use it also to update or delete? Thank YOU again! António 2013/1/21 Massimo Di Pierro massimo@gmail.com Here is my test. $ python web2py.py -S welcome (InteractiveConsole) import sys form = SQLFORM.factory(Field('name')) form.process(onvalidation=**lambda form:sys.stdout.write('check!\** n'),formname=None,session=**None) check! It works. Something else is wrong in your code. If you could post a complete example we can try help you debug it. Massimo On Monday, 21 January 2013 12:03:11 UTC-6, Ramos wrote: Sorry for insisting, I ´m using onvalidation in sqlform but if i use it in sqlform.factory i get a flash message Errors in Form. Please check it out!!! *Secondly* as i am using sqlform.factory to add records how to use it also to update or delete? Thank you António 2013/1/21 Massimo Di Pierro massimo@gmail.com yes. On Monday, 21 January 2013 11:35:00 UTC-6, Ramos wrote: can onvalidation be used with sqlform.factory ? i´m getting error Errors in Form. Please check it out!!! Thank you António 2013/1/17 Massimo Di Pierro massimo@gmail.com *You are storing the image twice:* * * *if trabalhador_form.process(onvalidation=attach_image_to_record).accepted: # here after validation * *def attach_image_to_record(form):* ... photo=db.trabalhador.foto.**stor**e(temp,'foto.jpg') # here on validation *... * form.vars.photo=photo *# here is where someting goes wrong* * * *The problem is that you altering the form on validation.* * * * * *This this:* * * ** *def attach_image_to_record(form):* import cgi response=requests.get(form.**var**s.fp_url) img=Image.open(StringIO(**respon**se.content)) img.save('foto1231.jpg','JPEG') photo = cgi.FieldStorage() photo.file = open('foto1231.jpg','rb') photo.filename = 'foto.jpg' form.vars.photo=photo # not this on, you let process do upload ** This is very important for me , * * * * On Wednesday, 16 January 2013 07:49:30 UTC-6, Ramos wrote: I just noticed one image created in upload folder and one txt file. Inside the txt file i see the name of jpg file created above. why is that? help please :) António 2013/1/16 António Ramos ramst...@gmail.com can onvalidation set upload file field? i was complaining that form.vars was empty. It is if the controller does not return the form to the view So i return the form and away with my quest. Now, in onvalidation i set the field with the upload file. I have to becaue i have a different upload button that goes online to get a file. Its working but the image file i set goes as a txt file to the database, why here my code: (I use PIL module) *if trabalhador_form.process(onvalidation=attach_image_to_record ).accepted:* *def attach_image_to_record(form):* response=requests.get(form.**var**s.fp_url) img=Image.open(StringIO(**respon**se.content)) img.save('foto1231.jpg','JPEG') temp=open('foto1231.jpg','rb') photo=db.trabalhador.foto.**stor**e(temp,'foto.jpg') *print photo # echoes something like trabalhador.foto. 989708787087078.9823492034.jpg* form.vars.photo=photo *# here is where someting goes wrong* This is very important for me , can anyone explain why a jpg is inserted as a txt? how to force jpg ? Thank you António 2013/1/15 António Ramos ramst...@gmail.com I´m testing this book example http://web2py.com/books/**defaul**t/chapter/29/07#** onvalidationhttp://web2py.com/books/default/chapter/29/07#onvalidation I get error on field named 'a' Traceback (most recent call last): File C:\web2pyGit\web2py\gluon\**res**tricted.py, line 212, in restricted exec ccode in environment File C:/web2pyGit/web2py/**applicati**ons/teste1/models/db.**py http://127.0.0.1:8000/admin/default/edit/teste1/models/db.py, line 91, in module Field('c', 'integer', readable=False, writable=False)) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7189, in define_table table = self.lazy_define_table(tablename,*fields,**args) File C:\web2pyGit\web2py\gluon\**dal**.py, line 7206, in
[web2py] temporary tables to easily use native smartgrid with session-specific data?
I want a controller that fetches a user-chosen subset of data via JSON from an external site, and then presents that for review using smartgrids. Being lazy, I could put the fetched data into a couple of tables. There is a one-to-many relationship in the data (orders and order lines). But the fetched subset is session specific: another user may be looking at a different subset. This application is backended with SQL Server but sqlite would be fine for this temporary data. There is no need to refer to any existing tables so a separate database is fine. I could use tables and put a session id in a column, to keep different users 'sandboxed' to their own requests. But this means I have to clean up old sessions. sqlite has temporary tables which survive for the current database connection, which I suppose means they would survive for the current web2py action, not for the current session, although I think this could still work for my requirement. I think this problem has been solved before, although I couldn't find what I was looking for by searching. There was a discussion in 2009 about using sqlite:memory but it didn't seem very conclusive. --
[web2py] Re: temporary tables to easily use native smartgrid with session-specific data?
there's no such thing as a db that holds records just for the duration of a session automatically (with a session being n1 requests). Just add the usual suspects to the tableupdated_on, a user_id and a status column, with a default temp and change it to confirmed as soon as the user submits the data. Then put something in cron (or in the scheduler) to erase all records that are not confirmed once a day. Or, track the ids being edited by the user in session and upon submission erase/modify/store based on the ids stored in session. PS: sqlite:memory holds on just for a single request. On Tuesday, January 22, 2013 12:38:42 AM UTC+1, Tim Richardson wrote: I want a controller that fetches a user-chosen subset of data via JSON from an external site, and then presents that for review using smartgrids. Being lazy, I could put the fetched data into a couple of tables. There is a one-to-many relationship in the data (orders and order lines). But the fetched subset is session specific: another user may be looking at a different subset. This application is backended with SQL Server but sqlite would be fine for this temporary data. There is no need to refer to any existing tables so a separate database is fine. I could use tables and put a session id in a column, to keep different users 'sandboxed' to their own requests. But this means I have to clean up old sessions. sqlite has temporary tables which survive for the current database connection, which I suppose means they would survive for the current web2py action, not for the current session, although I think this could still work for my requirement. I think this problem has been solved before, although I couldn't find what I was looking for by searching. There was a discussion in 2009 about using sqlite:memory but it didn't seem very conclusive. --
[web2py] Re: web2py best practices/patterns
look, this is for big project : Model Less Apps (using data models and modules in web2py) http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py http://www.web2pyslices.com/slice/show/1479/model-less-apps-using-data-models-and-modules-in-web2py El miércoles, 16 de enero de 2013 07:35:21 UTC-5, H.C. v. Stockhausen escribió: Hi, working with web2py is fun and I've learned a lot about web development and Python. So 'yes', web2py is a great teaching tool and the docs are very good too. Small projects are a breeze to realize and MVC separates the concerns nicely. In larger projects however, I still manage to end up in a bit of a mess. What I lack is a set of w2p design principles that go beyond MVC. The type of questions I had are: - What should one never place into a Model, View, Controller, Module and why? - What should one always place into a Model, View, Controller, Module and why? - What known exceptions are there to these rules? - Should a view ideally be assembled entirely from components? - At what granularity should components, controllers and plugins operate? - Should one try to create a (Rest) API first and then consume it oneself? ... Here's how I would answer some of them today: - Create a distinct controller for every business function (blog, shopping cart, ...) - Keep controller actions as small as possible. - Move all utility functions into custom modules that don't depend on w2p (i.e. they don't import gluon). - Allow strictly no logic in views except for loops and branches. - If DAL is too low-level or an alternative storage backend is used create a ORM-type wrapper as a custom module. - Assemble pages from components. ... This is how I would go about my next w2p project today but I am sure that I would have to learn some new lessons the hard way. How do you structure your apps to avoid spaghetti logic and to keep them maintainable? I would also be interested to hear the kind of questions you have? Maybe we can collect our lessons learned and compile a nice document/catalogue. If there's already such a doc, please let me know. Best regards, HC --
[web2py] Help on Unit Tests
Hi there! I'm new in web2py, I come from programming a lot in django which has built in unit test support and I'm kind of a testing freak. There are like 3 or 4 different articles with different approaches for testing in web2py and the official documentation of the webclient (which helps a lot by the way), I would like to know if there is any official approach when it comes to testing and, if not, I would like to see how could I help, if there is any contributor guidelines or any to-do list, I came into web2py in my new job and the first thing that shocked me a little was the DAL (i was so used to the django's ORM that at first I hated it), I think testing is very important so, if there is no official testing approach, I would really love to contribute and help to improve the tool I'll be working with now. Thank you very much and sorry if this is a duplicate. --
Re: [web2py] Help on Unit Tests
There is no official approach, testing is being an issue for a long time, there was a project called web2py test runner, but the maintainer abandoned the project. If you can contribute with something on this subject, your contribution will be very welcome. The main problem of testing is the fact that web2py runs its own environment, for some things this environment depends on request, response session and other state objects which exists only when the application is running on a webserver. I think a good test approach would be creating mocks for that objects and so having a fake environment to run the tests on shell. $ python web2py.py -S appname -M -R /path/tests.py The above command will open web2py in a shell mode and runs the tests.py script since the environment is ready, but on this environment we do not have full request, session and response objects, so we need some mocking for this. --
[web2py] Re: Help on Unit Tests
Regarding unit testing specifically, I think there are two basic approaches. One approach is to slightly modify the way you write and call the unit test file, and rely on web2py to build its environment in the usual way. This method is described here: http://web2py.com/AlterEgo/default/show/260. In that case, rather than running the test file directly, you would run it as a web2py script using web2py command line options: python web2py.py -S myapp -M -R applications/myapp/tests/test.py That will run the test.py test file in the environment of the myapp application (including all the models). Note, the example test.py code executes the controller being tested via: execfile(applications/api/controllers/10.py, globals()) However, an alternative is to simply specify the controller directly in the command line options: python web2py.py -S myapp/mycontroller -M -R applications/myapp/tests/test. py That will run the test.py file in the environment of the mycontroller controller of myapp (again, including all the models). The alternative approach is to write and run unit tests as usual, and manually build the needed web2py environment within the unit test itself. The web2py Test Runner library was designed with this approach, and it includes some methods to make it easy to build the web2py environment automatically. See http://packages.python.org/web2py_utils/test_runner.html and http://pypi.python.org/pypi/web2py_utils/0.0.13dev. Finally, for basic testing of controller functions, doctests can be included in the controller function docstrings, and the admin interface includes functionality to automatically run all such doctests. Anthony On Monday, January 21, 2013 3:48:49 PM UTC-5, Israel Fermin Montilla wrote: Hi there! I'm new in web2py, I come from programming a lot in django which has built in unit test support and I'm kind of a testing freak. There are like 3 or 4 different articles with different approaches for testing in web2py and the official documentation of the webclient (which helps a lot by the way), I would like to know if there is any official approach when it comes to testing and, if not, I would like to see how could I help, if there is any contributor guidelines or any to-do list, I came into web2py in my new job and the first thing that shocked me a little was the DAL (i was so used to the django's ORM that at first I hated it), I think testing is very important so, if there is no official testing approach, I would really love to contribute and help to improve the tool I'll be working with now. Thank you very much and sorry if this is a duplicate. --
[web2py] How I can use code tag with Markmin?
How I can use code tag with Markmin? Thank you. --
Re: [web2py] How I can use code tag with Markmin?
`` htmlbodyHello World/body/html ``:code_html `` print hello world ``:code_python On Tue, Jan 22, 2013 at 1:50 AM, Ignacio Ocampo naf...@gmail.com wrote: How I can use code tag with Markmin? Thank you. -- --
Re: [web2py] How I can use code tag with Markmin?
Bruno, thank you. But if I only need the simple code? code anything /code How I can do it? On Monday, January 21, 2013 9:56:35 PM UTC-6, rochacbruno wrote: `` htmlbodyHello World/body/html ``:code_html `` print hello world ``:code_python On Tue, Jan 22, 2013 at 1:50 AM, Ignacio Ocampo naf...@gmail.comjavascript: wrote: How I can use code tag with Markmin? Thank you. -- --
Re: [web2py] How I can use code tag with Markmin?
`` Your code here `` for testing: http://web2py.com/markmin --
Re: [web2py] How I can use code tag with Markmin?
Thank you Bruno, and precodeanything/code/pre :) ? On Mon, Jan 21, 2013 at 10:09 PM, Bruno Rocha rochacbr...@gmail.com wrote: `` Your code here `` for testing: http://web2py.com/markmin -- -- Ignacio Ocampo Millán --
Re: [web2py] How I can use code tag with Markmin?
for this I thinnk you sould use extra render. {{text = `` here is my code ``:pre_with_code}} {{=MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.format(text)})}} Tested on shell In [4]: text = `` here is my code ``:pre_with_code In [5]: print MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.format(text)}) precode here is my code /code/pre --
Re: [web2py] How I can use code tag with Markmin?
This works MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.format(text)}) but is is a little dangerous since the user can do `` /code/pre scriptalert('oops!');/script precode `` The argument of text should be escaped somehow. Not sure how since you want to allow verbatim code. On Monday, 21 January 2013 22:30:51 UTC-6, rochacbruno wrote: for this I thinnk you sould use extra render. {{text = `` here is my code ``:pre_with_code}} {{=MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.format(text)})}} Tested on shell In [4]: text = `` here is my code ``:pre_with_code In [5]: print MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.format(text)}) precode here is my code /code/pre --
Re: [web2py] How I can use code tag with Markmin?
Very fun! :) On Mon, Jan 21, 2013 at 11:22 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: This works MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.**format(text)}) but is is a little dangerous since the user can do `` /code/pre scriptalert('oops!');/script precode `` The argument of text should be escaped somehow. Not sure how since you want to allow verbatim code. On Monday, 21 January 2013 22:30:51 UTC-6, rochacbruno wrote: for this I thinnk you sould use extra render. {{text = `` here is my code ``:pre_with_code}} {{=MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.**format(text)})}} Tested on shell In [4]: text = `` here is my code ``:pre_with_code In [5]: print MARKMIN(text, extra={pre_with_code: lambda text: precode{0}/code/pre.**format(text)}) precode here is my code /code/pre -- -- Ignacio Ocampo Millán --
Re: [web2py] Re: Book in epub format?
On 21 January 2013 22:49, Niphlod niph...@gmail.com wrote: rotfl. always available, but I don't know a single thing about the epub format. did anyone tried just converting the pdf to epub using calibre ? The success of converting pdf to epub using calibre depends on how the pdf was created. I had some successes and some miserable results. Anyhow I have sent Massimo an epub of the book. I used Sigil to create the epub by loading the html-files. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) --
[web2py] Re: temporary tables to easily use native smartgrid with session-specific data?
Thanks again Niphlod; I think this will be a handy technique to have up my sleeve. --
Re: [web2py] Re: temporary tables to easily use native smartgrid with session-specific data?
I use the following method which is not session dependent (and therefore not as as complicated as your requirement): Define a model for the query Drop the table before the query is executed Use Postgresql's 'SELECT INTO' or 'CREATE TABLE AS XXX FROM' in the query to populate the table. Maybe in your case one can use a conditional model which uses the session-id in the table's name, execute the query and drop it after the session has ended. I don't know whether it is possible. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) --