[web2py] Re: How to pass an array from jQuery to controller

2014-07-02 Thread Noel Villamor
Nice one Chris and thanks for reviewing this post. Web2py has indeed come a long way from 2 years ago and is worthy of a revisit. Cheers! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

Re: [web2py] Re: web2py still unable to create application on WebFaction

2012-04-08 Thread Noel Villamor
Hi All, I encountered this issue as well. Here is how I resolved it. *- web2py directory should have welcome.w2p* Happy Easter! Noel Villamor On Sunday, 6 March 2011 09:54:19 UTC+13, Jonathan Lundell wrote: On Mar 5, 2011, at 12:07 PM, Jonathan Lundell wrote: On Mar 5, 2011, at 11:35

Re: [web2py] Re: Link calling function w/results in modal popup?

2011-09-27 Thread noel villamor
within the view you would get two different ids. If you want to specify the id yourself, just do PluginMModal(..., id='your_id'). Anyway, instantiating in the controller should work. Can you show your controller and view code? Anthony On Tuesday, September 27, 2011 1:00:39 AM UTC-4, Noel

[web2py] Re: Link calling function w/results in modal popup?

2011-09-27 Thread Noel Villamor
Gotcha! Thanks for the hint Anthony. Controller: a=PluginMModal(title='Hello World',content='give this a try!',close=close,width=30,height=30,id='59d38b19-05aa-4125-a19b-6e17069cd873') ... a.link(...) View: {{extend 'layout.html'}} {{=form}} {{a=PluginMModal(title='Hello World',content='give

[web2py] Re: Link calling function w/results in modal popup?

2011-09-27 Thread Noel Villamor
Anthony, I did a similar thing on my first try but with the link created at the controller, like so: Controller: def func(): ... ... modal = PluginMModal(title='Hello World',content='give this a try!',close=close,width=30,height=30) form = TABLE(... lots of TR( ...

[web2py] Re: Link calling function w/results in modal popup?

2011-09-26 Thread Noel Villamor
The Minimal Modal docs states that the plugin is to be instantiated in the View. I wonder if it is possible to do it in the Controller as I am constructing my form (and links) in the Controller. I tried it but the a.link defined in the controller has an id w/c differs from the a.link defined in a

[web2py] Do we have a calendar plugin?

2011-09-19 Thread Noel Villamor
It would be handy if I can get hold of a calendar whose individual dates/days I can decorate based on an event table. I won't use it as a pop-up or date selector. I just need to display it on a page and be able to pan the month and year. I see quite a few in .js, do we have any in .py or

[web2py] Re: python * function in Html Helpers

2011-09-14 Thread Noel Villamor
abasta...@gmail.com wrote: On Tuesday, September 13, 2011 6:11:42 PM UTC-4, Noel Villamor wrote: I got the * and the ** explanations but António is asking about ***. Where do you see any mention of ***?

[web2py] Re: python * function in Html Helpers

2011-09-14 Thread Noel Villamor
Interesting! The old: https://groups.google.com/group/web2py/browse_frm/thread/f4475684a88fef17/45622d797458e974?hl=en#45622d797458e974 The new: https://groups.google.com/forum/#!topic/web2py/9EdWhKiP7xc Thanks for clearing up the confusion Anthony. Noel On Sep 15, 9:07 am, Anthony

[web2py] Re: python * function in Html Helpers

2011-09-13 Thread Noel Villamor
I got the * and the ** explanations but António is asking about ***. On Sep 14, 5:51 am, Anthony abasta...@gmail.com wrote: In Python, if you have a list or tuple, you can precede it with an * and pass it as an argument to a function, and the function will treat it as if each item in the

[web2py] Re: How to flash a message after a callback

2011-09-12 Thread Noel Villamor
Thanks Jan. On Sep 12, 8:47 pm, jot.be jan.beili...@gmail.com wrote: Hi, On Mon, Sep 12, 2011 at 4:57 AM, Noel Villamor noe...@gmail.com wrote: I have a button which does the following callback: ajax('{{=URL('callback')}}',['btn1'],':eval'); Then I have the following callback

[web2py] How to flash a message after a callback

2011-09-11 Thread Noel Villamor
I have a button which does the following callback: ajax('{{=URL('callback')}}',['btn1'],':eval'); Then I have the following callback function in my controller: def callback(): db(db.tbl.id==100).update(data='sampledata') jquery = ??? return jquery I can use jquery = alert('Lame

[web2py] Re: How to flash a message after a callback

2011-09-11 Thread Noel Villamor
Thank you guys!

[web2py] Re: How to flash a message after a callback

2011-09-11 Thread Noel Villamor
Book states: Code in models, views and controllers is enclosed in web2py code that looks like this: try: execute models, controller function and view except: rollback all connections log the traceback send a ticket to the visitor else: commit all connections save

[web2py] Re: physics examples in web2py + processing.js

2011-09-11 Thread Noel Villamor
Massimo, I feel like a toddler in a playpen right now. Too many toys I can't decide which one to play! Nice and fun projects you have there. On Sep 12, 2:56 pm, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Not really server side intensive, mostly client side but fun project.

[web2py] Re: Data entry for list:integer or list:string field

2011-09-09 Thread Noel Villamor
:                  val, error = IS_INT_IN_RANGE(0,10)(item)                  if error:                     return (val, error)             return (mylist, None) On Thu, Sep 8, 2011 at 11:44 PM, Noel Villamor noe...@gmail.com wrote: That worked!  Thanks Bruno. I wonder now if I can do

[web2py] Array initialization in Class

2011-09-09 Thread Noel Villamor
I am dissecting gluon/contrib/spreadsheet.py and I am trying to understand the ff: class Sheet: snip def __init__(self, rows, cols, url='.', readonly=False, active=True, onchange=None): self.rows = rows self.cols = cols self.url = url

[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-08 Thread Noel Villamor
Title is well deserved! Congratulations to the team.

[web2py] select (field alias)

2011-09-08 Thread Noel Villamor
I am aware about: tblAlias = db.mytbl.with_alias('tblAlias') Is there a similar thing that we can use for fields in select()? As in: ... .select( db.mytbl.id, db.mytbl.id*2 as fld2)

[web2py] Re: select (field alias)

2011-09-08 Thread Noel Villamor
it with something like rows[0]['(mytbl.id * 2)']. Of course, for convenience, you could define fld2='(mytbl.id * 2)' and  then do rows[0][fld2]. What do you want to do with the results? Anthony On Thursday, September 8, 2011 3:07:55 AM UTC-4, Noel Villamor wrote: I am aware about: tblAlias

[web2py] Data entry for list:integer or list:string field

2011-09-08 Thread Noel Villamor
I wanted the data entry of a list type field as a plain text box with comma separated data values. Thus, in my model,I defined the field as: Field('fld', 'list:integer', widget=SQLFORM.widgets.string.widget) Using a crud.create form, what extra steps should I do to be able to save a value such

[web2py] Re: Data entry for list:integer or list:string field

2011-09-08 Thread Noel Villamor
That worked! Thanks Bruno. I wonder now if I can do further validation to ensure that all items are integers and in a specific range. In particular, I wanted to use the already available validator IS_INT_IN_RANGE. Something like: IS_LIST(IS_INT_IN_RANGE(0, 10)) It is hacking time. :) On

[web2py] Re: Iterate through form.vars

2011-09-07 Thread Noel Villamor
Thanks for the info Anthony. Denes, you just added a trick to my python arsenal. TY. Noel

[web2py] Iterate through form.vars

2011-09-06 Thread Noel Villamor
Code: if form.accepts(request.vars, session): arr = ['a','b','c'] for i in range(3): arr[i] = form.vars.x Desired: In the for loop, I wanted to have arr[0] = form.vars.x0 arr[1] = form.vars.x1 arr[2] = form.vars.x2 As you can see, I am not yet a

[web2py] Re: Bug: Text field length default limit to 512 characters ?

2011-09-06 Thread Noel Villamor
Do an explicit length declaration in your model definition: Field('txt','text', length=65536), Look here: http://www.web2py.com/book/default/chapter/06?search=Field+constructor On Sep 7, 3:10 pm, toan75 toa...@gmail.com wrote: Hi. I found in 1.98.2, text field type default length is

[web2py] request.args inconsistent behaviour and ignoring URI valid characters

2011-09-05 Thread Noel Villamor
I am trying to pass a '.' and a '*' as parameters to a controller function. controller: test.py def t(): arr = request.args return 'alert(%s);' % repr(arr) url: /myapp/test/t/1/2/3 alert: ['1', '2', '3'] With one dot in between 1 and 3 url: /myapp/test/t/1/./3 alert: ['1', '3'] With

[web2py] Re: button calling a action

2011-09-05 Thread Noel Villamor
I found this for you: http://www.plus2net.com/html_tutorial/button-linking.php Try this: INPUT type=button value=Finalizar onclick=location.href='{{=URL(r=request,f='atualizar')}}'/ Noel On Sep 6, 7:07 am, Fabiano Faver far...@gmail.com wrote: I'm tryng to put a button thaat calls a action

[web2py] Re: request.args inconsistent behaviour and ignoring URI valid characters

2011-09-05 Thread Noel Villamor
I see. So that explains the backtracking when two dots are in the URL (similar behaviour to cd .. at the command line).

[web2py] Re: How to pass an array from jQuery to controller

2011-09-04 Thread Noel Villamor
:18 pm, Bruno Rocha rochacbr...@gmail.com wrote: I dont know if this is the best approach, but I juste tested here and works. On Wed, Aug 31, 2011 at 2:17 AM, Noel Villamor noe...@gmail.com wrote: I wanted to pass an array from jQuery to a controller. script var xyz= ['Sun','Mon','Tue','Wed

[web2py] Left joining two queries

2011-09-03 Thread Noel Villamor
Say I have a parent table tblA and child table tblX: db.define_table('tblA', Field(fldA')) db.define_table('tblB', Field('fkA', db.tblA), Field('name', 'integer'), Field('data')) How do I left join the two queries on tblB below: 1st: db(db.tblB.fkA ==

[web2py] Re: Left joining two queries

2011-09-03 Thread Noel Villamor
TABLE db.tblB fkA, name, data 1,100,'aaa' 1,101,'bbb' 1,102,'ccc' 2,100,'xxx' 2,101,'yyy' 1st query: db(db.tblB.fkA == 1).select(db.tblB.name,db.tblB.data) name,data 100,'aaa' 101,'bbb' 102,'ccc' 2nd query: db(db.tblB.fkA == 2).select(db.tblB.name,db.tblB.data) name,data 100,'xxx' 101,'yyy'

[web2py] Re: Left joining two queries

2011-09-03 Thread Noel Villamor
Thank you guys, I sort of zeroed in on the solution from your replies. Little by little I am learning how things are done in web2py. :) tblBalias = db.skedp.with_alias('tblBalias') desired_result = db(db.tblB.fkA == 1).select(db.tblB.name, db.tblB.data, tblBalias.data, left =

[web2py] Bug in TR when rendering an array

2011-08-31 Thread Noel Villamor
To reproduce, create a view with the ff contents: style type=text/css td { border-width: 5px; border-color: #80; border-style: solid; } /style {{arr=['second','third']}} {{=TABLE(TR(TD('first'),[TD(x) for x in arr]))}} HTML result: table tbody tr tdfirst/td td/td -- This extra td

[web2py] Re: Bug in TR when rendering an array

2011-08-31 Thread Noel Villamor
this: {{=TABLE(TR(TD('first'),*[TD(x) for x in arr]))}} Notice the * before the list comprehension -- that converts the list to a set of positional arguments. Anthony On Wednesday, August 31, 2011 8:03:48 PM UTC-4, Noel Villamor wrote: To reproduce, create a view with the ff

[web2py] Re: Bug in TR when rendering an array

2011-08-31 Thread Noel Villamor
*expression The syntax appears reasonable to me. Perhaps in the future, developers would consider allowing this. On Sep 1, 12:31 pm, Noel Villamor noe...@gmail.com wrote: Just when I thought I have helped find a bug, I am faced with the revelation that I need to hone my python some more. He he he

[web2py] Re: Bug in TR when rendering an array

2011-08-31 Thread Noel Villamor
positional argument was a list, so TR wrapped it in a TD for you (it turned out that your list itself contained two TD's, so they ended up inside another TD). Anthony On Wednesday, August 31, 2011 8:31:09 PM UTC-4, Noel Villamor wrote: Just when I thought I have helped find a bug, I am faced

[web2py] Re: Bug in TR when rendering an array

2011-08-31 Thread Noel Villamor
Anthony, you surely have another way to killl the cat: {{=TABLE(TR([TD('first')]+[TD(x) for x in arr]+[TD('fourth')]))}} Thanks for that. Noel On Sep 1, 12:55 pm, Jonathan Lundell jlund...@pobox.com wrote: On Aug 31, 2011, at 5:50 PM, Noel Villamor wrote: By the way, the reason why I

[web2py] Re: Bug in TR when rendering an array

2011-08-31 Thread Noel Villamor
Jonathan, you surely have another way to killl the cat: {{=TABLE(TR([TD('first')]+[TD(x) for x in arr]+[TD('fourth')]))}} Thanks for that. Anthony, thanks to you as well. Noel On Sep 1, 12:55 pm, Jonathan Lundell jlund...@pobox.com wrote: On Aug 31, 2011, at 5:50 PM, Noel Villamor wrote

[web2py] Re: How to pass an array from jQuery to controller

2011-08-30 Thread Noel Villamor
Please ignore the above post, as it was submitted prematurely. If a moderator is around, please delete the post. Thank you.

[web2py] How to pass an array from jQuery to controller

2011-08-30 Thread Noel Villamor
In chapter 9 there is this view that calls a controller using getJSON. VIEW: script var xyz; $(function() { $.getJSON('{{=URL(r=request,f='weekdays')}}', function(data){ xyz=data; alert(data); }); $(body).click(function(event) { ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']

[web2py] How to pass an array from jQuery to controller

2011-08-30 Thread Noel Villamor
I wanted to pass an array from jQuery to a controller. script var xyz= ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; $(function() { $(body).click(function(event) { call controller here using .getJSON? }); }); /script def mycontroller(): # Here, I wanted to receive xyz as

[web2py] Weird admin editing of views but ok on controllers

2011-08-29 Thread Noel Villamor
Just got a fresh clone from trunk. Am on Apache2+wsgi. When clicking the edit button of a view, I get the following at the browser resulting to a 404 Not Found. Notice the '%2F' which is supposed to be just '/'. https://.../admin/default/edit/welcome/views/default%2Findex.html When clicking

[web2py] Re: Weird admin editing of views but ok on controllers

2011-08-29 Thread Noel Villamor
wrote: Probably due to this recent fix:http://code.google.com/p/web2py/source/detail?r=c5f6a123b846d9c9c84e2... On Monday, August 29, 2011 6:49:22 AM UTC-4, Noel Villamor wrote: Just got a fresh clone from trunk. Am on Apache2+wsgi. When clicking the edit button of a view, I get

[web2py] Re: Weird admin editing of views but ok on controllers

2011-08-29 Thread Noel Villamor
Anthony, your suspicion is confirmed. I reverted to the older gluon/ html.py and the '%2F' issue is gone. On Aug 29, 11:28 pm, Noel Villamor noe...@gmail.com wrote: Hmmm ... I can verify this by reverting gluon/html.py to the 2011-08-25 version. What is the command for that in hg

[web2py] Passing variables and field values to crud onaccept function

2011-08-26 Thread Noel Villamor
The model: db.define_table('comment', Field('txt'), Field('tag')) How do I pass/access the variable xyz, and the txt and tag field values in funcdone below? def funcdone(form): comment_id = form.vars.id ... def post_comment(): xyz = 123 form = crud.create(db.comment,

[web2py] Re: Passing variables and field values to crud onaccept function

2011-08-26 Thread Noel Villamor
,xyz=xyz:funcdone(form,xyz))    return dict(form=form) On Aug 26, 5:38 am, Noel Villamor noe...@gmail.com wrote: The model: db.define_table('comment', Field('txt'), Field('tag')) How do I pass/access the variable xyz, and the txt and tag field values in funcdone below? def

[web2py] Filtering dropdown

2011-08-25 Thread Noel Villamor
From the manual: subset=db(db.person.id100) db.dog.owner.requires = IS_IN_DB(db, 'person.id', '%(name)s', _and=IS_NOT_IN_DB(subset,'person.id')) Am I right in my interpretation that the dog.owner dropdown will only show person names who are not in the subset? Am trying to implement '_and' but

[web2py] Passing around a list reference to view

2011-08-20 Thread Noel Villamor
My model has two tables: db.define_table('tag', Field('name')) db.define_table('data', Field('title'), Field('tags','list:reference tag')) My view for data table has a callback: {{=form}} ... ajax(.../tagcallback, [tags], ...) In my tagcallback controller: tags = request.vars.tags ... It seems

[web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Noel Villamor
I tried inserting crud.settings.formstyle = 'divs' but it only changed to divs the layout(?) but not the widget. DEFAULT FORM STYLE tr id=tag_tags__row td class=w2p_fl td class=w2p_fw table id=tag_tags class=list name=tags ... FORM STYLE SET TO divs div id=tag_tags__row div class=w2p_fl div

[web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Noel Villamor
Thanks for the link Anthony, it is what I need. Now, what is the proper way implement the custom widget? Should I simply copy the code, make the necessary alterations to it, and insert it in my app's controller?

[web2py] Re: How to customize widget rendering in form

2011-08-17 Thread Noel Villamor
Thanks for the tip(s). Have a nice day!

[web2py] How to customize widget rendering in form

2011-08-16 Thread Noel Villamor
I have this for a field definition: Field('tags','list:reference tag',widget=SQLFORM.widgets.checkboxes.widget) I use crud and it renders the field as an html table, as shown below: table name=tags id=tag_tags class=listtbody trtdinput type=checkbox value=12 name=tagsbusiness/td/ tr trtdinput