[web2py] Re: Translate Controller names and Function names
I have this in models till now: views_translate = { # Controllers Names 'default' : 'principal', 'principal' : 'default', 'articles' : 'artigo', 'artigo': 'articles', # Function Names 'index' : 'inicio', 'inicio': 'index', 'new' : 'novo', 'novo' : 'new', 'search': 'procurar', 'procurar' : 'search', } controllers_translate = { 'default' : T('default', lazy=False), 'principal' : T('default', lazy=False), 'articles' : T('articles', lazy=False), 'artigo': T('articles', lazy=False), } functions_translate = { 'index' : T('index', lazy=False), 'inicio': T('index', lazy=False), 'new' : T('new', lazy=False), 'novo' : T('new', lazy=False), 'search': T('search', lazy=False), 'procurar' : T('search', lazy=False), } #Translate Views if T.accepted_language != 'en' and request.extension and request.extension == 'html': response.view = '%s/%s.html' % (views_translate[request.controller], views_translate[request.function]) #Redirect controllers and functions if necessary if not T.accepted_language == 'en': if request.controller != controllers_translate[request.controller] or request.function != functions_translate[request.function]: redirect(URL(scheme='https', host=True, r=request, c= controllers_translate[request.controller], f=functions_translate[request. function], args=request.args, vars=request.vars), how=301) else: if request.controller != controllers_translate[request.controller] or request.function != functions_translate[request.function]: redirect(URL(scheme='https', host=True, r=request, c= controllers_translate[request.controller], f=functions_translate[request. function], args=request.args, vars=request.vars), how=301) But on the views I also have to assign translation for every URL() function: {{=URL(r=request, c=T('articles', lazy=False), f=T('search', lazy=False))}} is there a better way to do this? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Translate Controller names and Function names
IMHO you're better suited for routes http://web2py.com/books/default/chapter/29/04/the-core#URL-rewrite. As long at the mapping is fixed, it's exactly what they've been engineered for. I'd use the pattern-based system On Tuesday, January 27, 2015 at 2:51:31 PM UTC+1, Francisco Costa wrote: I have this in models till now: views_translate = { # Controllers Names 'default' : 'principal', 'principal' : 'default', 'articles' : 'artigo', 'artigo': 'articles', # Function Names 'index' : 'inicio', 'inicio': 'index', 'new' : 'novo', 'novo' : 'new', 'search': 'procurar', 'procurar' : 'search', } controllers_translate = { 'default' : T('default', lazy=False), 'principal' : T('default', lazy=False), 'articles' : T('articles', lazy=False), 'artigo': T('articles', lazy=False), } functions_translate = { 'index' : T('index', lazy=False), 'inicio': T('index', lazy=False), 'new' : T('new', lazy=False), 'novo' : T('new', lazy=False), 'search': T('search', lazy=False), 'procurar' : T('search', lazy=False), } #Translate Views if T.accepted_language != 'en' and request.extension and request.extension == 'html': response.view = '%s/%s.html' % (views_translate[request.controller], views_translate[request.function]) #Redirect controllers and functions if necessary if not T.accepted_language == 'en': if request.controller != controllers_translate[request.controller] or request.function != functions_translate[request.function]: redirect(URL(scheme='https', host=True, r=request, c= controllers_translate[request.controller], f=functions_translate[request. function], args=request.args, vars=request.vars), how=301) else: if request.controller != controllers_translate[request.controller] or request.function != functions_translate[request.function]: redirect(URL(scheme='https', host=True, r=request, c= controllers_translate[request.controller], f=functions_translate[request. function], args=request.args, vars=request.vars), how=301) But on the views I also have to assign translation for every URL() function: {{=URL(r=request, c=T('articles', lazy=False), f=T('search', lazy=False ))}} is there a better way to do this? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
Derek, I understand your point, but from the testing point of view, the only option remaining for testing view is Selenium HQ which is slow, so if you want to be able to test your controller that depend a lot of the view, what I can only see is to limit as much as possible the view to unpack web2py controller variables packed with everything... Do I am wrong in thinking that? Richard On Tue, Jan 27, 2015 at 12:19 PM, Derek sp1d...@gmail.com wrote: What I mean by 'you are mixing your view with your controller' is that you are using your controller to build HTML that will be used as-is. You should never create HTML in your controllers, leave that to the views. The whole point of MVC is that each part has a very specific purpose. Don't create your models in your controllers or views, don't create html in your models or controllers, and don't put logic in models and views. https://www.youtube.com/watch?v=8FWdQVNeTlI On Tuesday, January 27, 2015 at 10:15:50 AM UTC-7, Derek wrote: Well, where do I start? It looks like you are a victim of copy and paste coding. Delete your two functions and start over again. That said, you are mixing your view with your controller, please don't do that. I would suggest you use this web2pyslice as a starting point. (yes, I wrote it) http://www.web2pyslices.com/slice/show/1724/cascading- dropdowns-simplified On Monday, January 26, 2015 at 1:28:20 PM UTC-7, Omi Chiba wrote: I have a three dropdown and the value will be dynamically changed using ajax. It's working fine but something is wrong. In second dropdown (id=lead_name), I specify jQuery('#model_name') but it's actually jQuery('#leadl_name') but then when the value for the second drop changed, the value disappear from the second and third. When I keep the current way (which is wrong name) it's working as expected Do you guys know what's wrong? This is my view form enctype=multipart/form-data action={{URL()}} method=post tr tdselect name='model_name' onchange=jQuery( '#model_name').empty(); ajax('lead_ajax', ['model_name'], 'lead_name'); {{for model in models:}} option value={{=model.Name}} {{= selected='selected' if str(model.Name)= =request.vars.model_name else }} {{=model.Name}} /option {{pass}} /select/td tdselect id='lead_name' name='lead_name' onchange= jQuery('#model_name').empty(); ajax('block_ajax', ['lead_name'], 'block_name'); {{for lead in leads:}} option value={{=lead.Name}} {{= selected='selected' if str(lead.Name)= =request.vars.lead_name else }} {{=lead.Name}} /option {{pass}} /select/td tdselect id='block_name' name='block_name' {{for block in blocks:}} option value={{=block.Name}} {{= selected='selected' if str(block.Name)= =request.vars.block_name else }} {{=block.Name}} /option {{pass}} /select/td td/td td/td tdinput type=submit value='Submit'/td /tr /form My controller def index(): response.title='KR Quick Delivery Service' if request.vars.model_name: lists = db((db.KR_Product.Model==request.vars.model_name) (db. KR_Product.Lead==request.vars.lead_name) (db.KR_Product.Block==request .vars.block_name)).select(db.KR_Product.ALL) else: lists='' models = db().select(db.KR_Model.ALL) leads = db(db.KR_Lead.ModelName == '20').select(db.KR_Lead.ALL) blocks = db(db.KR_Block.LeadName == '01').select(db.KR_Block.ALL) return dict(lists=lists,models=models,leads=leads,blocks=blocks) def lead_ajax(): leads = db(db.KR_Lead.ModelName==request.vars.model_name).select(db. KR_Lead.ALL) result = '' for lead in leads: result += option value=' + lead.Name + ' + lead.Name + /option return XML(result) def block_ajax(): blocks = db(db.KR_Block.LeadName==request.vars.lead_name).select(db. KR_Block.ALL) result = '' for block in blocks: result += option value=' + block.Name + ' + block.Name + /option return XML(result) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to
Re: [web2py] Translate Controller names and Function names
On Tuesday, 27 January 2015 17:14:48 UTC, Carlos Costa wrote: Very interesting question. It must have some effect on SEO. I have seen this post but it does not seem to solve exactly this https://groups.google.com/forum/#!searchin/web2py/translate$20url/web2py/3adXUSCGQQQ/TaKfRagHyvMJ Yes, that's why I'm trying to figure this out. This would be a valuable feature for web2py framework. Where can you add this to the roadmap? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: what's wrong with printing URL?
If you don't want the href printed, wouldn't you want to get rid of this line: a:after { content: ( attr(href) ); } Anthony On Tuesday, January 27, 2015 at 2:54:05 PM UTC-5, Vladimir Makarov wrote: Hey! So I have this piece of code in my view file: *a href={{=URL('kkm', 'kkm', vars={'kkm':row.id http://row.id, 'client':curClient.id, 'contract':curContract.id})}}{{=row.model}}/a* There is nothing special or magical but if I try to print the page ... ooopppss ...I see this result: *Some_model (/gemma/kkm/kkm? client=156contract=596kkm=107)* instead of *Some_model* Say how can I get rid of link parameters in view when I click to print page? PS This is piece of my css file but itsn't work for me: @media print { * { background: transparent !important; color: #444 !important; text-shadow: none !important; } a, a:visited { color: #444 !important; text-decoration: none; } a:after { content: ( attr(href) ); } @page { margin: 0.5cm; } } Any ideas?!? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: what's wrong with printing URL?
no way! I excluded* a:after { content: ( attr(href) ); **}* but nothing happened. On Tuesday, January 27, 2015 at 11:05:25 PM UTC+3, Anthony wrote: If you don't want the href printed, wouldn't you want to get rid of this line: a:after { content: ( attr(href) ); } Anthony On Tuesday, January 27, 2015 at 2:54:05 PM UTC-5, Vladimir Makarov wrote: Hey! So I have this piece of code in my view file: *a href={{=URL('kkm', 'kkm', vars={'kkm':row.id http://row.id, 'client':curClient.id, 'contract':curContract.id})}}{{=row.model}}/a* There is nothing special or magical but if I try to print the page ... ooopppss ...I see this result: *Some_model (/gemma/kkm/kkm? client=156contract=596kkm=107)* instead of *Some_model* Say how can I get rid of link parameters in view when I click to print page? PS This is piece of my css file but itsn't work for me: @media print { * { background: transparent !important; color: #444 !important; text-shadow: none !important; } a, a:visited { color: #444 !important; text-decoration: none; } a:after { content: ( attr(href) ); } @page { margin: 0.5cm; } } Any ideas?!? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
Also, consider tools like SQLFORM.grid(), it's generate everything... Richard On Tue, Jan 27, 2015 at 2:13 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Derek, I understand your point, but from the testing point of view, the only option remaining for testing view is Selenium HQ which is slow, so if you want to be able to test your controller that depend a lot of the view, what I can only see is to limit as much as possible the view to unpack web2py controller variables packed with everything... Do I am wrong in thinking that? Richard On Tue, Jan 27, 2015 at 12:19 PM, Derek sp1d...@gmail.com wrote: What I mean by 'you are mixing your view with your controller' is that you are using your controller to build HTML that will be used as-is. You should never create HTML in your controllers, leave that to the views. The whole point of MVC is that each part has a very specific purpose. Don't create your models in your controllers or views, don't create html in your models or controllers, and don't put logic in models and views. https://www.youtube.com/watch?v=8FWdQVNeTlI On Tuesday, January 27, 2015 at 10:15:50 AM UTC-7, Derek wrote: Well, where do I start? It looks like you are a victim of copy and paste coding. Delete your two functions and start over again. That said, you are mixing your view with your controller, please don't do that. I would suggest you use this web2pyslice as a starting point. (yes, I wrote it) http://www.web2pyslices.com/slice/show/1724/cascading- dropdowns-simplified On Monday, January 26, 2015 at 1:28:20 PM UTC-7, Omi Chiba wrote: I have a three dropdown and the value will be dynamically changed using ajax. It's working fine but something is wrong. In second dropdown (id=lead_name), I specify jQuery('#model_name') but it's actually jQuery('#leadl_name') but then when the value for the second drop changed, the value disappear from the second and third. When I keep the current way (which is wrong name) it's working as expected Do you guys know what's wrong? This is my view form enctype=multipart/form-data action={{URL()}} method=post tr tdselect name='model_name' onchange=jQuery( '#model_name').empty(); ajax('lead_ajax', ['model_name'], 'lead_name'); {{for model in models:}} option value={{=model.Name}} {{= selected='selected' if str(model.Name)= =request.vars.model_name else }} {{=model.Name}} /option {{pass}} /select/td tdselect id='lead_name' name='lead_name' onchange= jQuery('#model_name').empty(); ajax('block_ajax', ['lead_name'], 'block_name'); {{for lead in leads:}} option value={{=lead.Name}} {{= selected='selected' if str(lead.Name)= =request.vars.lead_name else }} {{=lead.Name}} /option {{pass}} /select/td tdselect id='block_name' name='block_name' {{for block in blocks:}} option value={{=block.Name}} {{= selected='selected' if str(block.Name)= =request.vars.block_name else }} {{=block.Name}} /option {{pass}} /select/td td/td td/td tdinput type=submit value='Submit'/td /tr /form My controller def index(): response.title='KR Quick Delivery Service' if request.vars.model_name: lists = db((db.KR_Product.Model==request.vars.model_name) (db .KR_Product.Lead==request.vars.lead_name) (db.KR_Product.Block== request.vars.block_name)).select(db.KR_Product.ALL) else: lists='' models = db().select(db.KR_Model.ALL) leads = db(db.KR_Lead.ModelName == '20').select(db.KR_Lead.ALL) blocks = db(db.KR_Block.LeadName == '01').select(db.KR_Block.ALL) return dict(lists=lists,models=models,leads=leads,blocks=blocks) def lead_ajax(): leads = db(db.KR_Lead.ModelName==request.vars.model_name).select(db .KR_Lead.ALL) result = '' for lead in leads: result += option value=' + lead.Name + ' + lead.Name + /option return XML(result) def block_ajax(): blocks = db(db.KR_Block.LeadName==request.vars.lead_name).select(db .KR_Block.ALL) result = '' for block in blocks: result += option value=' + block.Name + ' + block.Name + /option return XML(result) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You
Re: [web2py] Re: Question about web2py roadmap.
Joe, I don't understand the dichotomy of your question? I don't think web2py serve each others as much... Richard On Tue, Jan 27, 2015 at 12:17 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I never thought about it in those terms. I think it serves web developers by taking care of administrative issues for them. On Tuesday, 27 January 2015 11:14:06 UTC-6, JoeCodeswell wrote: Dear web2py-users, Here is my question about the roadmap goals for web2py development. Will the goals for web2py development be oriented to serve Web Developers MORE THAN Website Administrators or vice versa? I personally think web2py should serve Web Developers MORE THAN Website Administrators. However, i think it is often the case that web2py serves Website Administrators MORE THAN Web Developers. I think this is especially true regarding the target users of plugins and wizards. Thanks for a GREAT framework. Love and peace, Joe -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: About validators
Make sure you check form.vars (after calling .process) rather than request.vars. Anthony On Tuesday, January 27, 2015 at 10:15:34 AM UTC-5, mweissen wrote: In the book I find:IS_LOWER This validator never returns an error. It just converts the value to lower case. requires = IS_LOWER() Now I try a piece of code: form=FORM(INPUT(_type=text, _name=n, requires=IS_LOWER())) On input abcDEF I expected n==abcdef, but I get abcDEF (not converted to lower characters). What is wrong? Regards, Martin -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Override update defaults?
I think you can take two approaches. One option would be to conditionally set the update attribute depending on the request: Field('modified_on', 'datetime', update=request.now if request.function != 'admin_routine' else None, ...) The other approach is to pass in the current value when doing the update in the admin routine: def admin_routine: ... idb.student(source.id).address.update(student=target.id, modified_on =idb.student.address) Anthony On Tuesday, January 27, 2015 at 9:48:54 AM UTC-5, tim.n...@conted.ox.ac.uk wrote: I'm really liking the ability to automatically timestamp when records are updated, but I'm wondering if there's a simple way of suppressing this behaviour when needed: I have these signature fields appended to a number of tables, automatically recording when users update records: signature_fields = idb.Table( idb, 'signature_fields', #Dummy table, not actually in the db Field('created_on', 'datetime', default=request.now, writable=False, readable=False, label='Created on'), Field('created_by', 'string', default=auth.user.username writable=False, readable=False, label='Created by'), Field('modified_on', 'datetime', update=request.now, default=request.now, writable=False, readable=False, label='Modified on'), Field('modified_by', 'string', default=auth.user.username, update=signature_username, writable=False, readable=False, label='Modified by'), ) For example: idb.define_table( 'address', Field('id', 'id', readable=False), Field('student', idb.student, readable=False, writable=False), Field('line1', 'string'), Field('line2', 'string'), Field('line3', 'string'), Field('town', 'string'), Field('countystate', 'string'), Field('country', 'string'), Field('postcode', 'string'), signature_fields ) But I have an admin routine that allows me to move addreses to another student, and I don't want the timestamping to occur when I run: idb.student(source.id).address.update(student=target.id) Is there a simple way to suppress automatic update values? e.g.: idb.student(source.id).address.update(student=target.id, _defaults=False) I know I can disable them one by one before running the queries, but it'll add lots of boilerplate a la: idb.address.modified_on.update = idb.address.modified_by.update = None -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: web2py 2.9.12 is OUT
Since the upgrade, I'm getting this annoyance in the web editor. When I save a controller with a syntax error, the operation stalls at saving now If I retry the save, I get the warning file changed on disk and have to merge it, losing the state of the editor. Is this a known bug? I'm using Windows 7 with the built-in web server, it was an automatic upgrade. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Is Web2py suitable for my project
I mean IPython notebook... On Tue, Jan 27, 2015 at 1:51 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Eric, Have you consider IPython? It is less appealing then the stack you are talking, but may be a fast solution that can fill in some of you needs... Richard On Tue, Jan 27, 2015 at 10:57 AM, Eric's Gmail eric.sh...@gmail.com wrote: Richard, I think Bokeh and MPLD3 are quite specifically designed to provide somewhat interactive scientific plots. Brython seems completely different. Eric - Eric On Jan 27, 2015, at 9:52 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: I will probably try, but not soon... I am really currious to know how it works and can provide that kind of feature, maybe it is similar to Brython (http://www.brython.info/)... Richard On Mon, Jan 26, 2015 at 10:58 AM, Eric eric.sh...@gmail.com wrote: Richard, If you try Bokeh and/or mpld3 please tell me how it went. I'll need scientific plots in my application and would welcome any hints on how to accomplish this in Web2py. Eric On Monday, January 26, 2015 at 9:30:48 AM UTC-6, Richard wrote: Didn't know bokeh thanks! Richard On Sun, Jan 25, 2015 at 10:43 PM, Kiran Subbaraman subbaram...@gmail.com wrote: Eric, The best option then is for you to try out the hello-world example in web2py. This will give you a good idea as to how to create a minimal web application, and also insert your code. You need to start here: http://web2py.com/books/default/chapter/29/03/overview#Say-hello The stuff you are talking about should be pretty straight-forward in web2py (or any other equivalent web framework). You need to create a model file (to store stuff in the db), a controller (where your plotting logic, like that of Bokeh / MPLD3, will reside), and the view (the html where you render your charts, or even embed javascript based plotting libraries - like d3js). Feel free to ask questions as you work your way through the initial web2py programming model. Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ On Mon, 26-01-2015 3:22 AM, Eric wrote: Kiran, Thanks for the response. I'm extremely new to any sort of web programming. I have a bit of Python experience. Unfortunately the response above was simply above my head. I've written file parsers in Python so I can handle that. I'm confident I can write the algorithms too. What I can't figure out is how to integrate a plotting utility like Bokeh or possibly MPLD3 (http://mpld3.github.io/index.html) into Web2py and get the plot to show up in a Web2py created page. I've seen a few examples of how to trigger a browser's file dialog, but don't know how to use that to get a file into the Python parsing script. I'm usually pretty good at finding resources on the web, but my general knowledge of web technologies is a problem. Eric On Sunday, January 25, 2015 at 3:24:18 AM UTC-6, Kiran Subbaraman wrote: I would use web2py for these requirements, because you get the authentication/authorization, sessions, DAL (for db access) capabilities out of the box. You probably need packages in addition to pydal (for DAL support), on top of Flask to accomplish this. Look at the gluino example to see what I mean: https://github.com/mdipierro/gluino Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ On Sat, 24-01-2015 9:53 PM, Eric wrote: Hi all, I'm new to web2py and have been working my way through the learning materials. I have a specific application and am wondering if web2py is a good choice for a framework or something simpler such as Flask. Specifically I want to create a web application (for an intranet) where a user would upload a data file using the standard browser file dialog, have it analyzed by an algorithm I've written in Python and then responses plotted on the page and also a file of results savable using the browsers standard save file dialog. I know enough Python to handle the file parsing, data analysis and result file generation. I'll need access to Python libraries such as Numpy. I've discovered Bokah ( http://bokeh.pydata.org) as an attractive plotting library. They use Flask in their tutorial. I haven't found anything particularly clear about how to invoke the browser file dialogs. Eventually I'd like to use a database to archive the uploaded data files and resulting result files along with other information such as user, date, instrument serial number, etc. Thanks, Eric -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to
Re: [web2py] Is Web2py suitable for my project
Eric, Have you consider IPython? It is less appealing then the stack you are talking, but may be a fast solution that can fill in some of you needs... Richard On Tue, Jan 27, 2015 at 10:57 AM, Eric's Gmail eric.sh...@gmail.com wrote: Richard, I think Bokeh and MPLD3 are quite specifically designed to provide somewhat interactive scientific plots. Brython seems completely different. Eric - Eric On Jan 27, 2015, at 9:52 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: I will probably try, but not soon... I am really currious to know how it works and can provide that kind of feature, maybe it is similar to Brython (http://www.brython.info/)... Richard On Mon, Jan 26, 2015 at 10:58 AM, Eric eric.sh...@gmail.com wrote: Richard, If you try Bokeh and/or mpld3 please tell me how it went. I'll need scientific plots in my application and would welcome any hints on how to accomplish this in Web2py. Eric On Monday, January 26, 2015 at 9:30:48 AM UTC-6, Richard wrote: Didn't know bokeh thanks! Richard On Sun, Jan 25, 2015 at 10:43 PM, Kiran Subbaraman subbaram...@gmail.com wrote: Eric, The best option then is for you to try out the hello-world example in web2py. This will give you a good idea as to how to create a minimal web application, and also insert your code. You need to start here: http://web2py.com/books/default/chapter/29/03/overview#Say-hello The stuff you are talking about should be pretty straight-forward in web2py (or any other equivalent web framework). You need to create a model file (to store stuff in the db), a controller (where your plotting logic, like that of Bokeh / MPLD3, will reside), and the view (the html where you render your charts, or even embed javascript based plotting libraries - like d3js). Feel free to ask questions as you work your way through the initial web2py programming model. Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ On Mon, 26-01-2015 3:22 AM, Eric wrote: Kiran, Thanks for the response. I'm extremely new to any sort of web programming. I have a bit of Python experience. Unfortunately the response above was simply above my head. I've written file parsers in Python so I can handle that. I'm confident I can write the algorithms too. What I can't figure out is how to integrate a plotting utility like Bokeh or possibly MPLD3 (http://mpld3.github.io/index.html) into Web2py and get the plot to show up in a Web2py created page. I've seen a few examples of how to trigger a browser's file dialog, but don't know how to use that to get a file into the Python parsing script. I'm usually pretty good at finding resources on the web, but my general knowledge of web technologies is a problem. Eric On Sunday, January 25, 2015 at 3:24:18 AM UTC-6, Kiran Subbaraman wrote: I would use web2py for these requirements, because you get the authentication/authorization, sessions, DAL (for db access) capabilities out of the box. You probably need packages in addition to pydal (for DAL support), on top of Flask to accomplish this. Look at the gluino example to see what I mean: https://github.com/mdipierro/gluino Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ On Sat, 24-01-2015 9:53 PM, Eric wrote: Hi all, I'm new to web2py and have been working my way through the learning materials. I have a specific application and am wondering if web2py is a good choice for a framework or something simpler such as Flask. Specifically I want to create a web application (for an intranet) where a user would upload a data file using the standard browser file dialog, have it analyzed by an algorithm I've written in Python and then responses plotted on the page and also a file of results savable using the browsers standard save file dialog. I know enough Python to handle the file parsing, data analysis and result file generation. I'll need access to Python libraries such as Numpy. I've discovered Bokah ( http://bokeh.pydata.org) as an attractive plotting library. They use Flask in their tutorial. I haven't found anything particularly clear about how to invoke the browser file dialogs. Eventually I'd like to use a database to archive the uploaded data files and resulting result files along with other information such as user, date, instrument serial number, etc. Thanks, Eric -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com -
[web2py] what's wrong with printing URL?
Hey! So I have this piece of code in my view file: *a href={{=URL('kkm', 'kkm', vars={'kkm':row.id, 'client':curClient.id, 'contract':curContract.id})}}{{=row.model}}/a* There is nothing special or magical but if I try to print the page ... ooopppss ...I see this result: *Some_model (/gemma/kkm/kkm? client=156contract=596kkm=107)* instead of *Some_model* Say how can I get rid of link parameters in view when I click to print page? PS This is piece of my css file but itsn't work for me: @media print { * { background: transparent !important; color: #444 !important; text-shadow: none !important; } a, a:visited { color: #444 !important; text-decoration: none; } a:after { content: ( attr(href) ); } @page { margin: 0.5cm; } } Any ideas?!? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: IMPORTANT - DO NOT POST ISSUE ON GOOGLE CODE
Remember to change the readme that reports ;-) : Issues? Report issues at http://code.google.com/p/web2py/issues/ On Tue, Jan 27, 2015 at 12:00 AM, Niphlod niph...@gmail.com wrote: migration completed. You can find in the original googlecode issue a last message by me linking to the newly migrated issue on github, and on the github issue the link to the original issue on googlecode. From now on: - googlecode issues WON'T be looked at - please post ONLY issues on https://github.com/web2py/web2py/issues - moreover, if your issues are relative to DAL, now it lives in a different repository, so the issues should be posted to https://github.com/web2py/pydal/issues Bye -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Massimiliano -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Google Cloud Storage libraries interaction web2py appengine
Finally solved. The solution: https://groups.google.com/forum/#!topic/google-appengine-stackoverflow/JZX2Yh67ylI I had to include: apiclient, gflags, httplib2, oauth2client, uritemplate in *site-packages* folder Thanks El jueves, 22 de enero de 2015, 23:59:11 (UTC+1), Massimo Di Pierro escribió: GAE does not provide httplib2 they want you to use urlfetch (their api). web2py provides gluon.tools.fetch which wraps urlfetch and works like urllib.urlopen when not on GAE. First step, I have adapted the example: https://cloud.google.com/storage/docs/json_api/v1/json-api-python-samples I works fine in localhost. Here it is the controller: import argparse import httplib2 import os import sys import json from apiclient import discovery from oauth2client import file from oauth2client import client from oauth2client import tools # Define sample variables. _BUCKET_NAME = 'mybucket' _API_VERSION = 'v1' # Parser for command-line arguments. parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, parents=[tools.argparser]) # CLIENT_SECRETS is name of a file containing the OAuth 2.0 information for this # application, including client_id and client_secret. You can see the Client ID # and Client secret on the APIs page in the Cloud Console: # https://console.developers.google.com/ CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json') # Set up a Flow object to be used for authentication. # Add one or more of the following scopes. PLEASE ONLY ADD THE SCOPES YOU # NEED. For more information on using scopes please see # https://developers.google.com/storage/docs/authentication#oauth. FLOW = client.flow_from_clientsecrets(CLIENT_SECRETS, scope=[ 'https://www.googleapis.com/auth/devstorage.full_control', 'https://www.googleapis.com/auth/devstorage.read_only', 'https://www.googleapis.com/auth/devstorage.read_write', ], message=tools.message_if_missing(CLIENT_SECRETS)) def index(): cliente=CLIENT_SECRETS flow= FLOW #va= main(sys.argv) # Parse the command-line flags. # flags = parser.parse_args(argv[1:]) # If the credentials don't exist or are invalid run through the native client # flow. The Storage object will ensure that if successful the good # credentials will get written back to the file. storage = file.Storage('sample.dat') credentials = storage.get() if credentials is None or credentials.invalid: credentials = tools.run_flow(FLOW, storage, flags) # Create an httplib2.Http object to handle our HTTP requests and authorize it # with our good Credentials. http = httplib2.Http() http = credentials.authorize(http) # Construct the service object for the interacting with the Cloud Storage API. service = discovery.build('storage', _API_VERSION, http=http) try: req = service.buckets().get(bucket=_BUCKET_NAME) resp = req.execute() print1= json.dumps(resp, indent=2) fields_to_return = 'nextPageToken,items(name,size,contentType,metadata(my-key))' req = service.objects().list(bucket=_BUCKET_NAME, fields=fields_to_return) # If you have too many items to list in one request, list_next() will # automatically handle paging with the pageToken. while req is not None: resp = req.execute() print2= json.dumps(resp, indent=2) req = service.objects().list_next(req, resp) except client.AccessTokenRefreshError: aviso= The credentials have been revoked or expired, please re-run the application to re-authorize form=SQLFORM(db.gfile) return dict(print1=print1,print2=print2, form=form) I get the result expected. But when I deploy it to the google app engine, there rises an error ticket: 14:49:26.005 Unable to store in FILE: /base/data/home/apps/s~merebafs/2.381697639759293929/applications/MRBFILE/controllers/default.py Traceback (most recent call last): File /base/data/home/apps/s~merebafs/2.381697639759293929/gluon/restricted.py, line 224 https://console.developers.google.com/project/merebafs/clouddev/source/resolve_location?appModule=defaultappVersion=2timestampNanos=142193456600500file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~merebafs%2F2.381697639759293929%2Fgluon%2Frestricted.pyline=224, in restricted exec ccode in environment File /base/data/home/apps/s~merebafs/2.381697639759293929/applications/MRBFILE/controllers/default.py, line 12 https://console.developers.google.com/project/merebafs/clouddev/source/resolve_location?appModule=defaultappVersion=2timestampNanos=142193456600500file=%2Fbase%2Fdata%2Fhome%2Fapps%2Fs~merebafs%2F2.381697639759293929%2Fapplications%2FMRBFILE%2Fcontrollers%2Fdefault.pyline=12, in module import httplib2 File /base/data/home/apps/s~merebafs/2.381697639759293929/gluon/custom_import.py, line 86
[web2py] SQLFORM.grid check if record in db
Hello I have a SQLFORM.grid page Values for one filed (code) in add or edit view is filed with js code from values of two other fields. User can deactivate this record - it can not be deleted only status is set to e.g. 100 If user creates a new record that creates the same values for code field (two users can have the same values in code field, since it is not based on id) I would like to remind the user that record with this value already exist in the db and if he wants to activate the record and not create a new one. I hope the question is clear enough Also if creating value for field sh_code is possible with python I would rather use it but user has to see the values of sc_code field before db insert Thank you my controler code def turnusi(): user = auth.user_id org = db(db.auth_user.id == user).select(db.auth_user.organization)[0][organization] db.worker.w_user.default = user db.worker.w_organisation.default = org #Naredimo še grid za šifrant turnusov db.shift.sh_organisation.default = org query_shifts = ((db.shift.sh_organisation == org) (db.shift.sh_status == 1)) query_inactive = db((db.shift.sh_organisation == org) (db.shift.sh_status == 100)).select().as_list() #print query_inactive fields_shifts =( db.shift.sh_code, db.shift.sh_name, db.shift.sh_color, db.shift.sh_start1, db.shift.sh_end1, db.shift.sh_length1, db.shift.sh_start2, db.shift.sh_end2, db.shift.sh_length2, db.shift.sh_duration1, # db.shift.sh_start3, # db.shift.sh_end3, # db.shift.sh_start4, # db.shift.sh_end4, # db.shift.sh_start5, # db.shift.sh_end5, db.shift.sh_note) db.shift.sh_organisation.readable = False db.shift.sh_organisation.writable = False db.shift.sh_organisation.editable = False #db.shift.sh_code.editable = db.shift.sh_code.writable = False #db.shift.sh_duration.writable = False db.shift.sh_duration1.readable = db.shift.sh_duration1.writable = False #db.shift.sh_length1.writable = False #db.shift.sh_start2.readable = db.shift.sh_start2.writable = False #db.shift.sh_start2.writable = False #db.shift.sh_end2.readable = db.shift.sh_end2.writable = False #db.shift.sh_end2.writable = False #db.shift.sh_length2.readable = db.shift.sh_length2.writable = False db.shift.sh_start3.readable = db.shift.sh_start3.writable = False #db.shift.sh_start3.writable = False db.shift.sh_end3.readable = db.shift.sh_end3.writable = False #db.shift.sh_end3.writable = False db.shift.sh_length3.readable = db.shift.sh_length3.writable = False db.shift.sh_start4.readable = db.shift.sh_start4.writable = False #db.shift.sh_start4.writable = False db.shift.sh_length4.readable = db.shift.sh_length4.writable = False db.shift.sh_end4.readable = db.shift.sh_end4.writable = False #db.shift.sh_end4.writable = False db.shift.sh_start5.readable = db.shift.sh_start5.writable = False #db.shift.sh_start5.writable = False db.shift.sh_length5.readable = db.shift.sh_length5.writable = False db.shift.sh_end5.readable = db.shift.sh_end5.writable = False #db.shift.sh_end5.writable = False# db.shift.sh_code.widget = SQLFORM.widgets.string.widget db.shift.sh_name.widget = SQLFORM.widgets.string.widget db.shift.sh_note.widget = SQLFORM.widgets.string.widget grid_shifts = SQLFORM.grid(query=query_shifts, fields=fields_shifts, searchable=False,create=True, deletable=False, editable=True, paginate=25, buttons_placement = 'right', showbuttontext = False,formname = 'shiftTable', formargs=dict(message_onsuccess=T('New record inserted'), message_onfailure=T('Form has errors')), #oncreate=myfunction, ui = dict(widget='', header='', content='', default='', cornerall='', cornertop='', cornerbottom='', button='button btn btn-default', buttontext='buttontext button', buttonadd='icon plus icon-plus glyphicon glyphicon-plus', buttonback='icon leftarrow icon-arrow-left glyphicon glyphicon-arrow-left', buttonexport='icon downarrow icon-download glyphicon glyphicon-download', buttondelete='icon trash icon-trash glyphicon glyphicon-trash', buttonedit='icon pen icon-pencil glyphicon glyphicon-pencil', buttontable='icon rightarrow icon-arrow-right glyphicon glyphicon-arrow-right', buttonview='icon magnifier icon-zoom-in glyphicon glyphicon-eye-open', buttonvidov = 'icon glyphicon glyphicon-euro' ), exportclasses = dict(csv_with_hidden_cols=False, html = False, tsv = False, tsv_with_hidden_cols=False, json = False)) # for input in grid_shifts.elements('input', _class='string'): # input['_class'] = 'testniKlass' if request.args and request.args[0] in ['edit', 'new']: #dolocamo sirino polj grid_shifts.element('input[name=sh_color]')['_style']='width:30%' grid_shifts.element('[title=Back]').parent['_href'] = URL('settings','turnusi') return dict(grid_shifts=grid_shifts,query_inactive=query_inactive) my js code in view to get
Re: [web2py] Re: Checksum for download of web2py?
If possible I'd suggest to also use PGP signatures 2015-01-26 18:07 GMT+01:00 Benjamin bnjmn.k...@googlemail.com: Thank you very much for your answer, Mr Di Pierro. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
I would test the fact that html generated work properly, I guess Selenium is the only way, but if I can interact with html object from python with someting like HTMLTestRunner ( http://tungwaiyip.info/software/HTMLTestRunner.html)... I never had time to think about test cases worth doing over generated html... Actually, you maybe right that it only allow to see if html get generated or compare html generated to an reference html (mean something like having app serving to test another app to make sure notting get modify on one hand without the other know it... Mean a lot of work merging stuff between repo in orther to maintain test case = a lot of works). Could you provide an example of good controller and view codes? Model is easier... In web2py, I am not sure we can really divide each differents part in M-V-C container... Look how you define validators over model field definition (I know old raised point). Richard On Tue, Jan 27, 2015 at 3:42 PM, Derek sp1d...@gmail.com wrote: You are wrong. If you need to test your views, you would have to use some kind of testing tool like Selenium, of course. However, you should not be generating views within the controllers, they have separate functions. It makes no sense. Besides, what are you going to test, the generation of the html? On Tuesday, January 27, 2015 at 12:13:09 PM UTC-7, Richard wrote: Derek, I understand your point, but from the testing point of view, the only option remaining for testing view is Selenium HQ which is slow, so if you want to be able to test your controller that depend a lot of the view, what I can only see is to limit as much as possible the view to unpack web2py controller variables packed with everything... Do I am wrong in thinking that? Richard On Tue, Jan 27, 2015 at 12:19 PM, Derek sp1...@gmail.com wrote: What I mean by 'you are mixing your view with your controller' is that you are using your controller to build HTML that will be used as-is. You should never create HTML in your controllers, leave that to the views. The whole point of MVC is that each part has a very specific purpose. Don't create your models in your controllers or views, don't create html in your models or controllers, and don't put logic in models and views. https://www.youtube.com/watch?v=8FWdQVNeTlI On Tuesday, January 27, 2015 at 10:15:50 AM UTC-7, Derek wrote: Well, where do I start? It looks like you are a victim of copy and paste coding. Delete your two functions and start over again. That said, you are mixing your view with your controller, please don't do that. I would suggest you use this web2pyslice as a starting point. (yes, I wrote it) http://www.web2pyslices.com/slice/show/1724/cascading-dropdo wns-simplified On Monday, January 26, 2015 at 1:28:20 PM UTC-7, Omi Chiba wrote: I have a three dropdown and the value will be dynamically changed using ajax. It's working fine but something is wrong. In second dropdown (id=lead_name), I specify jQuery('#model_name') but it's actually jQuery('#leadl_name') but then when the value for the second drop changed, the value disappear from the second and third. When I keep the current way (which is wrong name) it's working as expected Do you guys know what's wrong? This is my view form enctype=multipart/form-data action={{URL()}} method=post tr tdselect name='model_name' onchange=jQuery( '#model_name').empty(); ajax('lead_ajax', ['model_name'], 'lead_name'); {{for model in models:}} option value={{=model.Name}} {{= selected='selected' if str(model.Name)= =request.vars.model_name else }} {{=model.Name}} /option {{pass}} /select/td tdselect id='lead_name' name='lead_name' onchange= jQuery('#model_name').empty(); ajax('block_ajax', ['lead_name'], 'block_name'); {{for lead in leads:}} option value={{=lead.Name}} {{= selected='selected' if str(lead.Name)= =request.vars.lead_name else }} {{=lead.Name}} /option {{pass}} /select/td tdselect id='block_name' name='block_name' {{for block in blocks:}} option value={{=block.Name}} {{= selected='selected' if str(block.Name)= =request.vars.block_name else }} {{=block.Name}} /option {{pass}} /select/td td/td td/td tdinput type=submit value='Submit'/td /tr /form My controller def index(): response.title='KR Quick Delivery Service'
[web2py] Re: Groupby year on date field
the doc is rather incomplete. Either you want a set of distinct things, or you want to aggregate something over a group of distinct things. given that db.entries.date is a datetime field, the former is fetched with db(db.entries.id 0).select(db.entries.date.year(), distinct=True) while the latter, e.g. the entry count per year, with sum_of_entries = db.entries.id.count() db(db.entries.id 0).select(sum_of_entries, db.entries.date.year(), groupby =db.entries.date.year()) On Tuesday, January 27, 2015 at 10:25:40 AM UTC+1, Moiz Nagpurwala wrote: I found this code in web2py documentation: for row in db().select( db.entries.ALL, orderby=~db.entirs.Date, groupby=db.entirs.Date): print row.name How to amend this code to select distinct years from a date field. Please help. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: what's wrong with printing URL?
Did you force the CSS to be reloaded by the browser? If so, is it possible you have a similar CSS rule somewhere else? On Tuesday, January 27, 2015 at 3:13:24 PM UTC-5, Vladimir Makarov wrote: no way! I excluded* a:after { content: ( attr(href) ); **}* but nothing happened. On Tuesday, January 27, 2015 at 11:05:25 PM UTC+3, Anthony wrote: If you don't want the href printed, wouldn't you want to get rid of this line: a:after { content: ( attr(href) ); } Anthony On Tuesday, January 27, 2015 at 2:54:05 PM UTC-5, Vladimir Makarov wrote: Hey! So I have this piece of code in my view file: *a href={{=URL('kkm', 'kkm', vars={'kkm':row.id http://row.id, 'client':curClient.id, 'contract':curContract.id})}}{{=row.model}}/a* There is nothing special or magical but if I try to print the page ... ooopppss ...I see this result: *Some_model (/gemma/kkm/kkm? client=156contract=596kkm=107)* instead of *Some_model* Say how can I get rid of link parameters in view when I click to print page? PS This is piece of my css file but itsn't work for me: @media print { * { background: transparent !important; color: #444 !important; text-shadow: none !important; } a, a:visited { color: #444 !important; text-decoration: none; } a:after { content: ( attr(href) ); } @page { margin: 0.5cm; } } Any ideas?!? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: IMPORTANT - DO NOT POST ISSUE ON GOOGLE CODE
it's a pretty big change already. Never say never but I don't see it in the near future because developers aren't that much and frankly the google-group is working really fine for our community. On Tuesday, January 27, 2015 at 5:36:19 PM UTC+1, Ramos wrote: Are you going to use github Gitter ? Thank you -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
Yes, that is another issue... I am thinking more and more to learn Angularjs more then what I really know or start using Ractive.js that seems have easier learning curve... web2py component is great, but I feel really limited in developping complex form like user interraction for complex data management with them... I have made a few thing, but code get messy rappidly... I feel, angularjs deep linking missing with web2py component... But I may just didn't find how to make it happen with web2py component as well... TDD may be easier... Richard On Tue, Jan 27, 2015 at 4:49 PM, Niphlod niph...@gmail.com wrote: testing html generation is one-now-more-than-ever-shrinking-part of testing an app. In this particular case, you won't have noticed a thing: the important bits were/are played by javascript interaction. On Tuesday, January 27, 2015 at 10:38:49 PM UTC+1, Richard wrote: I would test the fact that html generated work properly, I guess Selenium is the only way, but if I can interact with html object from python with someting like HTMLTestRunner (http://tungwaiyip.info/ software/HTMLTestRunner.html)... I never had time to think about test cases worth doing over generated html... Actually, you maybe right that it only allow to see if html get generated or compare html generated to an reference html (mean something like having app serving to test another app to make sure notting get modify on one hand without the other know it... Mean a lot of work merging stuff between repo in orther to maintain test case = a lot of works). Could you provide an example of good controller and view codes? Model is easier... In web2py, I am not sure we can really divide each differents part in M-V-C container... Look how you define validators over model field definition (I know old raised point). Richard -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
TDD may be easier with angularjs... I would say... Richard On Tue, Jan 27, 2015 at 5:05 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Yes, that is another issue... I am thinking more and more to learn Angularjs more then what I really know or start using Ractive.js that seems have easier learning curve... web2py component is great, but I feel really limited in developping complex form like user interraction for complex data management with them... I have made a few thing, but code get messy rappidly... I feel, angularjs deep linking missing with web2py component... But I may just didn't find how to make it happen with web2py component as well... TDD may be easier... Richard On Tue, Jan 27, 2015 at 4:49 PM, Niphlod niph...@gmail.com wrote: testing html generation is one-now-more-than-ever-shrinking-part of testing an app. In this particular case, you won't have noticed a thing: the important bits were/are played by javascript interaction. On Tuesday, January 27, 2015 at 10:38:49 PM UTC+1, Richard wrote: I would test the fact that html generated work properly, I guess Selenium is the only way, but if I can interact with html object from python with someting like HTMLTestRunner (http://tungwaiyip.info/ software/HTMLTestRunner.html)... I never had time to think about test cases worth doing over generated html... Actually, you maybe right that it only allow to see if html get generated or compare html generated to an reference html (mean something like having app serving to test another app to make sure notting get modify on one hand without the other know it... Mean a lot of work merging stuff between repo in orther to maintain test case = a lot of works). Could you provide an example of good controller and view codes? Model is easier... In web2py, I am not sure we can really divide each differents part in M-V-C container... Look how you define validators over model field definition (I know old raised point). Richard -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: what's wrong with printing URL?
Bootstrap also has that.rule you need to override it with: @media print { a:after { content: ; } } -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
testing html generation is one-now-more-than-ever-shrinking-part of testing an app. In this particular case, you won't have noticed a thing: the important bits were/are played by javascript interaction. On Tuesday, January 27, 2015 at 10:38:49 PM UTC+1, Richard wrote: I would test the fact that html generated work properly, I guess Selenium is the only way, but if I can interact with html object from python with someting like HTMLTestRunner ( http://tungwaiyip.info/software/HTMLTestRunner.html)... I never had time to think about test cases worth doing over generated html... Actually, you maybe right that it only allow to see if html get generated or compare html generated to an reference html (mean something like having app serving to test another app to make sure notting get modify on one hand without the other know it... Mean a lot of work merging stuff between repo in orther to maintain test case = a lot of works). Could you provide an example of good controller and view codes? Model is easier... In web2py, I am not sure we can really divide each differents part in M-V-C container... Look how you define validators over model field definition (I know old raised point). Richard -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
You are wrong. If you need to test your views, you would have to use some kind of testing tool like Selenium, of course. However, you should not be generating views within the controllers, they have separate functions. It makes no sense. Besides, what are you going to test, the generation of the html? On Tuesday, January 27, 2015 at 12:13:09 PM UTC-7, Richard wrote: Derek, I understand your point, but from the testing point of view, the only option remaining for testing view is Selenium HQ which is slow, so if you want to be able to test your controller that depend a lot of the view, what I can only see is to limit as much as possible the view to unpack web2py controller variables packed with everything... Do I am wrong in thinking that? Richard On Tue, Jan 27, 2015 at 12:19 PM, Derek sp1...@gmail.com javascript: wrote: What I mean by 'you are mixing your view with your controller' is that you are using your controller to build HTML that will be used as-is. You should never create HTML in your controllers, leave that to the views. The whole point of MVC is that each part has a very specific purpose. Don't create your models in your controllers or views, don't create html in your models or controllers, and don't put logic in models and views. https://www.youtube.com/watch?v=8FWdQVNeTlI On Tuesday, January 27, 2015 at 10:15:50 AM UTC-7, Derek wrote: Well, where do I start? It looks like you are a victim of copy and paste coding. Delete your two functions and start over again. That said, you are mixing your view with your controller, please don't do that. I would suggest you use this web2pyslice as a starting point. (yes, I wrote it) http://www.web2pyslices.com/slice/show/1724/cascading- dropdowns-simplified On Monday, January 26, 2015 at 1:28:20 PM UTC-7, Omi Chiba wrote: I have a three dropdown and the value will be dynamically changed using ajax. It's working fine but something is wrong. In second dropdown (id=lead_name), I specify jQuery('#model_name') but it's actually jQuery('#leadl_name') but then when the value for the second drop changed, the value disappear from the second and third. When I keep the current way (which is wrong name) it's working as expected Do you guys know what's wrong? This is my view form enctype=multipart/form-data action={{URL()}} method=post tr tdselect name='model_name' onchange=jQuery( '#model_name').empty(); ajax('lead_ajax', ['model_name'], 'lead_name'); {{for model in models:}} option value={{=model.Name}} {{= selected='selected' if str(model.Name)= =request.vars.model_name else }} {{=model.Name}} /option {{pass}} /select/td tdselect id='lead_name' name='lead_name' onchange= jQuery('#model_name').empty(); ajax('block_ajax', ['lead_name'], 'block_name'); {{for lead in leads:}} option value={{=lead.Name}} {{= selected='selected' if str(lead.Name)= =request.vars.lead_name else }} {{=lead.Name}} /option {{pass}} /select/td tdselect id='block_name' name='block_name' {{for block in blocks:}} option value={{=block.Name}} {{= selected='selected' if str(block.Name)= =request.vars.block_name else }} {{=block.Name}} /option {{pass}} /select/td td/td td/td tdinput type=submit value='Submit'/td /tr /form My controller def index(): response.title='KR Quick Delivery Service' if request.vars.model_name: lists = db((db.KR_Product.Model==request.vars.model_name) (db .KR_Product.Lead==request.vars.lead_name) (db.KR_Product.Block== request.vars.block_name)).select(db.KR_Product.ALL) else: lists='' models = db().select(db.KR_Model.ALL) leads = db(db.KR_Lead.ModelName == '20').select(db.KR_Lead.ALL) blocks = db(db.KR_Block.LeadName == '01').select(db.KR_Block.ALL) return dict(lists=lists,models=models,leads=leads,blocks=blocks) def lead_ajax(): leads = db(db.KR_Lead.ModelName==request.vars.model_name).select(db .KR_Lead.ALL) result = '' for lead in leads: result += option value=' + lead.Name + ' + lead.Name + /option return XML(result) def block_ajax(): blocks = db(db.KR_Block.LeadName==request.vars.lead_name).select(db .KR_Block.ALL) result = '' for block in blocks: result += option
Re: [web2py] Re: Dropdown lists
it seems that you're rather full of issues and ideas but empty on the attempts side. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Translate Controller names and Function names
unfortunately it seams you can't use both rewrite systems, and I have other apps using the Parameter-based system On Tuesday, 27 January 2015 14:05:26 UTC, Niphlod wrote: IMHO you're better suited for routes http://web2py.com/books/default/chapter/29/04/the-core#URL-rewrite. As long at the mapping is fixed, it's exactly what they've been engineered for. I'd use the pattern-based system -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Translate Controller names and Function names
I think that Niphlod is probably right, though I might be inclined to stick with your programmatic logic rather than use pattern-based routing. And maybe write a wrapper for URL() so that all the logic is in the same place and driven off the same tables. On Tuesday, January 27, 2015 at 4:12:42 AM UTC-8, Francisco Costa wrote: I'm using the Parameter-based rewrite system http://web2py.com/books/default/chapter/29/04/the-core#Parameter-based-system and I would like to find a strategy to **translate controller names and function names**. I have 2 domains and I use only one app for both, but I would like to have the controllers and functions translated for the non-english one. Something like this: - http://domain.com/article/new (english - default language) - http://domain.pt/artigo/novo(portuguese - translation) What would be the best way to achieve this? PS: I also would like to have some redirection if someone typed the wrong domain extension: http://domain.pt/article/new - http://domain.pt/artigo/novo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Override update defaults?
I'm really liking the ability to automatically timestamp when records are updated, but I'm wondering if there's a simple way of suppressing this behaviour when needed: I have these signature fields appended to a number of tables, automatically recording when users update records: signature_fields = idb.Table( idb, 'signature_fields', #Dummy table, not actually in the db Field('created_on', 'datetime', default=request.now, writable=False, readable=False, label='Created on'), Field('created_by', 'string', default=auth.user.username writable=False, readable=False, label='Created by'), Field('modified_on', 'datetime', update=request.now, default=request.now, writable=False, readable=False, label='Modified on'), Field('modified_by', 'string', default=auth.user.username, update=signature_username, writable=False, readable=False, label='Modified by'), ) For example: idb.define_table( 'address', Field('id', 'id', readable=False), Field('student', idb.student, readable=False, writable=False), Field('line1', 'string'), Field('line2', 'string'), Field('line3', 'string'), Field('town', 'string'), Field('countystate', 'string'), Field('country', 'string'), Field('postcode', 'string'), signature_fields ) But I have an admin routine that allows me to move addreses to another student, and I don't want the timestamping to occur when I run: idb.student(source.id).address.update(student=target.id) Is there a simple way to suppress automatic update values? e.g.: idb.student(source.id).address.update(student=target.id, _update=False) I know I can disable them one by one before running the queries, but it'll add lots of boilerplate a la: idb.address.modified_on.update = idb.address.modified_by.update = None -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: represents currency format
I got this error... type 'exceptions.TypeError'(lambda() takes exactly 2 arguments (1 given)) Render also looks complicated to me so I will just use the JS Massimo suugested. Thank you both!! On Monday, January 26, 2015 at 6:01:08 PM UTC-6, Niphlod wrote: in the view, you have td style=text-align: right;{{=list.UnitPrice}}/td use instead td style=text-align: right;{{=db.KR_Product.UnitPrice.represent(list.UnitPrice)}}/td should work without issues. or read about render() here http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Rendering-rows-using-represent -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] About validators
In the book I find:IS_LOWER This validator never returns an error. It just converts the value to lower case. requires = IS_LOWER() Now I try a piece of code: form=FORM(INPUT(_type=text, _name=n, requires=IS_LOWER())) On input abcDEF I expected n==abcdef, but I get abcDEF (not converted to lower characters). What is wrong? Regards, Martin -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Translate Controller names and Function names
Tx Jonathan, how would a wrapper for the URL() look like? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] variable query
Hello! I need to build a variable query to select rows from a database. I need to get the last 11 records from my database, but only the even. This the code of the controller: # Muestra los últimos 11 artículos limite_articulos = 11 # Getting the max id of the table: maxID = db(db.articulos).select(db.articulos.id.max()).first()[db.articulos.id.max()] # Getting the maxID-11 limite_bajo = maxID-limite_articulos cuenta=0 even_query = for i in range(limite_bajo,maxID): cuenta+=1 if cuenta%2==0: # only the even records are saved #print str(i) + es + str(cuenta) query_par += (db.articulos.id==' + str(i) + ') | even_query = query_par[:-2] The resulted even_query is as follows: even_query= (db.articulos.id=='2297') | (db.articulos.id=='2299') | (db.articulos.id=='2301') | (db.articulos.id=='2303') | (db.articulos.id=='2305') I use the resulted string in a query: articulos = db(even_query).select(db.articulos.id, db.articulos.titulo, db.articulos.contenido, db.articulos.autor,orderby=~db.articulos.id) But, I get the following error: *class 'gluon.contrib.pymysql.err.ProgrammingError' (1064, uYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=='2297') | (db.articulos.id=='2299') | (db.articulos.id=='2301') | (db.articulo' at line 1)* If I write the query directy I don't get the error: articulos = db((db.articulos.id=='2297') | (db.articulos.id=='2299') | (db.articulos.id=='2301') | (db.articulos.id=='2303') | (db.articulos.id=='2305')).select(db.articulos.id, db.articulos.titulo, db.articulos.contenido, db.articulos.autor, orderby=~db.articulos.id) The database is SQL Server 2005, Web2py 1.99.7. How can to write a variable query? Thanks for any help. Regards. P. D. I know my english is not very well, I hope you can understand me. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: request_reset_password not returning a form
Thanks Cynthia. But I do have the right format in the keydata file. I'm also not sure that a problem in my email verification would produce my issue. It doesn't get as far as trying to send an email in my case, since no form is created. Cheers, Ian On Monday, January 26, 2015 at 6:04:28 PM UTC-5, Cynthia Butler wrote: It looks like your mail.settings.login = keydata['email_pass'] may be just a password. I'm guessing, it depends on what the value of 'email_pass' is. It needs to be the full user@domain:password, like this: name@maildomain:password On Monday, January 26, 2015 at 1:04:05 PM UTC-7, Ian W. Scott wrote: When I click on Lost Password in the user menu I just get a page with a blank body. The url to which I'm forwarded seems right ( http://ianwscott.webfactional.com/paideia/default/user/request_reset_password?_next=/paideia/default/index) but there's no form on the page. It's as if the page controller is returning an empty dict. But I'm not getting any error message either. I've looked through the page source and it's not that the form is hidden. It's just not being included in the page response. Other default/user forms are produced just fine: login, change_password, etc. So I can't figure out why request_reset_password returns nothing. Since there's no error ticket it's very difficult for me to debug. Any suggestions? Here is my setup for mail and the relevant auth settings (from controllers/db.py): mail = Mail() mail.settings.server = keydata['email_sender'] # 'logging' # SMTP server mail.settings.sender = keydata['email_address'] # email mail.settings.login = keydata['email_pass'] # credentials or None current.mail = mail auth.settings.mailer = mail# for user email verification auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.messages.verify_email = 'Click on the link http://' \ + request.env.http_host + URL('default', 'user', args=['verify_email' ]) \ + '/%(key)s to verify your email' auth.settings.reset_password_requires_verification = True auth.messages.reset_password = 'Click on the link http://' \ + request.env.http_host + URL('default', 'user', args=[ 'reset_password'])\ + '/%(key)s to reset your password' -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: IMPORTANT - DO NOT POST ISSUE ON GOOGLE CODE
Really nice job. I particularly liked the issues division between the whole web2py and the dal. On Monday, January 26, 2015 at 12:08:15 PM UTC-3, Massimo Di Pierro wrote: We have a migration in process and we will be moving all the open issues form googlecode to gihub (thanks Niphlod for handling all of this). So until it is done please: - don't touch existing issues on googlecode - don't open new ones on googlecode - wait a day or two for the complete migration - don't open issues on github - wait for our approval to start opening/modifying issues on github Thanks for the understanding and sorry for the trouble. Everything will be better when done. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Translate Controller names and Function names
I'm using the Parameter-based rewrite system http://web2py.com/books/default/chapter/29/04/the-core#Parameter-based-system and I would like to find a strategy to **translate controller names and function names**. I have 2 domains and I use only one app for both, but I would like to have the controllers and functions translated for the non-english one. Something like this: - http://domain.com/article/new (english - default language) - http://domain.pt/artigo/novo(portuguese - translation) What would be the best way to achieve this? PS: I also would like to have some redirection if someone typed the wrong domain extension: http://domain.pt/article/new - http://domain.pt/artigo/novo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Date format
Hey Sh. Moiz Python dates have a strftime method, you can just use that. See: https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: variable query
This one is simpler than it looks. Heres how you could get the even numbers from the last 11 rows in just one line: db((db.articulos.id % 2) == 0).select(orderby=~db.articulos.id, limitby=(0, 11)) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Date format
db.mytable.datetime_field.represent = lambda value, row: value.strftime(format-here) (thanks Rocha http://stackoverflow.com/questions/12605934/formating-date-in-web2py-python) see here for the directives to use in 'format-here'... https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior On Monday, January 26, 2015 at 10:16:49 PM UTC-7, Moiz Nagpurwala wrote: I want to Display date as *Tuesday, January 27, 2015* How to do that. Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: represents currency format
whoopsie, since you passed a lambda that takes *value, row* you should have passed *list.UnitPrice, list* On Tuesday, January 27, 2015 at 3:44:07 PM UTC+1, Omi Chiba wrote: I got this error... type 'exceptions.TypeError'(lambda() takes exactly 2 arguments (1 given)) Render also looks complicated to me so I will just use the JS Massimo suugested. Thank you both!! On Monday, January 26, 2015 at 6:01:08 PM UTC-6, Niphlod wrote: in the view, you have td style=text-align: right;{{=list.UnitPrice}}/td use instead td style=text-align: right;{{=db.KR_Product.UnitPrice.represent(list.UnitPrice)}}/td should work without issues. or read about render() here http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Rendering-rows-using-represent -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: About validators
'but I get abcDEF' How did you get that? form=FORM(INPUT(_type=text, _name=n, requires=IS_LOWER())) if form.process().accepted: response.flash = form.vars.n The above spits out 'uppercase' when I entered 'UPPERCASE' On Tuesday, 27 January 2015 15:15:34 UTC, mweissen wrote: In the book I find:IS_LOWER This validator never returns an error. It just converts the value to lower case. requires = IS_LOWER() Now I try a piece of code: form=FORM(INPUT(_type=text, _name=n, requires=IS_LOWER())) On input abcDEF I expected n==abcdef, but I get abcDEF (not converted to lower characters). What is wrong? Regards, Martin -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Record format and SQLFORM.factory
form = SQLFORM.factory( Field('Presupuesto', requires=IS_IN_DB(db, db.presupuesto, *db.presupuesto._format*)), submit_button='Continuar', table_name='presupuesto', ) On Monday, 26 January 2015 16:09:31 UTC, César Bustíos Benites wrote: Hello! I have a table called *presupuesto *with a custom *format*: db.define_table('presupuesto', Field('jar', db.jar, label='JAR'), Field('monto', 'decimal(11, 2)', label='Presupuesto inicial', requires =IS_NOT_EMPTY(error_message='Ingrese un monto para el presupuesto')), Field('monto_mensual', 'decimal(11, 2)', label='Presupuesto mensual', compute=lambda r: Decimal(r.monto)/Decimal('12')), Field('ano', 'integer', label='Año', requires=[IS_NOT_EMPTY( error_message='Ingrese el año'), IS_INT_IN_RANGE(1980, 2100, error_message ='Año inválido')]), format=lambda record: '%s %s' % (record.jar.nombre, record.ano) ) I'm using the following SQLFORM.factory in a view: @auth.requires_login() def control_gastos(): form = SQLFORM.factory( Field('Presupuesto', requires=IS_IN_DB(db, db.presupuesto)), submit_button='Continuar', table_name='presupuesto', ) form.element(_type='submit')['_class'] = 'btn btn-success' form.element('#presupuesto_Presupuesto')['_class'] = 'form-control' form.element('#presupuesto_Presupuesto')['_style'] = 'width: 100%' return dict(form=form) Somehow, I was expecting that the records shown in the form were formatted as define in the table but that's not happening. It's only showing IDs: https://lh6.googleusercontent.com/-HVtGNOVneTI/VMZm_thtOTI/YFs/YrDCU2mdVLI/s1600/Screenshot%2Bfrom%2B2015-01-26%2B11%3A09%3A18.png What am I missing? Thanks, César -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Is Web2py suitable for my project
I will probably try, but not soon... I am really currious to know how it works and can provide that kind of feature, maybe it is similar to Brython (http://www.brython.info/)... Richard On Mon, Jan 26, 2015 at 10:58 AM, Eric eric.sh...@gmail.com wrote: Richard, If you try Bokeh and/or mpld3 please tell me how it went. I'll need scientific plots in my application and would welcome any hints on how to accomplish this in Web2py. Eric On Monday, January 26, 2015 at 9:30:48 AM UTC-6, Richard wrote: Didn't know bokeh thanks! Richard On Sun, Jan 25, 2015 at 10:43 PM, Kiran Subbaraman subbaram...@gmail.com wrote: Eric, The best option then is for you to try out the hello-world example in web2py. This will give you a good idea as to how to create a minimal web application, and also insert your code. You need to start here: http://web2py.com/books/default/chapter/29/03/overview#Say-hello The stuff you are talking about should be pretty straight-forward in web2py (or any other equivalent web framework). You need to create a model file (to store stuff in the db), a controller (where your plotting logic, like that of Bokeh / MPLD3, will reside), and the view (the html where you render your charts, or even embed javascript based plotting libraries - like d3js). Feel free to ask questions as you work your way through the initial web2py programming model. Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ On Mon, 26-01-2015 3:22 AM, Eric wrote: Kiran, Thanks for the response. I'm extremely new to any sort of web programming. I have a bit of Python experience. Unfortunately the response above was simply above my head. I've written file parsers in Python so I can handle that. I'm confident I can write the algorithms too. What I can't figure out is how to integrate a plotting utility like Bokeh or possibly MPLD3 (http://mpld3.github.io/index.html) into Web2py and get the plot to show up in a Web2py created page. I've seen a few examples of how to trigger a browser's file dialog, but don't know how to use that to get a file into the Python parsing script. I'm usually pretty good at finding resources on the web, but my general knowledge of web technologies is a problem. Eric On Sunday, January 25, 2015 at 3:24:18 AM UTC-6, Kiran Subbaraman wrote: I would use web2py for these requirements, because you get the authentication/authorization, sessions, DAL (for db access) capabilities out of the box. You probably need packages in addition to pydal (for DAL support), on top of Flask to accomplish this. Look at the gluino example to see what I mean: https://github.com/mdipierro/gluino Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ On Sat, 24-01-2015 9:53 PM, Eric wrote: Hi all, I'm new to web2py and have been working my way through the learning materials. I have a specific application and am wondering if web2py is a good choice for a framework or something simpler such as Flask. Specifically I want to create a web application (for an intranet) where a user would upload a data file using the standard browser file dialog, have it analyzed by an algorithm I've written in Python and then responses plotted on the page and also a file of results savable using the browsers standard save file dialog. I know enough Python to handle the file parsing, data analysis and result file generation. I'll need access to Python libraries such as Numpy. I've discovered Bokah (http://bokeh.pydata.org) as an attractive plotting library. They use Flask in their tutorial. I haven't found anything particularly clear about how to invoke the browser file dialogs. Eventually I'd like to use a database to archive the uploaded data files and resulting result files along with other information such as user, date, instrument serial number, etc. Thanks, Eric -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -
[web2py] Re: Translate Controller names and Function names
This is a good question, maybe there should be more direct web2py support for it, as usability wise it's a nice feature. A wrapper is just a function that calls the other for you, like a decorator. In your case you could have something like this in your models. def TURL(**kwargs): if 'c' in kwargs: kwargs['c'] = T(kwargs['c'], lazy=False) if 'f' in kwargs: kwargs['f'] = T(kwargs['f'], lazy=False) return URL(**kwargs) Then you could use it in the views {{=TURL(r=request, c='articles', f='search'))}} Could Francisco use pattern based routing just for this app if he puts it in the application's folder routes.py? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Dropdown lists
Well, where do I start? It looks like you are a victim of copy and paste coding. Delete your two functions and start over again. That said, you are mixing your view with your controller, please don't do that. I would suggest you use this web2pyslice as a starting point. (yes, I wrote it) http://www.web2pyslices.com/slice/show/1724/cascading-dropdowns-simplified On Monday, January 26, 2015 at 1:28:20 PM UTC-7, Omi Chiba wrote: I have a three dropdown and the value will be dynamically changed using ajax. It's working fine but something is wrong. In second dropdown (id=lead_name), I specify jQuery('#model_name') but it's actually jQuery('#leadl_name') but then when the value for the second drop changed, the value disappear from the second and third. When I keep the current way (which is wrong name) it's working as expected Do you guys know what's wrong? This is my view form enctype=multipart/form-data action={{URL()}} method=post tr tdselect name='model_name' onchange=jQuery( '#model_name').empty(); ajax('lead_ajax', ['model_name'], 'lead_name'); {{for model in models:}} option value={{=model.Name}} {{= selected='selected' if str(model.Name)= =request.vars.model_name else }} {{=model.Name}} /option {{pass}} /select/td tdselect id='lead_name' name='lead_name' onchange= jQuery('#model_name').empty(); ajax('block_ajax', ['lead_name'], 'block_name'); {{for lead in leads:}} option value={{=lead.Name}} {{= selected='selected' if str(lead.Name)= =request.vars.lead_name else }} {{=lead.Name}} /option {{pass}} /select/td tdselect id='block_name' name='block_name' {{for block in blocks:}} option value={{=block.Name}} {{= selected='selected' if str(block.Name)= =request.vars.block_name else }} {{=block.Name}} /option {{pass}} /select/td td/td td/td tdinput type=submit value='Submit'/td /tr /form My controller def index(): response.title='KR Quick Delivery Service' if request.vars.model_name: lists = db((db.KR_Product.Model==request.vars.model_name) (db. KR_Product.Lead==request.vars.lead_name) (db.KR_Product.Block==request. vars.block_name)).select(db.KR_Product.ALL) else: lists='' models = db().select(db.KR_Model.ALL) leads = db(db.KR_Lead.ModelName == '20').select(db.KR_Lead.ALL) blocks = db(db.KR_Block.LeadName == '01').select(db.KR_Block.ALL) return dict(lists=lists,models=models,leads=leads,blocks=blocks) def lead_ajax(): leads = db(db.KR_Lead.ModelName==request.vars.model_name).select(db. KR_Lead.ALL) result = '' for lead in leads: result += option value=' + lead.Name + ' + lead.Name + /option return XML(result) def block_ajax(): blocks = db(db.KR_Block.LeadName==request.vars.lead_name).select(db. KR_Block.ALL) result = '' for block in blocks: result += option value=' + block.Name + ' + block.Name + /option return XML(result) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: IMPORTANT - DO NOT POST ISSUE ON GOOGLE CODE
Are you going to use github Gitter ? Thank you 2015-01-27 8:39 GMT+00:00 Massimiliano mbelle...@gmail.com: Remember to change the readme that reports ;-) : Issues? Report issues at http://code.google.com/p/web2py/issues/ On Tue, Jan 27, 2015 at 12:00 AM, Niphlod niph...@gmail.com wrote: migration completed. You can find in the original googlecode issue a last message by me linking to the newly migrated issue on github, and on the github issue the link to the original issue on googlecode. From now on: - googlecode issues WON'T be looked at - please post ONLY issues on https://github.com/web2py/web2py/issues - moreover, if your issues are relative to DAL, now it lives in a different repository, so the issues should be posted to https://github.com/web2py/pydal/issues Bye -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Massimiliano -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Translate Controller names and Function names
Honestly, I have never seen a need for this. Any time I visit a foreign language site, the URL mapping is in english. Chinese, Japanese, Russian, all seem to keep the URL pretty much the same regardless of the language. I can usually hunt my way around a foreign language website by the links.For example, on a Russian site, i'll hover over 'novosti' to find the url '/news/' etc etc. On Tuesday, January 27, 2015 at 5:12:42 AM UTC-7, Francisco Costa wrote: I'm using the Parameter-based rewrite system http://web2py.com/books/default/chapter/29/04/the-core#Parameter-based-system and I would like to find a strategy to **translate controller names and function names**. I have 2 domains and I use only one app for both, but I would like to have the controllers and functions translated for the non-english one. Something like this: - http://domain.com/article/new (english - default language) - http://domain.pt/artigo/novo(portuguese - translation) What would be the best way to achieve this? PS: I also would like to have some redirection if someone typed the wrong domain extension: http://domain.pt/article/new - http://domain.pt/artigo/novo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Is Web2py suitable for my project
Richard, I think Bokeh and MPLD3 are quite specifically designed to provide somewhat interactive scientific plots. Brython seems completely different. Eric - Eric On Jan 27, 2015, at 9:52 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: I will probably try, but not soon... I am really currious to know how it works and can provide that kind of feature, maybe it is similar to Brython (http://www.brython.info/). http://www.brython.info/)... Richard On Mon, Jan 26, 2015 at 10:58 AM, Eric eric.sh...@gmail.com mailto:eric.sh...@gmail.com wrote: Richard, If you try Bokeh and/or mpld3 please tell me how it went. I'll need scientific plots in my application and would welcome any hints on how to accomplish this in Web2py. Eric On Monday, January 26, 2015 at 9:30:48 AM UTC-6, Richard wrote: Didn't know bokeh thanks! Richard On Sun, Jan 25, 2015 at 10:43 PM, Kiran Subbaraman subbaram...@gmail.com wrote: Eric, The best option then is for you to try out the hello-world example in web2py. This will give you a good idea as to how to create a minimal web application, and also insert your code. You need to start here:http://web2py.com/books/default/chapter/29/03/overview#Say-hello http://web2py.com/books/default/chapter/29/03/overview#Say-hello The stuff you are talking about should be pretty straight-forward in web2py (or any other equivalent web framework). You need to create a model file (to store stuff in the db), a controller (where your plotting logic, like that of Bokeh / MPLD3, will reside), and the view (the html where you render your charts, or even embed javascript based plotting libraries - like d3js). Feel free to ask questions as you work your way through the initial web2py programming model. Kiran Subbaraman http://subbaraman.wordpress.com/about/ http://subbaraman.wordpress.com/about/ On Mon, 26-01-2015 3:22 AM, Eric wrote: Kiran, Thanks for the response. I'm extremely new to any sort of web programming. I have a bit of Python experience. Unfortunately the response above was simply above my head. I've written file parsers in Python so I can handle that. I'm confident I can write the algorithms too. What I can't figure out is how to integrate a plotting utility like Bokeh or possibly MPLD3 (http://mpld3.github.io/index.html http://mpld3.github.io/index.html) into Web2py and get the plot to show up in a Web2py created page. I've seen a few examples of how to trigger a browser's file dialog, but don't know how to use that to get a file into the Python parsing script. I'm usually pretty good at finding resources on the web, but my general knowledge of web technologies is a problem. Eric On Sunday, January 25, 2015 at 3:24:18 AM UTC-6, Kiran Subbaraman wrote: I would use web2py for these requirements, because you get the authentication/authorization, sessions, DAL (for db access) capabilities out of the box. You probably need packages in addition to pydal (for DAL support), on top of Flask to accomplish this. Look at the gluino example to see what I mean: https://github.com/mdipierro/gluino https://github.com/mdipierro/gluino Kiran Subbaraman http://subbaraman.wordpress.com/about/ http://subbaraman.wordpress.com/about/On Sat, 24-01-2015 9:53 PM, Eric wrote: Hi all, I'm new to web2py and have been working my way through the learning materials. I have a specific application and am wondering if web2py is a good choice for a framework or something simpler such as Flask. Specifically I want to create a web application (for an intranet) where a user would upload a data file using the standard browser file dialog, have it analyzed by an algorithm I've written in Python and then responses plotted on the page and also a file of results savable using the browsers standard save file dialog. I know enough Python to handle the file parsing, data analysis and result file generation. I'll need access to Python libraries such as Numpy. I've discovered Bokah (http://bokeh.pydata.org http://bokeh.pydata.org/) as an attractive plotting library. They use Flask in their tutorial. I haven't found anything particularly clear about how to invoke the browser file dialogs. Eventually I'd like to use a database to archive the uploaded data files and resulting result files along with other information such as user, date, instrument serial number, etc. Thanks, Eric -- Resources: - http://web2py.com http://web2py.com/ - http://web2py.com/book http://web2py.com/book (Documentation) - http://github.com/web2py/web2py http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users
[web2py] Question about web2py roadmap.
Dear web2py-users, Here is my question about the roadmap goals for web2py development. Will the goals for web2py development be oriented to serve Web Developers MORE THAN Website Administrators or vice versa? I personally think web2py should serve Web Developers MORE THAN Website Administrators. However, i think it is often the case that web2py serves Website Administrators MORE THAN Web Developers. I think this is especially true regarding the target users of plugins and wizards. Thanks for a GREAT framework. Love and peace, Joe -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Groupby year on date field
I found this code in web2py documentation: for row in db().select( db.entries.ALL, orderby=~db.entirs.Date, groupby=db.entirs.Date): print row.name How to amend this code to select distinct years from a date field. Please help. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Translate Controller names and Function names
Very interesting question. It must have some effect on SEO. I have seen this post but it does not seem to solve exactly this https://groups.google.com/forum/#!searchin/web2py/translate$20url/web2py/3adXUSCGQQQ/TaKfRagHyvMJ Although if you have a different URL for different content it will be indexed. If the two apps are working in two different domains they will be indexed accordingly. I tried to do what you want by interception the request object but it doe not work. One way is to use routes.py and write one rule per URL. 2015-01-27 10:12 GMT-02:00 Francisco Costa m...@franciscocosta.com: I'm using the Parameter-based rewrite system http://web2py.com/books/default/chapter/29/04/the-core#Parameter-based-system and I would like to find a strategy to **translate controller names and function names**. I have 2 domains and I use only one app for both, but I would like to have the controllers and functions translated for the non-english one. Something like this: - http://domain.com/article/new (english - default language) - http://domain.pt/artigo/novo(portuguese - translation) What would be the best way to achieve this? PS: I also would like to have some redirection if someone typed the wrong domain extension: http://domain.pt/article/new - http://domain.pt/artigo/novo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Carlos J. Costa Cientista da Computação | BS Computer Science Esp. Gestão em Telecom | PgC Telecom Mangement º)) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Date format
This worked for me: entry.Date.strftime(%A, %d %B %Y) On Tuesday, January 27, 2015 at 10:46:49 AM UTC+5:30, Sh. Moiz M. Husain Bhai Nagpurwala wrote: I want to Display date as *Tuesday, January 27, 2015* How to do that. Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Question about web2py roadmap.
I never thought about it in those terms. I think it serves web developers by taking care of administrative issues for them. On Tuesday, 27 January 2015 11:14:06 UTC-6, JoeCodeswell wrote: Dear web2py-users, Here is my question about the roadmap goals for web2py development. Will the goals for web2py development be oriented to serve Web Developers MORE THAN Website Administrators or vice versa? I personally think web2py should serve Web Developers MORE THAN Website Administrators. However, i think it is often the case that web2py serves Website Administrators MORE THAN Web Developers. I think this is especially true regarding the target users of plugins and wizards. Thanks for a GREAT framework. Love and peace, Joe -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Dropdown lists
What I mean by 'you are mixing your view with your controller' is that you are using your controller to build HTML that will be used as-is. You should never create HTML in your controllers, leave that to the views. The whole point of MVC is that each part has a very specific purpose. Don't create your models in your controllers or views, don't create html in your models or controllers, and don't put logic in models and views. https://www.youtube.com/watch?v=8FWdQVNeTlI On Tuesday, January 27, 2015 at 10:15:50 AM UTC-7, Derek wrote: Well, where do I start? It looks like you are a victim of copy and paste coding. Delete your two functions and start over again. That said, you are mixing your view with your controller, please don't do that. I would suggest you use this web2pyslice as a starting point. (yes, I wrote it) http://www.web2pyslices.com/slice/show/1724/cascading-dropdowns-simplified On Monday, January 26, 2015 at 1:28:20 PM UTC-7, Omi Chiba wrote: I have a three dropdown and the value will be dynamically changed using ajax. It's working fine but something is wrong. In second dropdown (id=lead_name), I specify jQuery('#model_name') but it's actually jQuery('#leadl_name') but then when the value for the second drop changed, the value disappear from the second and third. When I keep the current way (which is wrong name) it's working as expected Do you guys know what's wrong? This is my view form enctype=multipart/form-data action={{URL()}} method=post tr tdselect name='model_name' onchange=jQuery( '#model_name').empty(); ajax('lead_ajax', ['model_name'], 'lead_name'); {{for model in models:}} option value={{=model.Name}} {{= selected='selected' if str(model.Name)= =request.vars.model_name else }} {{=model.Name}} /option {{pass}} /select/td tdselect id='lead_name' name='lead_name' onchange= jQuery('#model_name').empty(); ajax('block_ajax', ['lead_name'], 'block_name'); {{for lead in leads:}} option value={{=lead.Name}} {{= selected='selected' if str(lead.Name)= =request.vars.lead_name else }} {{=lead.Name}} /option {{pass}} /select/td tdselect id='block_name' name='block_name' {{for block in blocks:}} option value={{=block.Name}} {{= selected='selected' if str(block.Name)= =request.vars.block_name else }} {{=block.Name}} /option {{pass}} /select/td td/td td/td tdinput type=submit value='Submit'/td /tr /form My controller def index(): response.title='KR Quick Delivery Service' if request.vars.model_name: lists = db((db.KR_Product.Model==request.vars.model_name) (db. KR_Product.Lead==request.vars.lead_name) (db.KR_Product.Block==request. vars.block_name)).select(db.KR_Product.ALL) else: lists='' models = db().select(db.KR_Model.ALL) leads = db(db.KR_Lead.ModelName == '20').select(db.KR_Lead.ALL) blocks = db(db.KR_Block.LeadName == '01').select(db.KR_Block.ALL) return dict(lists=lists,models=models,leads=leads,blocks=blocks) def lead_ajax(): leads = db(db.KR_Lead.ModelName==request.vars.model_name).select(db. KR_Lead.ALL) result = '' for lead in leads: result += option value=' + lead.Name + ' + lead.Name + /option return XML(result) def block_ajax(): blocks = db(db.KR_Block.LeadName==request.vars.lead_name).select(db. KR_Block.ALL) result = '' for block in blocks: result += option value=' + block.Name + ' + block.Name + /option return XML(result) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] pydal / postgres / jsonb
Any plans for the the postgres adapter to support *jsonb* type, by default, and not the basic json type? The *jsonb* type seems to have a lot more capabilities going for it, than the basic json type: http://www.postgresql.org/docs/devel/static/datatype-json.html Indexing support, containment checks, and postgres' recommendation: ..most applications should prefer to store JSON data as jsonb.. makes this rather attractive to me. Any thoughts? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Dropdown lists
Thank you for your feedback! I found onchange=jQuery('#model_name').empty(); this is unnecessary operation for my purpose so it's removed! On Tue, Jan 27, 2015 at 11:19 AM, Derek sp1d...@gmail.com wrote: What I mean by 'you are mixing your view with your controller' is that you are using your controller to build HTML that will be used as-is. You should never create HTML in your controllers, leave that to the views. The whole point of MVC is that each part has a very specific purpose. Don't create your models in your controllers or views, don't create html in your models or controllers, and don't put logic in models and views. https://www.youtube.com/watch?v=8FWdQVNeTlI On Tuesday, January 27, 2015 at 10:15:50 AM UTC-7, Derek wrote: Well, where do I start? It looks like you are a victim of copy and paste coding. Delete your two functions and start over again. That said, you are mixing your view with your controller, please don't do that. I would suggest you use this web2pyslice as a starting point. (yes, I wrote it) http://www.web2pyslices.com/slice/show/1724/cascading- dropdowns-simplified On Monday, January 26, 2015 at 1:28:20 PM UTC-7, Omi Chiba wrote: I have a three dropdown and the value will be dynamically changed using ajax. It's working fine but something is wrong. In second dropdown (id=lead_name), I specify jQuery('#model_name') but it's actually jQuery('#leadl_name') but then when the value for the second drop changed, the value disappear from the second and third. When I keep the current way (which is wrong name) it's working as expected Do you guys know what's wrong? This is my view form enctype=multipart/form-data action={{URL()}} method=post tr tdselect name='model_name' onchange=jQuery( '#model_name').empty(); ajax('lead_ajax', ['model_name'], 'lead_name'); {{for model in models:}} option value={{=model.Name}} {{= selected='selected' if str(model.Name)= =request.vars.model_name else }} {{=model.Name}} /option {{pass}} /select/td tdselect id='lead_name' name='lead_name' onchange= jQuery('#model_name').empty(); ajax('block_ajax', ['lead_name'], 'block_name'); {{for lead in leads:}} option value={{=lead.Name}} {{= selected='selected' if str(lead.Name)= =request.vars.lead_name else }} {{=lead.Name}} /option {{pass}} /select/td tdselect id='block_name' name='block_name' {{for block in blocks:}} option value={{=block.Name}} {{= selected='selected' if str(block.Name)= =request.vars.block_name else }} {{=block.Name}} /option {{pass}} /select/td td/td td/td tdinput type=submit value='Submit'/td /tr /form My controller def index(): response.title='KR Quick Delivery Service' if request.vars.model_name: lists = db((db.KR_Product.Model==request.vars.model_name) (db. KR_Product.Lead==request.vars.lead_name) (db.KR_Product.Block==request .vars.block_name)).select(db.KR_Product.ALL) else: lists='' models = db().select(db.KR_Model.ALL) leads = db(db.KR_Lead.ModelName == '20').select(db.KR_Lead.ALL) blocks = db(db.KR_Block.LeadName == '01').select(db.KR_Block.ALL) return dict(lists=lists,models=models,leads=leads,blocks=blocks) def lead_ajax(): leads = db(db.KR_Lead.ModelName==request.vars.model_name).select(db. KR_Lead.ALL) result = '' for lead in leads: result += option value=' + lead.Name + ' + lead.Name + /option return XML(result) def block_ajax(): blocks = db(db.KR_Block.LeadName==request.vars.lead_name).select(db. KR_Block.ALL) result = '' for block in blocks: result += option value=' + block.Name + ' + block.Name + /option return XML(result) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/ZnZtTw-HXFc/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com -
[web2py] Re: variable query
If you are writing the SQL manually, you cannot have db. in the table names, as that is Python code, not SQL. Anyway, this is probably not the best approach because IDs may not remain consecutive integers (e.g., if you delete a record). Instead, maybe it would be simpler to just select that last 22 records and then just take every other one of those. As an aside, you can build up a query dynamically in a loop by using = or |=: query_par |= db.articulos.id == i As another aside, if you have a DAL query that works and you want to see the SQL that was generated, you can use ._select instead of .select to generate the SQL without executing the query (you can also look in response.toolbar or db._lastsql). Anthony On Tuesday, January 27, 2015 at 6:59:32 PM UTC-5, José Eloy wrote: Hello! I need to build a variable query to select rows from a database. I need to get the last 11 records from my database, but only the even. This the code of the controller: # Muestra los últimos 11 artículos limite_articulos = 11 # Getting the max id of the table: maxID = db(db.articulos).select(db.articulos.id.max()).first()[db.articulos.id.max()] # Getting the maxID-11 limite_bajo = maxID-limite_articulos cuenta=0 even_query = for i in range(limite_bajo,maxID): cuenta+=1 if cuenta%2==0: # only the even records are saved #print str(i) + es + str(cuenta) query_par += (db.articulos.id==' + str(i) + ') | even_query = query_par[:-2] The resulted even_query is as follows: even_query= (db.articulos.id=='2297') | (db.articulos.id=='2299') | ( db.articulos.id=='2301') | (db.articulos.id=='2303') | (db.articulos.id =='2305') I use the resulted string in a query: articulos = db(even_query).select(db.articulos.id, db.articulos.titulo, db.articulos.contenido, db.articulos.autor,orderby=~ db.articulos.id) But, I get the following error: *class 'gluon.contrib.pymysql.err.ProgrammingError' (1064, uYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=='2297') | (db.articulos.id http://db.articulos.id=='2299') | (db.articulos.id http://db.articulos.id=='2301') | (db.articulo' at line 1)* If I write the query directy I don't get the error: articulos = db((db.articulos.id=='2297') | (db.articulos.id=='2299') | (db.articulos.id=='2301') | (db.articulos.id=='2303') | (db.articulos.id =='2305')).select(db.articulos.id, db.articulos.titulo, db.articulos.contenido, db.articulos.autor, orderby=~db.articulos.id) The database is SQL Server 2005, Web2py 1.99.7. How can to write a variable query? Thanks for any help. Regards. P. D. I know my english is not very well, I hope you can understand me. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.