here the controller and template sources....
#controller.py:
from turbogears import controllers, expose
import turbogears
from tgfklookup.widgets import AutoCompletingFKLookupField
listtable = [(1, 'John Doe'),
(2, 'Jane Doe'),
(3, 'John Smith') ]
class TestInputDuo(controllers.Controller):
@expose(template="autocompletefield.templates.auto")
def index(self):
return dict(acfield = self.acfield)
def __init__(self):
self.acfield = AutoCompletingFKLookupField(
controller = "search",
id_search_param='code',
text_search_param='description',
var_name = "matches")
@turbogears.expose(format = "json")
def search(self, code=None, description=None):
matches = []
if description:
for match in listtable:
if description.lower() in match[1].lower():
matches.append(match)
else:
try:
matches.append(self.listtable[int(code) - 1])
except IndexError:
pass
except ValueError:
pass
return dict(matches = matches)
class Root(controllers.RootController):
test2 = TestInputDuo()
--------------------------------------------------------
#auto.kid:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://purl.org/kid/ns#"
py:extends="'master.kid'">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"
py:replace="''"/>
</head>
<body>
${acfield.display()}
</body>
</html>
---------------------------------------------------------
jo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---