You may be making all your data publicly readable/writable and deletable if you do that.
On Thursday, 30 August 2012 21:27:29 UTC-5, lyn2py wrote: > > I finally figured out how. Just remove user_signature=True and it works > > On Thursday, August 30, 2012 9:48:21 PM UTC+8, Richard wrote: >> >> Will try to do a dummy app ASAP. >> >> Richard >> >> On Wed, Aug 29, 2012 at 10:07 PM, lyn2py <[email protected]> wrote: >> >>> Ok noted on your points below. I would like to clarify. >>> >>> First, the plugin files are only a controller file and a module file. >>> they are both the same as on the web page. >>> Second, I have modified the module file so that it recognizes the first >>> SELECT field, so the widget initialization looks different from the example >>> on the website. >>> Third, regarding your comment that the plugin (module file) should be >>> the one that returns the HTML, this I am not too sure. When I run the >>> original code, the ajax call goes to the controller, not the module file. >>> And the controller looks like >>> >>> def index(): >>> >>> form = SQLFORM(db.product) >>> >>> if form.accepts(request.vars, session): >>> >>> session.flash = 'submitted %s' % form.vars >>> >>> redirect(URL('index')) >>> >>> return dict(form=form, >>> >>> categories=SQLTABLE(db().select(db.category.ALL)), >>> >>> colors=SQLTABLE(db(db.color.id > 0)(db.color.category == >>> db.category.id >>> >>> ).select(db.color.id, db.category.name, >>> db.color.name))) >>> >>> >>> Questions: >>> Per your reply below, How does the widget "call" itself from the >>> controller and return the select field? >>> >>> I think I don't understand the widget as well as you do. As you already >>> have my model and controller code, can you give me an example of how my >>> controller code should look like so that the widget works? >>> >>> Thanks. >>> >>> On Thursday, August 30, 2012 3:44:58 AM UTC+8, Richard wrote: >>> >>>> Here the example about how to initialize the widget : >>>> >>>> db.product.color.widget = lazy_options_widget( >>>> >>>> >>>> 'product_category__selected', >>>> 'product_category__unselected'**, >>>> >>>> >>>> lambda category_id: (db.color.category == category_id), >>>> >>>> >>>> request.vars.category, >>>> >>>> >>>> orderby=db.color.id, >>>> >>>> >>>> user_signature=True, >>>> >>>> >>>> # If you want to process ajax requests at the time of >>>> the object construction (not at the form rendered), >>>> >>>> >>>> # specify your target field in the following: >>>> field=db.product.color, >>>> >>>> >>>> ) >>>> >>>> >>>> I am not sure what are : 'jsChangeOn','jsChangeOff', >>>> >>>> In your widget init... >>>> >>>> And I don't understand why you need to create a lazy_option function?? >>>> >>>> Did you install the plugin into your app and make the proper import or >>>> did you try to just copy/paste the code provided on the web page of >>>> s-cubism?? >>>> >>>> You don't need the your function it suppose to be the >>>> lazy_option_widget that do this task of making the ajax call and return >>>> the >>>> answer from the database to your view and update you dropbox (html SELECT >>>> OPTIONS)... >>>> >>>> I am puzzled a bit. >>>> >>>> R >>>> >>>> On Wed, Aug 29, 2012 at 12:02 PM, lyn2py <[email protected]> wrote: >>>> >>>>> OK sure :) >>>>> >>>>> MODELS >>>>> db.define_table('quotations', >>>>> Field('company_id','reference companies'), >>>>> Field('contact_id','reference contacts', >>>>> widget=lazy_options_widget('**jsChangeOn','jsChangeOff', >>>>> lambda customer_id: (db.contacts.customer_id == customer_id), >>>>> trigger=request.vars.customer_**id, keyword="id", >>>>> user_signature=True) >>>>> ), >>>>> Field('name','string',length=**255,requires=IS_NOT_EMPTY()), >>>>> ) >>>>> >>>>> db.companies and db.contacts are just separate tables, where each >>>>> company can have many different contacts. >>>>> >>>>> CONTROLLER >>>>> def test(): >>>>> form=SQLFORM(db.quotations) >>>>> # rows = >>>>> db(db.contacts.customer_id==re**quest.post_vars.id<http://request.post_vars.id> >>>>> ).select() >>>>> return locals() >>>>> >>>>> def lazy_options(): >>>>> if request.env.request_method=='**POST': >>>>> rows = >>>>> db(db.contacts.customer_id==re**quest.post_vars.id<http://request.post_vars.id> >>>>> ).select() >>>>> return SQLTABLE(rows) >>>>> else: >>>>> return None >>>>> >>>>> As I have no intentions to save the form, dbio codes has been left out. >>>>> >>>>> I am using a generic view. >>>>> I made changes to the plugin to recognize the javascript onchange, so >>>>> there is no problems with detecting and making the ajax call. The ajax >>>>> call >>>>> goes to a separate page "lazy_options" in the same controller. >>>>> >>>>> Whenever the first field onchange is triggered, the second field will >>>>> update (expected behavior). >>>>> But the html that appears is not a SELECT field. >>>>> >>>>> I use SQLTABLE(rows) because that was in the example provided. In >>>>> place of that I have tried "return rows", tried to assemble >>>>> SELECT/OPTIONS >>>>> on my own to no avail. >>>>> >>>>> I appreciate your help! What am I missing? Thank you :) >>>>> >>>>> >>>>> On Wednesday, August 29, 2012 11:06:37 PM UTC+8, Richard wrote: >>>>> >>>>>> Can you provide : >>>>>> >>>>>> Models (for the concerned tables) >>>>>> Controller (page form concerned) >>>>>> View (of the function page) >>>>>> >>>>>> It will be easier to help. >>>>>> >>>>>> Richard >>>>>> >>>>>> >>>>>> On Wed, Aug 29, 2012 at 10:56 AM, lyn2py <[email protected]> wrote: >>>>>> >>>>>>> Yes that is the internal code. >>>>>>> >>>>>>> I don't understand the example given. I have tested it but I don't >>>>>>> know what I'm missing. >>>>>>> >>>>>>> My setup is also different than the example given in their website. >>>>>>> >>>>>>> My current and only bottleneck is what value to return to the ajax >>>>>>> call. I have tried SQLTABLE(rows), SELECT, rows, XML versions and none >>>>>>> could produce a select field with the filtered options. >>>>>>> >>>>>>> Please help, I am out of ideas. >>>>>>> >>>>>>> -- >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> -- >>>>> >>>>> >>>>> >>>>> >>>> >>>> -- >>> >>> >>> >>> >> >> --

