There's a bug in your custom validator code -- should be: self.error_message = error_message
On Tuesday, January 7, 2014 1:12:51 PM UTC-5, Akash Agrawall wrote: > > on doing the change you mentioned a ticket comes up..... > > Traceback (most recent call last): > File "/home/hornet632/webapps/joyofreading/web2py/gluon/restricted.py", > line 217, in restricted > exec ccode in environment > File > "/home/hornet632/webapps/joyofreading/web2py/applications/AK_M14/models/db.py" > <https://joyofreading.org/admin/default/edit/AK_M14/models/db.py>, line 125, > in <module> > db.Field('Category','string',requires=IS_CATEGORYIT()), > File > "/home/hornet632/webapps/joyofreading/web2py/applications/AK_M14/models/db.py" > <https://joyofreading.org/admin/default/edit/AK_M14/models/db.py>, line 105, > in __init__ > self.error_message = error > NameError: global name 'error' is not defined > > > > On Tuesday, January 7, 2014 3:21:09 AM UTC+5:30, Anthony wrote: >> >> Yes, please provide more detail. >> >> Also, requires=IS_CATEGORYIT should be requires=IS_CATEGORYIT(). >> >> Anthony >> >> On Monday, January 6, 2014 3:41:35 PM UTC-5, Dave S wrote: >>> >>> On Monday, January 6, 2014 12:32:01 PM UTC-8, Akash Agrawall wrote: >>>> >>>> I am getting this error: >>>> "Need more than one value to unpack" >>>> >>>> >>> Can you tell us which line the error message is referencing? Is there a >>> traceback in the ticket? >>> >>> /dps >>> >>> >>> >>> >>>> *db.py:* >>>> class IS_CATEGORYIT(object): >>>> def __init__(self, error_message="Zip code not allowed"): >>>> self.error_message = error >>>> def __call__(self, value): >>>> error = None >>>> print len(value) >>>> if len(value)==0: >>>> error = self.error_message >>>> return (value, error) >>>> db.define_table('book', >>>> db.Field('Name','string'), >>>> db.Field('Category','string',requires=IS_CATEGORYIT), >>>> db.Field('Quantity','integer'), >>>> db.Field('ISBN','string',unique=True), >>>> db.Field('Age_group','list:string', >>>> requires=IS_IN_SET(['1-4','5-8','9-12','13-17'])), >>>> >>>> db.Field('entry_date','date',default=datetime.date.today(),requires=IS_DATE(format=('%d-%m-%Y'))), >>>> db.Field('Description','text'), >>>> db.Field('Image','upload',uploadfield='picture_file'), >>>> db.Field('picture_file','blob'), >>>> db.Field('Available','integer'), >>>> db.Field('Author','string'), >>>> >>>> db.Field('Link','string',requires=IS_EMPTY_OR(IS_URL()))) >>>> >>>> db.book.Description.widget= lambda field,value: >>>> SQLFORM.widgets.text.widget(field,value,_style='width:400px',_rows=5) >>>> db.book.Category.requires=IS_IN_SET(['ficton','non-fiction','action and >>>> adventure','travel','biography','story'],multiple=True,zero=None),IS_NOT_EMPTY(error_message="cannot >>>> >>>> be empty") >>>> db.book.Category.widget= lambda field,value: >>>> SQLFORM.widgets.checkboxes.widget(field,value) >>>> >>>> *controller: default.py* >>>> def add_book(): >>>> form1=SQLFORM(db.book) >>>> form1.add_button('Cancel', URL('add_book')) >>>> if form1.accepts(request.vars,session): >>>> response.flash="Book Inserted" >>>> elif form1.errors: >>>> response.flash="Errors in form" >>>> return dict(form1=form1) >>>> >>>> *view:add_book.html* >>>> {{=form1.custom.begin}} >>>> <table> >>>> <tr><td style="width:51%">Name <span >>>> style="color:red;">*</span>:</td><td> {{=form1.custom.widget.Name >>>> }}</td></tr> >>>> <tr><td> Quantity <span style="color:red;">*</span>:</td><td> >>>> {{=form1.custom.widget.Quantity}}</td></tr> >>>> <tr><td style="width:51%">Available <span >>>> style="color:red;">*</span>:</td><td> >>>> {{=form1.custom.widget.Available}}</td></tr> >>>> <tr><td style="width:51%">ISBN <span style="color:red;">*</span>: >>>> </td><td>{{=form1.custom.widget.ISBN}}</td></tr> >>>> <tr><td style="width:51%">Entry Date <span >>>> style="color:red;">*</span>: >>>> </td><td>{{=form1.custom.widget.entry_date}}</td></tr> >>>> </table> >>>> >>>> <span style="color:#666666;" >Category</span><span >>>> style="color:red;">*</span>: >>>> <br/> >>>> <span style="position:relative;left:43%;color:rgb(102, 102, >>>> 102);"><label class="checkbox >>>> inline">{{=form1.custom.widget.Category[0]}}</label></span> >>>> <span style="position:relative;left:50%;color:rgb(102, 102, >>>> 102);"><label class="checkbox >>>> inline">{{=form1.custom.widget.Category[1]}}</label></span><br/> >>>> <span style="position:relative;left:43%;color:rgb(102, 102, >>>> 102);"><label class="checkbox >>>> inline">{{=form1.custom.widget.Category[3]}}</label></span> >>>> <span style="position:relative;left:50.5%;color:rgb(102, 102, >>>> 102);"><label class="checkbox >>>> inline">{{=form1.custom.widget.Category[4]}}</label></span><br/> >>>> <span style="position:relative;left:43%;color:rgb(102, 102, >>>> 102);"><label class="checkbox >>>> inline">{{=form1.custom.widget.Category[5]}}</label></span> >>>> <span style="position:relative;left:51%;color:rgb(102, 102, >>>> 102);"><label class="checkbox >>>> inline">{{=form1.custom.widget.Category[2]}}</label></span> >>>> </tr> >>>> </tr> >>>> <table> >>>> <tr><td style="width:45%">Age Group <span >>>> style="color:red;">*</span>:</td> >>>> <td>{{=form1.custom.widget.Age_group}}</td></tr> >>>> <tr><td style="width:45%">Author:</td><td> >>>> {{=form1.custom.widget.Author}}</td></tr> >>>> <tr><td style="width:45%">Amazon Link:</td> >>>> <td>{{=form1.custom.widget.Link}}</td></tr> >>>> <tr><td style="width:45%">Description:</td><td> >>>> {{=form1.custom.widget.Description}}</td></tr> >>>> <tr><td style="width:45%">Image:</td><td> >>>> {{=form1.custom.widget.Image}}</td></tr> >>>> <tr><td >>>> style="width:45%"></td><td>{{=form1.custom.submit}} {{=form1[0][11][1][1]}}</td></tr> >>>> </table> >>>> {{=form1.custom.end}} >>>> >>>> Please hava look at this..... need reply to this..... ASAP..... thanx >>>> in advance >>>> >>>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.