sry just realized that mr web2py himself is called massimo, I should really go and sleep now
On Jan 27, 2:20 am, selecta <gr...@delarue-berlin.de> wrote: > IGNORE THE POST ABOVE > NOW TRULY SOLVED > > The problem with the post above was that the validator was not order > preserving, I added some lines to the IS_IN_SET constructor, not it > truly works > > .... > >>> IS_IN_SET([('a','max'), ('b','john')])('max') > ('a', None) > """ > > def __init__( > self, > theset, > labels=None, > error_message='value not allowed', > multiple=False, > zero='', > sort=False, > ): > self.multiple = multiple > self.labels = labels > if theset and len(theset[0])==2 and (isinstance(theset[0], > list) or isinstance(theset[0], tuple)): > self.theset = [str(item) for item,label in theset] > self.labels = [str(label) for item,label in theset] > else: > self.theset = [str(item) for item in theset] > if isinstance(theset, dict): > self.labels = theset.values() > self.error_message = error_message > self.zero = zero > self.sort = sort > .... > contrutor ends there > > maximo if you could add this code to the trunk it would be very nice > > On Jan 27, 12:07 am, selecta <gr...@delarue-berlin.de> wrote: > > > > > SOLVED > > > i thought i have to write my own validator, looking into IS_IN_SET i > > stumbeled upon the following code in the first few lines > > > if isinstance(theset, dict): > > self.labels = theset.values() > > > hmmm, lets try > > > folders = dict(folders) > > db_webfolder.parent.requires = IS_IN_SET(folders) > > form_file = SQLFORM(db_webfolder) > > > and it works!!! > > > maybe this should be documented somewhere, e.g. in the docstring of > > IS_IN_SET! would make it at least a bit easier to find out > > > On Jan 26, 11:23 pm, selecta <gr...@delarue-berlin.de> wrote: > > > > oh it can ?:) sounds good, but still it solves only part of my > > > problem, I also want to change what is shown to the user in option, I > > > better show you what I want to do > > > > def getfolders(root = 0, spaces = '-'): > > > folders = [] > > > for f in db(db_webfolder.id>0)(db_webfolder.parent==root) > > > (db_webfolder.file==None).select(): > > > folders.append((f.id,spaces+f.name)) > > > folders += getfolders(f.id, '-'+spaces) > > > return folders > > > > folders = [(0,'root')]+getfolders() > > > form_folder = FORM(SELECT([OPTION(name,_value=id) for id,name in > > > folders],_name='parent'),INPUT(_name='name'),INPUT > > > (_type='submit',_value="create")) > > > > it should return something like > > > <select name="parent"> > > > <option value="0">root</option> > > > <option value="1">-test</option> > > > <option value="5">--subfolder of test</option> > > > <option value="6">--another sub of test</option> > > > <option value="7">--another one</option> > > > <option value="2">-another folder</option> > > > <option value="3">-yet another</option> > > > <option value="4">-okok</option> > > > <option value="8">--tesing still</option> > > > </select> > > > > On Jan 26, 10:59 pm, Thadeus Burgess <thade...@thadeusb.com> wrote: > > > > > IS_IN_DB can use a query can't it? > > > > > -Thadeus > > > > > On Tue, Jan 26, 2010 at 3:46 PM, selecta <gr...@delarue-berlin.de> > > > > wrote: > > > > > Is there a validator that creates a select with options from a list of > > > > > tuples > > > > > > what I want do do is > > > > > Field("folder","integer",requires = IS_IN_TUPLELIST([('myfolder',12), > > > > > ('subfoler',23)])) > > > > > > so that is creates > > > > > SELECT([OPTION(name,_value=id) for name,id in [('myfolder',12), > > > > > ('subfoler',23)] ],_name='parent'),INPUT(_name='name') > > > > > > in this case I cannot use IS_IN_DB because i need to filter the > > > > > results from the table > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > > > Groups "web2py-users" group. > > > > > To post to this group, send email to web...@googlegroups.com. > > > > > To unsubscribe from this group, send email to > > > > > web2py+unsubscr...@googlegroups.com. > > > > > For more options, visit this group > > > > > athttp://groups.google.com/group/web2py?hl=en. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.