Re: [web2py] AutocompleteWidget: experimental, magic, RFC

2010-02-09 Thread Wes James
When text is typed that is not in the list and submitted there is this error:

Traceback (most recent call last):
  File /opt/00/gluon/restricted.py, line 173, in restricted
exec ccode in environment
  File /opt/00/applications/0/controllers/default.py, line 60, in module
  File /opt/00/gluon/globals.py, line 96, in lambda
self._caller = lambda f: f()
  File /opt/00/applications/0/controllers/default.py, line 12, in launch
return dict(new_torpedo=crud.create(db.photon_torpedo),
  File /opt/00/gluon/tools.py, line 2324, in create
deletable=False,
  File /opt/00/gluon/tools.py, line 2271, in update
keepvalues=self.settings.keepvalues):
  File /opt/00/gluon/sqlhtml.py, line 944, in accepts
fields[fieldname] = int(fields[fieldname])
ValueError: invalid literal for int() with base 10: ''

Is this supposed to have built in validation?

-wes

On Sat, Feb 6, 2010 at 1:30 PM, mdipierro mdipie...@cs.depaul.edu wrote:
 People say there is some magic in web2py.
 Here is some real magic now in trunk that I am sure you have never
 seen.

 Caveats:
 0) requires latest trunk (bzr 1603, hg 175:e42b559254f6)
 1) this is an experiment, not sure it is a good idea
 2) this is the first function in web2py that REQUIRES jQuery
 3) works but I am not yet convinced it should stay there
 4) even if it stays, I am sure the API should stay


snip

-- 
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.



[web2py] AutocompleteWidget: experimental, magic, RFC

2010-02-06 Thread mdipierro
People say there is some magic in web2py.
Here is some real magic now in trunk that I am sure you have never
seen.

Caveats:
0) requires latest trunk (bzr 1603, hg 175:e42b559254f6)
1) this is an experiment, not sure it is a good idea
2) this is the first function in web2py that REQUIRES jQuery
3) works but I am not yet convinced it should stay there
4) even if it stays, I am sure the API should stay

Example:

### assume this model
db.define_table('target',Field('name'))
if not db(db.target.id0).count():
db.target.insert(name=Klingon)
db.target.insert(name=Romulans)
db.target.insert(name=Borg)
db.target.insert(name=Borg2)
db.define_table('photon_torpedo',Field('target',db.target))

### assume this action in controller default.py
def launch():
db.photon_torpedo.target.represent=lambda target: target.name
return dict(new_torpedo=crud.create(db.photon_torpedo),
launched_torpedos=db().select(db.photon_torpedo.ALL))

So far nothing new.

Now append to the model or insert at top of controller the following:

from gluon.sqlhtml import AutocompleteWidget
db.photon_torpedo.target.widget=AutocompleteWidget(request,db.target.name,db.target.id)

No need to define any callback action (there is no callback action!)
No plugin required (perhaps some optional css to style).
No js coding required.
Applies to existing apps, including those that use custom forms.

Let's see who can figure out how it works!

Massimo

-- 
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.



Re: [web2py] AutocompleteWidget: experimental, magic, RFC

2010-02-06 Thread Jason Brower
I have my current autocomplete but it doesn't do öäå in a search.  Does
this handle that?
Best Regards,
Jason
On Sat, 2010-02-06 at 12:30 -0800, mdipierro wrote: 
 People say there is some magic in web2py.
 Here is some real magic now in trunk that I am sure you have never
 seen.
 
 Caveats:
 0) requires latest trunk (bzr 1603, hg 175:e42b559254f6)
 1) this is an experiment, not sure it is a good idea
 2) this is the first function in web2py that REQUIRES jQuery
 3) works but I am not yet convinced it should stay there
 4) even if it stays, I am sure the API should stay
 
 Example:
 
 ### assume this model
 db.define_table('target',Field('name'))
 if not db(db.target.id0).count():
 db.target.insert(name=Klingon)
 db.target.insert(name=Romulans)
 db.target.insert(name=Borg)
 db.target.insert(name=Borg2)
 db.define_table('photon_torpedo',Field('target',db.target))
 
 ### assume this action in controller default.py
 def launch():
 db.photon_torpedo.target.represent=lambda target: target.name
 return dict(new_torpedo=crud.create(db.photon_torpedo),
 launched_torpedos=db().select(db.photon_torpedo.ALL))
 
 So far nothing new.
 
 Now append to the model or insert at top of controller the following:
 
 from gluon.sqlhtml import AutocompleteWidget
 db.photon_torpedo.target.widget=AutocompleteWidget(request,db.target.name,db.target.id)
 
 No need to define any callback action (there is no callback action!)
 No plugin required (perhaps some optional css to style).
 No js coding required.
 Applies to existing apps, including those that use custom forms.
 
 Let's see who can figure out how it works!
 
 Massimo
 


-- 
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.