[web2py] Re: weird bug with redis
Thanks A LOT Simone, that solved this problem! Much much appreciated your help!! Le vendredi 19 juillet 2013 02:15:25 UTC+2, Niphlod a écrit : seems a more general problem within the os than a bug with web2py and redis. although I'm a heavy user of redis, I never encountered that error. this http://askubuntu.com/questions/142508/how-to-fix-5-no-address-associated-with-hostname-error-while-updating is just a reference on a similar error on a totally different problem (resolving hostnames for apt sources) but indeed is related to the same issue : something is going on strangely on your server and it doesn't resolve properly what localhost is. Shameless trial to fix the problem (read: it may work, but I can't test it cause I can't reproduce the error): try replacing localhost with 127.0.0.1 On Thursday, July 18, 2013 4:35:48 PM UTC+2, dederocks wrote: Hello, I have encountered a weird bug using Redis. I understand it would be too complicated to get detailed help (software is running to supervise a machine), but I'm looking for cues on where to look. Here is the problem: I use redis to share variables between processes. After a while, I get the following error in web2py: class 'redis.exceptions.ConnectionError' Error -5 connecting localhost:6379. No address associated with hostname. The instruction raising this message is never the same, allthough it's a redis command, of course: it always comes down to redis connexion missing that cannot be re-established (line 125 in redis' connection.py). What is weird is that redis remains accessible from the other processes, e.g. the server still operates without any problem. The only solution I've found so far to solve the problem is restarting web2py (touch /etc/uwsgi/web2py.xml), and then it works again. Any cue from someone on what could be wrong? Thanks, Andre -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Pass helpers in variable to views
You cannot use the template language inside a string. You can use inside a template file. content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, should be content_block = XML('h1Some Title/h1 img src=%s /' % URL('static','images/python.gif')) On Monday, 22 July 2013 00:20:07 UTC-5, shapova...@gmail.com wrote: Hi! Know that I missing something obvious here, but still: I store parts of page to be displayed in db, in html code, and return it to view, so content from db is in content_block var: def get_block(): [some other code] content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, sanitize=False return dict(form=form, content_block = content_block) view: {{extend 'layout.html'}} {{=form}} {{block content_block}} {{=content_block}} {{end}} but it turns out that URL helper is not executed when passed to view in an variable, so I get img src={{=URL( static',images= python.gif')}}= in the browser. Probably the view gets constructed (parsed) before vars passed to it are added. So, what is the best way to pass HTML parts with helpers (for IMG, A, etc) to view in an variable and still use the advantages of URL helper? I don't like the idea of statically setting links in html parts. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: offtopic : beautiful code
Nice. I did not know partial from functools. There are a few places in web2py related to streaming where we could use it to simplify code. On Sunday, 21 July 2013 17:07:04 UTC-5, Niphlod wrote: I actually skipped over this a few times and today I finally reached its place in my playlist for free time... sorry if you seen it before, but I actually learned at least 5 things out of it that I really didn't know of. https://www.youtube.com/watch?v=OSGv2VnC0go if you want slides https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1 On Sunday, 21 July 2013 17:07:04 UTC-5, Niphlod wrote: I actually skipped over this a few times and today I finally reached its place in my playlist for free time... sorry if you seen it before, but I actually learned at least 5 things out of it that I really didn't know of. https://www.youtube.com/watch?v=OSGv2VnC0go if you want slides https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] invalid table/column name comment
Interesting problem I've encountered. I'm getting the error: *type 'exceptions.SyntaxError' invalid table/column name comment is a ALL reserved SQL/NOSQL keyword* * * after defining my tables as such: # define tables for blog posts db.define_table('post', Field('title', unique=True), Field('body', 'text'), format = '%(title)s') # define tables for comments on a blog post db.define_table('comment', Field('post_id', 'reference post'), Field('author'), Field('email'), Field('body', 'text')) db.post.title.requires = IS_NOT_IN_DB(db, db.post.title) db.post.body.requires = IS_NOT_EMPTY() db.comment.post_id.requires = IS_IN_DB(db, db.post.id, '%(title)s') db.comment.author.requires = IS_NOT_EMPTY() db.comment.email.requires = IS_EMAIL() db.comment.body.requires = IS_NOT_EMPTY() Comment isn't a reserved keyword by mysql from what I have looked up. I've tried to look this up in google and got nowhere, so here I am again. xD Currently self-teaching myself python and web2py and do plan to pay it forward to open-source in the future and all help is appreciated in advance! -Jeremy -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] FPDF database image
I followed your advised Massimo. It installed well. I already figured the dimensions of the images conflict. The 320x479 uploaded file works well. But if the users uploaded 1600x1200 or more, it makes the same error. Am I missing something? On Tuesday, July 16, 2013 1:13:53 PM UTC+3, Massimo Di Pierro wrote: You need to pip install PIL or sudo apt-get install python-imaging or on mac brew brew install pil On Tuesday, 16 July 2013 00:52:15 UTC-5, Tribo Eila wrote: Mariano, I already took your advised. But I can't figure out this error: RuntimeError: FPDF error: PIL not installed After I installed the latest Binary Installer of PIL to python/../site-package. Still error exist. Copy the folder to web2py/../site-packages, still the same. I tried to import PIL in python command line. No error. Any advised? Regards, Eila On Monday, July 15, 2013 6:49:00 PM UTC+3, Mariano Reingart wrote: You shoud have the picture in a file, so PyFPDF can load it. Take a look at build_badge_dict in web2conf: https://code.google.com/p/web2conf/source/browse/controllers/badge.py#103 It uses some icons (speaker, country flag) from the private directory, and uses the sponsor logo from a upload field in the database. Basically, you should pass the full image path to PyFPDF (sponsor.logo is the upload field): fn = db.sponsor[user.sponsor_id].logo source = os.path.join(request.folder, 'uploads', fn) See the sample function, that uses that info to generate the pdf. Best regads Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Mon, Jul 15, 2013 at 2:03 AM, Tribo Eila tribo@gmail.com wrote: Hi, Supposed the code below: db.define_table('person', Field('name'), Field('picture', 'upload')). I'm trying to figured out, how to implement the picture to retrieve from database(postgreSQL) to FPDF. Any ideas to share? Thanks. Newbie -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] invalid table/column name comment
It's not mysql comment, but DAL is written so it works with a lot of databases. This could stop you from moving to another database engine later. If you want to turn it off, just edit your db.py file and remove check_reserved argument from your DAL(...) init call. I'd rather change column name - but this is just my preference. I like this check for reserved keywords :) Note, you can use check_reserved=['mysql'] etc Marin On Mon, Jul 22, 2013 at 10:32 AM, Jeremy Hankenson hankensonjer...@gmail.com wrote: Interesting problem I've encountered. I'm getting the error: *type 'exceptions.SyntaxError' invalid table/column name comment is a ALL reserved SQL/NOSQL keyword* * * after defining my tables as such: # define tables for blog posts db.define_table('post', Field('title', unique=True), Field('body', 'text'), format = '%(title)s') # define tables for comments on a blog post db.define_table('comment', Field('post_id', 'reference post'), Field('author'), Field('email'), Field('body', 'text')) db.post.title.requires = IS_NOT_IN_DB(db, db.post.title) db.post.body.requires = IS_NOT_EMPTY() db.comment.post_id.requires = IS_IN_DB(db, db.post.id, '%(title)s') db.comment.author.requires = IS_NOT_EMPTY() db.comment.email.requires = IS_EMAIL() db.comment.body.requires = IS_NOT_EMPTY() Comment isn't a reserved keyword by mysql from what I have looked up. I've tried to look this up in google and got nowhere, so here I am again. xD Currently self-teaching myself python and web2py and do plan to pay it forward to open-source in the future and all help is appreciated in advance! -Jeremy -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Radio Buttons layout problem with trunk
Paolo and Massimo, Thank you very much for correcting this in the trunk. Regards Johann On 18 July 2013 18:46, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Thanks! :-) On Thursday, 18 July 2013 11:16:12 UTC-5, Paolo Caruccio wrote: I answered to a specific question but you are right: the code should go in web2py_bootstrap.css in order to solve the conflict. Anyway we have to check that the patch doesn't break anything else. Therefore please give me a bit of the time and I will open an issue ticket on the issue tracker together with the patch. Il giorno giovedì 18 luglio 2013 17:56:50 UTC+2, Massimo Di Pierro ha scritto: Should this go in web2py_bootstrap.css? On Thursday, 18 July 2013 10:51:15 UTC-5, Paolo Caruccio wrote: Please put the following code in your custom css file (or in the bottom of web2py_bootstrap.css if you are using the welcome app scaffolding): .generic-widget input[type='radio'] {margin:-1px 0 0 0; vertical-align:middle ;} .generic-widget input[type='radio'] + label {display:inline-block;margin :0 0 0 6px; vertical-align: middle;} Bootstrap framework has a html structure for radio controls different from web2py radio widget. For this reason the issue has been raised. Il giorno giovedì 18 luglio 2013 10:12:20 UTC+2, Johann Spies ha scritto: I took the welcome app (trunk version), added the following model: db.define_table(toets_radio, Field('yesno', requires=IS_IN_SET([(0, 'No'), (1, 'Yes')]), widget = SQLFORM.widgets.radio.widget)) And it produced this view there the radio button and the label are on two different lines (see attached screenshot). Then I replaced the /static directory and /views/layout.html with a version from an older app and the radio button and it's label was next to each other as expected (see second screenshot). I was so far unable to determine what exactly causes this and have wasted several hours to solve the problem in the trunk version. I would appreciate it if someone more knowledgable than me can solve this. The bootstrap version in the css that worked correctly was 2.04. Unfortunately the web2py*.css files did not have a version in. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Prevent specific field from update
Hi, Massimo, thanks for the solution, it looks totally fine but I just wasn't clear enough on this - my bad. The thing is I'm using crud.update() to generate the form I described earlier. How would I adapt your code to crud? I could use onaccept but it's triggered after the update nad before redirect. In my case I must influence crud.update() so it performs the additional action I need *during*the update. On Monday, July 22, 2013 12:20:38 AM UTC+2, Massimo Di Pierro wrote: How about this? record = db.table[id] newfieldvalues = {'field_X':'value', } if record.field_X == 'B': del newfieldvalues['field_X'] record.update_record(**newfieldvalues) if db.table[id].field_X == A: #perform full update elif db.table[id].field_X == B: #update all fields except field_X On Sunday, 21 July 2013 08:11:44 UTC-5, lesssugar wrote: When going to update page I would like to check the value of field_X. Then, depending on its current value, field_X should be updated along with the other fields OR be excluded from upload: if db.table[id].field_X == A: #perform full update elif db.table[id].field_X == B: #update all fields except field_X Not sure how to achieve this. Ideas? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] import from csv
with this db setup: db.define_table('station', Field('name'), Field('location'), Field('file', 'upload') db.define_table('records', ('station_id', db.station), Field('col1'), Field('col2')) col1-col2 are from file uploaded i want to have a controller that takes this csv file and imports the data, assigning also a station_id value with a form.process().accepted i can handle the file, but with which method should be better to import? db import from csv can have custom columns layout such as SQLFORM.grid() for example? thanks -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Prevent specific field from update
Do not use CRUD. Use SQLFORM instead. form = SQLFORM(...) if form.process(dbio=False).accepted: if form.record.field_X == 'B': del form.vars['field_X'] form.record.update_record(**form.vars) On Monday, 22 July 2013 05:26:41 UTC-5, lesssugar wrote: Hi, Massimo, thanks for the solution, it looks totally fine but I just wasn't clear enough on this - my bad. The thing is I'm using crud.update() to generate the form I described earlier. How would I adapt your code to crud? In my case I must influence crud.update() so it performs the additional action (checking field_X) * during* the update. I could of course use onaccept but it's triggered after the update nad before redirect, which is sort of going around the problem. On Monday, July 22, 2013 12:20:38 AM UTC+2, Massimo Di Pierro wrote: How about this? record = db.table[id] newfieldvalues = {'field_X':'value', } if record.field_X == 'B': del newfieldvalues['field_X'] record.update_record(**newfieldvalues) if db.table[id].field_X == A: #perform full update elif db.table[id].field_X == B: #update all fields except field_X On Sunday, 21 July 2013 08:11:44 UTC-5, lesssugar wrote: When going to update page I would like to check the value of field_X. Then, depending on its current value, field_X should be updated along with the other fields OR be excluded from upload: if db.table[id].field_X == A: #perform full update elif db.table[id].field_X == B: #update all fields except field_X Not sure how to achieve this. Ideas? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Prevent specific field from update
Cool, thanks a lot! On Monday, July 22, 2013 12:59:08 PM UTC+2, Massimo Di Pierro wrote: Do not use CRUD. Use SQLFORM instead. form = SQLFORM(...) if form.process(dbio=False).accepted: if form.record.field_X == 'B': del form.vars['field_X'] form.record.update_record(**form.vars) On Monday, 22 July 2013 05:26:41 UTC-5, lesssugar wrote: Hi, Massimo, thanks for the solution, it looks totally fine but I just wasn't clear enough on this - my bad. The thing is I'm using crud.update() to generate the form I described earlier. How would I adapt your code to crud? In my case I must influence crud.update() so it performs the additional action (checking field_X) * during* the update. I could of course use onaccept but it's triggered after the update nad before redirect, which is sort of going around the problem. On Monday, July 22, 2013 12:20:38 AM UTC+2, Massimo Di Pierro wrote: How about this? record = db.table[id] newfieldvalues = {'field_X':'value', } if record.field_X == 'B': del newfieldvalues['field_X'] record.update_record(**newfieldvalues) if db.table[id].field_X == A: #perform full update elif db.table[id].field_X == B: #update all fields except field_X On Sunday, 21 July 2013 08:11:44 UTC-5, lesssugar wrote: When going to update page I would like to check the value of field_X. Then, depending on its current value, field_X should be updated along with the other fields OR be excluded from upload: if db.table[id].field_X == A: #perform full update elif db.table[id].field_X == B: #update all fields except field_X Not sure how to achieve this. Ideas? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Pass helpers in variable to views
Massimo, thanks again. I'm aware of security risks, the html in db is just legacy static pages, no user input there, ever. I'm just converting static pages to dynamic website with apps. But your suggestion to use replace looks even better! On Monday, July 22, 2013 1:57:20 PM UTC+3, Massimo Di Pierro wrote: You are telling me you are storing this h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}} in db? From a technical standpoint you can do: XML(reponse.render(pageElementsTable.content_block)) but this MAY introduce a major vulnerability, depending on where the content comes from. The response render is not just evaluating {{=URL...}}. It will evaluate any CODE present in within {{...}} in pageElementsTable.content_block. I would never use {{...}} in HTML stored in database. There is always a better option. Details depend on what you are trying to achieve. For example, if you problem is allowing to link static files from HTML in database I would do: content_block = 'h1 Some Title /h1 img src=$STATIC/mages/ python.gif/' XML(pageElementsTable. content_block.replace('$STATIC',URL('static','x')[:-1]),sanitize=True) On Monday, 22 July 2013 04:48:05 UTC-5, shapova...@gmail.com wrote: Thanks Massimo, I've completely missed that. But in my case, I'm reading this html from db. So it is: content_block = XML(pageElementsTable.content_block, sanitize=False) actually. So, if I keep html content of a page with IMG, A, SRCs, HREFs, etc in db, how to pass it to the view to properly visualize in browser? On Monday, July 22, 2013 11:52:36 AM UTC+3, Massimo Di Pierro wrote: You cannot use the template language inside a string. You can use inside a template file. content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, should be content_block = XML('h1Some Title/h1 img src=%s /' % URL('static','images/python.gif')) On Monday, 22 July 2013 00:20:07 UTC-5, shapova...@gmail.com wrote: Hi! Know that I missing something obvious here, but still: I store parts of page to be displayed in db, in html code, and return it to view, so content from db is in content_block var: def get_block(): [some other code] content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, sanitize=False return dict(form=form, content_block = content_block) view: {{extend 'layout.html'}} {{=form}} {{block content_block}} {{=content_block}} {{end}} but it turns out that URL helper is not executed when passed to view in an variable, so I get img src={{=URL( static',images= python.gif')}}= in the browser. Probably the view gets constructed (parsed) before vars passed to it are added. So, what is the best way to pass HTML parts with helpers (for IMG, A, etc) to view in an variable and still use the advantages of URL helper? I don't like the idea of statically setting links in html parts. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: real time graph
I use d3.js - seems to at least awesome. Here are some examples with real time paths: http://bost.ocks.org/mike/path/ W dniu piątek, 19 lipca 2013 00:58:54 UTC+2 użytkownik Vera Moreira napisał: hi everyone, I need some help, does anyone have examples on how to do a real time graph. What I need is a graph to constantly show random numbers, I´m using matplotlib I already have this info: from Antonis Tzorvas an idea for a real-time approach graph you have to go with gifs generated by the several .draw()s and save *.gif in static/images folder but i've just found this one: http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/ from Ovidio Marinho A good option would also google maps. See this done with google maps and web2py. http://mosaico.no-ip.org/mosaico/regionalizacao/regmapa . For graphs with movements that would be better http://mosaico.no-ip.org/mosaico/mortalidadeinfantil/neonatalmun.html?municipio=Agua+Brancabotao=muniind=neonatal graphs are interactive and very good http://www.highcharts.com/ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Pass helpers in variable to views
You are telling me you are storing this h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}} in db? From a technical standpoint you can do: XML(reponse.render(pageElementsTable.content_block)) but this MAY introduce a major vulnerability, depending on where the content comes from. The response render is not just evaluating {{=URL...}}. It will evaluate any CODE present in within {{...}} in pageElementsTable.content_block. I would never use {{...}} in HTML stored in database. There is always a better option. Details depend on what you are trying to achieve. For example, if you problem is allowing to link static files from HTML in database I would do: content_block = 'h1 Some Title /h1 img src=$STATIC/mages/ python.gif/' XML(pageElementsTable. content_block.replace('$STATIC',URL('static','x')[:-1]),sanitize=True) On Monday, 22 July 2013 04:48:05 UTC-5, shapova...@gmail.com wrote: Thanks Massimo, I've completely missed that. But in my case, I'm reading this html from db. So it is: content_block = XML(pageElementsTable.content_block, sanitize=False) actually. So, if I keep html content of a page with IMG, A, SRCs, HREFs, etc in db, how to pass it to the view to properly visualize in browser? On Monday, July 22, 2013 11:52:36 AM UTC+3, Massimo Di Pierro wrote: You cannot use the template language inside a string. You can use inside a template file. content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, should be content_block = XML('h1Some Title/h1 img src=%s /' % URL('static','images/python.gif')) On Monday, 22 July 2013 00:20:07 UTC-5, shapova...@gmail.com wrote: Hi! Know that I missing something obvious here, but still: I store parts of page to be displayed in db, in html code, and return it to view, so content from db is in content_block var: def get_block(): [some other code] content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, sanitize=False return dict(form=form, content_block = content_block) view: {{extend 'layout.html'}} {{=form}} {{block content_block}} {{=content_block}} {{end}} but it turns out that URL helper is not executed when passed to view in an variable, so I get img src={{=URL( static',images= python.gif')}}= in the browser. Probably the view gets constructed (parsed) before vars passed to it are added. So, what is the best way to pass HTML parts with helpers (for IMG, A, etc) to view in an variable and still use the advantages of URL helper? I don't like the idea of statically setting links in html parts. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] invalid table/column name comment
Thank you! This explains why when I created a separate model file it worked just fine, cause I didn't include that check_reserved argument. On Monday, July 22, 2013 4:39:23 AM UTC-5, Marin Pranjić wrote: It's not mysql comment, but DAL is written so it works with a lot of databases. This could stop you from moving to another database engine later. If you want to turn it off, just edit your db.py file and remove check_reserved argument from your DAL(...) init call. I'd rather change column name - but this is just my preference. I like this check for reserved keywords :) Note, you can use check_reserved=['mysql'] etc Marin On Mon, Jul 22, 2013 at 10:32 AM, Jeremy Hankenson hankens...@gmail.comjavascript: wrote: Interesting problem I've encountered. I'm getting the error: *type 'exceptions.SyntaxError' invalid table/column name comment is a ALL reserved SQL/NOSQL keyword* * * after defining my tables as such: # define tables for blog posts db.define_table('post', Field('title', unique=True), Field('body', 'text'), format = '%(title)s') # define tables for comments on a blog post db.define_table('comment', Field('post_id', 'reference post'), Field('author'), Field('email'), Field('body', 'text')) db.post.title.requires = IS_NOT_IN_DB(db, db.post.title) db.post.body.requires = IS_NOT_EMPTY() db.comment.post_id.requires = IS_IN_DB(db, db.post.id, '%(title)s') db.comment.author.requires = IS_NOT_EMPTY() db.comment.email.requires = IS_EMAIL() db.comment.body.requires = IS_NOT_EMPTY() Comment isn't a reserved keyword by mysql from what I have looked up. I've tried to look this up in google and got nowhere, so here I am again. xD Currently self-teaching myself python and web2py and do plan to pay it forward to open-source in the future and all help is appreciated in advance! -Jeremy -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Pass helpers in variable to views
Thanks Massimo, I've completely missed that. But in my case, I'm reading this html from db. So it is: headerad_block = XML(pageElementsTable.content_block, sanitize=False) actually. So, if I keep html content of a page with IMG, A, SRCs, HREFs, etc in db, how to pass it to the view to properly visualize in browser? On Monday, July 22, 2013 11:52:36 AM UTC+3, Massimo Di Pierro wrote: You cannot use the template language inside a string. You can use inside a template file. content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, should be content_block = XML('h1Some Title/h1 img src=%s /' % URL('static','images/python.gif')) On Monday, 22 July 2013 00:20:07 UTC-5, shapova...@gmail.com wrote: Hi! Know that I missing something obvious here, but still: I store parts of page to be displayed in db, in html code, and return it to view, so content from db is in content_block var: def get_block(): [some other code] content_block = XML(h1 Some Title /h1 img src='{{=URL('static','images/python.gif')}}, sanitize=False return dict(form=form, content_block = content_block) view: {{extend 'layout.html'}} {{=form}} {{block content_block}} {{=content_block}} {{end}} but it turns out that URL helper is not executed when passed to view in an variable, so I get img src={{=URL( static',images= python.gif')}}= in the browser. Probably the view gets constructed (parsed) before vars passed to it are added. So, what is the best way to pass HTML parts with helpers (for IMG, A, etc) to view in an variable and still use the advantages of URL helper? I don't like the idea of statically setting links in html parts. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: offtopic : beautiful code
Thanks, good material. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: real time graph
Nice. In the example there is this code: data.push(random()); In the example the problem is updated using random() points. I think Vera's problem is that the data must be pushed from the server to the client. She needs a websocket. On Monday, 22 July 2013 04:19:26 UTC-5, Zbigniew Pomianowski wrote: I use d3.js - seems to at least awesome. Here are some examples with real time paths: http://bost.ocks.org/mike/path/ W dniu piątek, 19 lipca 2013 00:58:54 UTC+2 użytkownik Vera Moreira napisał: hi everyone, I need some help, does anyone have examples on how to do a real time graph. What I need is a graph to constantly show random numbers, I´m using matplotlib I already have this info: from Antonis Tzorvas an idea for a real-time approach graph you have to go with gifs generated by the several .draw()s and save *.gif in static/images folder but i've just found this one: http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/ from Ovidio Marinho A good option would also google maps. See this done with google maps and web2py. http://mosaico.no-ip.org/mosaico/regionalizacao/regmapa . For graphs with movements that would be better http://mosaico.no-ip.org/mosaico/mortalidadeinfantil/neonatalmun.html?municipio=Agua+Brancabotao=muniind=neonatal graphs are interactive and very good http://www.highcharts.com/ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: best advice for checking/unchecking all INPUT checkboxes with certain pattern in name
Document ready doesn't help?? On Sat, Jul 20, 2013 at 8:30 PM, lucas sjluk...@gmail.com wrote: i stuck the jQuery code in the body after my form block using the SCRIPT helper and it works fine. not really sure its placement is so critical to its workings. lucas -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Off topic - Ubuntu Edge
Does it worth it? I´m in the process of buying a Galaxy S4 https://www.youtube.com/watch?v=eQLe3iIMN7k -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] offtopic : beuatiful code
Thanks for sharing Simone! Appreciate! I notice one change that can improve web2py, but not seems available in python 2.7 : with ignore(OSError): os.unlink(filename) In replacement to : if os.path.exists(filename): os.unlink(filename) https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1?slide=37 http://mmoya.org/blog/2013/03/17/python-gets-a-new-ignored-context-manager/ Seems that there is a small risk of concurent access with os.path.exists() and os.unlink() http://stackoverflow.com/questions/10840533/most-pythonic-way-to-delete-a-file-which-may-not-exist :) Richard On Sun, Jul 21, 2013 at 6:07 PM, Niphlod niph...@gmail.com wrote: I actually skipped over this a few times and today I finally reached its place in my playlist for free time... sorry if you seen it before, but I actually learned at least 5 things out of it that I really didn't know of. https://www.youtube.com/watch?v=OSGv2VnC0go if you want slides https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] offtopic : beuatiful code
Technically it would be equivalent to try: os.unlink(filename) except IOError: pass one could define OSError= IOError and from future import with_statement, then define ignore(...). It is not difficult but slower than the above syntax. I prefer if os.path.exists(filename). On Monday, 22 July 2013 10:35:03 UTC-5, Richard wrote: Thanks for sharing Simone! Appreciate! I notice one change that can improve web2py, but not seems available in python 2.7 : with ignore(OSError): os.unlink(filename) In replacement to : if os.path.exists(filename): os.unlink(filename) https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1?slide=37 http://mmoya.org/blog/2013/03/17/python-gets-a-new-ignored-context-manager/ Seems that there is a small risk of concurent access with os.path.exists() and os.unlink() http://stackoverflow.com/questions/10840533/most-pythonic-way-to-delete-a-file-which-may-not-exist :) Richard On Sun, Jul 21, 2013 at 6:07 PM, Niphlod nip...@gmail.com javascript:wrote: I actually skipped over this a few times and today I finally reached its place in my playlist for free time... sorry if you seen it before, but I actually learned at least 5 things out of it that I really didn't know of. https://www.youtube.com/watch?v=OSGv2VnC0go if you want slides https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] dynamic url/functions in controller
is there any way to get dynamic urls? for example i have ip.com/app/nodes/list (smartgrid) ip.com/app/nodes/edit/[db.node.name] ip.com/app/nodes/show/[db.node.name] (details about each node) ip.com/app/nodes/graph/[db.node.name] and i am thinking on changing the url-scheme into something like this: ip.com/app/nodes/[db.node.name] (details about each node) ip.com/app/nodes/[db.node.name]/edit ip.com/app/nodes/[db.node.name]/graph any idea on how to achieve this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] offtopic : beuatiful code
it's on the slide after that. I think he says he committed that on python 3.x but of course its backportable. Il giorno lunedì 22 luglio 2013 17:35:03 UTC+2, Richard ha scritto: Thanks for sharing Simone! Appreciate! I notice one change that can improve web2py, but not seems available in python 2.7 : with ignore(OSError): os.unlink(filename) In replacement to : if os.path.exists(filename): os.unlink(filename) https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1?slide=37 http://mmoya.org/blog/2013/03/17/python-gets-a-new-ignored-context-manager/ Seems that there is a small risk of concurent access with os.path.exists() and os.unlink() http://stackoverflow.com/questions/10840533/most-pythonic-way-to-delete-a-file-which-may-not-exist :) Richard On Sun, Jul 21, 2013 at 6:07 PM, Niphlod nip...@gmail.com javascript:wrote: I actually skipped over this a few times and today I finally reached its place in my playlist for free time... sorry if you seen it before, but I actually learned at least 5 things out of it that I really didn't know of. https://www.youtube.com/watch?v=OSGv2VnC0go if you want slides https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: [web2pyy] Mysql 2 Mongodb
I am just playing around with mongodb and web2py I noticed that when I just make a web2py dump of my mysql db and then upload it to mongodb some of the joins now just rec id's are right and some are newly generated. Also would it be possible to keep id to be web2py specific and to use _id for mongodb ? The current implementation of the mongodb adapter maps web2py id to mongodb _id transparently, so the apps can use .id attributes yet storing _id in database. I was wondering if it was a bug. In this case in the setup table the pointers to the frame work fine, but the pointers in the setupprofile named lparprofile do not exist anymore in the lparprofile table. What tool are you using to load the records from mysql to mongodb? The import_from_csv_file method should keep references between tables, but AFAIK, it is not possible to force insert of specific _id numbers if you are restoring records to mongodb -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: dynamic url/functions in controller
In routes.py routes_in = [ ['/app/nodes/$name', '/app/nodes/show/$node'], ['/app/nodes/$name/edit', '/app/nodes/edit/$node'], ['/app/nodes/$name/graph', '/app/nodes/graph/$node'], ] routes_out = [(y,x) for (x,y) in routes_in] On Monday, 22 July 2013 13:37:57 UTC-5, Antonis Konstantinos Tzorvas wrote: is there any way to get dynamic urls? for example i have ip.com/app/nodes/list (smartgrid) ip.com/app/nodes/edit/[db.node.name]http://ip.com/app/nodes/edit/%5Bdb.node.name%5D ip.com/app/nodes/show/[db.node.name]http://ip.com/app/nodes/show/%5Bdb.node.name%5D(details about each node) ip.com/app/nodes/graph/[db.node.name]http://ip.com/app/nodes/graph/%5Bdb.node.name%5D and i am thinking on changing the url-scheme into something like this: ip.com/app/nodes/[db.node.name]http://ip.com/app/nodes/%5Bdb.node.name%5D(details about each node) ip.com/app/nodes/[db.node.name]/edithttp://ip.com/app/nodes/%5Bdb.node.name%5D/edit ip.com/app/nodes/[db.node.name]/graphhttp://ip.com/app/nodes/%5Bdb.node.name%5D/graph any idea on how to achieve this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: dynamic url/functions in controller
routes_in = [ ['/droughtmonitor/stations/$name', '/droughtmonitor/stations/show/$name'], ['/droughtmonitor/stations/$name/edit', '/droughtmonitor/stations/edit/$name'], ] routes_out = [(y,x) for (x,y) in routes_in] it worked! care in the $node-$name difference as it wanted to be the same var $name-$name thanks On Monday, July 22, 2013 9:59:17 PM UTC+3, Massimo Di Pierro wrote: In routes.py routes_in = [ ['/app/nodes/$name', '/app/nodes/show/$node'], ['/app/nodes/$name/edit', '/app/nodes/edit/$node'], ['/app/nodes/$name/graph', '/app/nodes/graph/$node'], ] routes_out = [(y,x) for (x,y) in routes_in] On Monday, 22 July 2013 13:37:57 UTC-5, Antonis Konstantinos Tzorvas wrote: is there any way to get dynamic urls? for example i have ip.com/app/nodes/list (smartgrid) ip.com/app/nodes/edit/[db.node.name]http://ip.com/app/nodes/edit/%5Bdb.node.name%5D ip.com/app/nodes/show/[db.node.name]http://ip.com/app/nodes/show/%5Bdb.node.name%5D(details about each node) ip.com/app/nodes/graph/[db.node.name]http://ip.com/app/nodes/graph/%5Bdb.node.name%5D and i am thinking on changing the url-scheme into something like this: ip.com/app/nodes/[db.node.name]http://ip.com/app/nodes/%5Bdb.node.name%5D(details about each node) ip.com/app/nodes/[db.node.name]/edithttp://ip.com/app/nodes/%5Bdb.node.name%5D/edit ip.com/app/nodes/[db.node.name]/graphhttp://ip.com/app/nodes/%5Bdb.node.name%5D/graph any idea on how to achieve this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: dynamic url/functions in controller
oops. I fixed the typo in my message. On Monday, 22 July 2013 14:31:20 UTC-5, Antonis Konstantinos Tzorvas wrote: routes_in = [ ['/droughtmonitor/stations/$name', '/droughtmonitor/stations/show/$name'], ['/droughtmonitor/stations/$name/edit', '/droughtmonitor/stations/edit/$name'], ] routes_out = [(y,x) for (x,y) in routes_in] it worked! care in the $node-$name difference as it wanted to be the same var $name-$name thanks On Monday, July 22, 2013 9:59:17 PM UTC+3, Massimo Di Pierro wrote: In routes.py routes_in = [ ['/app/nodes/$name', '/app/nodes/show/$node'], ['/app/nodes/$name/edit', '/app/nodes/edit/$node'], ['/app/nodes/$name/graph', '/app/nodes/graph/$node'], ] routes_out = [(y,x) for (x,y) in routes_in] On Monday, 22 July 2013 13:37:57 UTC-5, Antonis Konstantinos Tzorvas wrote: is there any way to get dynamic urls? for example i have ip.com/app/nodes/list (smartgrid) ip.com/app/nodes/edit/[db.node.name]http://ip.com/app/nodes/edit/%5Bdb.node.name%5D ip.com/app/nodes/show/[db.node.name]http://ip.com/app/nodes/show/%5Bdb.node.name%5D(details about each node) ip.com/app/nodes/graph/[db.node.name]http://ip.com/app/nodes/graph/%5Bdb.node.name%5D and i am thinking on changing the url-scheme into something like this: ip.com/app/nodes/[db.node.name]http://ip.com/app/nodes/%5Bdb.node.name%5D(details about each node) ip.com/app/nodes/[db.node.name]/edithttp://ip.com/app/nodes/%5Bdb.node.name%5D/edit ip.com/app/nodes/[db.node.name]/graphhttp://ip.com/app/nodes/%5Bdb.node.name%5D/graph any idea on how to achieve this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Errors in form, please check it out....... HOW?
In the last trunk of web2py, the form input error message is more visible. See attached image. Il giorno lunedì 17 giugno 2013 16:04:50 UTC+2, REM ha scritto: I'm attempting to understand a few things and decided to test out one of the items at: http://web2py.com/appliances Specifically, the video library example at the bottom of the page. I tried installing it from the URL feature on the admin page but I get the message: Errors in form, please check it out However, how in the world does one check it out? WHERE is it? WHAT, in fact, am I checking out? I downloaded the referenced .web2py file and my (Ubuntu) system tells me it's a gzipped file, but I can't open it with anything. I then tried installing that locally downloaded file through admin: same error. So, I tried downloading and installing others and, in every single case: no donuts! So, how does one even begin to figure out the cause of this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. attachment: error_msg_more_visible_i.jpg
[web2py] Re: Off topic - Ubuntu Edge
yes, it's Fantastic http://www.indiegogo.com/projects/ubuntu-edge El lunes, 22 de julio de 2013 11:38:54 UTC-5, Ramos escribió: Does it worth it? I´m in the process of buying a Galaxy S4 https://www.youtube.com/watch?v=eQLe3iIMN7k -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: offtopic : beautiful code
I see a chapter about python in the web2py book, why not add this talk to the web2py.com site somewhere... 2013/7/22 Massimo Di Pierro massimo.dipie...@gmail.com Nice. I did not know partial from functools. There are a few places in web2py related to streaming where we could use it to simplify code. On Sunday, 21 July 2013 17:07:04 UTC-5, Niphlod wrote: I actually skipped over this a few times and today I finally reached its place in my playlist for free time... sorry if you seen it before, but I actually learned at least 5 things out of it that I really didn't know of. https://www.youtube.com/watch?**v=OSGv2VnC0gohttps://www.youtube.com/watch?v=OSGv2VnC0go if you want slides https://speakerdeck.com/**pyconslides/transforming-code-** into-beautiful-idiomatic-**python-by-raymond-hettinger-1https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1 On Sunday, 21 July 2013 17:07:04 UTC-5, Niphlod wrote: I actually skipped over this a few times and today I finally reached its place in my playlist for free time... sorry if you seen it before, but I actually learned at least 5 things out of it that I really didn't know of. https://www.youtube.com/watch?**v=OSGv2VnC0gohttps://www.youtube.com/watch?v=OSGv2VnC0go if you want slides https://speakerdeck.com/**pyconslides/transforming-code-** into-beautiful-idiomatic-**python-by-raymond-hettinger-1https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: real time graph
the best option in python is http://mokshaproject.net/ El jueves, 18 de julio de 2013 17:58:54 UTC-5, Vera Moreira escribió: hi everyone, I need some help, does anyone have examples on how to do a real time graph. What I need is a graph to constantly show random numbers, I´m using matplotlib I already have this info: from Antonis Tzorvas an idea for a real-time approach graph you have to go with gifs generated by the several .draw()s and save *.gif in static/images folder but i've just found this one: http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/ from Ovidio Marinho A good option would also google maps. See this done with google maps and web2py. http://mosaico.no-ip.org/mosaico/regionalizacao/regmapa . For graphs with movements that would be better http://mosaico.no-ip.org/mosaico/mortalidadeinfantil/neonatalmun.html?municipio=Agua+Brancabotao=muniind=neonatal graphs are interactive and very good http://www.highcharts.com/ -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] fw:
http://mrcarinsurance.co.za/bbemolh/ljpnjralx Michael Wolfe 7/23/2013 2:16:39 AM -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] DAL select help
In my database, I have a list of items stored. What I am trying to do is select a database row when the list in the database contains the item that I am iterating through in the controller. Do anyone know how this could be done ? model db.define_table('table', Field('field_list','string') ) controller for item in items: #db select here Thanks ! -Trevor -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] cursor closed errors after refactoring code from controller into modules
I had some support functions in a controller. They access DAL objects, particularly databases. I'm using SQLSERVER. I moved these functions to a module. To tell my module about the databases, I store the databases in the model db.py like so current.db1 = db1 and then use a global in the module db1. = current.db1 But now I get class 'pyodbc.ProgrammingError' The cursor's connection has been closed. when an SQLFORM is trying to be displayed. The trace indicates that the error is coming from the new module. The utility functions build SQLGRIDs for example. Apart from moving them to modules, nothing has changed intentionally. I suspect something to do with the way the modules are accessing the DAL variables. This is using git but checked out is R-2.5.1 -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: cursor closed errors after refactoring code from controller into modules
I bet this has got something to do with the models being executed at every interaction and my global code assigned a variable to the database in the module perhaps not being updated. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: cursor closed errors after refactoring code from controller into modules
Ah yes, as the book says: and now all modules imported can access current.auth. current and import create a powerful mechanism to build extensible and reusable modules for your applications. Beware! Given from gluon import current, it is correct to use current.request and any of the other thread local objects but one should never assign them to global variables in the module, such as in request = current.request # WRONG! DANGER! nor one should use it assign class attributes class MyClass: request = current.request # WRONG! DANGER! This is because the thread local object must be extracted at runtime. Global variables instead are defined only once when the model is imported for the first time. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Composite Unique Key
I need to keep composite unique attributes in the db and depending of which certain actions are to be performed. If the pair of that attributes are duplicate then wrong actions will be performed. This is critical for my app. So i need to have composite unique attributes. On Thursday, July 18, 2013 8:58:22 PM UTC+5:30, Massimo Di Pierro wrote: What problem are you trying to solve? On Thursday, 18 July 2013 08:32:07 UTC-5, Apoorve Mohan wrote: Hello All Please guide me on how to create a composite unique key. -- Thanks and Regards Apoorve -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.