[web2py] Re: Solidform error: list indices must be integers
https://lh5.googleusercontent.com/-qrlS92szKAE/T7Sbh21ZjPI/AGM/M4GpWU4XMjY/s1600/readonly.png https://lh4.googleusercontent.com/-StOS7GeF4T8/T7Sba3P801I/AGE/JVsInDhicow/s1600/edit.png Thanks for that (mind in neutral) (Seems to be a issue with tags on read only forms but will try to work around that) On Thursday, May 17, 2012 12:41:48 PM UTC+10, Massimo Di Pierro wrote: Assuming SOLIDFORM is an SQLFORM form1 = SOLIDFORM(db.Sample, q1, fields=fields1, readonly=True) q1 should be a record id or a Row object. You are passing a Rows object. On Wednesday, 16 May 2012 21:32:08 UTC-5, Simon Ashley wrote: Any one with any ideas on this one? (been trying to trouble shoot it all morning) Environment: Version 1.99.4 (2011-12-31 04:51:15) Getting the following error, and unable to work it out. (have other areas using soldiform that are working OK) Traceback (most recent call last): File C:\web2py\gluon\restricted.py, line 204, in restricted exec ccode in environment File C:/web2py/applications/tree/controllers/stree.py http://127.0.0.1:8000/admin/default/edit/tree/controllers/stree.py, line 310, in module File C:\web2py\gluon\globals.py, line 172, in lambda self._caller = lambda f: f() File C:/web2py/applications/tree/controllers/stree.py http://127.0.0.1:8000/admin/default/edit/tree/controllers/stree.py, line 302, in SV2 form1 = SOLIDFORM(db.Sample, q1, fields=fields1, readonly=True) File applications\tree\modules\plugin_solidform.py, line 94, in __init__ SQLFORM.__init__(self, *args, **kwds) File C:\web2py\gluon\sqlhtml.py, line 805, in __init__ v = record['id'] File C:\web2py\gluon\dal.py, line 6532, in __getitem__ row = self.records[i] *TypeError: list indices must be integers, not str* *Model* db.define_table('Sample', Field('Compartment', db.Compartment), Field('Date', 'date'), Field('Comments'), Field('Pb', 'integer'), Field('Fe', 'integer'), Field('Al', 'integer'), Field('Cu', 'integer'), Field('Cr', 'integer'), Field('Sn', 'integer'), Field('Ni', 'integer'), Field('Si', 'integer'), Field('Na', 'integer'), Field('Mg', 'integer'), Field('Zn', 'integer'), Field('Mo', 'integer'), Field('Ca', 'integer'), Field('P', 'integer'), Field('Bo', 'integer'), format='%(Date)s %(id)s') *Controller* Methods 2 and 3 work, 1 doesn't * * def SV2(): session.sample = 1 q1 = db(db.Sample.id == session.sample).select() #q2 = db.Sample.id == session.sample #q3 = db.Sample.id == session.sample fields1 = ['Date','Comments','Fe','Cu','Cr'] #fields3 = ['Date','Comments','Fe','Cu','Cr'] form1 = SOLIDFORM(db.Sample, q1, fields=fields1, readonly=True) #form2 = SQLFORM.grid(q2, searchable=False, create=False,csv=False,editable=False,deletable=False, sortable=False ) #form3 = SQLFORM(db.Sample, session.sample, fields=fields3, readonly=True) return dict(form=form1) #does not work #return dict(form=form2) #works #return dict(form=form3) #works
[web2py] Multi computed fields
Hi all, I have a simple table with 3 computed fields, the function that set their values is almost the same. However, unfortunately I had to set up three different functions because I didn't find a better approach. The code: db.define_table('cities', Field('name', 'string', requires=IS_TRIM()), Field('full_address', 'string',requires=IS_TRIM()), Field(lat, double, label=T('Latitude')), Field(lgt, double, label=T('Longitude'))) db.cities.full_address.compute = compute_geoCode_place db.cities.lat.compute = compute_geoCode_lat db.cities.lgt.compute = compute_geoCode_lng def compute_geoCode_place(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return place def compute_geoCode_lat(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return lat def compute_geoCode_lng(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return lng What I would like to find is a way to fire the execution of a function when the form is submitted. More or less something like a compute action at table level. Regards, -- Paolo
[web2py] cpdb errors
I'm trying to copy a database from Sqlite to MySQL using the cpdb.py script. In the manual, it states: cd web2py python scripts/cpdb.py \ -f applications/app/databases \ -y 'sqlite://storage.sqlite' \ -Y 'postgresql://username:password@hocalhost/mydb' However, if I do that I get gluon path not found. The help file suggests that I can specify the path to dal.py with -d, but: python scripts/cpdb.py -d gluon/dal.py -f applications/pytrack2/databases -y 'sqlite://storage.sqlite' -Y 'mysql://pytrack2:pytrack2@localhost/pytrack2' gluon path not found EXCEPTION: could not set DAL No module named dal If I use '-d gluon', it's better but now fails with a MySQL error (which I think relates to foreign keys), although it still gives the 'gluon path not found' error: $ python scripts/cpdb.py -d gluon -f applications/pytrack2/databases -y 'sqlite://storage.sqlite' -Y 'mysql://pytrack2:pytrack2@localhost/pytrack2' gluon path not found creating tables... EXCEPTION: could not make a copy of the database (1005, uCan't create table 'pytrack2.t_companies_archive' (errno: 150)) I'm going to continue by migrating by hand; if I should report this elsewhere or if you need more details, let me know. -- You can have everything in life you want if you help enough other people get what they want - Zig Ziglar. Who did you help today?
[web2py] gae + wsgi testing with lettuce and webtest
The overall setup is that I have a gae, wsgi application and I am trying to include lettuce with webtest to automate the testing. 1. I am trying to run lettuce from myapp/tests/ directory. 2. myapp/tests/features directory contains the features and steps description as input to lettuce. In one of these steps (TestApp constructor) I need to use wsgiapp as an input as described in the webtest tutorial [1]. I am having difficulty performing both 1. and 2. [1] http://webtest.pythonpaste.org/en/latest/index.html#testapp
Re: [web2py] Updated slice: nginx and SCGI | Recipe | Web2py Slices - Recipes, Tutorials, Code, Questions
Hi Roberto, No I think not, but I did not investigate the nginx - scgi side of the connection much. I am referring to the Connection: keep-alive in browser-nginx dialog, the answer before was always Connection: close from nginx, so the client browser had to reopen the connection to nginx for each request going to an upstream server, while request going to static files where kept alive. I think it would be dangerous for a simple server such scgi to keep connections alive, because it is a simple dispatcher without queue. The number of requests coming from different clients can be N M (where N is the number of client requests while M is the number web2py processes). Actually it could be done by using an async version of the SCGI dispatcher, but I would not expect much benefit, since nginx is doing already exactly that much faster unless opening TCP connection to SCGI becomes expensive for some reason (ex. due to net topology). So IMHO what happens now is that nginx enqueues the requests and keeps connections over the Internet alive, while connections on localhost or the network behind nginx are opened each time and dispatched to the first available web2py process. I should try to use unix socket in the case of the local machine and see if there is a faster response time due to bypassing the 3way handshake of TCP. About uWSGI. I think the benefit of building another level of connection buffering is on a geographical/Internet topology. For a standard topology (i.e. on same server or lan segment/bus) uWSGI should benefit already from the same slice (just change scgi_pass to uwsgi_pass and put the correct directive in the upstream definition) and since uWSGI can support unix socket it should perform even better without any effort! mic 2012/5/17 Roberto De Ioris robe...@unbit.it: Changes: - keep-alive support from nginx. Hi Michele, does wsgitools SCGI server really supports keepalive connections ? That would be a kick-ass feature i need to copy for sure :) -- Roberto De Ioris http://unbit.it
Re: [web2py] Re: web2py uWSGI cherokee -- I give up
I still think that for you best of all is to use uwsgi without nginx - simpler setup, less layers, I use it and I can't say that it is less performant then nginx+uwsgi my webfaction setup - web2py folder is in /home/myuser/web2py - myuser and myport are my webfaction user and wget http://projects.unbit.it/downloads/uwsgi-1.2.3.tar.gz tar xvzf uwsgi-1.2.3.tar.gz cd uwsgi-1.2.3 /home/myuser/bin/python2.7 uwsgiconfig.py --build mv uwsgi /home/myuser/bin uwsgi --http 127.0.0.1:myport --pythonpath /home/myuser/web2py --module wsgihandler -d /home/myuser/tmp/uwsgi.log -t 20 -r --no-orphans --touch-reload /home/myuser/tmp/uwsgireload.txt --evil-reload-on-rss 100
Re: [web2py] Re: URL vars doesn't like Storage
As I pass it as vars via LOAD: {{=LOAD('default', 'send_suggestion', vars={ 'c':request.controller, 'f':request.function, 'args':request.args, 'vars':request.vars}, ajax_trap=True)}} does it mean that request.vars has not been serialized/deserialized correctly ? On Thu, May 17, 2012 at 2:14 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: _vars = request.vars['vars'] or {} subject = 'FEEDBACK: %s' % URL(c=_c,f=_f,args=_args,vars=**_vars) # vars doesn't like Storage _vars is a string. You are trying to pass a string where it expects a dict() On Wednesday, 16 May 2012 18:01:13 UTC-5, sebastian wrote: Hi All, I'd like to add a feedback form in layout.html so that the users can click on it on whatever page they are and send a message to the site admin. To be useful, the form must include the current page and vars so that the admin can click on a link and go to exactly the same place where the user wrote the feedback from. in layout I've added {{=LOAD('default', 'send_suggestion', vars={ 'c':request.controller, 'f':request.function, 'args':request.args, 'vars':request.vars}, ajax_trap=True)}} in default.py def send_suggestion(): form = SQLFORM.factory( Field('message', 'text', requires=IS_NOT_EMPTY()) ) if form.process().accepted: _c = request.vars['c'] _f = request.vars['f'] _args = request.vars['args'] or [] _vars = request.vars['vars'] or {} subject = 'FEEDBACK: %s' % URL(c=_c,f=_f,args=_args) **# it works subject = 'FEEDBACK: %s' % URL(c=_c,f=_f,args=_args,vars=**_vars) # vars doesn't like Storage response.flash = 'Thanks for your feedback' # will send email return form The problem is that URL *vars* doesn't like storage... Traceback (most recent call last): File /home/sebas/dev/web2py/**peerservices/gluon/restricted.**py, line 205, in restricted exec ccode in environment File /home/sebas/dev/web2py/**peerservices/applications/**peerservices/controllers/**default.py http://localhost:8000/admin/default/edit/peerservices/controllers/default.py, line 370, in module File /home/sebas/dev/web2py/**peerservices/gluon/globals.py**, line 173, in lambda self._caller = lambda f: f() File /home/sebas/dev/web2py/**peerservices/applications/**peerservices/controllers/**default.py http://localhost:8000/admin/default/edit/peerservices/controllers/default.py, line 301, in send_suggestion subject = 'FEEDBACK: %s' % URL(c=_c,f=_f,args=_args,vars=**_vars) File /home/sebas/dev/web2py/**peerservices/gluon/html.py, line 290, in URL if vars.has_key('_signature'): vars.pop('_signature') AttributeError: 'str' object has no attribute 'has_key' Any better way than converting the Storage into dict ? thanks -- Sebastian E. Ovide -- Sebastian E. Ovide
[web2py] Re: Table/grid with checkboxes for selecting records?
http://www.hymarkets.com/servlet/track?campaignid=701_d000l_gg9utm_landingpageid=en_2029utm_source=affiliateutm_campaign=yazan_mareiutm_papaffiliateid=cab7eebfa_aid=cab7eebfutm_medium=affiliate بتاريخ السبت، 12 مايو، 2012 UTC+4 2:13:27 ص، كتب Brian M: How can I create a table/grid with a checkbox in front of each row so that multiple records can be selected for update/delete? Something like your standard webmail inbox - check off a series of messages and then you can do something with them. I've got a version working with SQLFORM.factory and a field that uses widget=SQLFORM.widgets.checkboxes.widget but it isn't anywhere near as polished of a look as I would like (my checkbox labels end up being rediculously long and really should be separate columns). Is there a nifty web2py way of doing this or do I just need to create the form/checkboxes myself in the view and leave behind the web2py form validation? Thanks, Brian
Re: [web2py] Re: URL vars doesn't like Storage
As I pass it as vars via LOAD: {{=LOAD('default', 'send_suggestion', vars={ 'c':request.controller, 'f':request.function, 'args':request.args, 'vars':request.vars}, ajax_trap=True)}} does it mean that request.vars has not been serialized/deserialized correctly ? When you pass a dict as a URL var, the dict is converted to a string representation of the dict and then urlencoded. When it is decoded, you have a string representation of the dict (equivalent to repr(request.vars) in this case), not the dict itself (actually, I think it's a list with the string representation of the dict as its sole element). To get the dict back, you can safely eval it using ast.literal_eval: import ast _vars = ast.literal_eval(request.vars.vars[0]) if request.vars.vars else {} Anthony
[web2py] web2py back reference and compute fields problem
Hello. I have two models: order (fields: id,cost) and order_item (fields: id, order, price, quantity). order_item.order looks like: Field('order', db.order) i'll try to add total_price field to order table: Field('total_price', 'integer' ,compute=lambda row: calc(row)) where calc(row) looks like: def calc(order): result = 0 for item in order.order_item.select() result += item.price return result But this code doesn't work. Completely - there are no any errors and log messages. I found that invocation of order.order_item stops execution of calc function. It looks like back referenced fields are not available during compute invocation... Any ideas ? P.S. I don't want to use virtual fields because them slow down object list rendering (each virtual field invocation makes new query to db)
[web2py] url rewrite for a multilingual / international site
I am using web2py for a multilingual web-site with. I want to manage language setting the same way that it is managed in the admin application (that is through session and cookies I guess), but at the sale time I want the language to be explicitly indicated on the url structure as mysite.com/application/LANGUAGE/controller/function The reason is that I want to have the url structure that GOOGLE recommends for websites with international content: http://support.google.com/webmasters/bin/answer.py?hl=enanswer=182192#1 My question is How can I add LANGUAGE to the web2py visible url? That is Web2py gives me application/controller/function and I need it to become application/*LANGUAGE*/controller/function Thanks
[web2py] url rewrite for a multilingual / international site and search engine visibility
I am using web2py for a multilingual web-site with. I want to manage language setting the same way that it is managed in the admin application (that is through session and cookies I guess), but at the sale time I want the language to be explicitly indicated on the url structure as mysite.com/application/LANGUAGE/controller/function The reason is that I want to have the url structure that GOOGLE recommends for websites with international content: http://support.google.com/webmasters/bin/answer.py?hl=enanswer=182192#1 My question is How can I add LANGUAGE to the web2py visible url? That is Web2py gives me application/controller/function and I need it to become application/*LANGUAGE*/controller/function Thanks
[web2py] Re: Multi computed fields
The onsuccess parameter of form.process() seems to cover your problems: from http://web2py.com/books/default/chapter/29/7 onsuccess and onfailure can be functions like lambda form: do_something(form) Il giorno giovedì 17 maggio 2012 10:35:46 UTC+2, Gabriella Canavesi ha scritto: Hi all, I have a simple table with 3 computed fields, the function that set their values is almost the same. However, unfortunately I had to set up three different functions because I didn't find a better approach. The code: db.define_table('cities', Field('name', 'string', requires=IS_TRIM()), Field('full_address', 'string',requires=IS_TRIM()), Field(lat, double, label=T('Latitude')), Field(lgt, double, label=T('Longitude'))) db.cities.full_address.compute = compute_geoCode_place db.cities.lat.compute = compute_geoCode_lat db.cities.lgt.compute = compute_geoCode_lng def compute_geoCode_place(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return place def compute_geoCode_lat(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return lat def compute_geoCode_lng(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return lng What I would like to find is a way to fire the execution of a function when the form is submitted. More or less something like a compute action at table level. Regards, -- Paolo
[web2py] Re: url rewrite for a multilingual / international site and search engine visibility
Yes, but there's a bug associated with this feature in the latest release. For more info, check this out: http://code.google.com/p/web2py/issues/detail?id=798sort=-id On Thursday, May 17, 2012 9:21:30 AM UTC-3, yus wrote: I am using web2py for a multilingual web-site with. I want to manage language setting the same way that it is managed in the admin application (that is through session and cookies I guess), but at the sale time I want the language to be explicitly indicated on the url structure as mysite.com/application/LANGUAGE/controller/function The reason is that I want to have the url structure that GOOGLE recommends for websites with international content: http://support.google.com/webcurrentlycurrentlymasters/bin/answer.py?hl=enanswer=182192#1http://support.google.com/webmasters/bin/answer.py?hl=enanswer=182192#1 My question is How can I add LANGUAGE to the web2py visible url? That is Web2py gives me application/controller/function and I need it to become application/*LANGUAGE*/controller/function Thanks
[web2py] Re: web2py back reference and compute fields problem
I don't know about the order.order_item.select() part. Have you tried debugging the calc method? Insert this line right above result = 0: import pdb; pdb.set_trace() Run the app from the console (i.e: python web2py.py -a password ...) and when the method gets called, the application should freeze. If you look at the console, you will have a (Pdb) prompt. Continue to enter n to move to the next line and type print result to show the value of result at any time. You should be able to figure out the problem this way. If the application continues to work without freezing, then the calc method is not even being called, so you'd need to figure out why.
Re: [web2py] url rewrite for a multilingual / international site and search engine visibility
On May 17, 2012, at 5:21 AM, yus wrote: I am using web2py for a multilingual web-site with. I want to manage language setting the same way that it is managed in the admin application (that is through session and cookies I guess), but at the sale time I want the language to be explicitly indicated on the url structure as mysite.com/application/LANGUAGE/controller/function The reason is that I want to have the url structure that GOOGLE recommends for websites with international content: http://support.google.com/webmasters/bin/answer.py?hl=enanswer=182192#1 My question is How can I add LANGUAGE to the web2py visible url? That is Web2py gives me application/controller/function and I need it to become application/LANGUAGE/controller/function Do you use URL routing at all? The parametric router provides support for what you're after. There's a little documentation in the book, IIRC, and a recipe in the cookbook. Another good source of routing documentation is the unit-test file in gluon/tests.
Re: [web2py] Re: url rewrite for a multilingual / international site and search engine visibility
On May 17, 2012, at 6:20 AM, csantos wrote: Yes, but there's a bug associated with this feature in the latest release. For more info, check this out: http://code.google.com/p/web2py/issues/detail?id=798sort=-id BTW, that issues says: For instance, the URL /myapp/static/images/poweredby.png became /myapp/pt-br/static/images/poweredby.png, which is not what the documentation specified (worst case scenario it should be /myapp/static/pt-br/images/poweredby.png instead). That's actually the intended behavior. There *are* some errors in the documentation that need fixing. Where in the docs did you find the /app/static/lang/... pattern?
[web2py] Re: RFC: web2py-based workflow engine
Ross, I understand your reasons for attaching approvals to the workflow. I do it the other way because if a deliverable needs approval by six parties, putting six additional steps in the flow makes things a little cluttered. If you add six people as performers of an approval step, does that mean that any one of the six can approve or must all of them? I very much like your workflow object table. I'm still debating over whether to use auth to handle the roles. I think auth needs a table called auth_role, actually a group of groups, to collect permissions. It would be nice to have a 'has_role' decorator for it. On Wednesday, May 16, 2012 2:33:35 PM UTC-4, Ross Peoples wrote: The data model I already have does things a bit differently, but I think it accomplishes the same thing. I am in the process of writing all of the support methods. This is my current data model: # workflow table db.define_table('workflow', Field('name', length=50), Field('is_template', 'boolean', default=False), Field('created_by', db.auth_user, default=current_user), Field('created_on', 'datetime', default=self.request.now), Field('table_name', length=128), Field('row_id', 'integer'), Field('order_id', 'integer', default=self.ORDER_ID_STOP, comment='Current position of the workflow'), Field('priority', 'integer', requires=IS_INT_IN_RANGE(1, 9), default=self.DEFAULT_PRIORITY) ) # allow users / groups to monitor select workflows without needing to be a part of the workflow # if workflow is template, this list is copied to the new workflow db.define_table('workflow_monitor', Field('workflow_id', db.workflow), Field('user_id', db.auth_user), Field('group_id', db.auth_group), Field('viewed', 'boolean', default=False) # once the monitor looks at it, mark as viewed until another change happens ) # comments can be attached to workflows so that users can voice questions and concerns db.define_table('workflow_comment', Field('workflow_id', db.workflow), Field('user_id', db.auth_user, default=current_user), Field('event_date', 'datetime', default=self.request.now), Field('is_active', 'boolean', default=True, comment='Is the comment waiting to be addressed'), Field('comment', length=512, comment='The question, comment, or concern'), Field('response', length=512, comment='Response to the question, comment, or concern') ) # high-level list of goals for workflows. Users mark items as completed as they complete the goals # if workflow is template, the checklist is copied to new workflow db.define_table('workflow_checklist', Field('workflow_id', db.workflow), Field('name', length=50), Field('order_id', 'integer', comment='Ordering position of the item'), Field('is_active', 'boolean', default=True, comment='Is the item waiting to be addressed'), Field('completed_by', db.auth_user), Field('completed_at', 'datetime'), Field('completed_note', length=512) ) # workflow step table db.define_table('workflow_step', Field('workflow_id', db.workflow), Field('order_id', 'integer', comment='Ordering position of the step'), Field('name', length=50), Field('user_id', db.auth_user), Field('group_id', db.auth_group), Field('hours', 'decimal(10,2)', requires=IS_DECIMAL_IN_RANGE(0), default=0, comment='Optional time limit in hours'), Field('due_date', 'datetime', comment='Optional due date'), Field('note', length=512, comment='Note on current state of the step') # represents a stateful note (i.e. kickback reason). Can change at any time. ) # audit tables db.define_table('workflow_event', Field('workflow_id', 'integer'), Field('table_name', length=128), # i.e. document, folder, etc Field('row_id', 'integer'), # i.e. the ID of the document Field('user_id', db.auth_user, default=current_user), Field('event_date', 'datetime', default=self.request.now), Field('action', length=10, default='update'), # could be: create, update, delete Field('field_name', length=128), # i.e order_id, name, hours, etc Field('value_before', length=128), # None if create or delete Field('value_after', length=128) # None if delete ) db.define_table('workflow_step_event', Field('workflow_id', 'integer'), Field('step_id', 'integer'), # the ID of the workflow_step modified (used to match up fields in batch changes) Field('user_id', db.auth_user, default=current_user), Field('event_date', 'datetime', default=self.request.now), Field('action', length=10, default='update'), # could be: create, update, delete Field('field_name', length=128), # i.e order_id, name, hours, etc Field('value_before', length=128), # None if create or delete Field('value_after', length=128) # None if delete ) As you can see, this model has quite a few of the features we discussed: workflows,
Re: [web2py] Re: plugin_lazy_options_widget trigger event
What to do to not have dependency, I don't like to have autocomplete, but in the pass I didn't find how to avoid of using Suggest Widget. Thanks Richard On Wed, May 16, 2012 at 8:30 PM, kenji4569 hos...@s-cubism.jp wrote: Hi Jim, In puling_suggest_widget, trigger events are invoked from a js file: https://github.com/sqlabs/sqlabs/blob/master/static/plugin_suggest_widget/suggest.js by $input.trigger($input.attr('id') + '__unselected'); $input.trigger($input.attr('id') + '__selected', [val]); methods. To setup your trigger events, first you need to create a custom widget for a field, and then trigger events inside the widget using the jQuery trigger method. Regards, Kenji 2012年5月16日水曜日 4時46分20秒 UTC+9 Jim S: Hi I'm trying to use the plugin_lazy_options_widget to build a dependent select list. I have to fields on the screen, both with the IS_IN_DB validator and values available in the second depend on what is selected in the first. This widget from s-cubism seems like just the thing, but I can't figure out how to pass the right event that will trigger the population of the second widget. The example shows it working with another widget from s-cubism which triggers an event on the 'body' element but I can't see how to trigger the right event to get mien working off another SELECT element. Can someone give me some pointers on how to determine the event to watch for? -Jim
Re: [web2py] Re: plugin_lazy_options_widget trigger event
Thanks Kenji - I was trying to do this with the default widgets provided by web2py. Thanks for the info though, I will go down this path when I get the time to dig deeper. -Jim On 5/16/2012 7:30 PM, kenji4569 wrote: Hi Jim, In puling_suggest_widget, trigger events are invoked from a js file: https://github.com/sqlabs/sqlabs/blob/master/static/plugin_suggest_widget/suggest.js by $input.trigger($input.attr('id') + '__unselected'); $input.trigger($input.attr('id') + '__selected', [val]); methods. To setup your trigger events, first you need to create a custom widget for a field, and then trigger events inside the widget using the jQuery trigger method. Regards, Kenji 2012年5月16日水曜日 4時46分20秒 UTC+9 Jim S: Hi I'm trying to use the plugin_lazy_options_widget to build a dependent select list. I have to fields on the screen, both with the IS_IN_DB validator and values available in the second depend on what is selected in the first. This widget from s-cubism seems like just the thing, but I can't figure out how to pass the right event that will trigger the population of the second widget. The example shows it working with another widget from s-cubism which triggers an event on the 'body' element but I can't see how to trigger the right event to get mien working off another SELECT element. Can someone give me some pointers on how to determine the event to watch for? -Jim
[web2py] empty classes
I noticed, using SQLFORM.grid, that I get occasional empty class attributes, something like th classfoo/th. I assume that this is a consequence of calls like this one: head.append(TH(header, _class=ui.get('default',''))) It'd be nice, though probably not critical, to fix that, but it's a subtle problem. Stripping all attributes with empty values is likely to cause behavioral changes, since there are attributes (I forget which ones at the moment) that have effect without having values. It does seem worth a little effort, though, to clean up what we can. Maybe XML() (or wherever) could have a frozenset of attribute names that should be suppressed if they come without values?
[web2py] Re: empty classes
It should be head.append(TH(header, _class=ui.get('default'))) when an attribute is None, it is not displayed. On Thursday, 17 May 2012 09:28:33 UTC-5, Jonathan Lundell wrote: I noticed, using SQLFORM.grid, that I get occasional empty class attributes, something like th classfoo/th. I assume that this is a consequence of calls like this one: head.append(TH(header, _class=ui.get('default',''))) It'd be nice, though probably not critical, to fix that, but it's a subtle problem. Stripping all attributes with empty values is likely to cause behavioral changes, since there are attributes (I forget which ones at the moment) that have effect without having values. It does seem worth a little effort, though, to clean up what we can. Maybe XML() (or wherever) could have a frozenset of attribute names that should be suppressed if they come without values?
Re: [web2py] Re: empty classes
On May 17, 2012, at 7:51 AM, Massimo Di Pierro wrote: It should be head.append(TH(header, _class=ui.get('default'))) when an attribute is None, it is not displayed. That makes sense. On Thursday, 17 May 2012 09:28:33 UTC-5, Jonathan Lundell wrote: I noticed, using SQLFORM.grid, that I get occasional empty class attributes, something like th classfoo/th. I assume that this is a consequence of calls like this one: head.append(TH(header, _class=ui.get('default',''))) It'd be nice, though probably not critical, to fix that, but it's a subtle problem. Stripping all attributes with empty values is likely to cause behavioral changes, since there are attributes (I forget which ones at the moment) that have effect without having values. It does seem worth a little effort, though, to clean up what we can. Maybe XML() (or wherever) could have a frozenset of attribute names that should be suppressed if they come without values?
[web2py] Re: web2py back reference and compute fields problem
On Thursday, May 17, 2012 7:46:28 AM UTC-4, bioform wrote: Hello. I have two models: order (fields: id,cost) and order_item (fields: id, order, price, quantity). order_item.order looks like: Field('order', db.order) i'll try to add total_price field to order table: Field('total_price', 'integer' ,compute=lambda row: calc(row)) No need for a lambda above -- just do compute=calc, since calc is already callable. where calc(row) looks like: def calc(order): result = 0 for item in order.order_item.select() result += item.price return result Note, the Row object is passed to the compute function, so in your calc() function, order is actually the Row object of the record being entered into the order table. The order table doesn't have an order_item field, so order.order_item doesn't make sense. Even if that was a field, the .select() method cannot be called on a field -- it must be called on a DAL Set object. (Also missing the colon at the end of the for statement.) You'd probably want something more like this: for item in db(db.order_item.order == order.id).select(): However, when a record is first inserted into the order table, the calc function won't have anything to calculate, because there won't yet be any records in the order_item table associated with the new order. You might have to update the db.order record after the db.order_item records have been added. Or maybe a virtual field would be better here. Anthony
[web2py] Re: Multi computed fields
To get it down to it down to one function, how about: def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return eval(component) db.cities.full_address.compute = lambda r: compute_geoCode(r, 'place') db.cities.lat.compute = lambda r: compute_geoCode(r, 'lat') db.cities.lgt.compute = lambda r: compute_geoCode(r, 'lng') Anthony On Thursday, May 17, 2012 4:35:46 AM UTC-4, Gabriella Canavesi wrote: Hi all, I have a simple table with 3 computed fields, the function that set their values is almost the same. However, unfortunately I had to set up three different functions because I didn't find a better approach. The code: db.define_table('cities', Field('name', 'string', requires=IS_TRIM()), Field('full_address', 'string',requires=IS_TRIM()), Field(lat, double, label=T('Latitude')), Field(lgt, double, label=T('Longitude'))) db.cities.full_address.compute = compute_geoCode_place db.cities.lat.compute = compute_geoCode_lat db.cities.lgt.compute = compute_geoCode_lng def compute_geoCode_place(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return place def compute_geoCode_lat(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return lat def compute_geoCode_lng(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name) return lng What I would like to find is a way to fire the execution of a function when the form is submitted. More or less something like a compute action at table level. Regards, -- Paolo
[web2py] error in Book: Setting up email
Maybe someone else already posted about it but where the Book says: You need to replace the mail.settings with the proper parameters for your SMTP server. Set mail.settings.login=False if the SMTP server does not require authentication. I think it should be: mail.settings.login=None, because if set to False you get the error: WARNING:web2py:Mail.send failure:'bool' object has no attribute 'split' carlo
[web2py] Re: SNI or dedicated IP.
Setting up SNI on Apache is quite straightforward. If anyone has any problems, ask in this thread and I'll try to help. Upside: - dedicated IP isn't needed - it works in all major browsers and OSes Downside: - SNI on Windows XP should work in Firefox, Opera, etc. but not in IE (it will work in IE in Vista or later) That's the biggest downside in my book, looking from the client's perspective - it doesn't work in Android 2.x default browser, works in Android 3 and 4 - it doesn't work with python 2's ssl, urllib and httplib modules (this could only be a problem if you use these modules to access such a site, it won't affect building a site in web2py). We're using SNI on quite a few sites, since we need to support a large number of virtual hosts. Since IPv4 IPs are getting scarce these days, be prepared to get more and more recommendations to use SNI from your hosting providers... Regards On Wednesday, May 16, 2012 7:36:18 PM UTC+2, Anthony wrote: On Wednesday, May 16, 2012 1:08:20 PM UTC-4, Ross Peoples wrote: I wouldn't know the first thing about setting up SNI, so I would tell WebFaction that if they will do it for me and it works, then sure, I'll use SNI, otherwise stick with what you know. I think in this case, what you know (i.e., dedicated IP address) is an extra $5/month. The downside of SNI, though, is that it appears not to be supported on Android 2.x (also not on Windows XP). SSL will still technically work on those clients, but will result in a certificate error being displayed. Anthony
[web2py] Re: Redirect and try except ?
How i can use? def mycaller(f): try: return f() except *(HTTP...)* : return f() else: raise(HTTP(400)) How about: def mycaller(f): try: return f() except HTTP: return f() except: raise HTTP(400) Anyway, what exactly are you trying to do? Do you want to send a 400 response regardless of the type of error generated by the function (note, that will only work for code in the function itself, not code in the models or view)? I'm not sure it's a good idea to play with response._caller -- that's not part of the framework API and could therefore change in the future. Another option is to use the routes_onerror functionality to always serve the same static error page, regardless of error type, or to direct all errors to a special error handling function, which can always issue a 400 error. See http://web2py.com/books/default/chapter/29/4#Routes-on-error. Anthony
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Is it conceivable that a uwsgi + nginx bundle could be produced making python deployment super easy?
Re: [web2py] Re: Multi computed fields
Hi Niphlod, thanks for your answer. Actually, I am looking for something that I can put in my model without touch the code of the forms, e.g., I don't want to change the code of the admin application to solve the problem. Paolo Il 17.05.2012 13:14 Niphlod ha scritto: The onsuccess parameter of form.process() seems to cover your problems: from http://web2py.com/books/default/chapter/29/7 onsuccess and onfailure can be functions like lambda form: do_something(form) Il giorno giovedì 17 maggio 2012 10:35:46 UTC+2, Gabriella Canavesi ha scritto: Hi all, I have a simple table with 3 computed fields, the function that set their values is almost the same. However, unfortunately I had to set up three different functions because I didn't find a better approach. The code: db.define_table('cities', Field('name', 'string', requires=IS_TRIM()), Field('full_address', 'string',requires=IS_TRIM()), Field(lat, double, label=T('Latitude')), Field(lgt, double, label=T('Longitude'))) db.cities.full_address.compute = compute_geoCode_place db.cities.lat.compute = compute_geoCode_lat db.cities.lgt.compute = compute_geoCode_lng def compute_geoCode_place(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [1]) return place def compute_geoCode_lat(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [2]) return lat def compute_geoCode_lng(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [3]) return lng What I would like to find is a way to fire the execution of a function when the form is submitted. More or less something like a compute action at table level. Regards, -- Paolo Links: -- [1] http://r.name [2] http://r.name [3] http://r.name
Re: [web2py] Re: Multi computed fields
Hi Anthony, thanks for the answer, Your solution is pretty nice but I am still calling it 3 times which actually is the main problem since I am asking 'google' 3 times the same stuff. Is it possible to store the answer somewhere (cache?) the first time and then use the cache copy for the latter calls? Regards, Paolo Il 17.05.2012 15:09 Anthony ha scritto: To get it down to it down to one function, how about: def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [4]) return eval(component) db.cities.full_address.compute = lambda r: compute_geoCode(r, 'place') db.cities.lat.compute = lambda r: compute_geoCode(r, 'lat') db.cities.lgt.compute = lambda r: compute_geoCode(r, 'lng') Anthony On Thursday, May 17, 2012 4:35:46 AM UTC-4, Gabriella Canavesi wrote: Hi all, I have a simple table with 3 computed fields, the function that set their values is almost the same. However, unfortunately I had to set up three different functions because I didn't find a better approach. The code: db.define_table('cities', Field('name', 'string', requires=IS_TRIM()), Field('full_address', 'string',requires=IS_TRIM()), Field(lat, double, label=T('Latitude')), Field(lgt, double, label=T('Longitude'))) db.cities.full_address.compute = compute_geoCode_place db.cities.lat.compute = compute_geoCode_lat db.cities.lgt.compute = compute_geoCode_lng def compute_geoCode_place(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [1]) return place def compute_geoCode_lat(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [2]) return lat def compute_geoCode_lng(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [3]) return lng What I would like to find is a way to fire the execution of a function when the form is submitted. More or less something like a compute action at table level. Regards, -- Paolo Links: -- [1] http://r.name [2] http://r.name [3] http://r.name [4] http://r.name/ -- Paolo
[web2py] Re: RFC: web2py-based workflow engine
On Thursday, May 17, 2012 9:37:46 AM UTC-4, Cliff wrote: Ross, I understand your reasons for attaching approvals to the workflow. I do it the other way because if a deliverable needs approval by six parties, putting six additional steps in the flow makes things a little cluttered. If you add six people as performers of an approval step, does that mean that any one of the six can approve or must all of them? If you were to put all of them in a group and add the group as part of the workflow, any one of them can approve. For cases when you need all 6 to approve, then you would add all 6 of them as steps in the workflow. I don't know of a good, clean, and understandable way to do that otherwise. I very much like your workflow object table. I'm still debating over whether to use auth to handle the roles. I think auth needs a table called auth_role, actually a group of groups, to collect permissions. It would be nice to have a 'has_role' decorator for it. Authorization is the only thing in this I'm having trouble wrapping my head around. Previously, I had the objects the workflows were attached to handle their own security with minimal restrictions on the workflow side. It worked out great because the documents were tightly integrated with the workflow system. The major problem being that only documents could participate in the workflows. So I'm still having trouble figuring out how to do this in a more general way without making it so complicated that no one would use it. I am definitely open to suggestions on this one.
[web2py] Re: error in Book: Setting up email
Good catch. Fixed in trunk! On Thursday, 17 May 2012 10:16:30 UTC-5, carlo wrote: Maybe someone else already posted about it but where the Book says: You need to replace the mail.settings with the proper parameters for your SMTP server. Set mail.settings.login=False if the SMTP server does not require authentication. I think it should be: mail.settings.login=None, because if set to False you get the error: WARNING:web2py:Mail.send failure:'bool' object has no attribute 'split' carlo
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
You mean like a virtual machine? or an installation script? On Thursday, 17 May 2012 10:34:57 UTC-5, pbreit wrote: Is it conceivable that a uwsgi + nginx bundle could be produced making python deployment super easy?
Re: [web2py] Re: Multi computed fields
def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = cache.ram(r.name, lambda: g.geocode(r.name), None) return eval(component) Anthony On Thursday, May 17, 2012 11:44:16 AM UTC-4, Gabriella Canavesi wrote: Hi Anthony, thanks for the answer, Your solution is pretty nice but I am still calling it 3 times which actually is the main problem since I am asking 'google' 3 times the same stuff. Is it possible to store the answer somewhere (cache?) the first time and then use the cache copy for the latter calls? Regards, Paolo Il 17.05.2012 15:09 Anthony ha scritto: To get it down to it down to one function, how about: def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [4]) return eval(component) db.cities.full_address.compute = lambda r: compute_geoCode(r, 'place') db.cities.lat.compute = lambda r: compute_geoCode(r, 'lat') db.cities.lgt.compute = lambda r: compute_geoCode(r, 'lng') Anthony On Thursday, May 17, 2012 4:35:46 AM UTC-4, Gabriella Canavesi wrote: Hi all, I have a simple table with 3 computed fields, the function that set their values is almost the same. However, unfortunately I had to set up three different functions because I didn't find a better approach. The code: db.define_table('cities', Field('name', 'string', requires=IS_TRIM()), Field('full_address', 'string',requires=IS_TRIM()), Field(lat, double, label=T('Latitude')), Field(lgt, double, label=T('Longitude'))) db.cities.full_address.compute = compute_geoCode_place db.cities.lat.compute = compute_geoCode_lat db.cities.lgt.compute = compute_geoCode_lng def compute_geoCode_place(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [1]) return place def compute_geoCode_lat(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [2]) return lat def compute_geoCode_lng(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [3]) return lng What I would like to find is a way to fire the execution of a function when the form is submitted. More or less something like a compute action at table level. Regards, -- Paolo Links: -- [1] http://r.name [2] http://r.name [3] http://r.name [4] http://r.name/ -- Paolo
[web2py] Windows binaries version of Python
Hello all, I'm developping over web2py source (1.99.7) using Eclipse, with Python (I used to use the version 2.7.2, but now because of my problem I use version 2.5.4 but...). When I think my application is worth it, I zip its folder and I give it to someone else in order to test it. This person uses a compiled Web2py server for Windows (current version too) which uses embarked Python (2.5.x ?) binaries. The issue I have is that I always have problems with the exported database. With my old use of version 2.7 I had problems with the ON DELETE CASCADE directive. My current problem with version 2.5.4 is the following one (when I try to log in) (I did not tamper with the definitions of auth tables, which are defined with auth.define_tables() ): Traceback (most recent call last): File gluon/restricted.py, line 205, in restricted File C:/Users/cedric/projets/LACT/devWeb2py/lact_web2py/applications/lact/controllers/default.py http://127.0.0.1:8000/admin/default/edit/lact/controllers/default.py, line 74, in module File gluon/globals.py, line 173, in lambda File C:/Users/cedric/projets/LACT/devWeb2py/lact_web2py/applications/lact/controllers/default.py http://127.0.0.1:8000/admin/default/edit/lact/controllers/default.py, line 33, in user File gluon/tools.py, line 1161, in __call__ File gluon/tools.py, line 1729, in login File gluon/dal.py, line 7578, in select File gluon/dal.py, line 1315, in select File gluon/dal.py, line 1305, in response File gluon/dal.py, line 1392, in execute File gluon/dal.py, line 1386, in log_execute OperationalError: no such column: auth_user.registration_id So my questions are (at least one answer to any one would please me) : 1) what is the correct way to export a web2py application from a development environment to a Windows production environment, without deleting the entire database ? 2) what is the correct source execution environment compatible with compiled version ? Thank you a lot, Cédric
[web2py] Re: modules
i don't find the error in this code... El miércoles, 16 de mayo de 2012 10:57:15 UTC-5, Aurigadl escribió: I did Thank you for entering Issue 800http://code.google.com/p/web2py/issues/detail?id=800 El miércoles, 16 de mayo de 2012 10:43:36 UTC-5, Massimo Di Pierro escribió: Please open a ticket in googlecode and give more details about your web2py version, python version and os version. On Wednesday, 16 May 2012 10:40:54 UTC-5, Aurigadl wrote: if you have: /applications/examples/modules/prueba.py $python web2py.py -S examples import prueba this does not work But if you used: from applications.examples.modules import prueba this work very well. way?? I have all whit the __init__py for import modules. El miércoles, 16 de mayo de 2012 10:32:00 UTC-5, Anthony escribió: Are you importing from within the examples application? In that case you can just do: import test Anthony On Wednesday, May 16, 2012 11:13:16 AM UTC-4, Aurigadl wrote: I always work with modules. In the latest versions of web2py not work. doing the following to import: from applications.examples.modules import test Restricting the application name.The modules are placed in the / app / modules web2py.app.prueba.w2p Description: Binary data
Re: [web2py] Re: Multi computed fields
Hi Niphlod, thanks for your answer. Actually, I am looking for something that I can put in my model without touch the code of the forms, e.g., I don't want to change the code of the admin application to solve the problem. In this case, I think caching in the compute_geoCode function is probably the best approach, but in general, if you want to execute a function (or set of functions) when doing inserts, updates, or deletes, you can append functions to the table's _before_insert, _before_update, _before_delete, _after_insert, _after_update, or _after_delete lists. The _after_insert functions receive a dictionary of the fields that were inserted as well as the record ID of the inserted record. After insert, you could update the record with the three values from the g.geocode() call. def compute_geoCode(r, id): g = geocoders.Google() place, (lat, lng) = g.geocode(r http://r.name/['name']) db.cities[id] = dict(full_address=place, lat=lat, lgt=lng) db.cities._after_insert.append(compute_geoCode) db.cities._after_update.append(compute_geoCode) That results in a second db operation (i.e., the update). An alternative would be to use a _before_insert function to call g.geocode() and cache the result, and then have the individual fields' compute functions retrieve the result from the cache. Note, the _before_ and _after_ functionality is available in trunk, but I don't think it's in the current stable release. Anthony
Re: [web2py] Re: Multi computed fields
This is perfect! Thank you very much Anthony. Paolo Il 17.05.2012 16:47 Anthony ha scritto: def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = cache.ram(r.name, lambda: g.geocode(r.name [9]), None) return eval(component) Anthony On Thursday, May 17, 2012 11:44:16 AM UTC-4, Gabriella Canavesi wrote: Hi Anthony, thanks for the answer, Your solution is pretty nice but I am still calling it 3 times which actually is the main problem since I am asking 'google' 3 times the same stuff. Is it possible to store the answer somewhere (cache?) the first time and then use the cache copy for the latter calls? Regards, Paolo Il 17.05.2012 15:09 Anthony ha scritto: To get it down to it down to one function, how about: def compute_geoCode(r, component): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [1] [4]) return eval(component) db.cities.full_address.compute = lambda r: compute_geoCode(r, 'place') db.cities.lat.compute = lambda r: compute_geoCode(r, 'lat') db.cities.lgt.compute = lambda r: compute_geoCode(r, 'lng') Anthony On Thursday, May 17, 2012 4:35:46 AM UTC-4, Gabriella Canavesi wrote: Hi all, I have a simple table with 3 computed fields, the function that set their values is almost the same. However, unfortunately I had to set up three different functions because I didn't find a better approach. The code: db.define_table('cities', Field('name', 'string', requires=IS_TRIM()), Field('full_address', 'string',requires=IS_TRIM()), Field(lat, double, label=T('Latitude')), Field(lgt, double, label=T('Longitude'))) db.cities.full_address.compute = compute_geoCode_place db.cities.lat.compute = compute_geoCode_lat db.cities.lgt.compute = compute_geoCode_lng def compute_geoCode_place(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [2] [1]) return place def compute_geoCode_lat(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [3] [2]) return lat def compute_geoCode_lng(r): g = geocoders.Google() place, (lat, lng) = g.geocode(r.name [4] [3]) return lng What I would like to find is a way to fire the execution of a function when the form is submitted. More or less something like a compute action at table level. Regards, -- Paolo Links: -- [1] http://r.name [5] [2] http://r.name [6] [3] http://r.name [7] [4] http://r.name/ [8] -- Paolo Links: -- [1] http://r.name [2] http://r.name [3] http://r.name [4] http://r.name [5] http://r.name [6] http://r.name [7] http://r.name [8] http://r.name/ [9] http://r.name/
Re: [web2py] 75€ BOUNTY - Massively Complicated Query Required
I am not sure if I understand your model. Can you explain tag_link ? Marin On Thu, May 17, 2012 at 6:28 PM, Jason Brower encomp...@gmail.com wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75€ with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID Nickname Tags your looking for that they have Your Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag4 3 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag4 3 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag4 3 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen. I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell. I will give you another 25€ for that implementation as well. :) --- BR, Jason Brower
Re: [web2py] 75€ BOUNTY - Massively Complicated Query Required
It is a many-to-many but it can link to multiple tables. event is the event that a user can attend table_link is the ID that is used in a particular table. tag is the tag.id that this row is linking to. intent is as described before. tag_type is the table that the system will link to. Notice there is a booth, auth_user, and happening table. All of those support tags and instead of needing to create a table for each one, I combined them. Aslo comes in handy in other ways too. Like if I want to create tag relations on other parts of my database. I could even create tag relations on tags or other tag relations. Very powerful. br, Jason On 05/17/2012 08:32 PM, Marin Pranjic' wrote: I am not sure if I understand your model. Can you explain tag_link ? Marin On Thu, May 17, 2012 at 6:28 PM, Jason Brower encomp...@gmail.com mailto:encomp...@gmail.com wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75€ with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID NicknameTags your looking for that they haveYour Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag43 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag43 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag43 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen. I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell. I will give you another 25€ for that implementation as well. :) --- BR, Jason Brower
Re: [web2py] Re: URL vars doesn't like Storage
thanks for that Anthony I thought that in some automagicaly way web2py was seriallizing/deserializing... ;) by the way as the request.vars.vars contains Storage {'': '', 'www': '4'} ast.literal_eval(request.vars.vars[9:-1]) did the trick Just wondering if there is an easier way of doing it (I mean: to pass the current URL+vars to the LOAD) On Thu, May 17, 2012 at 1:03 PM, Anthony abasta...@gmail.com wrote: As I pass it as vars via LOAD: {{=LOAD('default', 'send_suggestion', vars={ 'c':request.controller, 'f':request.function, 'args':request.args, 'vars':request.vars}, ajax_trap=True)}} does it mean that request.vars has not been serialized/deserialized correctly ? When you pass a dict as a URL var, the dict is converted to a string representation of the dict and then urlencoded. When it is decoded, you have a string representation of the dict (equivalent to repr(request.vars) in this case), not the dict itself (actually, I think it's a list with the string representation of the dict as its sole element). To get the dict back, you can safely eval it using ast.literal_eval: import ast _vars = ast.literal_eval(request.vars.vars[0]) if request.vars.vars else {} Anthony -- Sebastian E. Ovide
[web2py] Re: 75€ BOUNTY - Massively Complicated Query Required
If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 So, is the third similar to the first, but with a city clause. Sounds like it's a +2 if you have something UserA is looking for, but it's only +1 if you live in the same city ? Andrew W On Friday, May 18, 2012 4:28:02 AM UTC+12, encompass wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75� with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID Nickname Tags your looking for that they have Your Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag4 3 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag4 3 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag4 3 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen.� I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell.� I will give you another 25� for that implementation as well. :) --- BR, Jason Brower
[web2py] SQL avg()
Hello, How I can make an avg() aggregate with web2py? Richard
[web2py] Re: 75€ BOUNTY - Massively Complicated Query Required
So, is the third similar to the first, but with a city clause. Sounds like it's a +2 if you have something UserA is looking for, but it's only +1 if you live in the same city ? Oh, I see from your example that it is an *additional* +1 if you are in the same city. Got it.
Re: [web2py] Re: 75€ BOUNTY - Massively Complicated Query Required
For the third one this is to further show the relevance of a user because they are living near you, but they should be someone that at least has something in common with you. BR, Jason Brower On 05/17/2012 09:22 PM, Andrew wrote: If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 So, is the third similar to the first, but with a city clause. Sounds like it's a +2 if you have something UserA is looking for, but it's only +1 if you live in the same city ? Andrew W On Friday, May 18, 2012 4:28:02 AM UTC+12, encompass wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75� with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID NicknameTags your looking for that they haveYour Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag43 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag43 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag43 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen.� I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell.� I will give you another 25� for that implementation as well. :) --- BR, Jason Brower
Re: [web2py] Re: 75€ BOUNTY - Massively Complicated Query Required
I found a way quite simple but It does not include the Relevance columns. 2012/5/17 Andrew awillima...@gmail.com If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 So, is the third similar to the first, but with a city clause. Sounds like it's a +2 if you have something UserA is looking for, but it's only +1 if you live in the same city ? Andrew W On Friday, May 18, 2012 4:28:02 AM UTC+12, encompass wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75� with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID Nickname Tags your looking for that they have Your Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag4 3 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag4 3 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag4 3 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen.� I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell.� I will give you another 25� for that implementation as well. :) --- BR, Jason Brower -- Carlos J. Costa Cientista da Computação Esp. Gestão em Telecom EL MELECH NEEMAN! אָמֵן
Re: [web2py] Re: 75€ BOUNTY - Massively Complicated Query Required
On 05/17/2012 09:29 PM, Andrew wrote: So, is the third similar to the first, but with a city clause. Sounds like it's a +2 if you have something UserA is looking for, but it's only +1 if you live in the same city ? Oh, I see from your example that it is an _additional_ +1 if you are in the same city. Got it. Yes, that is correct. BR, Jason Brower
Re: [web2py] SQL avg()
I see sum, min, and max aggregates in the book at section 6.24.4, but no avg. But, using sum and count (from 6.21.3) you could get there. -Jim On 5/17/2012 1:25 PM, Richard Vézina wrote: Hello, How I can make an avg() aggregate with web2py? Richard
Re: [web2py] Re: 75€ BOUNTY - Massively Complicated Query Required
The relevance columns are vital as I need to know how strong the relation is to UserA. It's used in a tag cloud module that I have built. BR, Jason On 05/17/2012 09:30 PM, Carlos Costa wrote: I found a way quite simple but It does not include the Relevance columns. 2012/5/17 Andrew awillima...@gmail.com mailto:awillima...@gmail.com If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 So, is the third similar to the first, but with a city clause. Sounds like it's a +2 if you have something UserA is looking for, but it's only +1 if you live in the same city ? Andrew W On Friday, May 18, 2012 4:28:02 AM UTC+12, encompass wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75� with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID NicknameTags your looking for that they haveYour Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag43 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag43 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag43 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen.� I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell.� I will give you another 25� for that implementation as well. :) --- BR, Jason Brower -- Carlos J. Costa Cientista da Computação Esp. Gestão em Telecom EL MELECH NEEMAN! אָמֵן
Re: [web2py] SQL avg()
Yeah, that's what I thought just after press send :) Richard On Thu, May 17, 2012 at 2:33 PM, Jim Steil j...@qlf.com wrote: I see sum, min, and max aggregates in the book at section 6.24.4, but no avg. But, using sum and count (from 6.21.3) you could get there. -Jim On 5/17/2012 1:25 PM, Richard Vézina wrote: Hello, How I can make an avg() aggregate with web2py? Richard
Re: [web2py] SQL avg()
print db().select(db.tab1.f2.sum()/db.tab1.f2.count(), groupby=db.tab1.f1) Richard On Thu, May 17, 2012 at 2:38 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Yeah, that's what I thought just after press send :) Richard On Thu, May 17, 2012 at 2:33 PM, Jim Steil j...@qlf.com wrote: I see sum, min, and max aggregates in the book at section 6.24.4, but no avg. But, using sum and count (from 6.21.3) you could get there. -Jim On 5/17/2012 1:25 PM, Richard Vézina wrote: Hello, How I can make an avg() aggregate with web2py? Richard
Re: [web2py] SQL avg()
Now I am searching a way to sum a list:reference type field with the proper representation of id... Richard On Thu, May 17, 2012 at 2:54 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: print db().select(db.tab1.f2.sum()/db.tab1.f2.count(), groupby=db.tab1.f1) Richard On Thu, May 17, 2012 at 2:38 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Yeah, that's what I thought just after press send :) Richard On Thu, May 17, 2012 at 2:33 PM, Jim Steil j...@qlf.com wrote: I see sum, min, and max aggregates in the book at section 6.24.4, but no avg. But, using sum and count (from 6.21.3) you could get there. -Jim On 5/17/2012 1:25 PM, Richard Vézina wrote: Hello, How I can make an avg() aggregate with web2py? Richard
[web2py] Re: Load data from sqlite file?
Yes, that's exactly what i need to do. I was going to try it like you described using the filename to create a new DAL, and defining it as an import function somewhere in the model, so glad to hear that it should be doable! Will post my code once i have I get around to writing it. Thanks, Dave On Friday, 11 May 2012 16:22:57 UTC-6, Brian M wrote: So the user is going to be uploading a .sqlite file which you want to connect to with the DAL and import? You should be able to create a new DAL connection within a controller function or probably better yet a module instead of in a model file (which would have been run too early in the request process). So save the uploaded .sqlite file then find out the filename that web2py gave it and then pass that filename (and path) to a new dal connection, proceed to define the tables as usual and import away. On Thursday, May 10, 2012 6:38:41 PM UTC-5, Dave wrote: Any examples or suggestions on how to load data from a user-uploaded .sqlite database? I will have the database structure of the uploaded files ahead of time (they are being generated by a mobile app), so I need a way to transfer the data from an uploaded .sqlite file to my web2py tables. is it possible to just use the uploaded file as a new dal, then transfer the data to the main dal, all within a function? Thanks in advance, Dave
Re: [web2py] SQL avg()
I just hacked a quick and dirty solution by inserting the following to dal.py at line 7370: def avg(self): return Expression(self.db, self.db._adapter.AGGREGATE, self, 'AVG', self.type) Worked fine on my tests with MySQL, using it just like sum, but using avg instead. -Jim On 5/17/2012 1:38 PM, Richard Vézina wrote: Yeah, that's what I thought just after press send :) Richard On Thu, May 17, 2012 at 2:33 PM, Jim Steil j...@qlf.com mailto:j...@qlf.com wrote: I see sum, min, and max aggregates in the book at section 6.24.4, but no avg. But, using sum and count (from 6.21.3) you could get there. -Jim On 5/17/2012 1:25 PM, Richard Vézina wrote: Hello, How I can make an avg() aggregate with web2py? Richard
Re: [web2py] SQL avg()
Maybe open a ticket and propose a patch!! Richard On Thu, May 17, 2012 at 3:09 PM, Jim Steil j...@qlf.com wrote: I just hacked a quick and dirty solution by inserting the following to dal.py at line 7370: def avg(self): return Expression(self.db, self.db._adapter.AGGREGATE, self, 'AVG', self.type) Worked fine on my tests with MySQL, using it just like sum, but using avg instead. -Jim On 5/17/2012 1:38 PM, Richard Vézina wrote: Yeah, that's what I thought just after press send :) Richard On Thu, May 17, 2012 at 2:33 PM, Jim Steil j...@qlf.com wrote: I see sum, min, and max aggregates in the book at section 6.24.4, but no avg. But, using sum and count (from 6.21.3) you could get there. -Jim On 5/17/2012 1:25 PM, Richard Vézina wrote: Hello, How I can make an avg() aggregate with web2py? Richard
Re: [web2py] 75€ BOUNTY - Massively Complicated Query Required
and why both tag and tag_link have an event.id field? is this redundant? On Thu, May 17, 2012 at 7:56 PM, Jason Brower encomp...@gmail.com wrote: It is a many-to-many but it can link to multiple tables. event is the event that a user can attend table_link is the ID that is used in a particular table. tag is the tag.id that this row is linking to. intent is as described before. tag_type is the table that the system will link to. Notice there is a booth, auth_user, and happening table. All of those support tags and instead of needing to create a table for each one, I combined them. Aslo comes in handy in other ways too. Like if I want to create tag relations on other parts of my database. I could even create tag relations on tags or other tag relations. Very powerful. br, Jason On 05/17/2012 08:32 PM, Marin Pranjić wrote: I am not sure if I understand your model. Can you explain tag_link ? Marin On Thu, May 17, 2012 at 6:28 PM, Jason Brower encomp...@gmail.com wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75€ with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID Nickname Tags your looking for that they have Your Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag4 3 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag4 3 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag4 3 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen. I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell. I will give you another 25€ for that implementation as well. :) --- BR, Jason Brower
Re: [web2py] SQL avg()
Done http://code.google.com/p/web2py/issues/detail?id=803 -Jim On 5/17/2012 2:27 PM, Richard Vézina wrote: Maybe open a ticket and propose a patch!! Richard On Thu, May 17, 2012 at 3:09 PM, Jim Steil j...@qlf.com mailto:j...@qlf.com wrote: I just hacked a quick and dirty solution by inserting the following to dal.py at line 7370: def avg(self): return Expression(self.db, self.db._adapter.AGGREGATE, self, 'AVG', self.type) Worked fine on my tests with MySQL, using it just like sum, but using avg instead. -Jim On 5/17/2012 1:38 PM, Richard Vézina wrote: Yeah, that's what I thought just after press send :) Richard On Thu, May 17, 2012 at 2:33 PM, Jim Steil j...@qlf.com mailto:j...@qlf.com wrote: I see sum, min, and max aggregates in the book at section 6.24.4, but no avg. But, using sum and count (from 6.21.3) you could get there. -Jim On 5/17/2012 1:25 PM, Richard Vézina wrote: Hello, How I can make an avg() aggregate with web2py? Richard
Re: [web2py] Re: SNI or dedicated IP.
SNI does not work with Android 2.x browser and also any other application using the unfortunate java api implementation. They were in a hurry and just put something that worked on ssl but without SNI support even if SNI standard was out since long before... mic 2012/5/17 LightDot light...@gmail.com: Setting up SNI on Apache is quite straightforward. If anyone has any problems, ask in this thread and I'll try to help. Upside: - dedicated IP isn't needed - it works in all major browsers and OSes Downside: - SNI on Windows XP should work in Firefox, Opera, etc. but not in IE (it will work in IE in Vista or later) That's the biggest downside in my book, looking from the client's perspective - it doesn't work in Android 2.x default browser, works in Android 3 and 4 - it doesn't work with python 2's ssl, urllib and httplib modules (this could only be a problem if you use these modules to access such a site, it won't affect building a site in web2py). We're using SNI on quite a few sites, since we need to support a large number of virtual hosts. Since IPv4 IPs are getting scarce these days, be prepared to get more and more recommendations to use SNI from your hosting providers... Regards On Wednesday, May 16, 2012 7:36:18 PM UTC+2, Anthony wrote: On Wednesday, May 16, 2012 1:08:20 PM UTC-4, Ross Peoples wrote: I wouldn't know the first thing about setting up SNI, so I would tell WebFaction that if they will do it for me and it works, then sure, I'll use SNI, otherwise stick with what you know. I think in this case, what you know (i.e., dedicated IP address) is an extra $5/month. The downside of SNI, though, is that it appears not to be supported on Android 2.x (also not on Windows XP). SSL will still technically work on those clients, but will result in a certificate error being displayed. Anthony
Re: [web2py] nginx uwsgi error 502 bad gate way
Hi! Not sure if it's your case. I had a similar problem, asked around and Bruce Wade told me that there were a few changes on uwsgi on ubuntu, so he changed the installation script a bit and posted it on the list. The link is: https://groups.google.com/forum/#!searchin/web2py/nginx$20update/web2py/ysmeR0mZVZo/nOBTKhPOgi8J Worked for me. Hope it works for you too. Cheers, Marco Tulio 2012/5/16 Lewis lewis_le...@hotmail.com Guys, I have followed the cookbook, the posts here, and a posting at stackoverflow. I am getting error 502 bad gateway. My stuff looks like everyone else's but there are deeper layers of indirection in uwsgi itself and nginx. I have several uwsgi sym links in /etc/init.dIt is not clear which is the real one and how to invoke it. Here is the error from the nginx log. I guess I interpret this to mean that nginx can't find uwsgi: 2012/05/16 22:53:29 [error] 2460#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 76.104.195.84, server: www.lewcl.com, request: GET / HTTP/1.1, upstream: uwsgi:// 127.0.0.1:9001, host: www.lewcl.com I have no clue what to do. Guys, I think that python and web2py have a profoundly serious problem with config. Documentation is often wrong--a single punctuation mark, directory or option being off means it won't work. If we have that in our Python code it won't run, but we have great traceback and debugging tools to tell us exactly where the error is and often what the error is. But when one of 5 or 6 text files scattered across the file system is wrong, all we find out is that it won't run. There are no diagnostics (or very course ones like error). I'd like to work with some people in the community to redo a lot of the guides and get them to be accurate. I don't think script files are much of a solution (except as a way to document something that once worked on some arbitrary system). Running an arbitrary script file blindly can do serious harm to your environment. Script files are not fully debugged and recoverable setup programs. Setup is one of the hardest things to do right. It is not a throw-away task to be done at the end of the project. -- []'s Marco Tulio
[web2py] Re: RFC: web2py-based workflow engine
Let's inject manufacturing into the order processing scenario you were using before. It's a three step process. Step one fabricates widgets. Step 2 attaches the widgets to widget bicarackets, purchased from another vendor. Step 3 packages the assemblies for shipment. If the last batch of widgets from the fabricator won't fit the brackets because they are oversize, obviously the guy in assembly wants to send them back for rework. How would the system handle this? And how would it avoid forcing the guy in charge of assembly to take action on every batch of good widgets, assuming the system's intent is to manage by exception? On Thursday, May 17, 2012 11:47:48 AM UTC-4, Ross Peoples wrote: On Thursday, May 17, 2012 9:37:46 AM UTC-4, Cliff wrote: Ross, I understand your reasons for attaching approvals to the workflow. I do it the other way because if a deliverable needs approval by six parties, putting six additional steps in the flow makes things a little cluttered. If you add six people as performers of an approval step, does that mean that any one of the six can approve or must all of them? s If you were to put all of them in a group and add the group as part of the workflow, any one of them can approve. For cases when you need all 6 to approve, then you would add all 6 of them as steps in the workflow. I don't know of a good, clean, and understandable way to do that otherwise. I very much like your workflow object table. I'm still debating over whether to use auth to handle the roles. I think auth needs a table called auth_role, actually a group of groups, to collect permissions. It would be nice to have a 'has_role' decorator for it. Authorization is the only thing in this I'm having trouble wrapping my head around. Previously, I had the objects the workflows were attached to handle their own security with minimal restrictions on the workflow side. It worked out great because the documents were tightly integrated with the workflow system. The major problem being that only documents could participate in the workflows. So I'm still having trouble figuring out how to do this in a more general way without making it so complicated that no one would use it. I am definitely open to suggestions on this one.
Re: [web2py] Re: URL vars doesn't like Storage
by the way as the request.vars.vars contains Storage {'': '', 'www': '4'} ast.literal_eval(request.vars.vars[9:-1]) did the trick Sorry, I was thinking dict instead of Storage. Just wondering if there is an easier way of doing it (I mean: to pass the current URL+vars to the LOAD) How about: {{=LOAD('default', 'send_suggestion', vars=dict(url=URL(args=request.args, vars=request.get_vars)), ajax_trap=True)}} def send_suggestion(): import urllib form = SQLFORM.factory(Field('message', 'text', requires=IS_NOT_EMPTY ())) if form.process().accepted: subject = 'FEEDBACK: %s' % urllib.unquote(request.get_vars.url) response.flash = 'Thanks for your feedback' Anthony
Re: [web2py] Re: URL vars doesn't like Storage
Even better, just put the URL in a hidden field in the form: {{=LOAD('default', 'send_suggestion', ajax_trap=True)}} def send_suggestion(): form = SQLFORM.factory(Field('message', 'text', requires=IS_NOT_EMPTY ()), hidden=dict(url=XML(URL(args=request.args, vars=request.get_vars if form.process().accepted: subject = 'FEEDBACK: %s' % request.vars.url response.flash = 'Thanks for your feedback' Anthony On Thursday, May 17, 2012 4:00:02 PM UTC-4, Anthony wrote: by the way as the request.vars.vars contains Storage {'': '', 'www': '4'} ast.literal_eval(request.vars.vars[9:-1]) did the trick Sorry, I was thinking dict instead of Storage. Just wondering if there is an easier way of doing it (I mean: to pass the current URL+vars to the LOAD) How about: {{=LOAD('default', 'send_suggestion', vars=dict(url=URL(args=request.args, vars=request.get_vars)), ajax_trap=True)}} def send_suggestion(): import urllib form = SQLFORM.factory(Field('message', 'text', requires=IS_NOT_EMPTY ())) if form.process().accepted: subject = 'FEEDBACK: %s' % urllib.unquote(request.get_vars.url) response.flash = 'Thanks for your feedback' Anthony
[web2py] Routing help
Hello, I'm new to web2py and am having a difficult time understanding how to use either the parameter or pattern based systems as well how web2py default routing works. *I'll start off with the first point of confusion for me;* The web2py book and documentation has led me to believe that the following would work; http://120.0.0.1/myapp/default/somefunction can be written as http://120.0.0.1/myapp/somefunction but I get invalid request error If I copy router.example.py to routes.py in the base directory, the above case then works as I expected, but I thought that even with a lack of a routes.py file, web2py would still automatically default to the same behavior. This isn't so at all? If I then overwrite routes.py using routes.example.py, the above case no longer works. Looking at both routes.example.py and router.example.py, it looks like both of them configure web2py's routing behavior in the same way, but the actual behavior is not the same. So I'm pretty confused about this. Note, after each changes to routes.py I do reload the routes in web2py's admin console. *The second point of confusion for me is;* * * In the application I'm writing, which uses AJAX heavily and uses PUT and DELETE in addition to GET and POST. I have in one of the controller, users, the following; def index(): def GET(): blah def POST(*vars, **fields): blah def PUT(*vars, **fields): blah def DELETE(*vars, **fields): blah I want to map a PUT request to users/5 to users/index/5 Right now the current default routing configuration returns users/5 as invalid request which is expected. Unfortunately I still don't understand web2py well enough to know how to set up one of the routing systems to map users/id to users/index/id I think I need to use the pattern matching system but I'm not able to get it working properly. Would appreciate your tips. Thanks Alex
Re: [web2py] Re: Single error message for radio group
I can't find any documentation of the hideerror feature, but looking at html.py, I don't see how the above example would work: INPUT( _type='radio', _name='age', _value='5', _id='age5', hideerror=True,value =self.request.vars['age']) The hideerror flag seems to work if you do this, though: input = INPUT( _type='radio', _name='age', _value='5', _id='age5', value= self.request.vars['age']) input['hideerror'] = True I see nothing that transfers the hideerror argument from the constructor to a property of the input object, where it needs to be during serialization. What's the correct use of hideerror and where is it documented?
[web2py] list:reference shouldn't return list of lists in case of aggregates?
Hello, I don't know if this has be fixed since 1.99.4, but I can't aggregates a table if a list:reference field is present in the requested fields. db().select(db.tab1.f2.sum()/db.tab1.f2.count(), db.tab1.f3_list-reference.sum(), groupby=db.tab1.f4) give error... Ok, here I think that ok since the list-reference field maybe should not be consider a normal field and maybe an other set of function should be developped?! I have 3 records : list-reference fields : [1,2,3], [4,5,6], [7] I mean : .sum_list_reference() : Should return [[1,2,3], [4,5,6], [7]] .avg_list_reference() : Should return : [1,2,3,4,5,6,7] .count_list_reference() : Should count the number of list-reference field in this case 3 etc. What do you think? Richard
[web2py] Re: RFC: web2py-based workflow engine
On Thursday, May 17, 2012 3:54:44 PM UTC-4, Cliff wrote: Let's inject manufacturing into the order processing scenario you were using before. It's a three step process. Step one fabricates widgets. Step 2 attaches the widgets to widget bicarackets, purchased from another vendor. Step 3 packages the assemblies for shipment. If the last batch of widgets from the fabricator won't fit the brackets because they are oversize, obviously the guy in assembly wants to send them back for rework. How would the system handle this? In this case, assembly would reject their step, and enter a short message to explain why they rejected it. Assembly would also select a previous step in the workflow to send it back to, in this case the fabricator (step 1). The message from assembly goes into the workflow_comments table as needing to be resolved. Once the fabricator fixes the problem, they mark the problem resolved and send the workflow on to the next step (which in this case would be to step 2). And how would it avoid forcing the guy in charge of assembly to take action on every batch of good widgets, assuming the system's intent is to manage by exception? Let's say the guy in assembly has 5 work orders to assemble for the day and each work order makes 20 assemblies (for a total of 100 things to make for the day). He would come in with the parts waiting for him for all 5 work orders, and he would have 5 workflows waiting on him. When he completes one work order (20 assemblies), he marks that workflow as completed and the workflow moves on to the shipping department. If we wanted, we could even add a progress field that allows him to enter a percentage of how close he is finishing the 20 assemblies for the one work order. The great thing about doing it this way is allows management to track where everything thing is. My implementation puts an emphasis on accountability and making sure nothing gets lost or forgotten. Most manufacturing places have computers on the floor, so asking the assembly guy to click a button isn't a stretch for most places. In fact, by making this whole implementation generic like this, you could even put a simple keypad out there in assembly, shipping, and other places that don't have full computers to manage workflows. Nothing about the implementation forces you to use a GUI. You could program a keypad to accept a work order number that marks the associated workflow as complete via a REST call or something. And worst case, you could always have the assembly supervisor handle the workflows for the guys in assembly. That's what supervisors are for, right? :)
[web2py] Re: modules
the problem was caused because the file is not created __ init__ in the first folder of the project. / myapp / __init__.py why not this file is always created automatically? .. El jueves, 17 de mayo de 2012 12:14:21 UTC-5, Aurigadl escribió: i don't find the error in this code... El miércoles, 16 de mayo de 2012 10:57:15 UTC-5, Aurigadl escribió: I did Thank you for entering Issue 800http://code.google.com/p/web2py/issues/detail?id=800 El miércoles, 16 de mayo de 2012 10:43:36 UTC-5, Massimo Di Pierro escribió: Please open a ticket in googlecode and give more details about your web2py version, python version and os version. On Wednesday, 16 May 2012 10:40:54 UTC-5, Aurigadl wrote: if you have: /applications/examples/modules/prueba.py $python web2py.py -S examples import prueba this does not work But if you used: from applications.examples.modules import prueba this work very well. way?? I have all whit the __init__py for import modules. El miércoles, 16 de mayo de 2012 10:32:00 UTC-5, Anthony escribió: Are you importing from within the examples application? In that case you can just do: import test Anthony On Wednesday, May 16, 2012 11:13:16 AM UTC-4, Aurigadl wrote: I always work with modules. In the latest versions of web2py not work. doing the following to import: from applications.examples.modules import test Restricting the application name.The modules are placed in the / app / modules
[web2py] Re: Routing help
I believe to hide 'default' and 'index' you need to use routes.py and: routers = dict( # base router BASE = dict( default_application = 'init', default_controller = 'default', default_function = 'index', ), ) Setting the default application will hide it as well. Can you do it like this: def users(): if request.method == 'POST': id = request.args(0) ...
Re: [web2py] Re: Single error message for radio group
I can't find any documentation of the hideerror feature, but looking at html.py, I don't see how the above example would work: INPUT( _type='radio', _name='age', _value='5', _id='age5', hideerror=True,value =self.request.vars['age']) That should work. Note, INPUT inherits from DIV, and all named arguments to a DIV get added to the .attributes attribute ( http://code.google.com/p/web2py/source/browse/gluon/html.py#630). DIV also overrides the __getitem__ method ( http://code.google.com/p/web2py/source/browse/gluon/html.py#687), so input['hideerror'] will retrieve the hideerror attribute from input.attributes (i.e., it is equivalent to input.attributes['hideerror']). Finally, the hideerror attribute is retrieved during serialization in the INPUT.xml() method: http://code.google.com/p/web2py/source/browse/gluon/html.py#1661. The hideerror flag seems to work if you do this, though: input = INPUT( _type='radio', _name='age', _value='5', _id='age5', value= self.request.vars['age']) input['hideerror'] = True I see nothing that transfers the hideerror argument from the constructor to a property of the input object, where it needs to be during serialization. What's the correct use of hideerror and where is it documented? Unfortunately, it appears hideerror as an argument to INPUT() is not documented in the book, though its use as an argument to forms is documented in the forms chapter: http://web2py.com/books/default/chapter/29/7#keepvalues, http://web2py.com/books/default/chapter/29/7#Hide-errors. Anthony
[web2py] Re: Windows binaries version of Python
1. Use Pack All. It creates a W2P file that you can send. The production site would use the upload and install packed... 2. I believe it's developed on 2.7.x - when it says it supports 2.5.x that means it is backwards compatible to that version. No idea what the binary version is - I prefer to use the source version, it's easier to update (as you might have witnessed yourself). On Thursday, May 17, 2012 9:59:22 AM UTC-7, Cédric Mayer wrote: Hello all, I'm developping over web2py source (1.99.7) using Eclipse, with Python (I used to use the version 2.7.2, but now because of my problem I use version 2.5.4 but...). When I think my application is worth it, I zip its folder and I give it to someone else in order to test it. This person uses a compiled Web2py server for Windows (current version too) which uses embarked Python (2.5.x ?) binaries. The issue I have is that I always have problems with the exported database. With my old use of version 2.7 I had problems with the ON DELETE CASCADE directive. My current problem with version 2.5.4 is the following one (when I try to log in) (I did not tamper with the definitions of auth tables, which are defined with auth.define_tables() ): Traceback (most recent call last): File gluon/restricted.py, line 205, in restricted File C:/Users/cedric/projets/LACT/devWeb2py/lact_web2py/applications/lact/controllers/default.py http://127.0.0.1:8000/admin/default/edit/lact/controllers/default.py, line 74, in module File gluon/globals.py, line 173, in lambda File C:/Users/cedric/projets/LACT/devWeb2py/lact_web2py/applications/lact/controllers/default.py http://127.0.0.1:8000/admin/default/edit/lact/controllers/default.py, line 33, in user File gluon/tools.py, line 1161, in __call__ File gluon/tools.py, line 1729, in login File gluon/dal.py, line 7578, in select File gluon/dal.py, line 1315, in select File gluon/dal.py, line 1305, in response File gluon/dal.py, line 1392, in execute File gluon/dal.py, line 1386, in log_execute OperationalError: no such column: auth_user.registration_id So my questions are (at least one answer to any one would please me) : 1) what is the correct way to export a web2py application from a development environment to a Windows production environment, without deleting the entire database ? 2) what is the correct source execution environment compatible with compiled version ? Thank you a lot, Cédric
[web2py] Re: modules
It should be created automatically. I see it when I go through the wizard and when I create a new simple app. On Thursday, May 17, 2012 2:19:27 PM UTC-7, Aurigadl wrote: the problem was caused because the file is not created __ init__ in the first folder of the project. / myapp / __init__.py why not this file is always created automatically? .. El jueves, 17 de mayo de 2012 12:14:21 UTC-5, Aurigadl escribió: i don't find the error in this code... El miércoles, 16 de mayo de 2012 10:57:15 UTC-5, Aurigadl escribió: I did Thank you for entering Issue 800http://code.google.com/p/web2py/issues/detail?id=800 El miércoles, 16 de mayo de 2012 10:43:36 UTC-5, Massimo Di Pierro escribió: Please open a ticket in googlecode and give more details about your web2py version, python version and os version. On Wednesday, 16 May 2012 10:40:54 UTC-5, Aurigadl wrote: if you have: /applications/examples/modules/prueba.py $python web2py.py -S examples import prueba this does not work But if you used: from applications.examples.modules import prueba this work very well. way?? I have all whit the __init__py for import modules. El miércoles, 16 de mayo de 2012 10:32:00 UTC-5, Anthony escribió: Are you importing from within the examples application? In that case you can just do: import test Anthony On Wednesday, May 16, 2012 11:13:16 AM UTC-4, Aurigadl wrote: I always work with modules. In the latest versions of web2py not work. doing the following to import: from applications.examples.modules import test Restricting the application name.The modules are placed in the / app / modules
[web2py] Re: Routing help
Oh, I see, that's how you code the REST stuff. My bad.
[web2py] Re: require login on submit
Try this: #Controller## def status_checker(): if auth.is_logged_in(): pass else: redirect(URL(f=user, args=login)) form = SQLFORM(db.blah) if form.accepts(request.vars, session, onvalidation=status_checker): redirect(URL(index)) On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco On Wednesday, May 16, 2012 4:55:23 PM UTC+1, Marco Prosperi wrote: hi all, what could be a clean way to require login (if not already logged in) when a user clicks on the submit button of a form? thanks in advance for advice Marco
[web2py] Re: Routing help
The web2py book and documentation has led me to believe that the following would work; http://120.0.0.1/myapp/default/somefunction can be written as http://120.0.0.1/myapp/somefunction but I get invalid request error Here's what the book says: web2py maps a URL of the form: 1. http://127.0.0.1:8000/a/c/f.html to the function f() in controller c.py in application a. If f is not present, web2py defaults to the indexcontroller function. If c is not present, web2py defaults to the default.py controller, and if a is not present, web2py defaults to the init application. If there is no init application, web2py tries to run the welcomeapplication. I think I see the confusion. It says if the controller is not present, web2py defaults to the default.py controller. However, when you have the URL /myapp/somefunction, technically the controller is present, as web2py will interpret the second element of the URL as the controller (just because you know somefunction is a function doesn't mean the default router does) -- in that case, it's actually the function that is missing, not the controller. So, what the above really means is: /myapp maps to /myapp/default/index /myapp/default maps to /myapp/default/index but /myapp/somefunction does not map to /myapp/default/somefunction because somefunction is interpreted as a controller in that URL (instead, it maps to /myapp/somefunction/index, and you get an error because such a controller doesn't exist). If I then overwrite routes.py using routes.example.py, the above case no longer works. Looking at both routes.example.py and router.example.py, it looks like both of them configure web2py's routing behavior in the same way, but the actual behavior is not the same. I assume you're referring to the default_controller='default' parameter set in the routes.example.py example. I agree that's a little confusing because you might expect it to work much like setting the default controller in the parameter-based system, but again, let's look at what the book says: When using the pattern-based system, the name of the default application, controller, and function can be changed from *init*, *default*, and *index* respectively to another name by setting the appropriate value in routes.py That's saying that setting the value of default_controller merely changes the default value used by the standard routing system when that item is missing from the URL. So, let's say you set default_controller='mycontroller'. In that case, /myapp would map to /myapp/mycontroller/index instead of /myapp/default/index, but /myapp/somefunction would still cause a problem because somefunction would be seen as a controller. One thing to note is that the parameter-based system was created quite a while after the pattern-based system, so seemingly similar functionality wasn't necessarily designed to behave the same way (hopefully the behavior of the parameter-based system is seen as an improvement in this case). Anyway, I agree some of this could be better explained in the book. Anthony
[web2py] Re: change the size of a text field in a form
I would suggest you using custom forms in your view and targeting the attribute you wish to change with CSS. I find that approach more flexible. In the view: {{=form.custom.begin}} ###you can include normal HTML here to build up the form elements and target it with CSS or textarea id=#, class=# rows=20, cols=30/textarea {{=form.custom.end}} hope that helps? On Wednesday, May 16, 2012 4:59:14 PM UTC+1, Marco Prosperi wrote: hello, how can I change the default size of a 'text' field in a form? (at first appearance, not dragging the corner) thanks Marco
[web2py] Re: require login on submit
if form.accepts(request.vars, session, onvalidation=status_checker): redirect(URL(index)) This would not be a good user experience. A user who isn't logged in would fill out and submit the form, and upon submission they would end up being redirected to the login page, but their form submission would be lost. Even worse, they would not know it was lost. It's probably best to get them to log in before they waste time filling out a form (particularly if they're not even registered yet). Anthony
[web2py] Re: require login on submit
I agree with you. That was a quick and dirty solution. If you really want your user case and also want a good UX experience for the unlogged in user, you can consider using some JQuery, maybe .focus() on the first field of the form to trigger some the login function. This would save the un-logged in user from useless keystrokes or use $().onClick() function on the submit function. On Thursday, May 17, 2012 11:04:12 PM UTC+1, Anthony wrote: if form.accepts(request.vars, session, onvalidation=status_checker): redirect(URL(index)) This would not be a good user experience. A user who isn't logged in would fill out and submit the form, and upon submission they would end up being redirected to the login page, but their form submission would be lost. Even worse, they would not know it was lost. It's probably best to get them to log in before they waste time filling out a form (particularly if they're not even registered yet). Anthony
[web2py] Re: RFC: web2py-based workflow engine
I think you are just using abstract examples, though workflows are more than just creating a widget or approving invoices. The standard for workflow support is here: http://www.workflowpatterns.com/ (look here for a tidy list of workflow types... http://www.workflowpatterns.com/evaluations/opensource/) If your workflow engine can support all those patterns, then you have an all-purpose workflow. They've thought about this problem longer than any one of us have, so take a gander before you write your workflow engine. Also, Fantasm is another workflow engine that works with Python (and GAE) though I'm not certain if GAE is optional or not. It might be worth checking out to see how that works. https://developers.google.com/appengine/articles/fantasm It appears you are planning on supporting sequential workflows, but what about parallel split? say you have an image file and you need to have a workflow such as this: reviewer (reviews image - if it is appropriate, approve and move to next stage which is split in two parts that operate in parallel) art director - enhances image, fixing color balance, etc etc... classifier - reviews content of image, adds tags for the website, advertising, etc then it goes to the next stage only after the preceding two are complete (which may be done in any order). The art director doesn't care if the art has tags, so his work doesn't need to wait on that, and the guy doing the tagging could care less if it matches the rest of the website design...however they both have their own separate and independent jobs to do. there are a lot more workflow patterns than those. In the example of 6 approvers - if one of the first approvers has a sick day, the other 5 guys won't be able to do any work. With multiple parallel tasks, the rest of the guys can keep working, though nothing will be complete until the sick guy comes back. On Thursday, May 17, 2012 2:16:17 PM UTC-7, Ross Peoples wrote: On Thursday, May 17, 2012 3:54:44 PM UTC-4, Cliff wrote: Let's inject manufacturing into the order processing scenario you were using before. It's a three step process. Step one fabricates widgets. Step 2 attaches the widgets to widget bicarackets, purchased from another vendor. Step 3 packages the assemblies for shipment. If the last batch of widgets from the fabricator won't fit the brackets because they are oversize, obviously the guy in assembly wants to send them back for rework. How would the system handle this? In this case, assembly would reject their step, and enter a short message to explain why they rejected it. Assembly would also select a previous step in the workflow to send it back to, in this case the fabricator (step 1). The message from assembly goes into the workflow_comments table as needing to be resolved. Once the fabricator fixes the problem, they mark the problem resolved and send the workflow on to the next step (which in this case would be to step 2). And how would it avoid forcing the guy in charge of assembly to take action on every batch of good widgets, assuming the system's intent is to manage by exception? Let's say the guy in assembly has 5 work orders to assemble for the day and each work order makes 20 assemblies (for a total of 100 things to make for the day). He would come in with the parts waiting for him for all 5 work orders, and he would have 5 workflows waiting on him. When he completes one work order (20 assemblies), he marks that workflow as completed and the workflow moves on to the shipping department. If we wanted, we could even add a progress field that allows him to enter a percentage of how close he is finishing the 20 assemblies for the one work order. The great thing about doing it this way is allows management to track where everything thing is. My implementation puts an emphasis on accountability and making sure nothing gets lost or forgotten. Most manufacturing places have computers on the floor, so asking the assembly guy to click a button isn't a stretch for most places. In fact, by making this whole implementation generic like this, you could even put a simple keypad out there in assembly, shipping, and other places that don't have full computers to manage workflows. Nothing about the implementation forces you to use a GUI. You could program a keypad to accept a work order number that marks the associated workflow as complete via a REST call or something. And worst case, you could always have the assembly supervisor handle the workflows for the guys in assembly. That's what supervisors are for, right? :)
Re: [web2py] Re: URL vars doesn't like Storage
I like that ! On Thu, May 17, 2012 at 9:10 PM, Anthony abasta...@gmail.com wrote: Even better, just put the URL in a hidden field in the form: {{=LOAD('default', 'send_suggestion', ajax_trap=True)}} def send_suggestion(): form = SQLFORM.factory(Field('message', 'text', requires=IS_NOT_EMPTY ()), hidden=dict(url=XML(URL(args=request.args, vars=request.get_vars if form.process().accepted: subject = 'FEEDBACK: %s' % request.vars.url response.flash = 'Thanks for your feedback' Anthony On Thursday, May 17, 2012 4:00:02 PM UTC-4, Anthony wrote: by the way as the request.vars.vars contains Storage {'': '', 'www': '4'} ast.literal_eval(reques**t.vars.vars[9:-1]) did the trick Sorry, I was thinking dict instead of Storage. Just wondering if there is an easier way of doing it (I mean: to pass the current URL+vars to the LOAD) How about: {{=LOAD('default', 'send_suggestion', vars=dict(url=URL(args=request**.args, vars=request.get_vars)), ajax_trap=True)}} def send_suggestion(): import urllib form = SQLFORM.factory(Field('**message', 'text', requires= IS_NOT_EMPTY())) if form.process().accepted: subject = 'FEEDBACK: %s' % urllib.unquote(request.get_**vars.url) response.flash = 'Thanks for your feedback' Anthony -- Sebastian E. Ovide
Re: [web2py] list:reference shouldn't return list of lists in case of aggregates?
This is not possible because the database does not support it. Lists are not even stored as lists, they are stored as strings. On Thursday, 17 May 2012 16:13:50 UTC-5, Richard wrote: Hello, I don't know if this has be fixed since 1.99.4, but I can't aggregates a table if a list:reference field is present in the requested fields. db().select(db.tab1.f2.sum()/db.tab1.f2.count(), db.tab1.f3_list-reference.sum(), groupby=db.tab1.f4) give error... Ok, here I think that ok since the list-reference field maybe should not be consider a normal field and maybe an other set of function should be developped?! I have 3 records : list-reference fields : [1,2,3], [4,5,6], [7] I mean : .sum_list_reference() : Should return [[1,2,3], [4,5,6], [7]] .avg_list_reference() : Should return : [1,2,3,4,5,6,7] .count_list_reference() : Should count the number of list-reference field in this case 3 etc. What do you think? Richard
[web2py] Re: Windows binaries version of Python
It is possible that different python version use different sqlite formats. If you develop with 2.5 and pack and unpack to 2.7 the sqlite file will be readable. I do not know for sure about the opposite. massimo On Thursday, 17 May 2012 16:40:07 UTC-5, Derek wrote: 1. Use Pack All. It creates a W2P file that you can send. The production site would use the upload and install packed... 2. I believe it's developed on 2.7.x - when it says it supports 2.5.x that means it is backwards compatible to that version. No idea what the binary version is - I prefer to use the source version, it's easier to update (as you might have witnessed yourself). On Thursday, May 17, 2012 9:59:22 AM UTC-7, Cédric Mayer wrote: Hello all, I'm developping over web2py source (1.99.7) using Eclipse, with Python (I used to use the version 2.7.2, but now because of my problem I use version 2.5.4 but...). When I think my application is worth it, I zip its folder and I give it to someone else in order to test it. This person uses a compiled Web2py server for Windows (current version too) which uses embarked Python (2.5.x ?) binaries. The issue I have is that I always have problems with the exported database. With my old use of version 2.7 I had problems with the ON DELETE CASCADE directive. My current problem with version 2.5.4 is the following one (when I try to log in) (I did not tamper with the definitions of auth tables, which are defined with auth.define_tables() ): Traceback (most recent call last): File gluon/restricted.py, line 205, in restricted File C:/Users/cedric/projets/LACT/devWeb2py/lact_web2py/applications/lact/controllers/default.py http://127.0.0.1:8000/admin/default/edit/lact/controllers/default.py, line 74, in module File gluon/globals.py, line 173, in lambda File C:/Users/cedric/projets/LACT/devWeb2py/lact_web2py/applications/lact/controllers/default.py http://127.0.0.1:8000/admin/default/edit/lact/controllers/default.py, line 33, in user File gluon/tools.py, line 1161, in __call__ File gluon/tools.py, line 1729, in login File gluon/dal.py, line 7578, in select File gluon/dal.py, line 1315, in select File gluon/dal.py, line 1305, in response File gluon/dal.py, line 1392, in execute File gluon/dal.py, line 1386, in log_execute OperationalError: no such column: auth_user.registration_id So my questions are (at least one answer to any one would please me) : 1) what is the correct way to export a web2py application from a development environment to a Windows production environment, without deleting the entire database ? 2) what is the correct source execution environment compatible with compiled version ? Thank you a lot, Cédric
[web2py] Re: modules
When you make a new app, web2py unpacks welcome.w2p. welcome.w2p is an image of the welcome app when web2py was installed or upgraded. Any new installation of web2py should include __init__.py in welcome.w2p but it is possible that you have deleted it and triggered the creation of a new welcome.w2p without the file. Check if your welcome has it. On Thursday, 17 May 2012 16:19:27 UTC-5, Aurigadl wrote: the problem was caused because the file is not created __ init__ in the first folder of the project. / myapp / __init__.py why not this file is always created automatically? .. El jueves, 17 de mayo de 2012 12:14:21 UTC-5, Aurigadl escribió: i don't find the error in this code... El miércoles, 16 de mayo de 2012 10:57:15 UTC-5, Aurigadl escribió: I did Thank you for entering Issue 800http://code.google.com/p/web2py/issues/detail?id=800 El miércoles, 16 de mayo de 2012 10:43:36 UTC-5, Massimo Di Pierro escribió: Please open a ticket in googlecode and give more details about your web2py version, python version and os version. On Wednesday, 16 May 2012 10:40:54 UTC-5, Aurigadl wrote: if you have: /applications/examples/modules/prueba.py $python web2py.py -S examples import prueba this does not work But if you used: from applications.examples.modules import prueba this work very well. way?? I have all whit the __init__py for import modules. El miércoles, 16 de mayo de 2012 10:32:00 UTC-5, Anthony escribió: Are you importing from within the examples application? In that case you can just do: import test Anthony On Wednesday, May 16, 2012 11:13:16 AM UTC-4, Aurigadl wrote: I always work with modules. In the latest versions of web2py not work. doing the following to import: from applications.examples.modules import test Restricting the application name.The modules are placed in the / app / modules
Re: [web2py] list:reference shouldn't return list of lists in case of aggregates?
On retrieve only? Richard On Thu, May 17, 2012 at 7:03 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: This is not possible because the database does not support it. Lists are not even stored as lists, they are stored as strings. On Thursday, 17 May 2012 16:13:50 UTC-5, Richard wrote: Hello, I don't know if this has be fixed since 1.99.4, but I can't aggregates a table if a list:reference field is present in the requested fields. db().select(db.tab1.f2.sum()/**db.tab1.f2.count(), db.tab1.f3_list-reference.sum(**), groupby=db.tab1.f4) give error... Ok, here I think that ok since the list-reference field maybe should not be consider a normal field and maybe an other set of function should be developped?! I have 3 records : list-reference fields : [1,2,3], [4,5,6], [7] I mean : .sum_list_reference() : Should return [[1,2,3], [4,5,6], [7]] .avg_list_reference() : Should return : [1,2,3,4,5,6,7] .count_list_reference() : Should count the number of list-reference field in this case 3 etc. What do you think? Richard
[web2py] MongoDb Adapter issues
Hello, I'm having issues with the mongo adapter doing selects (using latest code from git.) The initial issue i ran into was not being able to import SON in dal.py (i changed from pymongo to from bson and that fixed that) After that I ran into issues with pymongo.objectid, after a little research I found this http://api.mongodb.org/python/2.0/api/pymongo/objectid.html references to pymongo.objectid should be replaced in favor of bson.objectid when i did that in my local, everything started to work -Kris
[web2py] Re: MongoDb Adapter issues
Did you apply your changes to the latest trunk. If so, could you post your changes. We will review them and probably incorporate them. massimo On Thursday, 17 May 2012 19:46:00 UTC-5, Krzysztof Mulica wrote: Hello, I'm having issues with the mongo adapter doing selects (using latest code from git.) The initial issue i ran into was not being able to import SON in dal.py (i changed from pymongo to from bson and that fixed that) After that I ran into issues with pymongo.objectid, after a little research I found this http://api.mongodb.org/python/2.0/api/pymongo/objectid.html references to pymongo.objectid should be replaced in favor of bson.objectid when i did that in my local, everything started to work -Kris
Re: [web2py] 75€ BOUNTY - Massively Complicated Query Required
Yes, it can be redundant. Ignore it if you like. BR, Jason On 05/17/2012 10:32 PM, Marin Pranjić wrote: and why both tag and tag_link have an event.id http://event.id field? is this redundant? On Thu, May 17, 2012 at 7:56 PM, Jason Brower encomp...@gmail.com mailto:encomp...@gmail.com wrote: It is a many-to-many but it can link to multiple tables. event is the event that a user can attend table_link is the ID that is used in a particular table. tag is the tag.id http://tag.id that this row is linking to. intent is as described before. tag_type is the table that the system will link to. Notice there is a booth, auth_user, and happening table. All of those support tags and instead of needing to create a table for each one, I combined them. Aslo comes in handy in other ways too. Like if I want to create tag relations on other parts of my database. I could even create tag relations on tags or other tag relations. Very powerful. br, Jason On 05/17/2012 08:32 PM, Marin Pranjić wrote: I am not sure if I understand your model. Can you explain tag_link ? Marin On Thu, May 17, 2012 at 6:28 PM, Jason Brower encomp...@gmail.com mailto:encomp...@gmail.com wrote: I have the event management tool I have been working on for 2 years now and I have made some changes to the code that require my most complicated query to be rebuilt. After thinking about it for several hours I figure I should throw it at you guys to see what you can come up with. The winner of this query will get 75€ with paypal or other means after I have it implemented it in the code. I have the following model: model_diagram.png event_attender.py tag.py tag_link.py Description: I am building a list of connections based on relevance by tag. Tags have two states, looking for and attribute. Users attach themselves to these tags with the two attributes. I am looking for someone with this tag. and/or This tag is something about me that I want to offer. Now when they do this a list of users will show on the screen. ID NicknameTags your looking for that they haveYour Relevance Tags they are looking for that you have Their Relevance Total Relevance Image city 101 encompass Tag1, Tag2, Tag43 Tag4, Tag5, Tag 6 3 10 http:// Oulu 102 encompass Tag1, Tag2, Tag43 Tag4, Tag 6 3 8 http:// Oulu 150 encompass Tag1, Tag2, Tag43 Tag 6 3 7 http:// Helsinki This is build with the following: UserA is the user logged in using the system If another user has a tag that UserA is looking for, then relevance is +2 to UserA If another user is looking for something UserA has, then relevance is +1 to UserA If another user lives in the same city as UserA and has something they are looking for or something to offer then relevance is +1 Does this make sense? I just need to query that will happen. I can handle the view just fine. Feel free to comment or ask questions. If you can think of a good way to connect people better with the data in the model diagram attached do tell. I will give you another 25€ for that implementation as well. :) --- BR, Jason Brower
[web2py] Re: MongoDb Adapter issues
I will wait when you are done than... when you think this should be included, perhaps it will be easier to upload the dal.py as an issue in google code so I will not miss it. On Thursday, 17 May 2012 21:06:46 UTC-5, Krzysztof Mulica wrote: Yes latest trunk, but i'm working through a few more issues ( if column == '_id' and isinstance(record[column].objectid.ObjectId): I don't know python enough, but i think that line should beif column == '_id' and isinstance(record[column],bson.objectid.ObjectId): File /home/kris/web2py/gluon/dal.py, line 4634, in select if column == '_id' AttributeError: 'ObjectId' object has no attribute 'objectid' There's also an issue with list:string as far as i can tell, I have a record like this: { title : mongo, url : http://mongodb.org;, upvotes : 1, downvotes : 0, tags : [ kris, mongo ] } i put a debug statment and the list comes in as [u'kris', u'mongo'] which i believe bar_decode_string does not handle correctly ( since its expeciting pipe seperated ) File /home/kris/web2py/gluon/dal.py, line 1644, in parse_list_strings value = bar_decode_string(value) File /home/kris/web2py/gluon/dal.py, line 5991, in bar_decode_string return [x.replace('||', '|') for x in string_unpack.split(value[1:-1]) if x.strip()] TypeError: expected string or buffer i changed that logic around 1644 to if not self.dbengine=='google:datastore' and not self.dbengine=='mongodb': the line numbers may be veyr slightly off as i did add a debug statment or two On Thursday, May 17, 2012 8:29:52 PM UTC-5, Massimo Di Pierro wrote: Did you apply your changes to the latest trunk. If so, could you post your changes. We will review them and probably incorporate them. massimo On Thursday, 17 May 2012 19:46:00 UTC-5, Krzysztof Mulica wrote: Hello, I'm having issues with the mongo adapter doing selects (using latest code from git.) The initial issue i ran into was not being able to import SON in dal.py (i changed from pymongo to from bson and that fixed that) After that I ran into issues with pymongo.objectid, after a little research I found this http://api.mongodb.org/python/2.0/api/pymongo/objectid.html references to pymongo.objectid should be replaced in favor of bson.objectid when i did that in my local, everything started to work -Kris
Re: [web2py] web2py free cookbook raffle
On 05/18/2012 06:41 AM, Massimo Di Pierro wrote: http://web2py.com/cookbook Woot, thanks!