[web2py] how to get logout() to launch an ajax call
I want something like this to work, but it doesn't, obviously. def logout(): auth.logout() response.js = 'alert(goodbye world);' from gluon import HTTP HTTP(202) return dict() I've also tried auth.settings.logout_onlogout = [onlogoutfunction] but that's not working for me either. Can anyone shed light on this, please? Thanks.
[web2py] Re: web2py file location
Have you done a right click on web2py.app and then Show Contents from the pop up menu. You should see a Contents directory which you can now explore.
[web2py] Re: web2py 1.99.7 is OUT
In my app, LOAD not work fine with 1.99.7, i'm try a test: 1. copy my view (contain js script), example: index.html to index.load 2. run : .../index.html and then .../index.load Both work well with the 1.99.4, but the second was not correct with 1.99.7 I think this is problem of extension .html .load Vào 11:00:15 UTC+7 Thứ ba, ngày 27 tháng ba năm 2012, Anthony đã viết: Can you describe the problem? Is the below view the index.load view? What is in plugin_app/layout.html? Should that be extended rather than included? Anthony On Monday, March 26, 2012 11:23:34 PM UTC-4, IVINH wrote: I have two views similar but different extension (index.html index. load). Both work well with the 1.99.4, but index.load was not for 1.99.7? My view: {{include 'plugin_app/layout.html'}} script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pieRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.donutRenderer.min.js')}} type=text/javascript/script link href={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.css')}} rel=stylesheet type=text/css / script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.barRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.categoryAxisRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pointLabels.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasTextRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js')}} type=text/javascript/script div style=position:absolute;top:300px;left:150px; {{=content}} /div Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo
[web2py] Re: Problem with GAE and Cloud SQL
I've managed to figure out a solution. (Not sure if it's 100% correct though but it seems to work fine). The GoogleSqlAdapter needs the following change: class GoogleSQLAdapter(UseDatabaseStoredFile,MySQLAdapter): uploads_in_blob = True Hope this helps somebody else. Matt On Tuesday, 27 March 2012 11:21:57 UTC+13, Matt wrote: Hi there, I'm trying to install a web2py application on GAE using Cloud SQL. When I try and submit a form that contains an upload field I get the following exception: dal.py, line 6124, in store os.makedirs(path) AttributeError: 'module' object has no attribute 'makedirs' I'm currently running on web2py-1.99.7-stable. Any suggestions in fix this or is this a bug with the combination of GAE and Cloud SQL? Thanks in advance, Matt
[web2py] Re: DAL Challenge
When working with GAE datastore you want to execute minimum number of queries necessary to avoid delays and limit the use of DB API calls. Fetching comments one by one is not the best option then (even if done with ajax). Probably the most efficient way would be to store the list of comment ids as an attribute of each article entity. Then you could get all comment ids with a single query. Having the ids you could build a list of GAE keys, and fetch all needed comment entities at once. We discussed that recently here: https://groups.google.com/d/topic/web2py/7dvo_jqIR38/discussion I'm also guessing that this might be quite common GAE use case and you might find a better solution already optimised for this on GAE forum. The other option is to show comments only on the article individual page (not on the list of articles). If you use the wrapper for caching, then you could memorize the entire response, so this is very efficient as the views are not rendered but read straight from cache. If you need some extra parametrisation inside the controller you could either move some of the code to a separate function which output is cached or simply cache only the queries: http://web2py.com/books/default/chapter/29/6#Caching-selects
[web2py] Re: Bug? The DAL gives different SQL when query is provided as string.
you're right. the query actually is only the where part, and if you serialize that as a string it loses other attributes necessary to construct the other parts of the query. Now, I don't understand why this is a problem: you can: - cache the results without hitting the database twice using the cache argument of the select - display technically what query produced that results, you can use the ._select() - save the query and then retrieve the results you can, the only caveat is having the condition linking the tables alive and not serialized linkwebpage2comment = (db.comment.page_id == db.webpage.id) cond = (db.comment.id 0) (db.webpage.title == 'FAQ') print cond print 'a' print db(linkwebpage2comment)(cond)._select(db.comment.body) print 'b' cond = str(cond) print db(linkwebpage2comment)(cond)._select(db.comment.body) - serialize full query with the _select() and then retrieve results with executesql() I'm just missing the point: is this functionality really a limit to your application ? Il giorno martedì 27 marzo 2012 01:38:32 UTC+2, Limedrop ha scritto: Hi Niphlod, Thanks for your reply. I'm running 1.99.7 and here's the model: db.define_table('webpage', Field('title'), Field('body', 'text')) db.define_table('comment', Field('page_id', db.webpage), Field('body', 'text')) The issue is when you have an implicit inner join, but where you only want one table in the output. I've found a thread where Massimo says that support for stings in queries is clanky and that you need a db(db.table) or db(db.table.field) to determine which table is needed. http://groups.google.com/group/web2py/browse_thread/thread/2024f660a8981558/d4b0e90d701833bb So I guess it isn't supported? On Mar 27, 12:15 am, Niphlod niph...@gmail.com wrote: damn mobile phone screen I got it, seems a simple join, and for my simple model works without a hitch. can you please post your model and tell what web2py version are you running ? Il giorno lunedì 26 marzo 2012 01:58:31 UTC+2, Limedrop ha scritto: The difference is in the FROM clause. In the second SQL the webpage table is missing. On Mar 26, 12:51 pm, Niphlod niph...@gmail.com wrote: is that because of the extra () ? every time you call db() the where clause gets encapsulated in a pair of parenthesis. db(db.auth_user.id0)(db.auth_user.email==localhost) and db((db.auth_user.id0) (db.auth_user.email==localhost)) give you different raw strings, but the same exact result. Il giorno sabato 24 marzo 2012 21:49:58 UTC+1, Limedrop ha scritto: I've copied this from the bottom of another thread. The DAL gives different SQL when a query is provided in string format. Is this a bug, or should I not expect this to work? See the example below, the first SQL works, the second SQL raises an error. from gluon.dal import Query query = (db.comment.id 0) (db.webpage.title == 'FAQ') (db.comment.page_id == db.webpage.id) query_as_string = str(query) query_from_string = Query(db, query_as_string) print db(query)._select(db.comment.body) SELECT comment.body FROM comment, webpage WHERE (((comment.id 0) AND (webpage.title = 'FAQ')) AND (comment.page_id = webpage.id)); print db(query_from_string)._select(db.comment.body) SELECT comment.body FROM comment WHERE comment.id 0) AND (webpage.title = 'FAQ')) AND (comment.page_id = webpage.id))); Why do this? If the were possible it would enable you to easily save a query in the session. For example: ==Controller 1== query1 = (db.comment.id 0) (db.webpage.title == 'FAQ') (db.comment.page_id == db.webpage.id) session.query = str(query1) ==Controller 2== from gluon.dal import Query query2 = Query(db, session.query) This does NOT work because the DAL gives different SQL for query1 and query2.
[web2py] Re: DAL Challenge
On the cache side. function test(x): if cache.ram('key_%s' % x, 5): return cache.ram('key_%s' % x, 5) else: . cache.ram('key_%s' % x, lambda: x , 5)
[web2py] Re: Using single instance of LibreOffice to convert documents - is this safe?
If this processing is done after the form submission you can delegate that to a background task. Having a queue of tasks end executing them one by one should solve the concurrent access problem. Check out the book section on scheduler: http://web2py.com/books/default/chapter/29/4#Scheduler-%28experimental%29
Re: [web2py] Re: DAL and schema
On 26 March 2012 20:22, adesst adesantoas...@gmail.com wrote: @Johann, i don't know if you would copy paste the diff i've made into PgAdapter, and do some tests and post the results. Pg and Oracle schema works in the same way. I have downloaded and looked at MyDal and the README but I am not sure which 'diff' you refer to. I have looked at your code buit seems a bit risky for my to jump in before I understand fully what you are doing. I will have to spend some time to work through it. I was hoping that you will open a ticket and that the schema-option may become an official part of DAL. Maybe you are working in that direction. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: difference between script src= ... and response.files.append(...)
You *have to* set the response.files first, then include web2py_ajax.html. Look how this is done in the example app: http://code.google.com/p/web2py/source/browse/applications/welcome/views/layout.html Also notice that web2py_ajax.html already includes jquery and web2py.js: http://code.google.com/p/web2py/source/browse/applications/welcome/views/web2py_ajax.html Check the generated HTML to see exactly what scripts you include and in what order and post it here if you still have problems.
[web2py] Re: @auth.requires(lambda: auth.has_membership(VCARD))
You need web2py = 1.99.3 for the lambda to work.
[web2py] Re: Web Development Introduction Based On Web2py
Hey Marco, great tutorial but I got stuck at section 4.3 when we write the first test. when startng the funktional_tests.py! The Program writes ran 0 Tests! 0.0 seconds. Not even the firefox is opening. Anyone knows whats wrong. or what I could do? running Win7 python 2.7 selenium 2.20 thanks for your help.
[web2py] Re: Indentation Error in web2py web file editor
Version 1.99.1 (2011-09-22 16:59:24) stable
[web2py] Check out my new site! (also trouble with routes.py)
I just launched it this morning: http://RosterBrain.com I was having a lot of trouble getting routes.py to work with my form submits so I just stripped it for the time being. Is there anything wrong with the following syntax? routers = dict( BASE = dict( default_application = 'welcome', default_controller = 'default', default_function = 'index' ) ) This would sporadically give me invalid requests on form submits and when using the admin interface. Any ideas? Thanks, Brad
[web2py] Re: Using single instance of LibreOffice to convert documents - is this safe?
Thanks Wilkus. Further research this AM says Libre/Open Office does not multi-thread well. The scheduler is just what I need. On Mar 27, 6:33 am, Wikus van de Merwe dupakrop...@googlemail.com wrote: If this processing is done after the form submission you can delegate that to a background task. Having a queue of tasks end executing them one by one should solve the concurrent access problem. Check out the book section on scheduler:http://web2py.com/books/default/chapter/29/4#Scheduler-%28experimenta...
[web2py] Re: web2py file location
Specifically, /Programming/Python/web2py/applications/sample/ On Tuesday, March 27, 2012 12:35:40 PM UTC+8, genesisk wrote: I would think so too but I don't see any! Is there any other possibilities? Is it hidden somewhere? Please help me out Thanks. On Tuesday, March 27, 2012 11:52:47 AM UTC+9, lyn2py wrote: It would be /Programming/Python/web2py/
Re: [web2py] Check out my new site! (also trouble with routes.py)
On 27 March 2012 13:46, vtgorilla bradley.allmendin...@gmail.com wrote: I just launched it this morning: http://RosterBrain.com it looks impressive but you have got no rugby, cricket and tennis there! :) Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: Check out my new site! (also trouble with routes.py)
Very nice theme! Did you design it yourself? On Tuesday, March 27, 2012 7:46:02 PM UTC+8, vtgorilla wrote: I just launched it this morning: http://RosterBrain.com I was having a lot of trouble getting routes.py to work with my form submits so I just stripped it for the time being. Is there anything wrong with the following syntax? routers = dict( BASE = dict( default_application = 'welcome', default_controller = 'default', default_function = 'index' ) ) This would sporadically give me invalid requests on form submits and when using the admin interface. Any ideas? Thanks, Brad
[web2py] executing javascript after accepting a form
Hi, I'm having problems trying to show a modal window after the user submits correctly a form. I've tried to do it with: def index(): if form.accepts(request.vars): response.js='$( #dialog-message ).dialog({ modal: true });' ... being #dialog-message a div in the same index.html page, but response.js doesn't do anything, and it seems to work only inside componentes. Any idea to get this funcionality working? Thanks.
[web2py] Re: Check out my new site! (also trouble with routes.py)
Yes, but I borrowed inspiration heavily from another design. On Mar 27, 8:15 am, lyn2py lyn...@gmail.com wrote: Very nice theme! Did you design it yourself? On Tuesday, March 27, 2012 7:46:02 PM UTC+8, vtgorilla wrote: I just launched it this morning:http://RosterBrain.com I was having a lot of trouble getting routes.py to work with my form submits so I just stripped it for the time being. Is there anything wrong with the following syntax? routers = dict( BASE = dict( default_application = 'welcome', default_controller = 'default', default_function = 'index' ) ) This would sporadically give me invalid requests on form submits and when using the admin interface. Any ideas? Thanks, Brad
[web2py] Dotcloud now with support for websockets is += 1 service ?
Hi folks, I recently read about websockets and saw a video by Bruno Rocha showing the use of comet and web2py and it seems like a technology with lots of potential. What i would like to know is that if it is possible to replace comet with some server side service provided by dotcloud, so that web2py + postgres/mongo + websockets == 2 services instead of 3, and therefore keep prototyping apps right there on the free dotcloud account. http://techcrunch.com/2012/03/27/open-paas-dotcloud-adds-support-for-websockets-vertical-scaling-and-more/ http://blog.dotcloud.com Thanks in advance.
[web2py] Re: web2py file location
Great! Thank you Ron, and lyn2py for your help! On Tuesday, March 27, 2012 4:19:22 PM UTC+9, Ron McOuat wrote: Have you done a right click on web2py.app and then Show Contents from the pop up menu. You should see a Contents directory which you can now explore.
[web2py] How to allow Image Upload and Border Selection preview before saving to permanent table
Hi Massimo and All, I want a user to be able to upload an image and choose a border to surround it from a choice of images I have in the database. I want them to be able to play around and see what looks best to them before saving their final border choice and uploaded image to the database. I don't know how to do this. Can someone please provide some sample code that will get me going? Thanks a bunch Web2py_Superfan
Re: [web2py] How to allow Image Upload and Border Selection preview before saving to permanent table
There are many ways of doing that, one option is to overlay the image with the border images using CSS background clipping, so you can save the file and the ID of the border, so when you show this in view you choose the border dynamically. If you want to save the image with border on disk then you have to take a look at the PIL documentation. Another option is aviary API http://www.aviary.com/web On Tue, Mar 27, 2012 at 10:04 AM, mwk mwkant...@gmail.com wrote: Hi Massimo and All, I want a user to be able to upload an image and choose a border to surround it from a choice of images I have in the database. I want them to be able to play around and see what looks best to them before saving their final border choice and uploaded image to the database. I don't know how to do this. Can someone please provide some sample code that will get me going? Thanks a bunch Web2py_Superfan -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Rocket errors on importing python library
any updates? On Monday, 26 March 2012 20:03:07 UTC+5:30, Rohan wrote: Web2py Version 1.99.7 (2012-03-04 22:12:08) stable Python 2.7.2+ I am trying to load external library from python ( http://pypi.python.org/pypi/readability-lxml/0.2.3) import urllib2 import readability page = urllib2.urlopen(url) html = page.read() page is fetched properly but in my console I am getting Rocket errors. If i comment 'import readability' or not use this lib then no rocket errors are published. DEBUG:Rocket.Errors.ThreadPool:Examining ThreadPool. 10 threads and 0 Q'd conxions DEBUG:Rocket.Monitor:In receive timed-out connections loop. DEBUG:Rocket.Monitor:Received a timed out connection. DEBUG:Rocket.Monitor:Adding connection to monitor list. DEBUG:Rocket.Errors.ThreadPool:Examining ThreadPool. 10 threads and 0 Q'd conxions ... DEBUG:Rocket.Errors.ThreadPool:Examining ThreadPool. 10 threads and 0 Q'd conxions DEBUG:Rocket.Errors.ThreadPool:Examining ThreadPool. 10 threads and 0 Q'd conxions DEBUG:Rocket.Errors.ThreadPool:Examining ThreadPool. 10 threads and 0 Q'd conxions ... and it get keep on printing same message over and over again. I have not changed any values in rocket.py. Is this expected and Is there any way I can disable this? With this continuous printing actual debug messages are getting lost, making dev really hard.
[web2py] Re: How to allow Image Upload and Border Selection preview before saving to permanent table
Thanks Bruno, The css sounds like a good choice and I use that for final display, trick is I don't know how to get a preview/play around mode first. Do I need to have one db.tablename for the image preview upload and then another db.tablename for the final saved version? Currently I have one db.table for storing the upload image and border choice id, but i dont know how to get it so they can preview and play around with borders first before saving it off. I'm looking at an image preview uploader jquery plugin but I don't know how to configure it on web2py. It calls for some server settings and only shows php sample Would you mind taking a look and letting me know how to configure it if you get a chance? its here: http://css-tricks.com/ajax-image-uploading/ Thanks a ton. On Mar 27, 6:18 am, Bruno Rocha rochacbr...@gmail.com wrote: There are many ways of doing that, one option is to overlay the image with the border images using CSS background clipping, so you can save the file and the ID of the border, so when you show this in view you choose the border dynamically. If you want to save the image with border on disk then you have to take a look at the PIL documentation. Another option is aviary APIhttp://www.aviary.com/web On Tue, Mar 27, 2012 at 10:04 AM, mwk mwkant...@gmail.com wrote: Hi Massimo and All, I want a user to be able to upload an image and choose a border to surround it from a choice of images I have in the database. I want them to be able to play around and see what looks best to them before saving their final border choice and uploaded image to the database. I don't know how to do this. Can someone please provide some sample code that will get me going? Thanks a bunch Web2py_Superfan -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: How to Save Query in Session
Sorry. Stupid me. I responded from my phone and I did not see your entire post. Ignore my post and thanks for the recipe. :-) Massimo On Monday, 26 March 2012 22:47:24 UTC-5, Limedrop wrote: Huh? I'm sorry but I don't understand. On Mar 27, 4:28 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: you cannot. On Monday, 26 March 2012 21:09:49 UTC-5, Limedrop wrote: Just in case any of you want to do this...I've written a routine that enables you to save a Query/Expression object in the session. I have a controller that uses a form to build a relatively complex query and I want other controllers to use that query to generate reports and graphs. I initially explored saving the query in the session as a string, but it just wasn't working for me so I bit the bullet and wrote a seralization routine that takes a Query object and extracts it into a dictionary strucuture. There's another function that does the reverse. It's all here in this slice: http://www.web2pyslices.com/slice/show/1489/save-query-in-session It needs more testing for edge cases (I just don't know enough about the DAL to do all of that). I've written it as a module, but ultimately it would be nice to have something like it as a method within the gluon.dal.Query class itself? Better yet, get the framework to automatically invoke it when saving a Query/Expression to session (like it does for rows).
[web2py] Re: how to get logout() to launch an ajax call
I do not understand what you try to accomplish. What is this line supposed to do? HTTP(202) On Tuesday, 27 March 2012 01:01:23 UTC-5, weheh wrote: I want something like this to work, but it doesn't, obviously. def logout(): auth.logout() response.js = 'alert(goodbye world);' from gluon import HTTP HTTP(202) return dict() I've also tried auth.settings.logout_onlogout = [onlogoutfunction] but that's not working for me either. Can anyone shed light on this, please? Thanks.
[web2py] Re: changelog
Where are you looking for the changelog? On Tuesday, 27 March 2012 02:09:45 UTC-5, RyanTheLeach wrote: Just a heads up, the current stable version according to the download site is 1.99.7 but the changelog only goes up to 1.99.5 :S
[web2py] Re: web2py 1.99.7 is OUT
Please check trunk. I believe this was fixed. On Tuesday, 27 March 2012 03:56:35 UTC-5, IVINH wrote: In my app, LOAD not work fine with 1.99.7, i'm try a test: 1. copy my view (contain js script), example: index.html to index.load 2. run : .../index.html and then .../index.load Both work well with the 1.99.4, but the second was not correct with 1.99.7 I think this is problem of extension .html .load Vào 11:00:15 UTC+7 Thứ ba, ngày 27 tháng ba năm 2012, Anthony đã viết: Can you describe the problem? Is the below view the index.load view? What is in plugin_app/layout.html? Should that be extended rather than included? Anthony On Monday, March 26, 2012 11:23:34 PM UTC-4, IVINH wrote: I have two views similar but different extension (index.html index. load). Both work well with the 1.99.4, but index.load was not for 1.99.7? My view: {{include 'plugin_app/layout.html'}} script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pieRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.donutRenderer.min.js')}} type=text/javascript/script link href={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.css')}} rel=stylesheet type=text/css / script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.barRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.categoryAxisRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pointLabels.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasTextRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js')}} type=text/javascript/script div style=position:absolute;top:300px;left:150px; {{=content}} /div Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo
[web2py] Re: web2py 1.99.7 is OUT
Have you checked trunk or the nightly built. I believe this was fixed? On Tuesday, 27 March 2012 03:56:35 UTC-5, IVINH wrote: In my app, LOAD not work fine with 1.99.7, i'm try a test: 1. copy my view (contain js script), example: index.html to index.load 2. run : .../index.html and then .../index.load Both work well with the 1.99.4, but the second was not correct with 1.99.7 I think this is problem of extension .html .load Vào 11:00:15 UTC+7 Thứ ba, ngày 27 tháng ba năm 2012, Anthony đã viết: Can you describe the problem? Is the below view the index.load view? What is in plugin_app/layout.html? Should that be extended rather than included? Anthony On Monday, March 26, 2012 11:23:34 PM UTC-4, IVINH wrote: I have two views similar but different extension (index.html index. load). Both work well with the 1.99.4, but index.load was not for 1.99.7? My view: {{include 'plugin_app/layout.html'}} script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pieRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.donutRenderer.min.js')}} type=text/javascript/script link href={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.css')}} rel=stylesheet type=text/css / script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.barRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.categoryAxisRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pointLabels.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasTextRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js')}} type=text/javascript/script div style=position:absolute;top:300px;left:150px; {{=content}} /div Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo
[web2py] Re: DAL Challenge
I guess we could modify the cache object to to this automagically. Open a ticket about it. On Monday, 26 March 2012 17:57:15 UTC-5, Udi Milo wrote: Hi guys, I have an entity called article. I want to build the ability to comment on each article. comment at least need (created_on, user_id, article_id, text) I'm running on GAE. On my index page I'm showing 30-60 articles and I want each article to have its comments showing. how would you do it? a. sending the data when the page loads? if so, how? DAL or DAL + cache? b. load without it and use ajax to call each item separately? also, a random cache question: @cache('key',5) function test(x): return x Can I somehow get my parameter x into the key?
[web2py] Re: Indentation Error in web2py web file editor
This should have been fixed with the new web editor. On Tuesday, 27 March 2012 06:00:08 UTC-5, gubbanoa wrote: Version 1.99.1 (2011-09-22 16:59:24) stable
[web2py] Re: Check out my new site! (also trouble with routes.py)
:-) On Tuesday, 27 March 2012 06:46:02 UTC-5, vtgorilla wrote: I just launched it this morning: http://RosterBrain.com I was having a lot of trouble getting routes.py to work with my form submits so I just stripped it for the time being. Is there anything wrong with the following syntax? routers = dict( BASE = dict( default_application = 'welcome', default_controller = 'default', default_function = 'index' ) ) This would sporadically give me invalid requests on form submits and when using the admin interface. Any ideas? Thanks, Brad
[web2py] Re: DAL Challenge
Thanks! I'm trying to follow the logic of your suggestion all the way to rendering it, tell me if you have a better idea: once I hold the list of articles I want to show, I run over the list and get all the comment ids, I issue a large query with the ids of all comments for all articles together, pass it to the view as a large dictionary that has a key of article id and value list of comments and use it like that? On Tuesday, March 27, 2012 6:11:46 AM UTC-4, Wikus van de Merwe wrote: When working with GAE datastore you want to execute minimum number of queries necessary to avoid delays and limit the use of DB API calls. Fetching comments one by one is not the best option then (even if done with ajax). Probably the most efficient way would be to store the list of comment ids as an attribute of each article entity. Then you could get all comment ids with a single query. Having the ids you could build a list of GAE keys, and fetch all needed comment entities at once. We discussed that recently here: https://groups.google.com/d/topic/web2py/7dvo_jqIR38/discussion I'm also guessing that this might be quite common GAE use case and you might find a better solution already optimised for this on GAE forum. The other option is to show comments only on the article individual page (not on the list of articles). If you use the wrapper for caching, then you could memorize the entire response, so this is very efficient as the views are not rendered but read straight from cache. If you need some extra parametrisation inside the controller you could either move some of the code to a separate function which output is cached or simply cache only the queries: http://web2py.com/books/default/chapter/29/6#Caching-selects
[web2py] Re: Check out my new site! (also trouble with routes.py)
Nice. Just added to http://web2py.com/poweredby. Routes looks OK -- is that the entire routes.py file? Any app-specific routes? Anthony On Tuesday, March 27, 2012 7:46:02 AM UTC-4, vtgorilla wrote: I just launched it this morning: http://RosterBrain.com I was having a lot of trouble getting routes.py to work with my form submits so I just stripped it for the time being. Is there anything wrong with the following syntax? routers = dict( BASE = dict( default_application = 'welcome', default_controller = 'default', default_function = 'index' ) ) This would sporadically give me invalid requests on form submits and when using the admin interface. Any ideas? Thanks, Brad
[web2py] Re: executing javascript after accepting a form
Hi, If you are submitting your form via ajax then you can use eval to call a JS function. You can check out the syntax here : http://web2py.com/books/default/chapter/29/11#Eval-target create a JS function showDialog(){ // write code here } in the controller write the return statement as : return showDialog() Hope it helps ! On Tuesday, March 27, 2012 6:01:14 PM UTC+5:30, José L. wrote: Hi, I'm having problems trying to show a modal window after the user submits correctly a form. I've tried to do it with: def index(): if form.accepts(request.vars): response.js='$( #dialog-message ).dialog({ modal: true });' ... being #dialog-message a div in the same index.html page, but response.js doesn't do anything, and it seems to work only inside componentes. Any idea to get this funcionality working? Thanks.
[web2py] Re: how to get logout() to launch an ajax call
I want something like this to work, but it doesn't, obviously. def logout(): auth.logout() response.js = 'alert(goodbye world);' from gluon import HTTP HTTP(202) return dict() I've also tried auth.settings.logout_onlogout = [onlogoutfunction] but that's not working for me either. auth.logout() does a redirect, so the above won't make it to your HTTP(202) call. Also, response.js only works for Ajax requests for components (i.e., client-side calls to web2py_ajax_page(), which is what the LOAD helper does). How is the logout request made from the browser? If it is a regular full page request, your controller needs to return a full page (probably via the typical post-logout redirect), and that page then needs to include the relevant JS code (e.g., in a script element). If the logout request is made via Ajax, you might use the web2py ajax() function with :eval as the third argument, and then simply return the JS you want to execute (:eval tells the ajax() function to execute the returned value as JS rather than put it into a target element in the DOM). Anthony
[web2py] Re: executing javascript after accepting a form
Yes, response.js only works for requests for components (made via a client-side call to web2py_ajax_page(), which is called when you use the LOAD helper in the view). You might try something like this: def index(): ... if form.accepts(request.vars): js = SCRIPT('$(function() {$(#dialog-message).dialog({modal: true});});', _type='text/javascript') else: js = '' ... return dict(form=form, js=js) and then somewhere in your index.html view: {{=js}} Anthony On Tuesday, March 27, 2012 8:31:14 AM UTC-4, José L. wrote: Hi, I'm having problems trying to show a modal window after the user submits correctly a form. I've tried to do it with: def index(): if form.accepts(request.vars): response.js='$( #dialog-message ).dialog({ modal: true });' ... being #dialog-message a div in the same index.html page, but response.js doesn't do anything, and it seems to work only inside componentes. Any idea to get this funcionality working? Thanks.
[web2py] Date field mask or another value
Hi, I want a field (may be string,date or number, no prob) to have a format of MM (valid year and month) or if it is left null, to be 99. How Could I accomplished that? I have tried : Field('A0514_DT_FIN','date',notnull=True, label= 'Dt Fim (MM)', default= '99') and then the check: db.tb0514_bihc_consultor_nivel.A0514_DT_FIN.requires = IS_EMPTY_OR(IS_DATE(format=T('%Y%m'), error_message='formato deve ser MM! ou vazio')) It does not work as 99 is not a valid month and is not a valid year. Any ideas?
[web2py] Re: difference between script src= ... and response.files.append(...)
On Tuesday, March 27, 2012 1:46:50 AM UTC-4, weheh wrote: Ouch, ouch, ouch ... that causes things to really disintegrate! I tend to agree with your assessment that there's an order dependence somewhere. But I don't see it, yet. I think your URL function is wrong -- URL('static', 'js', script) assumes 'static' is the app, 'js' is the controller, and script is the function. Instead, try: URL('static', 'js%s' % script) Actually, for readability, I would do 'js/%s' and remove the leading '/' from your script values. Anthony
[web2py] Re: Problem with GAE and Cloud SQL
Can you submit an issue about this: http://code.google.com/p/web2py/issues/list Anthony On Tuesday, March 27, 2012 5:41:55 AM UTC-4, Matt wrote: I've managed to figure out a solution. (Not sure if it's 100% correct though but it seems to work fine). The GoogleSqlAdapter needs the following change: class GoogleSQLAdapter(UseDatabaseStoredFile,MySQLAdapter): uploads_in_blob = True Hope this helps somebody else. Matt On Tuesday, 27 March 2012 11:21:57 UTC+13, Matt wrote: Hi there, I'm trying to install a web2py application on GAE using Cloud SQL. When I try and submit a form that contains an upload field I get the following exception: dal.py, line 6124, in store os.makedirs(path) AttributeError: 'module' object has no attribute 'makedirs' I'm currently running on web2py-1.99.7-stable. Any suggestions in fix this or is this a bug with the combination of GAE and Cloud SQL? Thanks in advance, Matt
[web2py] Re: Check out my new site! (also trouble with routes.py)
That was the entire file. I only have the one public facing app, so I didn't try to do anything fancy with it yet. I kept having trouble after I took the routes.py out, and I think my issue was that web2py wasn't always figuring out my redirect(URL('pagename'))'s correctly. I explicitly added in the app and controller names to all the redirects and it solved whatever was happening. I had it up for testing on FluxFlex with no problem, but I have it on WebFaction now and that's when the issues started. Thanks for adding to the poweredby site! It's famous now! On Mar 27, 10:35 am, Anthony abasta...@gmail.com wrote: Nice. Just added tohttp://web2py.com/poweredby. Routes looks OK -- is that the entire routes.py file? Any app-specific routes? Anthony On Tuesday, March 27, 2012 7:46:02 AM UTC-4, vtgorilla wrote: I just launched it this morning:http://RosterBrain.com I was having a lot of trouble getting routes.py to work with my form submits so I just stripped it for the time being. Is there anything wrong with the following syntax? routers = dict( BASE = dict( default_application = 'welcome', default_controller = 'default', default_function = 'index' ) ) This would sporadically give me invalid requests on form submits and when using the admin interface. Any ideas? Thanks, Brad
[web2py] Re: Check out my new site! (also trouble with routes.py)
I kept having trouble after I took the routes.py out, and I think my issue was that web2py wasn't always figuring out my redirect(URL('pagename'))'s correctly. I explicitly added in the app and controller names to all the redirects and it solved whatever was happening. When you do URL('pagename') it takes 'pagename' as the function and assumes the current request.application and request.controller as the application and controller (it does *not* assume the default application and controller as specified in routes.py). If you're staying with the same app, you can safely exclude the app from URL(), but it's generally safest to include the controller (makes it easier to understand the code as well). Anthony
[web2py] sqlite to postgres
Hi! I was using sqlite as my database for a few projects, but decided to go to postgres. While to web2py going from one to another is pretty much a connection string that you'll change, there's still one problem remaining. How do I get the data that was on my app (on the sqlite database). On a small application, I managed to do that by exporting a csv file on the old app and importing it on the new one. And that's it. But I have another app that has quite a few tables now... wich means that I'd have to copy several cvs and import them. Question is: isn't there an easier way to do it? (to backup a sqlite database and restore it as postgres in one piece?) If there isn't, that means that worst case scenario, I'll have to export/import csv's corresponding to my tables. I can do that... but there really isn't another way ? Thanks! -- []'s Marco Tulio
[web2py] Customizing a widget
Forgive my N00b-ness - not a web developer (but I've said that before) I have the following code in an app I'm writing: Field('b_or_w', 'string', length=1, widget=SQLFORM.widgets.radio.widget, requires=IS_IN_SET(['b','w']), default='b') How do I customize this so that, instead of *b* and *w* appearing on my form, I can get *black* and *white*, but the former is what is entered into my database? (clear as mud, right?) Thanks, Larry
Re: [web2py] Re: Check out my new site! (also trouble with routes.py)
On Mar 27, 2012, at 7:35 AM, Anthony wrote: Routes looks OK -- is that the entire routes.py file? Any app-specific routes? It does look OK, though keep in mind that setting the default a/c/f in a parametric router is subtly different from setting them outside the router. Do you get any more information in the invalid-request messages? They've been enhanced (mostly, anyway) to give some indication of just what was invalid about them. Anthony On Tuesday, March 27, 2012 7:46:02 AM UTC-4, vtgorilla wrote: I just launched it this morning: http://RosterBrain.com I was having a lot of trouble getting routes.py to work with my form submits so I just stripped it for the time being. Is there anything wrong with the following syntax? routers = dict( BASE = dict( default_application = 'welcome', default_controller = 'default', default_function = 'index' ) ) This would sporadically give me invalid requests on form submits and when using the admin interface. Any ideas?
Re: [web2py] Re: executing javascript after accepting a form
It works perfectly. Thanks very much Anthony. Sushant: I didn't want to change my code to an ajax form. I wanted to keep it the way it was. Thanks for your suggestion anyway. Regards. 2012/3/27 Anthony abasta...@gmail.com: Yes, response.js only works for requests for components (made via a client-side call to web2py_ajax_page(), which is called when you use the LOAD helper in the view). You might try something like this: def index(): ... if form.accepts(request.vars): js = SCRIPT('$(function() {$(#dialog-message).dialog({modal: true});});', _type='text/javascript') else: js = '' ... return dict(form=form, js=js) and then somewhere in your index.html view: {{=js}} Anthony On Tuesday, March 27, 2012 8:31:14 AM UTC-4, José L. wrote: Hi, I'm having problems trying to show a modal window after the user submits correctly a form. I've tried to do it with: def index(): if form.accepts(request.vars): response.js='$( #dialog-message ).dialog({ modal: true });' ... being #dialog-message a div in the same index.html page, but response.js doesn't do anything, and it seems to work only inside componentes. Any idea to get this funcionality working? Thanks.
Re: [web2py] Customizing a widget
Field('b_or_w', 'string', length=1, widget=SQLFORM.widgets.radio.widget, requires=IS_IN_SET(*[('b', 'black'),('w', 'white')]*), default='b') On Tue, Mar 27, 2012 at 12:56 PM, Larry Wapnitsky la...@kvetsch.com wrote: Field('b_or_w', 'string', length=1, widget=SQLFORM.widgets.radio.widget, requires=IS_IN_SET(['b','w']), default='b') -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Customizing a widget
You can use a dictionary, list of tuples, or a separate labels argument: IS_IN_SET({'b':'black', 'w':'white'}) IS_IN_SET([('b', 'black'), ('w', 'white')]) IS_IN_SET(['b', 'w'], labels=['black', 'white']) Anthony On Tuesday, March 27, 2012 11:56:48 AM UTC-4, Larry Wapnitsky wrote: Forgive my N00b-ness - not a web developer (but I've said that before) I have the following code in an app I'm writing: Field('b_or_w', 'string', length=1, widget=SQLFORM.widgets.radio.widget, requires=IS_IN_SET(['b','w']), default='b') How do I customize this so that, instead of *b* and *w* appearing on my form, I can get *black* and *white*, but the former is what is entered into my database? (clear as mud, right?) Thanks, Larry
[web2py] Re: sqlite to postgres
http://web2py.com/books/default/chapter/29/6#CSV-(all-tables-at-once) On Tuesday, March 27, 2012 11:26:17 AM UTC-4, Marco Tulio wrote: Hi! I was using sqlite as my database for a few projects, but decided to go to postgres. While to web2py going from one to another is pretty much a connection string that you'll change, there's still one problem remaining. How do I get the data that was on my app (on the sqlite database). On a small application, I managed to do that by exporting a csv file on the old app and importing it on the new one. And that's it. But I have another app that has quite a few tables now... wich means that I'd have to copy several cvs and import them. Question is: isn't there an easier way to do it? (to backup a sqlite database and restore it as postgres in one piece?) If there isn't, that means that worst case scenario, I'll have to export/import csv's corresponding to my tables. I can do that... but there really isn't another way ? Thanks! -- []'s Marco Tulio
Re: [web2py] Re: Customizing a widget
Thank you, Bruno and Anthony. Perfect. On 3/27/2012 12:06 PM, Anthony wrote: You can use a dictionary, list of tuples, or a separate labels argument: IS_IN_SET({'b':'black', 'w':'white'}) IS_IN_SET([('b', 'black'), ('w', 'white')]) IS_IN_SET(['b', 'w'], labels=['black', 'white']) Anthony On Tuesday, March 27, 2012 11:56:48 AM UTC-4, Larry Wapnitsky wrote: Forgive my N00b-ness - not a web developer (but I've said that before) I have the following code in an app I'm writing: Field('b_or_w', 'string', length=1, widget=SQLFORM.widgets.radio.widget, requires=IS_IN_SET(['b','w']), default='b') How do I customize this so that, instead of *b* and *w* appearing on my form, I can get *black* and *white*, but the former is what is entered into my database? (clear as mud, right?) Thanks, Larry
[web2py] problem with encoding in javascript from the server
This is not strictly a web2py issue. Though it is a problem that apps dealing with some character sets must deal with. I confess that the source of my problem is that I have been delaying reading-up on encoding and decoding far too long. But I'm pressed for time and I'm sure that this is a simple issue to many of you. Here's is it (slightly embarrassed): It works if I hardcode a string in a script helper: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=['olá', 'olé']);}) % dict(...images=images), _language='javascript') It also works if (getting titles from the db, where it is stored as 'olá','olé' - note single quotes included): SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=[%(titles)]);}) % dict(images=images, titles=titles), _language='javascript') However, if I try to parse from the db (where titles is stored as olá|olé, such as: titles = [title.strip() for title in titles.split('|')] The jQuery string is adequately adjusted to receive a list: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=%(titles));}) % dict(images=images, titles=titles), _language='javascript') All works but when rendered by the browser I do not get: Olá instead I get: olá The same for Olé and olé My goal is to have a user supplied string, such as: olá|olé BTW this is a prettyPhoto widget I developed for plugin_wiki, which is awesome :-) Txs for the help, Miguel
[web2py] Re: problem with encoding in javascript from the server
No dia 27 de Mar de 2012 16:13, Miguel Lopes mig.e.lo...@gmail.com escreveu: BTW this is a prettyPhoto widget I developed for plugin_wiki, which is awesome :-) I mean plugin_wiki is awesome :-) lol
[web2py] Re: sqlite to postgres
On Tuesday, March 27, 2012 11:26:17 AM UTC-4, Marco Tulio wrote: How do I get the data that was on my app (on the sqlite database). Web2py comes with scripts/cpdb.py, which copies databases from one connection string to another with lots of other goodies. see http://web2py.com/books/default/chapter/29/6#Copy-data-from-one-db-into-another (if it doesn't get you to the right place, look for cpdb in the page)
[web2py] Fake_migrate with auth
How do I do a fake_migrate with the auth table so I don't get the following error? I know the table exists already I just pushed some major changes to my server and now when I run the app I get the tables already exists error. I really don't want to have to delete that table again, consider I have hundred people testing the site.. relation auth_group already exists -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Fake_migrate with auth
Tried fake_migrate_all which allowed the page to loaded. However now when I try to login I get an error that auth_user.username doesn't exist. When I go to the database administration in admin, I get the following error when clicking on auth_user, class 'psycopg2.InternalError' current transaction is aborted, commands ignored until end of transaction block On Tue, Mar 27, 2012 at 10:27 AM, Bruce Wade bruce.w...@gmail.com wrote: How do I do a fake_migrate with the auth table so I don't get the following error? I know the table exists already I just pushed some major changes to my server and now when I run the app I get the tables already exists error. I really don't want to have to delete that table again, consider I have hundred people testing the site.. relation auth_group already exists -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: problem with encoding in javascript from the server
What's the character set in your browser? On Tuesday, March 27, 2012 9:13:14 AM UTC-7, miguel wrote: This is not strictly a web2py issue. Though it is a problem that apps dealing with some character sets must deal with. I confess that the source of my problem is that I have been delaying reading-up on encoding and decoding far too long. But I'm pressed for time and I'm sure that this is a simple issue to many of you. Here's is it (slightly embarrassed): It works if I hardcode a string in a script helper: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=['olá', 'olé']);}) % dict(...images=images), _language='javascript') It also works if (getting titles from the db, where it is stored as 'olá','olé' - note single quotes included): SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=[%(titles)]);}) % dict(images=images, titles=titles), _language='javascript') However, if I try to parse from the db (where titles is stored as olá|olé, such as: titles = [title.strip() for title in titles.split('|')] The jQuery string is adequately adjusted to receive a list: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=%(titles));}) % dict(images=images, titles=titles), _language='javascript') All works but when rendered by the browser I do not get: Olá instead I get: olá The same for Olé and olé My goal is to have a user supplied string, such as: olá|olé BTW this is a prettyPhoto widget I developed for plugin_wiki, which is awesome :-) Txs for the help, Miguel
[web2py] Re: problem with encoding in javascript from the server
Check the meta tag - if it's UTF-8, that's most likely the issue. You can try ISO-8859-1 and see if that works for you. On Tuesday, March 27, 2012 10:41:53 AM UTC-7, Derek wrote: What's the character set in your browser? On Tuesday, March 27, 2012 9:13:14 AM UTC-7, miguel wrote: This is not strictly a web2py issue. Though it is a problem that apps dealing with some character sets must deal with. I confess that the source of my problem is that I have been delaying reading-up on encoding and decoding far too long. But I'm pressed for time and I'm sure that this is a simple issue to many of you. Here's is it (slightly embarrassed): It works if I hardcode a string in a script helper: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=['olá', 'olé']);}) % dict(...images=images), _language='javascript') It also works if (getting titles from the db, where it is stored as 'olá','olé' - note single quotes included): SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=[%(titles)]);}) % dict(images=images, titles=titles), _language='javascript') However, if I try to parse from the db (where titles is stored as olá|olé, such as: titles = [title.strip() for title in titles.split('|')] The jQuery string is adequately adjusted to receive a list: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=%(titles));}) % dict(images=images, titles=titles), _language='javascript') All works but when rendered by the browser I do not get: Olá instead I get: olá The same for Olé and olé My goal is to have a user supplied string, such as: olá|olé BTW this is a prettyPhoto widget I developed for plugin_wiki, which is awesome :-) Txs for the help, Miguel
[web2py] Re: problem with encoding in javascript from the server
Sorry, I am slow today. your meta charset tag in your layout - it's in the header. If it's UTF-8, it's wrong. On Tuesday, March 27, 2012 10:46:27 AM UTC-7, Derek wrote: Check the meta tag - if it's UTF-8, that's most likely the issue. You can try ISO-8859-1 and see if that works for you. On Tuesday, March 27, 2012 10:41:53 AM UTC-7, Derek wrote: What's the character set in your browser? On Tuesday, March 27, 2012 9:13:14 AM UTC-7, miguel wrote: This is not strictly a web2py issue. Though it is a problem that apps dealing with some character sets must deal with. I confess that the source of my problem is that I have been delaying reading-up on encoding and decoding far too long. But I'm pressed for time and I'm sure that this is a simple issue to many of you. Here's is it (slightly embarrassed): It works if I hardcode a string in a script helper: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=['olá', 'olé']);}) % dict(...images=images), _language='javascript') It also works if (getting titles from the db, where it is stored as 'olá','olé' - note single quotes included): SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=[%(titles)]);}) % dict(images=images, titles=titles), _language='javascript') However, if I try to parse from the db (where titles is stored as olá|olé, such as: titles = [title.strip() for title in titles.split('|')] The jQuery string is adequately adjusted to receive a list: SCRIPT( ... jQuery.prettyPhoto.open(images=%(images)s,titles=%(titles));}) % dict(images=images, titles=titles), _language='javascript') All works but when rendered by the browser I do not get: Olá instead I get: olá The same for Olé and olé My goal is to have a user supplied string, such as: olá|olé BTW this is a prettyPhoto widget I developed for plugin_wiki, which is awesome :-) Txs for the help, Miguel
[web2py] Re: changelog
The link right on the download page. http://web2py.com/examples/default/download http://web2py.com/examples/default/changelog On Tuesday, March 27, 2012 7:10:34 AM UTC-7, Massimo Di Pierro wrote: Where are you looking for the changelog? On Tuesday, 27 March 2012 02:09:45 UTC-5, RyanTheLeach wrote: Just a heads up, the current stable version according to the download site is 1.99.7 but the changelog only goes up to 1.99.5 :S
Re: [web2py] Re: problem with encoding in javascript from the server
No dia 27 de Mar de 2012 17:41, Derek sp1d...@gmail.com escreveu: What's the character set in your browser? I have safari set for default. But I don't think that's the problem, because if I hardcode the string there is no problem. I'm certainly missing something, but the culprit operation seems to be the string parsing, not the browser rendering: titles = [title.strip() for title in titles.split('|')] Miguel
Re: [web2py] Re: problem with encoding in javascript from the server
No dia 27 de Mar de 2012 17:46, Derek sp1d...@gmail.com escreveu: Check the meta tag - if it's UTF-8, that's most likely the issue. You can try ISO-8859-1 and see if that works for you. Txs. Will also check that.
Re: [web2py] Re: Fake_migrate with auth
I think the best way to avoid this is to define custom auth tables and then set them to migrate=false. Richard On Tue, Mar 27, 2012 at 1:40 PM, Bruce Wade bruce.w...@gmail.com wrote: Tried fake_migrate_all which allowed the page to loaded. However now when I try to login I get an error that auth_user.username doesn't exist. When I go to the database administration in admin, I get the following error when clicking on auth_user, class 'psycopg2.InternalError' current transaction is aborted, commands ignored until end of transaction block On Tue, Mar 27, 2012 at 10:27 AM, Bruce Wade bruce.w...@gmail.com wrote: How do I do a fake_migrate with the auth table so I don't get the following error? I know the table exists already I just pushed some major changes to my server and now when I run the app I get the tables already exists error. I really don't want to have to delete that table again, consider I have hundred people testing the site.. relation auth_group already exists -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Date field mask or another value
Does it need to be a date field? It not have a day so it will create some problems. You can make it a string field Field('A0514_DT_FIN',requires=IS_EMPTY_OR(IS_MATCH('\d{6}'))) On Tuesday, 27 March 2012 10:05:11 UTC-5, Adriano Almeida wrote: Hi, I want a field (may be string,date or number, no prob) to have a format of MM (valid year and month) or if it is left null, to be 99. How Could I accomplished that? I have tried : Field('A0514_DT_FIN','date',notnull=True, label= 'Dt Fim (MM)', default= '99') and then the check: db.tb0514_bihc_consultor_nivel.A0514_DT_FIN.requires = IS_EMPTY_OR(IS_DATE(format=T('%Y%m'), error_message='formato deve ser MM! ou vazio')) It does not work as 99 is not a valid month and is not a valid year. Any ideas?
[web2py] Re: changelog
My bad. The header should have been 1.99.5-1.99.7. The change log is the same. .7 was released two days after .4 to fix some bugs but no new features. On Tuesday, 27 March 2012 12:59:21 UTC-5, Derek wrote: The link right on the download page. http://web2py.com/examples/default/download http://web2py.com/examples/default/changelog On Tuesday, March 27, 2012 7:10:34 AM UTC-7, Massimo Di Pierro wrote: Where are you looking for the changelog? On Tuesday, 27 March 2012 02:09:45 UTC-5, RyanTheLeach wrote: Just a heads up, the current stable version according to the download site is 1.99.7 but the changelog only goes up to 1.99.5 :S
Re: [web2py] Re: problem with encoding in javascript from the server
Right, I was asking what the page shows as the character set. I was not so good at asking for what I wanted. On Tuesday, March 27, 2012 11:28:37 AM UTC-7, miguel wrote: No dia 27 de Mar de 2012 17:41, Derek sp1d...@gmail.com escreveu: What's the character set in your browser? I have safari set for default. But I don't think that's the problem, because if I hardcode the string there is no problem. I'm certainly missing something, but the culprit operation seems to be the string parsing, not the browser rendering: titles = [title.strip() for title in titles.split('|')] Miguel
Re: [web2py] Re: DAL or SQL?
On Sun, 25 Mar 2012 16:41:09 -0700 (PDT), niph...@gmail.com said: Doh, you're right. All the datetime api on fields are extracting, not converting the actual value Yes, and I've also found that, with Sqlite at least, web2py doesn't carry out datetime arithmetic correctly within the DAL (not entirely Web2py's fault). Rather than have another field in the table for duration, which could easily get out of sync with start/stop times, I created a view instead: CREATE VIEW v_durations as select id,f_date,f_start,f_end,strftime('%s',t_periods.f_end)-strftime('%s',t_periods.f_start) as f_duration,f_category,f_task,f_user from t_periods; I use that view, rather than the t_periods table, for reporting. It's defined in the model as migrate=false, and it works really well. If I move to another database (probably MySQL for production), I only need to create one new view. This way, edits to the table are no problem, and the duration from the view is always correct. -- You can have everything in life you want if you help enough other people get what they want - Zig Ziglar. Who did you help today?
Re: [web2py] Re: Fake_migrate with auth
Yes I think you are probably right. It is a shame that we can use auth for this kind of situation. On Tue, Mar 27, 2012 at 11:34 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: I think the best way to avoid this is to define custom auth tables and then set them to migrate=false. Richard On Tue, Mar 27, 2012 at 1:40 PM, Bruce Wade bruce.w...@gmail.com wrote: Tried fake_migrate_all which allowed the page to loaded. However now when I try to login I get an error that auth_user.username doesn't exist. When I go to the database administration in admin, I get the following error when clicking on auth_user, class 'psycopg2.InternalError' current transaction is aborted, commands ignored until end of transaction block On Tue, Mar 27, 2012 at 10:27 AM, Bruce Wade bruce.w...@gmail.comwrote: How do I do a fake_migrate with the auth table so I don't get the following error? I know the table exists already I just pushed some major changes to my server and now when I run the app I get the tables already exists error. I really don't want to have to delete that table again, consider I have hundred people testing the site.. relation auth_group already exists -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] unable to parse csv file 'NoneType' object is unsubscriptable with list:reference type field
Hello, Is it possible the table csv import method be broken? When I use list:reference type field I can't import back a exported CSV with the appadmin. I don't understand where the None value could come from... When I try to implement my own csv import function base on this thread : https://groups.google.com/forum/?fromgroups#!topic/web2py/lDi0lLK_Wm0 That work fine, until I try to import data with list:reference type field (|id| or |id|id|, etc.) I get this traceback : for v in bar_decode_string(value)] TypeError: 'NoneType' object is unsubscriptable - Function argument list (field=gluon.dal.Field object, value='|35|1|', id_map=None) Code listing 5683. 5684. 5685. 5686. 5687. 5688. 5689. 5690. 5691. 5692. elif field.type.startswith('list:string'): value = bar_decode_string(value) elif field.type.startswith(list_reference_s): ref_table = field.type[len(list_reference_s):].strip() value = [id_map[ref_table][int(v)] \ for v in bar_decode_string(value)] elif field.type.startswith('list:'): value = bar_decode_integer(value) elif id_map and field.type.startswith('reference'): try: Variablesglobal bar_decode_stringfunction bar_decode_stringvalue'|35|1|'v '35' What is exactly id_map? I think problem is coming from there... Thanks Richard
Re: [web2py] unable to parse csv file 'NoneType' object is unsubscriptable with list:reference type field
Seems related : https://groups.google.com/forum/#!topic/web2py/nYKsFPumXk0 Le mardi 27 mars 2012 15:20:27 UTC-4, Richard a écrit : Hello, Is it possible the table csv import method be broken? When I use list:reference type field I can't import back a exported CSV with the appadmin. I don't understand where the None value could come from... When I try to implement my own csv import function base on this thread : https://groups.google.com/forum/?fromgroups#!topic/web2py/lDi0lLK_Wm0 That work fine, until I try to import data with list:reference type field (|id| or |id|id|, etc.) I get this traceback : for v in bar_decode_string(value)] TypeError: 'NoneType' object is unsubscriptable - Function argument list (field=gluon.dal.Field object, value='|35|1|', id_map=None) Code listing 5683. 5684. 5685. 5686. 5687. 5688. 5689. 5690. 5691. 5692. elif field.type.startswith('list:string'): value = bar_decode_string(value) elif field.type.startswith(list_reference_s): ref_table = field.type[len(list_reference_s):].strip() value = [id_map[ref_table][int(v)] \ for v in bar_decode_string(value)] elif field.type.startswith('list:'): value = bar_decode_integer(value) elif id_map and field.type.startswith('reference'): try: Variables global bar_decode_string function bar_decode_string value'|35|1|' v '35' What is exactly id_map? I think problem is coming from there... Thanks Richard
Re: [web2py] unable to parse csv file 'NoneType' object is unsubscriptable with list:reference type field
This one to : https://groups.google.com/forum/?fromgroups#!topic/web2py/H_QqV2g8IgQ I experimented the problem with 1.99.4 and 1.99.7 What I understand so far is that id_map get None by default, so when it get here : [id_map[ref_table][int(v)] \ for v in bar_decode_string('|35|1|')] It clears that it will raise the exception... I try to call my import function like this : def import_csv(table, file): table.import_from_csv_file(file, id_map = {}) Noting better. Please help. Richard Le mardi 27 mars 2012 15:45:50 UTC-4, Richard a écrit : Seems related : https://groups.google.com/forum/#!topic/web2py/nYKsFPumXk0 Le mardi 27 mars 2012 15:20:27 UTC-4, Richard a écrit : Hello, Is it possible the table csv import method be broken? When I use list:reference type field I can't import back a exported CSV with the appadmin. I don't understand where the None value could come from... When I try to implement my own csv import function base on this thread : https://groups.google.com/forum/?fromgroups#!topic/web2py/lDi0lLK_Wm0 That work fine, until I try to import data with list:reference type field (|id| or |id|id|, etc.) I get this traceback : for v in bar_decode_string(value)] TypeError: 'NoneType' object is unsubscriptable - Function argument list (field=gluon.dal.Field object, value='|35|1|', id_map=None) Code listing 5683. 5684. 5685. 5686. 5687. 5688. 5689. 5690. 5691. 5692. elif field.type.startswith('list:string'): value = bar_decode_string(value) elif field.type.startswith(list_reference_s): ref_table = field.type[len(list_reference_s):].strip() value = [id_map[ref_table][int(v)] \ for v in bar_decode_string(value)] elif field.type.startswith('list:'): value = bar_decode_integer(value) elif id_map and field.type.startswith('reference'): try: Variables global bar_decode_string function bar_decode_string value'|35|1|' v '35' What is exactly id_map? I think problem is coming from there... Thanks Richard
[web2py] pop-up verification
Last question of the day, I promise... So, I have data that exists in my database. If a user enters a value that already exists, I want to prompt them with an are you sure? type question before the function that adds/updates the data continues. How do I interrupt my current function to do so without leaving the page and losing data? Thanks, Larry
[web2py] Re: Issue Tracking System Survey
Where is the issue tracking system in case I need to log an issue? On Tuesday, October 4, 2011 1:29:52 PM UTC-5, petrasadi wrote: I am currently working on a project meant to improve the current Web2Py Issue Tracking System. Are there any features that could use touch-ups or new features that should be implemented? Looking forward to your suggestions.
Re: [web2py] pop-up verification
I think you will have to write a ajax call back to the database that will look if the data already existing if so trigger your message if not let it go. There is the validators but they will not let pass the duplicated data if you have set your field to unique. Richard On Tue, Mar 27, 2012 at 4:14 PM, Larry G. Wapnitsky la...@kvetsch.comwrote: Last question of the day, I promise... So, I have data that exists in my database. If a user enters a value that already exists, I want to prompt them with an are you sure? type question before the function that adds/updates the data continues. How do I interrupt my current function to do so without leaving the page and losing data? Thanks, Larry
[web2py] Re: Broken application after upgrade.
No, After much trying to no avail these are the symptoms: All Controllers, Views, Tables show up in AppAdmin. No ability to administrate the DB from AppAdmin. No ability to connect to any application while the affected application is installed. I think somehow my database might have been corrupted. I was doing some stupid testing and one of my .table files was corrupted so I deleted it. They only store database structure right?... On Mar 26, 10:28 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: If this for a specific application? A specific action? On Monday, 26 March 2012 21:00:33 UTC-5, web-dev-m wrote: I am having a strange problem. I just upgraded from 1.99.2 to 1.99.7 (manually by running update-web2py.sh from /scripts as the link was not working in the application). I can see my application and all the files are there, but when I try to get into any of the files it doesn't load. It just hangs at connecting no matter what controller I try to access. I then packed it, and reinstalled via Web2py admin interface. Still no luck. Just before I started having this problem, I was having another wierd problem. I was getting an operational error:no such table after just creating a simple table like I have done many many times. Any suggestions?
[web2py] Re: Issue Tracking System Survey
On Tuesday, March 27, 2012 4:18:33 PM UTC-4, Bill Thayer wrote: Where is the issue tracking system in case I need to log an issue? http://code.google.com/p/web2py/issues/list
[web2py] New Google Groups functionality
Google Groups has added some new functionality that enables us to distinguish between discussion, question, and announcement posts. If you use the (new) web interface to make a post (https://groups.google.com/forum/?fromgroups#!forum/web2py), it will now default to a question post. However, you can easily change that to discussion or announcement once you are creating the post. It is also now possible to add a comma separated list of tags to each post. Enjoy. Anthony
[web2py] Re: New Google Groups functionality
Also, in the web interface, you will notice an icon immediately to the left of the thread title indicating whether it is a discussion, question, or announcement. On Tuesday, March 27, 2012 4:50:49 PM UTC-4, Anthony wrote: Google Groups has added some new functionality that enables us to distinguish between discussion, question, and announcement posts. If you use the (new) web interface to make a post ( https://groups.google.com/forum/?fromgroups#!forum/web2py), it will now default to a question post. However, you can easily change that to discussion or announcement once you are creating the post. It is also now possible to add a comma separated list of tags to each post. Enjoy. Anthony
[web2py] Re: Question about 0.py
I just started a brand-new app through the wizard and plugged in my mysql database settings during the setup process. I see that in 0.py I have the following : settings.database_uri = 'mysql://user:pass@server/database' (i censored the original) but in db.py it says: if not request.env.web2py_runtime_gae: ## if NOT running on Google App Engine use SQLite or other DB db = DAL('sqlite://storage.sqlite') after I changed the db= line to what was in settings.database the mysql tables showed up. Before that I did not see them. Is this a bug or was there something else I have to toggle after going through the app wizard? Thanks! Mike On Monday, February 7, 2011 8:48:09 PM UTC-5, Massimo Di Pierro wrote: 0.py is not a web2py file. It is created by the wizard. If a variable is not used is a bug in the wizard. Massimo On Feb 7, 7:21 pm, devGS vitali@geniestills.com wrote: I saw that object 'settings' is defined at 0.py, but I didn't see any usage of 'settings'. For instance, in db.py, instead of reusing the 0.py's 'settings', the stings are redefined, even though realize about some modules that use 'settings' instead of db.py set variables. Can this point be cleared please? Why is there mail.settings.XYZ = '...' instead of 'mail.settings.XYZ = settings.XYZ'? Thanks.
Re: [web2py] unable to parse csv file 'NoneType' object is unsubscriptable with list:reference type field
Same thing with trunk... Richard On Tue, Mar 27, 2012 at 3:52 PM, Richard ml.richard.vez...@gmail.comwrote: This one to : https://groups.google.com/forum/?fromgroups#!topic/web2py/H_QqV2g8IgQ I experimented the problem with 1.99.4 and 1.99.7 What I understand so far is that id_map get None by default, so when it get here : [id_map[ref_table][int(v)] \ for v in bar_decode_string('|35|1|')] It clears that it will raise the exception... I try to call my import function like this : def import_csv(table, file): table.import_from_csv_file(file, id_map = {}) Noting better. Please help. Richard Le mardi 27 mars 2012 15:45:50 UTC-4, Richard a écrit : Seems related : https://groups.google.com/**forum/#!topic/web2py/** nYKsFPumXk0 https://groups.google.com/forum/#!topic/web2py/nYKsFPumXk0 Le mardi 27 mars 2012 15:20:27 UTC-4, Richard a écrit : Hello, Is it possible the table csv import method be broken? When I use list:reference type field I can't import back a exported CSV with the appadmin. I don't understand where the None value could come from... When I try to implement my own csv import function base on this thread : https://groups.google.com/**forum/?fromgroups#!topic/** web2py/lDi0lLK_Wm0https://groups.google.com/forum/?fromgroups#!topic/web2py/lDi0lLK_Wm0 That work fine, until I try to import data with list:reference type field (|id| or |id|id|, etc.) I get this traceback : for v in bar_decode_string(value)] TypeError: 'NoneType' object is unsubscriptable - Function argument list (field=gluon.dal.Field object, value='|35|1|', id_map=None) Code listing 5683. 5684. 5685. 5686. 5687. 5688. 5689. 5690. 5691. 5692. elif field.type.startswith('list:**string'): value = bar_decode_string(value) elif field.type.startswith(list_**reference_s): ref_table = field.type[len(list_reference_**s):].strip() value = [id_map[ref_table][int(v)] \ for v in bar_decode_string(value)] elif field.type.startswith('list:')**: value = bar_decode_integer(value) elif id_map and field.type.startswith('**reference'): try: Variables global bar_decode_string function bar_decode_string value'|35|1|' v '35' What is exactly id_map? I think problem is coming from there... Thanks Richard
[web2py] LinkedIn Integration - Tutorial needed
Hi, For a while now I've been trying to get the linkedIn module to work as described in the book and in different posts around the web, without success. Can someone who has done it please describe how this can be achieved? Thanks!
[web2py] skeleton.css pre resetting possible css mistake
With web2py 1.99.7 i try to display preformatted code between pre /pre but the result does not look like preformatted text should look like. . In skeleton.css on line 28 i found that pre is being reset to default (inherit) font, I think this might be the cause. After I removed pre from line 28 in skeleton.css it looked ok. Can somebody confirm this is a mistake ?
[web2py] Form validation on passwords
Hi group, How do I enforce some simple validation for passwords matching on a form in a controller? All I want to do is to check the second password is the same as the first one, and here is some code I've come up so far: form = SQLFORM.factory( Field('email', requires=IS_NOT_EMPTY()), Field('pwd', requires=[IS_NOT_EMPTY(), IS_STRONG(min=6, special=0, upper=1 ), CRYPT()]), Field('re_pwd', requires=IS_MATCH(???))) I am attempting to use the validator 'IS_MATCH()' for the second password, but not sure how I reference the the input in the first password field of the same form. Any suggestion would be welcome. Thanks.
[web2py] Re: New Google Groups functionality
One more thing -- on the far right of the post editing menu is a { } icon that allows you to format text as code. For example: def index(): return dict(message='Hello World') Anthony On Tuesday, March 27, 2012 4:53:01 PM UTC-4, Anthony wrote: Also, in the web interface, you will notice an icon immediately to the left of the thread title indicating whether it is a discussion, question, or announcement. On Tuesday, March 27, 2012 4:50:49 PM UTC-4, Anthony wrote: Google Groups has added some new functionality that enables us to distinguish between discussion, question, and announcement posts. If you use the (new) web interface to make a post ( https://groups.google.com/forum/?fromgroups#!forum/web2py), it will now default to a question post. However, you can easily change that to discussion or announcement once you are creating the post. It is also now possible to add a comma separated list of tags to each post. Enjoy. Anthony
[web2py] Re: Form validation on passwords
Here's how auth.register() does it (slightly edited): requires=IS_EXPR('value==%s' % repr(request.vars.get('password', None)), error_message=Password fields don't match) Anthony On Tuesday, March 27, 2012 5:40:29 PM UTC-4, cyan wrote: Hi group, How do I enforce some simple validation for passwords matching on a form in a controller? All I want to do is to check the second password is the same as the first one, and here is some code I've come up so far: form = SQLFORM.factory( Field('email', requires=IS_NOT_EMPTY()), Field('pwd', requires=[IS_NOT_EMPTY(), IS_STRONG(min=6, special=0, upper= 1), CRYPT()]), Field('re_pwd', requires=IS_MATCH(???))) I am attempting to use the validator 'IS_MATCH()' for the second password, but not sure how I reference the the input in the first password field of the same form. Any suggestion would be welcome. Thanks.
[web2py] Re: Broken application after upgrade.
It's weird that one app would affect other apps since usually they are pretty insulated from each other. Deleting .table files can be a problem. Was the app under development and you wouldn't care if you erased the DB? If so (and it's SQLite), you can delete all the files in the database directory and start with a fresh new DB. When you say that it's not working, how exactly does it behave? Do you get any error messages? Have you touched the routes.py file? Another thing to consider is downloading a fresh version of Web2py and then copying the applications over one-by-one.
[web2py] Re: pop-up verification
I have a Jquery dialog on one of my pages that I think does something similar. So when the user clicks list, the dialog pops up and then when they press Ok it sets the window.location to a new URL. But I'm guessin you probably need to do a POST which I'm not quite sure how that would work. a id=opener href=#list/a $(function() { $(#dialog-form).dialog({ autoOpen: false, show: 'fade', hide: 'fade', modal: true, resizable: false, width: 200, minHeight: 190, buttons: { Close: function() { $(this).dialog(close); }, Ok: function() { window.location = {{=URL('ebay', 'api', args=['list', item.id])}}?ebay_category= + document.getElementById(ebay_category).value; } } }); $('#opener').click(function(e) { e.preventDefault(); $dialog.dialog('open'); }); });
Re: [web2py] Re: New Google Groups functionality
is there some markup for doing that on emails? On Tue, Mar 27, 2012 at 6:42 PM, Anthony abasta...@gmail.com wrote: One more thing -- on the far right of the post editing menu is a { } icon that allows you to format text as code. For example: def index(): return dict(message='Hello World') Anthony On Tuesday, March 27, 2012 4:53:01 PM UTC-4, Anthony wrote: Also, in the web interface, you will notice an icon immediately to the left of the thread title indicating whether it is a discussion, question, or announcement. On Tuesday, March 27, 2012 4:50:49 PM UTC-4, Anthony wrote: Google Groups has added some new functionality that enables us to distinguish between discussion, question, and announcement posts. If you use the (new) web interface to make a post (https://groups.google.com/** forum/?fromgroups#!forum/**web2pyhttps://groups.google.com/forum/?fromgroups#%21forum/web2py), it will now default to a question post. However, you can easily change that to discussion or announcement once you are creating the post. It is also now possible to add a comma separated list of tags to each post. Enjoy. Anthony -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: difference between script src= ... and response.files.append(...)
I'm a little confused. Here's what the most recent code looks like: === web2py_ajax.html === script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; //--/script {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} === layout.html === !-- include stylesheets -- {{ response.files.append(URL('static','css/skeleton.css')) response.files.append(URL('static','css/web2py.css')) if response.menu: response.files.append(URL('static','css/superfish.css')) response.files.append(URL('static','js/superfish.js')) pass }} {{include 'web2py_ajax.html'}}
Re: [web2py] Re: New Google Groups functionality
On Tuesday, March 27, 2012 6:06:17 PM UTC-4, rochacbruno wrote: is there some markup for doing that on emails? I don't know -- I just discovered this and enabled it in the web interface -- not sure what can be done via email. Anthony
[web2py] Re: difference between script src= ... and response.files.append(...)
What is confusing? On Tuesday, March 27, 2012 6:09:48 PM UTC-4, pbreit wrote: I'm a little confused. Here's what the most recent code looks like: === web2py_ajax.html === script type=text/javascript!-- // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). var w2p_ajax_confirm_message = {{=T('Are you sure you want to delete this object?')}}; var w2p_ajax_date_format = {{=T('%Y-%m-%d')}}; var w2p_ajax_datetime_format = {{=T('%Y-%m-%d %H:%M:%S')}}; //--/script {{ response.files.insert(0,URL('static','js/jquery.js')) response.files.insert(1,URL('static','css/calendar.css')) response.files.insert(2,URL('static','js/calendar.js')) response.files.insert(3,URL('static','js/web2py.js')) response.include_meta() response.include_files() }} === layout.html === !-- include stylesheets -- {{ response.files.append(URL('static','css/skeleton.css')) response.files.append(URL('static','css/web2py.css')) if response.menu: response.files.append(URL('static','css/superfish.css')) response.files.append(URL('static','js/superfish.js')) pass }} {{include 'web2py_ajax.html'}}
Re: [web2py] Re: problem with encoding in javascript from the server
Find it. titles = '+titles.replace('|', ',')+' with: SCRIPT( ... jQuery.prettyPhoto.open(**images=%(images)s,titles=[%(** titles)s]);}) % dict(images=images, titles=titles), _language='javascript') works! Tested on Firefox and Safari. Though I've failed to find any references on this (there must be), the problem seems to be Python string formatting. It seems that when the value of a dict is a list (haven't tested for other types such as dict and tuple?), Python uses repr instead of str, so we end-up with a representation! This does not happen if titles is a string. Note I'm using Python 2.5. Miguel On Tue, Mar 27, 2012 at 6:46 PM, Derek sp1d...@gmail.com wrote: Check the meta tag - if it's UTF-8, that's most likely the issue. You can try ISO-8859-1 and see if that works for you. On Tuesday, March 27, 2012 10:41:53 AM UTC-7, Derek wrote: What's the character set in your browser? On Tuesday, March 27, 2012 9:13:14 AM UTC-7, miguel wrote: This is not strictly a web2py issue. Though it is a problem that apps dealing with some character sets must deal with. I confess that the source of my problem is that I have been delaying reading-up on encoding and decoding far too long. But I'm pressed for time and I'm sure that this is a simple issue to many of you. Here's is it (slightly embarrassed): It works if I hardcode a string in a script helper: SCRIPT( ... jQuery.prettyPhoto.open(**images=%(images)s,titles=['**olá', 'olé']);}) % dict(...images=images), _language='javascript') It also works if (getting titles from the db, where it is stored as 'olá','olé' - note single quotes included): SCRIPT( ... jQuery.prettyPhoto.open(**images=%(images)s,titles=[%(**titles)]);}) % dict(images=images, titles=titles), _language='javascript') However, if I try to parse from the db (where titles is stored as olá|olé, such as: titles = [title.strip() for title in titles.split('|')] The jQuery string is adequately adjusted to receive a list: SCRIPT( ... jQuery.prettyPhoto.open(**images=%(images)s,titles=%(** titles));}) % dict(images=images, titles=titles), _language='javascript') All works but when rendered by the browser I do not get: Olá instead I get: olá The same for Olé and olé My goal is to have a user supplied string, such as: olá|olé BTW this is a prettyPhoto widget I developed for plugin_wiki, which is awesome :-) Txs for the help, Miguel
[web2py] Re: how to get logout() to launch an ajax call
I think I want a logout_bare() function so that I can logout via an ajax call without going through some contortions to avoid auth.logout()'s redirect. To be more specific, I want a link that says logout. When clicked, it logs me out and executes an ajax callback rather than a redirect.
[web2py] Re: Validating Registration fields
Thanks for the code snippets Anthony--but a minor caveat I didn't realize ahead of time is that the user is free to either upload an image or not. If the user does not upload an image, the IS_IMAGE() validators barks at the user. Is there a easy way of implementing such a logic: if a file is uploaded, check for IS_IMAGE(), otherwise ignore.? On Thursday, March 22, 2012 3:38:01 PM UTC-7, Anthony wrote: On Thursday, March 22, 2012 6:09:25 PM UTC-4, Peter G. wrote: I'm using the auth.settengs.extra_fields to add an extra upload field for the user to upload an avatar, how can I add an IS_IMAGE validator to the upload field so that the user can't upload random files? When you define the field, you can do: Field('avatar', 'upload', requires=IS_IMAGE()) or after the tables have been defined: db.auth_user.avatar.requires = IS_IMAGE() Also, how would I add an IS_ALPHANUMERIC to the built in First name and Last name form fields? Right now there are users registering with names like !@#$%^~ and some such... After the tables have been defined, you can do: db.auth_user.first_name.requires.append(IS_ALPHANUMERIC()) That adds the validator to the existing IS_NOT_EMPTY validator. However, I wouldn't use that validator for names because it doesn't allow valid name characters such as spaces, hyphens, and apostrophes. Anyway, if you prevent fake names with special characters, those users will just create fake names with alphanumeric characters, so either way you don't have a real name. Anthony
[web2py] Re: web2py 1.99.7 is OUT
This OK. Thanks. Vào 21:12:40 UTC+7 Thứ ba, ngày 27 tháng ba năm 2012, Massimo Di Pierro đã viết: Have you checked trunk or the nightly built. I believe this was fixed? On Tuesday, 27 March 2012 03:56:35 UTC-5, IVINH wrote: In my app, LOAD not work fine with 1.99.7, i'm try a test: 1. copy my view (contain js script), example: index.html to index.load 2. run : .../index.html and then .../index.load Both work well with the 1.99.4, but the second was not correct with 1.99.7 I think this is problem of extension .html .load Vào 11:00:15 UTC+7 Thứ ba, ngày 27 tháng ba năm 2012, Anthony đã viết: Can you describe the problem? Is the below view the index.load view? What is in plugin_app/layout.html? Should that be extended rather than included? Anthony On Monday, March 26, 2012 11:23:34 PM UTC-4, IVINH wrote: I have two views similar but different extension (index.html index. load). Both work well with the 1.99.4, but index.load was not for 1.99.7? My view: {{include 'plugin_app/layout.html'}} script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pieRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.donutRenderer.min.js')}} type=text/javascript/script link href={{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.css')}} rel=stylesheet type=text/css / script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.barRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.categoryAxisRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pointLabels.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasTextRenderer.min.js')}} type=text/javascript/script script src={{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js')}} type=text/javascript/script div style=position:absolute;top:300px;left:150px; {{=content}} /div Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro đã viết: Same as 1.99.5 and 1.99.6 but should solve all the outstanding compatibility issues. Massimo
[web2py] Re: difference between script src= ... and response.files.append(...)
Yay, Anthony! You 'da man. It works now. Phew. But truth be known, I don't exactly know what was going on here or what changes made the difference. I made the URL change you suggested -- it was some ancient code I had written years ago that I had developed a blindness towards 'cause it seemed to work. Anyway, I made the change to the URL and removed the leading '/' from the paths in the script list. This caused my system to fail. I then reordered the web2py_ajax.html loading. The system still failed. I then did an update to the latest versions of all my jquery files. And then ... magic .. the system worked. So bottom line, I think there were multiple problems here. One, there was an order dependence on loading the javascripts that bit me. Also, there were some bugs in the URL encoding. Finally, there may have been a mismatch in the versions of the javascript packages getting loaded up. It all added up to a snake pit. Thankfully, I'm out of it now. Thanks pbreit for your help, too. You guys are great. On Tuesday, March 27, 2012 11:08:25 PM UTC+8, Anthony wrote: On Tuesday, March 27, 2012 1:46:50 AM UTC-4, weheh wrote: Ouch, ouch, ouch ... that causes things to really disintegrate! I tend to agree with your assessment that there's an order dependence somewhere. But I don't see it, yet. I think your URL function is wrong -- URL('static', 'js', script) assumes 'static' is the app, 'js' is the controller, and script is the function. Instead, try: URL('static', 'js%s' % script) Actually, for readability, I would do 'js/%s' and remove the leading '/' from your script values. Anthony
[web2py] Re: Validating Registration fields
Try IS_EMPTY_OR(IS_IMAGE()) Anthony On Tuesday, March 27, 2012 7:12:45 PM UTC-4, Peter G. wrote: Thanks for the code snippets Anthony--but a minor caveat I didn't realize ahead of time is that the user is free to either upload an image or not. If the user does not upload an image, the IS_IMAGE() validators barks at the user. Is there a easy way of implementing such a logic: if a file is uploaded, check for IS_IMAGE(), otherwise ignore.? On Thursday, March 22, 2012 3:38:01 PM UTC-7, Anthony wrote: On Thursday, March 22, 2012 6:09:25 PM UTC-4, Peter G. wrote: I'm using the auth.settengs.extra_fields to add an extra upload field for the user to upload an avatar, how can I add an IS_IMAGE validator to the upload field so that the user can't upload random files? When you define the field, you can do: Field('avatar', 'upload', requires=IS_IMAGE()) or after the tables have been defined: db.auth_user.avatar.requires = IS_IMAGE() Also, how would I add an IS_ALPHANUMERIC to the built in First name and Last name form fields? Right now there are users registering with names like !@#$%^~ and some such... After the tables have been defined, you can do: db.auth_user.first_name.requires.append(IS_ALPHANUMERIC()) That adds the validator to the existing IS_NOT_EMPTY validator. However, I wouldn't use that validator for names because it doesn't allow valid name characters such as spaces, hyphens, and apostrophes. Anyway, if you prevent fake names with special characters, those users will just create fake names with alphanumeric characters, so either way you don't have a real name. Anthony
[web2py] Re: Fake_migrate with auth
you can do auth.define_tables(fake_migrate = True) On Tuesday, March 27, 2012 12:27:21 PM UTC-5, Detectedstealth wrote: How do I do a fake_migrate with the auth table so I don't get the following error? I know the table exists already I just pushed some major changes to my server and now when I run the app I get the tables already exists error. I really don't want to have to delete that table again, consider I have hundred people testing the site.. relation auth_group already exists -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: how to get logout() to launch an ajax call
On Tuesday, March 27, 2012 6:57:15 PM UTC-4, weheh wrote: I think I want a logout_bare() function so that I can logout via an ajax call without going through some contortions to avoid auth.logout()'s redirect. To be more specific, I want a link that says logout. When clicked, it logs me out and executes an ajax callback rather than a redirect. I guess it wouldn't be too hard to write your own function in that case: def logout_bare(): if auth.user: auth.log_event(auth.messages.logout_log, auth.user) session.auth = None Note, you may want to redirect to a non-protected page if the user happens to be on a protected page when logging out. Anthony