[web2py] Re: centralize file view *.html
did you by any chance looked at http://web2py.com/books/default/chapter/29/05#Page-layout ? On Thursday, February 14, 2013 8:51:50 AM UTC+1, 黄祥 wrote: hi, i want to try centralize file view *.html, but it's ended with failure when using extend and include. for example i want to create block footer separate file that can be replace the default layout.html, i know it can be done when define it block footer in each file, or redefine it on layout.html, but the problem is when i have a lot file using the same template footer it will make a lot of work. did anyone know how to simplified centralize file view? any hints, or suggestion is greatly appreciate. thank you so much before *example code that not work* *views/block_footer.html* {{block footer}} custom_footer {{end}} *views/default/blog.html* *1.* * *{{extend 'layout.html'}} {{include 'block_footer.html'}} * 2.* * *{{extend 'layout.html'}} {{extend 'block_footer.html'}} -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: From a component controller, can I force reload of entire page?
PS: the deletion happens via ajax through an onclick event attached to the delete button. The redirection was added only to keep the deletion working without javascript enabled. On Thursday, February 14, 2013 5:53:50 AM UTC+1, Anthony wrote: Here's the relevant code: elif deletable and len(request.args) 2 and request.args[-3] == 'delete': table = db[request.args[-2]] if ondelete: ondelete(table, request.args[-1]) db(table[table._id.name] == request.args[-1]).delete() redirect(referrer) Looks like it automatically does a regular redirect. You can get around that by specifying an ondelete function that does the deleting and then a client-side redirect (not tested): def my_ondelete(table, id): db(table[table._id.name] == id).delete() redirect(referrer, client_side=True) Anthony On Wednesday, February 13, 2013 8:47:25 PM UTC-5, Jim S wrote: Thanks Anthony. Is there also a way for me to force a reload of the entire page after a delete is processed from the list view of a SQLFORM.grid? On Wed, Feb 13, 2013 at 7:03 PM, Anthony abas...@gmail.com wrote: if form.process().accepted: redirect(URL(...), client_side=True) With client_side=True, redirect returns a regular 200 response along with a special header containing the redirect URL. Javascript code reads that header and does a client-side reload with the new URL. Anthony On Wednesday, February 13, 2013 5:53:33 PM UTC-5, Jim S wrote: I'm using a component with a LOAD statement. In my component I have a SQLFORM.factory form. When I submit that form I want to reload my entire page. I can't seem to envision how I could do that. Can anyone help? -Jim -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: centralize file view *.html
already, i even tested it : *example code that not work* *views/block_footer.html* {{block footer}} custom_footer {{end}} *views/default/blog.html* *1.* * *{{extend 'layout.html'}} {{include 'block_footer.html'}} i think the server is confused about which block footer that they will use, so the out put is not as expected, when using include (number 1) and using extend (number 2) any hints, or suggestion about this? thank you so much in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: outdated web2py plugin for jquery mobile
I had the same problem today. Looks like http://web2py.com/plugins/plugin_jqmobile/about still refers to the wrong plugin. Am Sonntag, 21. Oktober 2012 17:43:37 UTC+2 schrieb Massimo Di Pierro: Will do asap. The one that ships with admin is updated, the one on web2py.com/plugins is not. On Sunday, 21 October 2012 09:35:44 UTC-5, kirilisa wrote: Hi, I'm new to web2py (and to python in fact) and was very excited about the ease of use that seemed evident in web2py for building my HTML5 app. As I had previously determined to use jQuery Mobile, I was even more excited to see that there was a plugin for that. However, downloading the plugin from http://web2py.com/plugins/plugin_jqmobile/about always resulted in a blank page - the plugin did not work. On closer inspection, some of the pathing in the layout.html file was wrong, but fixing that still did not make it work. I was ready to give it up when I noticed that web2py 2.1 was out and that it had a mobile admin interface that was in fact using the jQuery Mobile plugin! However, still, installing the plugin in my custom app from the app creation wizard or even downloading it from the mobile admin page at http://192.168.1.11:8000/admin/plugin_jqmobile/about resulted in the same old outdated version of the plugin. I finally scrapped the install and just copied all the plugin files from the /admin/ app to my web2py app - it now works. To make a long story short - it would be great if the plugin download could be updated both on the mobile admin page and at http://web2py.com/plugins/plugin_jqmobile/about to spare someone else the frustration I went through trying to get it to work! Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Example JSON Code
How do you put that before the $.jsonp({ call? {{=SCRIPT(...)}} script ...here goes the js that uses .jsonp/script You can also do string interpolation with one SCRIPT call SCRIPT( ... url: %(url)s, % dict(url=URL(...))) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Setting up memcache on GAE - a basic question
I would like to store both session data and cached data in memcache when I upload my app to GAE. Can anybody point me in the right direction for setting this up? Based on the web2py scaffolding app I have tried (in models/db.py): if not request.env.web2py_runtime_gae: db = DAL('sqlite://storage.sqlite', lazy_tables=True) else: db = DAL('google:datastore', lazy_tables=True) from gluon.contrib.memdb import MEMDB from google.appengine.api.memcache import Client session.connect(request, response, db = MEMDB(Client())) cache.ram = cache.disk = cache.memcache My app runs OK on sqlite but, once moved to GAE I get an Internal Error whenever serving a page that attempts to store cache data in memcache. From http://web2py.com/books/default/chapter/29/13?search=cache#Memcache I see there is a suggestion to use: from gluon.contrib.gae_memcache import MemcacheClient from gluon.contrib.memdb import MEMDB cache.memcache = MemcacheClient(request) I don't understand how this relates to the scaffolding app code - what is MEMDB, what is the correct usage of gluon.contrib.gae_memcache and google.appengine.api.memcache? Trial and error has got me nowhere, so I thought I would confess my ignorance and ask the experts! Andy -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] make_min_web2py.py no longer working (anyserver)
script call anyserver.py, which is no longer present in 2.x :( -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: make_min_web2py.py no longer working (anyserver)
sure that anyserver is the problem? https://github.com/web2py/web2py/blob/master/anyserver.py On Thursday, February 14, 2013 11:48:23 AM UTC+1, Mirek Zvolský wrote: script call anyserver.py, which is no longer present in 2.x :( -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Cannot get a div to update, once form inputs have been successfully processed and Ajax used.
Hi, Please could someone tell me why this won't work (see between 'THIS PART NOT WORKING - START' and 'THIS PART NOT WORKING - END' in code entered below. In a nutshell, once a form is processed, I want to stay on same page (successfully achieved) and also update a div (ID = 'scan_info_previous') (won't work). I'm fairly new to web programming. Best regards Ann {{response.files.append(URL('static','css/columns_2_Liquid.css'))}} {{response.files.append(URL('static','js/input_patient_form.js'))}} {{extend 'layout.html'}} {{def get_entry_html(scan_instance_tree): }} {{get_entry_node_html(scan_instance_tree.child_nodes, -1, True) }} {{return }} {{def get_entry_node_html(a_nodes, a_parent_id, a_is_root): }} {{if a_is_root == False:}} {{str_class = 'class=field_dependancy_group'}} {{str_display = 'style=display:none'}} {{else:}} {{str_class = ''}} {{str_display = 'style=display:block'}} {{pass}} div id=has_parent_id_{{=a_parent_id }} {{=str_display}} {{=str_class}} /br {{for child_node in a_nodes:}} {{=child_node.field_name }} select id='field_phenotype_id_{{=child_node.field_phenotype_id}}' name='{{=child_node.field_phenotype_id}}' {{if len(child_node.child_nodes) 0:}} class=parent_field_select {{else:}} class='leaf_field_select' {{pass}} {{for value in child_node.values:}} {{str_selected = ''}} {{if (value['value'] == 0): }} {{str_selected = ' selected=selected'}} {{pass}} option value= {{=value['value']}} {{=str_selected}} {{=value['description']}} /option {{pass}} /select {{=A(IMG(_id=img_help, _src=URL(static,images/help.png), _alt=My Logo), callback=URL(default,get_phenotype_help, vars=dict(field_id=child_node.field_phenotype_id) ), target=scan_field_extra)}} /br/br {{if len(child_node.child_nodes) 0:}} {{get_entry_node_html(child_node.child_nodes, child_node.field_phenotype_id, False)}} {{pass}} {{pass}} /div {{return}} div id=masthead H1 {{=response.title or request.application}} Project/H1 /div div id=content div id=patient_info class=layout_block h3Patient Data/h3 form id=patient_form fieldset table tr td Patient ID (or leave empty for new patient): input name=patient_id id=patient_id value=12/td tdinput type=submit value=Search Patient/td div id=open_clearcanvas_target/div /tr /table /fieldset /form /div !--field_new_group = field_is_new_group, field_parent_group = field_row.field_phenotype_group.field_head_fk, field_parent_dependancy = field_row.field_phenotype_functional_dependancy.field_head_fk, -- form id=scaninstance_form action={{=URL('add_new_scan')}} method=post fieldset input name=hidden_patient_id id=hidden_patient_id style=display:none div id=source_input table tr tdSource: input type=text name=source id=source/td tdDiagnosis: input type=text name=diagnosis id=diagnosis/td /tr /table /div h3New Scan Data/h3 input type='submit' value='Submit New Scan Data' /br /br input type='button' value='Update Scan Type' /br /br div id=scan_info class=layout_block Age in Months: input type=text name=age_months class=field_input value='' {{response.write(get_entry_html(scan_instance_tree), escape=False)}} /div /fieldset /form /br div id=scan_info_previous class=layout_block /div /div div id=sidebar div id=patient_extra /div div id=scan_field_extra /div /br /br div id=model_field_extra H3 Phenotype Occurrences / Predictive Values /H3 H4 for Cortical-Cerebral: Gyriform - Depths of Sulci/H4 table cellpadding=3 cellspacing=3 ... /table /div /div div id=footer ... /div script $('#patient_form').submit(function(){ ajax('{{=URL('get_patient_info')}}',['patient_id'], 'source_input'); ajax('{{=URL('open_patient_images_clearcanvas')}}',['patient_id'], 'open_clearcanvas_target'); ajax('{{=URL('get_patient_scan_info')}}',['patient_id'], 'scan_info_previous'); return false; }); $('#patient_id').change(function(){
[web2py] Re: Cannot get a div to update, once form inputs have been successfully processed and Ajax used.
meh, next time include the code as an attachment or use the google group interface that can format code inline...far more readable! Anyway, I'm at work and can't test it (nor anyone, without models, controllers, and so on), but I spotted an error $('scan_info_previous').load( {{=URL('get_patient_scan_info')}}, document.getElementById(hidden_patient_id).value); if you refer to something like div id=scan_info_previous/div the jquery selector is $('#scan_info_previous') not $('scan_info_previous') -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Login does not redirect
Hello i have an app that with web2py 2.0.9 after pressing login button i am redirected to the index page. I tested my app with web2py 2.3.2 and the redirection is not done. I have after pressing login button to change the url and i´m redirected to index. Is this a bug? I´m using jquery mobile plugin. Do i have to check this plugin? I ´m using it for a long time. Maybe it need some kin of update... Or not... I dont know Help would be apreciated. Thank you -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Cannot get a div to update, once form inputs have been successfully processed and Ajax used.
Sorry, I've now attached the code as a file. I corrected that error, thanks. Still doesn't work. On Thursday, February 14, 2013 1:01:46 PM UTC, Niphlod wrote: meh, next time include the code as an attachment or use the google group interface that can format code inline...far more readable! Anyway, I'm at work and can't test it (nor anyone, without models, controllers, and so on), but I spotted an error $('scan_info_previous').load( {{=URL('get_patient_scan_info')}}, document.getElementById(hidden_patient_id).value); if you refer to something like div id=scan_info_previous/div the jquery selector is $('#scan_info_previous') not $('scan_info_previous') -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. {{response.files.append(URL('static','css/columns_2_Liquid.css'))}} {{response.files.append(URL('static','js/input_patient_form.js'))}} {{extend 'layout.html'}} {{def get_entry_html(scan_instance_tree): }} {{get_entry_node_html(scan_instance_tree.child_nodes, -1, True) }} {{return }} {{def get_entry_node_html(a_nodes, a_parent_id, a_is_root): }} {{if a_is_root == False:}} {{str_class = 'class=field_dependancy_group'}} {{str_display = 'style=display:none'}} {{else:}} {{str_class = ''}} {{str_display = 'style=display:block'}} {{pass}} div id=has_parent_id_{{=a_parent_id }} {{=str_display}} {{=str_class}} /br {{for child_node in a_nodes:}} {{=child_node.field_name }} select id='field_phenotype_id_{{=child_node.field_phenotype_id}}' name='{{=child_node.field_phenotype_id}}' {{if len(child_node.child_nodes) 0:}} class=parent_field_select {{else:}} class='leaf_field_select' {{pass}} {{for value in child_node.values:}} {{str_selected = ''}} {{if (value['value'] == 0): }} {{str_selected = ' selected=selected'}} {{pass}} option value= {{=value['value']}} {{=str_selected}} {{=value['description']}} /option {{pass}} /select {{=A(IMG(_id=img_help, _src=URL(static,images/help.png), _alt=My Logo), callback=URL(default,get_phenotype_help, vars=dict(field_id=child_node.field_phenotype_id) ), target=scan_field_extra)}} /br/br {{if len(child_node.child_nodes) 0:}} {{get_entry_node_html(child_node.child_nodes, child_node.field_phenotype_id, False)}} {{pass}} {{pass}} /div {{return}} div id=masthead H1 {{=response.title or request.application}} Project/H1 /div div id=content div id=patient_info class=layout_block h3Patient Data/h3 form id=patient_form fieldset table tr td Patient ID (or leave empty for new patient): input name=patient_id id=patient_id value=12/td tdinput type=submit value=Search Patient/td div id=open_clearcanvas_target/div /tr /table /fieldset /form /div !--field_new_group = field_is_new_group, field_parent_group = field_row.field_phenotype_group.field_head_fk, field_parent_dependancy = field_row.field_phenotype_functional_dependancy.field_head_fk, -- form id=scaninstance_form action={{=URL('add_new_scan')}} method=post fieldset input name=hidden_patient_id id=hidden_patient_id style=display:none div id=source_input table tr tdSource: input type=text name=source id=source/td tdDiagnosis: input type=text name=diagnosis id=diagnosis/td /tr /table /div h3New Scan Data/h3 input type='submit' value='Submit New Scan Data' /br /br input type='button' value='Update Scan Type' /br /br div id=scan_info class=layout_block Age in Months: input type=text name=age_months class=field_input value='' {{response.write(get_entry_html(scan_instance_tree), escape=False)}} /div /fieldset /form /br div id=scan_info_previous class=layout_block /div /div div id=sidebar div id=patient_extra /div div id=scan_field_extra /div /br /br div id=model_field_extra H3 Phenotype Occurrences / Predictive Values /H3 H4 for Cortical-Cerebral: Gyriform - Depths of Sulci/H4
Re: [web2py] 'Morsel' object has no attribute 'split' ?
Done, I 've placed my facebook.py in attachment. Not sure if any changes to web2py are necessary as I'm using a slightly modified (by me and applying a few patches on the rep) version of http://code.google.com/p/cfhowes/source/browse/#hg/web2py_multiauth instead of the standard auth. My guess is that no changes to web2py are necessary, as that get_user_from_cookie simply does not work as it is and it just does with this change. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. #!/usr/bin/env python # # Copyright 2010 Facebook # # Licensed under the Apache License, Version 2.0 (the License); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an AS IS BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. Python client library for the Facebook Platform. This client library is designed to support the Graph API and the official Facebook JavaScript SDK, which is the canonical way to implement Facebook authentication. Read more about the Graph API at http://developers.facebook.com/docs/api. You can download the Facebook JavaScript SDK at http://github.com/facebook/connect-js/. If your application is using Google AppEngine's webapp framework, your usage of this module might look like this: user = facebook.get_user_from_cookie(self.request.cookies, key, secret) if user: graph = facebook.GraphAPI(user[access_token]) profile = graph.get_object(me) friends = graph.get_connections(me, friends) import cgi import time import urllib import urllib2 import httplib import hashlib import hmac import base64 import logging import socket # Find a JSON parser try: import simplejson as json except ImportError: try: from django.utils import simplejson as json except ImportError: import json _parse_json = json.loads # Find a query string parser try: from urlparse import parse_qs except ImportError: from cgi import parse_qs class GraphAPI(object): A client for the Facebook Graph API. See http://developers.facebook.com/docs/api for complete documentation for the API. The Graph API is made up of the objects in Facebook (e.g., people, pages, events, photos) and the connections between them (e.g., friends, photo tags, and event RSVPs). This client provides access to those primitive types in a generic way. For example, given an OAuth access token, this will fetch the profile of the active user and the list of the user's friends: graph = facebook.GraphAPI(access_token) user = graph.get_object(me) friends = graph.get_connections(user[id], friends) You can see a list of all of the objects and connections supported by the API at http://developers.facebook.com/docs/reference/api/. You can obtain an access token via OAuth or by using the Facebook JavaScript SDK. See http://developers.facebook.com/docs/authentication/ for details. If you are using the JavaScript SDK, you can use the get_user_from_cookie() method below to get the OAuth access token for the active user from the cookie saved by the SDK. def __init__(self, access_token=None, timeout=None): self.access_token = access_token self.timeout = timeout def get_object(self, id, **args): Fetchs the given object from the graph. return self.request(id, args) def get_objects(self, ids, **args): Fetchs all of the given object from the graph. We return a map from ID to object. If any of the IDs are invalid, we raise an exception. args[ids] = ,.join(ids) return self.request(, args) def get_connections(self, id, connection_name, **args): Fetchs the connections for given object. return self.request(id + / + connection_name, args) def put_object(self, parent_object, connection_name, **data): Writes the given object to the graph, connected to the given parent. For example, graph.put_object(me, feed, message=Hello, world) writes Hello, world to the active user's wall. Likewise, this will comment on a the first post of the active user's feed: feed = graph.get_connections(me, feed) post = feed[data][0] graph.put_object(post[id], comments, message=First!) See http://developers.facebook.com/docs/api#publishing for all of
[web2py] Re: Cannot get a div to update, once form inputs have been successfully processed and Ajax used.
easier to read, still impossible to reproduce. You're doing everything without using the nice facilities web2py provides, but since you're going that way, let's try to break up and analyze the issue. You're attaching a submit handler and discarding completely the response $.post($(this).attr('action'), $(this).serialize(), function(response){ THIS PART NOT WORKING - START ** $('#scan_info_previous').load( {{=URL('get_patient_scan_info')}}, document.getElementById( hidden_patient_id).value); OR I've also tried... ajax('{{=URL('get_patient_scan_info')}}',['hidden_patient_id'], ' scan_info_previous'); THIS PART NOT WORKING - END ** },'json'); what you're sending to the action url is the inputs serialized as json. and until here, there should be no issues. When the action url returns something, scan_info_previous should be filled with the contents coming from what url ? Here it seems that it's the get_patient_scan_info . but you seem to want to pass along the hidden_patient_id parameter with that, and $(element).load() is a jquery function that doesn't work the same as the ajax() one that is coded within web2py. We don't know how your get_patient_scan_info works to give you the details on how to pass something to that. Have you at least checked that the request to get_patient_scan_info is being fired (i.e. you have problems firing the actual request or managing it at web2py's level)? On Thursday, February 14, 2013 3:26:05 PM UTC+1, AnnG wrote: Sorry, I've now attached the code as a file. I corrected that error, thanks. Still doesn't work. On Thursday, February 14, 2013 1:01:46 PM UTC, Niphlod wrote: meh, next time include the code as an attachment or use the google group interface that can format code inline...far more readable! Anyway, I'm at work and can't test it (nor anyone, without models, controllers, and so on), but I spotted an error $('scan_info_previous').load( {{=URL('get_patient_scan_info')}}, document.getElementById(hidden_patient_id).value); if you refer to something like div id=scan_info_previous/div the jquery selector is $('#scan_info_previous') not $('scan_info_previous') -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] web2py + exceptions(tickets) service?
Hello!, I would like to know if there's something like http://www.exceptional.io but with support for web2py?. Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: make_min_web2py.py no longer working (anyserver)
I'm sorry. It is problem of Windows distribution only. In Windows distribution in scripts\make_min_web2py.py variable REQUIRED contains few files, which are not part of the Windows distribution (anyserver.py, fcgihandler.py,..?). In source code distribution the script has no problem. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: centralize file view *.html
It is possible that we do not support extending a block from an included file. I never tried that. Please open a ticket about that. On Thursday, 14 February 2013 03:02:55 UTC-6, 黄祥 wrote: already, i even tested it : *example code that not work* *views/block_footer.html* {{block footer}} custom_footer {{end}} *views/default/blog.html* *1.* * *{{extend 'layout.html'}} {{include 'block_footer.html'}} i think the server is confused about which block footer that they will use, so the out put is not as expected, when using include (number 1) and using extend (number 2) any hints, or suggestion about this? thank you so much in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Purpose of creating group for each user?
@Massimo - Perhaps consider including: auth.settings.create_user_groups = True in the default db.py, along with a comment explaining that it's mostly useful for crud. I think this would clarify auth config for many users. On Friday, February 1, 2013 5:21:05 PM UTC-5, Massimo Di Pierro wrote: Disabling user groups is only a problem if you use crud which checks for auth.accessible() records based on permissions. If There are no user groups you do not know how to make an object accessible to the user who created. Honestly I envisioned a bigger role in web2py for auth permissions. Turns out most users (including me) do not use them and prefer to set simpler ad hoc permission rules. In case there is no problem in disabling user groups. On Friday, 1 February 2013 15:42:49 UTC-6, Yarin wrote: The documentationhttp://web2py.com/books/default/chapter/29/09#Authorizationstates: The creation of the group can be disabled with auth.settings.create_user_groups = None although we do not suggest doing so. Massimo also says herehttps://groups.google.com/d/msg/web2py/gN2LH6pX_IA/kcCBMWeDD8YJthat If you do not have those groups membership causes a nightmare. Yet I've never found any use for the individual user groups. Can someone explain their utility, and why the warnings against dropping them? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: centralize file view *.html
done, Issue 1335 http://code.google.com/p/web2py/issues/detail?id=1335 thank you so much in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: make_min_web2py.py no longer working (anyserver)
the binary package can not be stripped because it's compiled. On Thursday, February 14, 2013 5:26:41 PM UTC+1, Mirek Zvolský wrote: I'm sorry. It is problem of Windows distribution only. In Windows distribution in scripts\make_min_web2py.py variable REQUIRED contains few files, which are not part of the Windows distribution (anyserver.py, fcgihandler.py,..?). In source code distribution the script has no problem. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py + exceptions(tickets) service?
as far as I'm concerned no, but adding support shouldn't be that difficult if you have time to spend on it. PS: If you just need to be alerted as soon as an exception has been fired by your app, web2py has already all the bits you need. On Thursday, February 14, 2013 5:00:24 PM UTC+1, Luciano Laporta Podazza wrote: Hello!, I would like to know if there's something like http://www.exceptional.iobut with support for web2py?. Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] custom auth table on separate file not in db.py
hi, is it possible to custom auth table on separate file not in db.py? for example : *models/db_wizard.py* # append fields : auth.signature db._common_fields.append(auth.signature) # custom auth user table auth.settings.extra_fields['auth_user']=[ Field('gender', 'list:string'), Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone')] i've already tested it that and it not work, it should define in db.py, but i want to have the application that not change the default web2py generate scaffolding application as much as possible, for example in db.py. the idea is because you can modified the define table (not auth tables) in different file on the fly. for example at first you define the blog table *### first* *models/db_wizard.py* # create table : blog db.define_table('blog', Field('title'), Field('contents', 'text'), format='%(title)s') and then you can modified it by adding the new field or rename the defined field on the fly *### second* *models/db_wizard.py* # create table : blog db.define_table('blog', Field('title'), *### rename the defined field* *Field('body', 'text'),* *### adding the new field* *Field('tag'),* format='%(title)s') many thanks in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: custom auth table on separate file not in db.py
to define a table you must have the auth object and the DAL connection executed before than your auth customizations. models are executed alphabetically. You need to respect this order 1. db = DAL() 2. from gluon.tools import Auth auth = Auth(db) 3. your customizations 4. auth.define_tables(.) PS: use auth.define_tables(signature=True) instead of ...append(auth.signature) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: How to include a select field in a many to many relationship
You could make it a list:reference and then process that on accept by assigning the appropriate groups. On Wednesday, February 13, 2013 11:58:02 PM UTC-7, José Manuel López Muñoz wrote: Hi, I want to make a user creation form, and I need to select the group that this user belongs. As you know the user have a many to many relation with group using membership, here is the book chapter: http://web2py.com/books/default/chapter/29/9#Access-Control I don't know how to make a form in where I can select the group of this new user, I need a selection field. Do I need to code it or there is any way to make this with SQLFORM or something like that?. Thank you for your help -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: centralize file view *.html
uhm, I'm missing something. no exception is returned by both syntaxes. extend layout.html include block_footer.html works. extend layout.html extend block_footer.html doesn't raise an exception but overwrites the extend layout.html part So, what is the issue ? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] performance impact when put menu in controller
hi, is there any performance impact when put menu in controller? i know i can modify the menu.py or create the new file menu_custom.py in models but i don't want to change default web2py file scaffolding generated as much as possible. for example *controllers/default.py* * * # -*- coding: utf-8 -*- # menu response.menu = [ (T('Home'), False, URL('default', 'index'), []), (T('Room'), False, URL('default', 'room'), []), (T('Guest'), False, URL('default', 'guest'), []), (T('Booking'), False, URL('default', 'booking'), []), (T('Check In'), False, URL('default', 'check_in'), []), (T('Check Out'), False, URL('default', 'check_out'), []), (T('Repairing'), False, URL('default', 'repairing'), []), (T('Cleaning'), False, URL('default', 'cleaning'), []), ] if auth.user and auth.has_membership(role='Manager'): response.menu.append((T('Branch'), False, URL('default', 'branch'))) response.menu.append((T('Company'), False, URL('default', 'company'))) DEVELOPMENT_MENU = False thousand thanks in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: centralize file view *.html
hi niphlod, you re right it works for : extend layout.html extend block_footer.html but the problem is the block_footer.html replace all of the content of layout.html. my goal is to create the block footer html file separate from layout.html and then the other view files can use it to replace the default value that already define in layout.html do you have any example for use exception in views file? many thanks before -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: performance impact when put menu in controller
none whatsoever (in a normal environment). It's just that models are executed at every request, while controller gets called only when you hit the page. Usually to avoid to copy over and over the same menu items in multiple places, you put the code in models. From a theoric standpoint, having menu defined in every controller OR have the menu just in one model is equal in terms of performance. What's silly is having BOTH a model defining a menu AND every controller redefining that, because the time spent on defining the menu in the model is basically wasted. You need to balance code readability vs performance but defining a list doesn't take that much time. On Thursday, February 14, 2013 9:58:38 PM UTC+1, 黄祥 wrote: hi, is there any performance impact when put menu in controller? i know i can modify the menu.py or create the new file menu_custom.py in models but i don't want to change default web2py file scaffolding generated as much as possible. for example *controllers/default.py* * * # -*- coding: utf-8 -*- # menu response.menu = [ (T('Home'), False, URL('default', 'index'), []), (T('Room'), False, URL('default', 'room'), []), (T('Guest'), False, URL('default', 'guest'), []), (T('Booking'), False, URL('default', 'booking'), []), (T('Check In'), False, URL('default', 'check_in'), []), (T('Check Out'), False, URL('default', 'check_out'), []), (T('Repairing'), False, URL('default', 'repairing'), []), (T('Cleaning'), False, URL('default', 'cleaning'), []), ] if auth.user and auth.has_membership(role='Manager'): response.menu.append((T('Branch'), False, URL('default', 'branch'))) response.menu.append((T('Company'), False, URL('default', 'company'))) DEVELOPMENT_MENU = False thousand thanks in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: custom auth table on separate file not in db.py
hi Niphlod, thank you so much for your hints. i've already read the book, and just curious, is the web2py support to modified (alter) the auth tables after it's define. i've already do some experiment for it, but it didn't works, n i don't know the reason. yes, you right in term of auth table, it's better to use signature=True, my goal using db._common_fields.append(auth.signature) it to append auth.signature in all tables. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: performance impact when put menu in controller
hi Niphlod, thank you so much for your suggestion. so what is the best in terms to not change default web2py file scaffolding generated (the menu.py is in default): create the custom_menu.py in models or just define it on controllers (default.py)? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: performance impact when put menu in controller
Sorry, you're asking how not change the default web2py menu ? leave it where it is, or cutpaste in a model ^_^ On Thursday, February 14, 2013 10:17:49 PM UTC+1, 黄祥 wrote: hi Niphlod, thank you so much for your suggestion. so what is the best in terms to not change default web2py file scaffolding generated (the menu.py is in default): create the custom_menu.py in models or just define it on controllers (default.py)? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: custom auth table on separate file not in db.py
On Thursday, February 14, 2013 10:10:08 PM UTC+1, 黄祥 wrote: hi Niphlod, thank you so much for your hints. No problem, it's both a pleasure and an occasion to refresh topics i've already read the book, and just curious, is the web2py support to modified (alter) the auth tables after it's define. In the book there's the recommended way to do what you ask. You NEED to alter default auth tables only BEFORE doing auth.define_tables() -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] very important! we need to help Python
TLTR: a private company not affiliated with python.org is trying to claim copyright of the name Python in Europe for all software. http://pyfound.blogspot.ca/2013/02/python-trademark-at-risk-in-europe-we.html If you are in Europe or have colleagues in Europe, they can help as directed in the above document. Massimo -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Can web2py be used for highly complex relational databases?
Really interesting thread... Thanks Massimo about the clear explanation about web2py pros and con... Also I like the lookup table cache tricks... Richard On Sat, Dec 29, 2012 at 5:30 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The problem is that SQLA is from this prospective lower level. You can use scripts/extract_pgsql_models.py to introspect the database and guess the model, but while this information is sufficient for SQLA, it is not sufficient for web2py. Web2py needs to know more about the column than it is known to the database. For example a varchar field could be an hashed password, or a serialized list of references, etc. Introspection does not help you except in trivial cases. Massimo On Saturday, 29 December 2012 15:30:10 UTC-6, Michele Comitini wrote: This thread reminds me of a feature I would like to see in the DAL. The DAL is the missing introspection features SQLAlchemy has: legacy db introspection. So with the DAL the developer needs to write always the metadata to describe the db schema. I faced that in a fairly complex sqlite schema. I hate to write things that are already there ;-) ... so I *had* to make a simple script to translate DDL of sqlite schema to proper DAL data definition instructions, it can be found under the scripts directory in recent web2py versions. The DAL should have introspection and eventually build in memory cached table definitions on the fly. Optionally the developer could decide to make those table definitions persistent to reduce start-up times and make customizations. mic 2012/12/29 Massimo Di Pierro massimo@gmail.com To better illustrate my previous point I built an example which may be useful to others who are concerned about performance. https://dl.dropbox.com/u/**18065445/Tmp/a1000.ziphttps://dl.dropbox.com/u/18065445/Tmp/a1000.zip Contains two apps a1000_1 and a1000_2. Both apps define 1000 tables each with 10 columns (no attributes, validators, widgets, no auth). They have one controller which expose a grid http:///a1000_1/default/**index/t1 gives you the grid for table t1. a1000_1 uses normal web2py models (defined in db.py and db_tables.py) but it bytecode compiled, uses lazy_tables, and disables migrations. On my slow laptop is serves one page in 0.9 seconds. It means it takes less than 0.9ms to define each lazy table. a1000_2 defines all tables in modules/db_modules.py imports db in models/db.py. Now it takes 80ms/req. more of 50% of it is because of the complex template and cookie/session/languages logic. basically there is no overhead in creating 1000 tables. While web2py defaults to a1000_1, other frameworks default to a1000_2 but web2py can do it too! What are the drawbacks of the second approach? There are 2 and they are not web2py specific. 1) The web server occasionally creates new processes. They will need to reload the module. This takes time. Some users will experience the slow down. 2) Now the db object is shared by all request (not the connector, they still different db sessions/transactions). This means you cannot alter the attributes of models (db.t1.f001.readable=**False) because this will affect all concurrent requests and following requests. Web2py makes you pay a price in order to have one new clean db object at every request. You pay this price so that you do not have to worry about changing its state and affecting other requests. This costs ~1ms/table on my laptop. With conditional models this is a non-issue since you only the price for tables you use in the action. Hope I am making some sense. Massimo On Saturday, 29 December 2012 11:30:19 UTC-6, Massimo Di Pierro wrote: TLTR: if you can do it with others you can do it with web2py, although default behavior may be different. There are some important differences between web2py DAL and SQLAlchemy: sqlalchemy has better support for non-integer primary keys (dal supports them too but they make automatic form handling very difficult so we want to discourage that); 2) sqlalchemy allows multiple database sessions per thread over the same connection (in web2py if you want to use multiple session in the same thread, you need multiple connections, I have never seen a use case for this). 3) frameworks which use SQLAlchemy define tables only once when the program starts, web2py defines tables at every request. They are both equally reliable and fast. 3) causes a performance penalty for web2py compared with other frameworks when large number of tables are present. Yet this is not a DAL limitation. This is because of the way web2py choses to use the dal. We want to allow different http requests to see changes in the schema. This is part of the price for the easy to use approach. Using conditional models go a long way towards reducing this overhead. If you use the DAL from a pyhton script or a background process of other framework (for
[web2py] Re: centralize file view *.html
One should not extend twice. The behavior is not specified. You can extend once and import many. On Thursday, 14 February 2013 15:05:27 UTC-6, 黄祥 wrote: hi niphlod, you re right it works for : extend layout.html extend block_footer.html but the problem is the block_footer.html replace all of the content of layout.html. my goal is to create the block footer html file separate from layout.html and then the other view files can use it to replace the default value that already define in layout.html do you have any example for use exception in views file? many thanks before -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Connecting to MySQL via SSL
Hi, I'm trying to connect get web2py to connect to MySQL via SSL (or SSH). Based on the code, seems like I need to do something like: db = DAL('..', driver_args=dict(ssl=dict(ca='/path/to/mysql-ssl-ca-cert.pem'))) (I only need the CA cert file, the key and certificate files are not needed for the connection.) It works through my SQL client (Sequel Pro), but not through web2py. Anyone have any ideas? It gives me the following error message: type 'exceptions.RuntimeError' Failure to connect, tried 5 times: Traceback (most recent call last): File /Users/oamasood/src/web2py/gluon/dal.py, line 6853, in __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File /Users/oamasood/src/web2py/gluon/dal.py, line 2402, in __init__ if do_connect: self.reconnect() File /Users/oamasood/src/web2py/gluon/dal.py, line 576, in reconnect self.connection = f() File /Users/oamasood/src/web2py/gluon/dal.py, line 2400, in connector return self.driver.connect(**driver_args) File /Users/oamasood/src/web2py/gluon/contrib/pymysql/__init__.py, line 93, in Connect return Connection(*args, **kwargs) File /Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py, line 575, in __init__ self._connect() File /Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py, line 741, in _connect self._request_authentication() File /Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py, line 796, in _request_authentication self._send_authentication() File /Users/oamasood/src/web2py/gluon/contrib/pymysql/connections.py, line 822, in _send_authentication self.socket = ssl.wrap_self.socketet(self.socket, keyfile=self.key, AttributeError: 'module' object has no attribute 'wrap_self' Thanks, Osman -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: performance impact when put menu in controller
a, that's make me clear now. thank you very much, Niphlod -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: custom auth table on separate file not in db.py
yeah, i've already read that part, and think about another possiblity. again, thank you for your detail explaination, Niphlod -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: centralize file view *.html
hi massimo what do you mean about import? is it same like : from gluon.contrib.markmin.markmin2html import markmin2html from gluon.contrib.markmin.markmin2latex import markmin2latex from gluon.contrib.markmin.markmin2pdf import markmin2pdf best regards -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: Unable to send email - password reset.
Some time ago I ran into exactly the same problem and came to the solution exactly the same way (on Windows). The book now includes this setting but perhaps it is too subtle (search TLS). There are a lot of advantages to running debug/development sessions using an interactive web2py server started from the command prompt (on a different port), and one of them is easier access to console messages. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: custom auth table on separate file not in db.py
May I ask why you are working so hard to avoid modifying the scaffolding application? It is intended to be modified -- it's really just an example app that you should customize to fit your specific needs. Anthony On Thursday, February 14, 2013 2:45:17 PM UTC-5, 黄祥 wrote: hi, is it possible to custom auth table on separate file not in db.py? for example : *models/db_wizard.py* # append fields : auth.signature db._common_fields.append(auth.signature) # custom auth user table auth.settings.extra_fields['auth_user']=[ Field('gender', 'list:string'), Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone')] i've already tested it that and it not work, it should define in db.py, but i want to have the application that not change the default web2py generate scaffolding application as much as possible, for example in db.py. the idea is because you can modified the define table (not auth tables) in different file on the fly. for example at first you define the blog table *### first* *models/db_wizard.py* # create table : blog db.define_table('blog', Field('title'), Field('contents', 'text'), format='%(title)s') and then you can modified it by adding the new field or rename the defined field on the fly *### second* *models/db_wizard.py* # create table : blog db.define_table('blog', Field('title'), *### rename the defined field* *Field('body', 'text'),* *### adding the new field* *Field('tag'),* format='%(title)s') many thanks in advance -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: custom auth table on separate file not in db.py
hi anthony, when upgrade to the new version, web2py will updated the scaffolding that generated by default (like db.py, menu.py, default.py, layout.html, css, etc), isn't it? so to keep my code always can be run in the newer version, i'm trying to avoid to modify the default file. please correct me if i'm wrong. or do you have any hints or suggestion? thank you so much -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] DAL return number of rows affected?
Is it possible to get the number of rows affected by an update in the DAL? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] DAL return number of rows affected?
Is it possible to get the number of rows affected by an update in the DAL? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Validator: {Validator1 OR validator2} - Can I get that requires on a Field?
I am writing in a signup form for users of my site. To signup, they can either use their email address `IS_EMAIL()`; or an outside uid (covered by an `IS_MATCH()`). (it's a 1 field form) One solution to validating the form is to just check the vars in the controller, and have two Fields in the Table; one for email, the other for this outside uid. Is there another solution; utilising multiple validators in the requires, much like `IS_NONE_OR()` validator? Thanks for all suggestions, Alec Taylor -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Validator: {Validator1 OR validator2} - Can I get that requires on a Field?
class ANY(object): def __init__(self, validators): self.validators = validators def __call__(self, value): # validates the value against each validator results = [validator(value) for validator in self.validators] # Check if there is an invalid result for result in results: if result[1]: # if invalid value found returns it. return result #else returns the value and None, which means valid return (value, None) db.table.somefield.requires = ANY([IS_EMAIL(), IS_MATCH(), IS_NOT_EMPTY()]) it is a great idea to include ANY and ALL metavalidators to gluon.validators. On Thu, Feb 14, 2013 at 11:55 PM, Alec Taylor alec.tayl...@gmail.comwrote: I am writing in a signup form for users of my site. To signup, they can either use their email address `IS_EMAIL()`; or an outside uid (covered by an `IS_MATCH()`). (it's a 1 field form) One solution to validating the form is to just check the vars in the controller, and have two Fields in the Table; one for email, the other for this outside uid. Is there another solution; utilising multiple validators in the requires, much like `IS_NONE_OR()` validator? Thanks for all suggestions, Alec Taylor -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Validator: {Validator1 OR validator2} - Can I get that requires on a Field?
I guess the first one is wrong.. to amtch your criteria I think you need this class ANY(object): def __init__(self, validators): self.validators = validators def __call__(self, value): # validates the value against each validator results = [validator(value)[1] for validator in self.validators] # check if there is if not all(results): # invalid, so return the first error message return (value, [result for result in results if result]) else: # all valid return (value, None) db.table.somefield.requires = ANY([IS_EMAIL(), IS_MATCH(), IS_NOT_EMPTY()]) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Validator: {Validator1 OR validator2} - Can I get that requires on a Field?
Finally, I just testes on the shell *modules/anyvalidator.py* class ANY(object): def __init__(self, validators): self.validators = validators def __call__(self, value): # validates the value against each validator results = [validator(value)[1] for validator in self.validators] # check if all validations are invalid if all(results): # invalid, so return the first error message return (value, [result for result in results if result][0]) else: # all valid return (value, None) *models/db.py* db.table.field.requires = ANY([IS_IN_SET(['a','b']), IS_EMAIL()]) *shell* In [3]: from anyvalidator import ANY In [4]: ANY([IS_IN_SET(['a','b']), IS_EMAIL()])('m...@test.com') Out[4]: ('m...@test.com', None) In [5]: ANY([IS_IN_SET(['a','b']), IS_EMAIL()])('me') Out[5]: ('me', 'value not allowed') In [6]: ANY([IS_IN_SET(['a','b']), IS_EMAIL()])('a') Out[6]: ('a', None) In [7]: ANY([IS_IN_SET(['a','b']), IS_EMAIL()])('b') Out[7]: ('b', None) In [8]: ANY([IS_IN_SET(['a','b']), IS_EMAIL()])('foo') Out[8]: ('foo', 'value not allowed') In [9]: ANY([IS_IN_SET(['a','b']), IS_EMAIL()])('f...@bar.com') Out[9]: ('f...@bar.com', None) -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Validator: {Validator1 OR validator2} - Can I get that requires on a Field?
It gives me the idea of a CUSTOM validator class CUSTOM(object): def __init__(self, function): self.function = function def __call__(self, value): # the function should return the error_message or None return(value, self.function(value)) So the use should be: def my_validator_function(value): # do anything return error message or None db.table.field.requires = CUSTOM(my_validator_function) So, it works the same as onvalidation but can be applied in models. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] delete session strange behaviour
hi, i'm trying to delete session using del session, and found strange behaviour for example *#**views/default/order.html* table width=100% {{for id, qty in order.items():}} {{p=db.product(id)}} tr td{{=p.product_name}}/td tdRp. {{=p.unit_price}}/td tdspan id={{='item%s'%p.id}}{{=qty}}/span {{=SPAN(A('+', callback=URL('order_callback', vars=dict(id=p.id, action='add')), target='item%s'%p.id, _title='Add Product', _class='btn btn-navbar'))}} {{=SPAN(A('-', callback=URL('order_callback', vars=dict(id=p.id, action='subtract')), target='item%s'%p.id, _title='Substract Product', _class='btn btn-navbar'))}} *{{=SPAN(A('X', callback=URL('order_callback', vars=dict(id=p.id, action='remove')), delete='tr', _title='Remove Product', _class='btn btn-navbar'))}}*/td /tr {{pass}} /table * work* *#controllers/default.py* def order_callback(): id=int(request.vars.id) if request.vars.action=='add': session.order[id]=session.order.get(id, 0)+1 if request.vars.action=='subtract': session.order[id]=max(0,session.order.get(id, 0)-1) *if request.vars.action=='remove':* *del session.order[id]* *redirect(URL('product'))* return str(session.order[id]) * not work* *#controllers/default.py* def order_callback(): id=int(request.vars.id) if request.vars.action=='add': session.order[id]=session.order.get(id, 0)+1 if request.vars.action=='subtract': session.order[id]=max(0,session.order.get(id, 0)-1) *if request.vars.action=='remove':* *del session.order[id]* *session.flash=T(Order Deleted!!!)* return str(session.order[id]) * not work* *#controllers/default.py* def order_callback(): id=int(request.vars.id) if request.vars.action=='add': session.order[id]=session.order.get(id, 0)+1 if request.vars.action=='subtract': session.order[id]=max(0,session.order.get(id, 0)-1) *if request.vars.action=='remove':* *del session.order[id]* return str(session.order[id]) my question is it normal, or there is something error or lack in my code? thank you so much before -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: centralize file view *.html
One should not extend twice. The behavior is not specified. You can extend once and **include** many. On Thursday, 14 February 2013 17:17:35 UTC-6, 黄祥 wrote: hi massimo what do you mean about import? is it same like : from gluon.contrib.markmin.markmin2html import markmin2html from gluon.contrib.markmin.markmin2latex import markmin2latex from gluon.contrib.markmin.markmin2pdf import markmin2pdf best regards -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: DAL return number of rows affected?
affected_rows = db(...).update() On Thursday, 14 February 2013 19:47:35 UTC-6, Cliff Kachinske wrote: Is it possible to get the number of rows affected by an update in the DAL? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Crud Permissions
I want to have two auth_groups: administrator who will have complete CRUD access to all tables, and editor who will have complete CRUD access to a limited set of tables. I can give administrator access without even setting up permissions by doing the following: @auth.requires_membership(administrator) def data(): return dict(form=crud()) Supposedly crud() will automatically detect permissions if you name them the right way. Assume I created a permission like this in appadmin: Group ID: editor (2) Name: create Object or table name: person Record ID: 0 If I'm logged in as a user in the editor group and visit http://127.0.0.1:8000/testapp/default/data/create/person I get a Not authorized ACCESS DENIED message. Should I be setting up my auth_permission differently, or maybe use another decorator? Thanks is advance for any help. Greg -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Problem reading xls with xlrd
I have this code in controller trying to read an .xls file : def upload(): import xlrd form = SQLFORM.factory(Field('pago', 'upload', uploadfolder='/home/user/web2py/applications/pruebas/uploads')).process() if form.accepts(request.vars,keepvalues=True): archivo='/home/lu/web2py/applications/pruebas/uploads/'+form.vars.pago book = xlrd.open_workbook(archivo) sh = book.sheet_by_index(0) columnas = sh.ncols return dict(form=form, columnas=columnas) ** Get this error : type 'exceptions.ValueError' mmap offset is greater than file size -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] 2 grids loaded in a single form: back button reference
Trying to embed multiple grids (or at least 2 of them) on a single page using load statements as per the following controller, functions and views. It seems to work fine until you click view or edit, from the called grid, on the calling grid (step2). The related edit and view seem to be rendered ok, but the back button is rendered as a link to the called grid (step3). e.g. Step1 https://lh5.googleusercontent.com/-HYv2KUeb-3o/UR3RYcFqHrI/AH8/m3O5HU833B0/s1600/step1.png Step2 https://lh6.googleusercontent.com/-V_QGU4Cxh3w/UR3Rlu_WaJI/AIE/131_nspxuPU/s1600/step2.png Step3 https://lh5.googleusercontent.com/-yfPvXYWe4X0/UR3RzE_HS5I/AIM/gU8PpH2U270/s1600/step3.png i.e. Controller: def populate(): db.dogs.truncate() db.fleas.truncate() db.dogs.insert(dog_name='dagwood') db.dogs.insert(dog_name='daisy') db.fleas.insert(dog_name='daisy', flea_name='fatso') db.fleas.insert(dog_name='dagwood', flea_name='felix') db.fleas.insert(dog_name='dagwood', flea_name='fatso') def dogsfleas(): return locals() def dogs(): db.dogs.dog_name.represent = lambda value,row: A(value, _href=URL( fleas,vars=dict(dog_name=row.dog_name)), cid=fleas) grid = SQLFORM.grid(db.dogs, csv=False) return dict(form=grid) def fleas(): db.fleas.dog_name.default = request.vars.dog_name q = db(db.fleas.dog_name == request.vars.dog_name) q1 = (db.fleas.dog_name == request.vars.dog_name) if q.count() == 0: grid1 = SQLFORM.grid(db.fleas, csv=False) else: grid1 = SQLFORM.grid(q1, user_signature=False, csv=False) return dict(form1=grid1) Views: dogsfleas.html {{extend 'layout.html'}} div class=row-fluid {{=LOAD('dogs','dogs',ajax=True, cid='dogs')}} div class=span12 id='voyages' {{#=response.toolbar()}} /div /div div class=row-fluid div class=span12 id='fleas' /div /div dogs.html h4Dogs/h4 {{=form}} {{#=response.toolbar()}} fleas.html h4Fleas/h4 {{=form1}} {{E=response.toolbar()}} Inspecting the dog edit code, top line buttons div class=form_header row_buttons ... a class=w2p_trap button btn href= /lconfirm/dogs/fleas?dog_name=daisyspan class=icon leftar a class=w2p_trap button btn href=/lconfirm/dogs/dogs/view/dogs/2?_signature=9f67a154b0 .. Any work arounds/ code changes/ advice for this? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Date null display
Traditionally in other field types you could display a null value with an expression similar to the following: db.table.datefield.represent = lambda value, row: A(value) if value else 'unknown' Occasional we have a requirement to display null values as alternatively i.e. None, Unknown, Not recorded, Not applicable etc While it can be done with the above, as it stands, A(value) reverts any display formatting back to the default i.e. '%Y-%m-%d' rather than any other format that's been set as the default. Are there any alternatives to this to retain default formatting i.e. '%d/%m/%y'? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: web2py + exceptions(tickets) service?
On Thursday, February 14, 2013 4:39:14 PM UTC-3, Niphlod wrote: as far as I'm concerned no, but adding support shouldn't be that difficult if you have time to spend on it. PS: If you just need to be alerted as soon as an exception has been fired by your app, web2py has already all the bits you need. Thanks for the answer Niphlod, but didn't understand the last part about being alerted(besides taking a look at the admin app). Cheers! On Thursday, February 14, 2013 5:00:24 PM UTC+1, Luciano Laporta Podazza wrote: Hello!, I would like to know if there's something like http://www.exceptional.iobut with support for web2py?. Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Date null display
A(value.strftime(%d/%m/%Y)) Em 15/02/2013 05:01, Simon Ashley gregs...@gmail.com escreveu: Traditionally in other field types you could display a null value with an expression similar to the following: db.table.datefield.represent = lambda value, row: A(value) if value else 'unknown' Occasional we have a requirement to display null values as alternatively i.e. None, Unknown, Not recorded, Not applicable etc While it can be done with the above, as it stands, A(value) reverts any display formatting back to the default i.e. '%Y-%m-%d' rather than any other format that's been set as the default. Are there any alternatives to this to retain default formatting i.e. '%d/%m/%y'? -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: web2py + exceptions(tickets) service?
Cool website; however web2py has those features built-in :) As for setting up email alerts for tickets—e.g.: that have been reported a certain number of times—I think that's a strong feature-request to add into the issue queue (or build yourself and pull-request back). On Fri, Feb 15, 2013 at 6:39 PM, Luciano Laporta Podazza lucianopoda...@gmail.com wrote: On Thursday, February 14, 2013 4:39:14 PM UTC-3, Niphlod wrote: as far as I'm concerned no, but adding support shouldn't be that difficult if you have time to spend on it. PS: If you just need to be alerted as soon as an exception has been fired by your app, web2py has already all the bits you need. Thanks for the answer Niphlod, but didn't understand the last part about being alerted(besides taking a look at the admin app). Cheers! On Thursday, February 14, 2013 5:00:24 PM UTC+1, Luciano Laporta Podazza wrote: Hello!, I would like to know if there's something like http://www.exceptional.io but with support for web2py?. Thanks! -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.