Ok, thanks Diez.
I renamed class TestPic(TableForm) to PicForm
and now it goes a little something like this:
===================================================
class PicForm(TableForm):
#js = [JSLink(link=url('/public/js/chart.js'))]
#gav Hmmm, not too sure where to do this.
params = ["template", "js"]
template = "pkg.templates.pic.html"
js = [JSLink(link=url('/public/js/chart.js'))]
class fields(WidgetsList):
id = TextField()
title = TextField()
fig = TextArea()
#After init, widget is shared so mods not thread-safe
#def __init__(self, template):
#JSLink(link=url('/public/js/chart.js')).inject()
#inject_resources(template) #The new way tw does it
#If you need to fetch data from external sources, do it here
#http://toscawidgets.org/documentation/ToscaWidgets/modules/
api.html
def update_params(self, d): #d is a dict with all args stuffed in
it.
super(PicForm, self).update_params(d) #Must do this
explicitly
d.js = JSLink(link=url('/public/js/chart.js')).inject()
d.template = "pkg.templates.pic.html"
#inject_resources(template) #gav But no params allowed
here!
#Now create an instance of this form
pic_form = PicForm("pic_form") #gav What is this parameter for?
===============================================================
I thought TG was supposed to make the front end dev easy. Ye olde PL/
SQL
with all HTML inside "..." would be easier to follow. Hopefully the
power
and beauty of the MVC structure of all this stuff is going to kick in
any day now. Am I the only newbie struggling with this kind of
stuff?
Maybe not, as I see there was some fairly extensive discussion on tg-
trunk
re. this update_params stuff.
Now I get another ImportError. Is it because I haven't injected
because
no params are allowed in update_params? If so, where/how can I put
the call
to inject_resources?
======================================================
Module ?:27 in <Expression u'tmpl_context.pic_form()'> view
<< pic_form with template = "pkg.templates.pic.html"
This seems to want a 'pic' module. I have one in /
model -->
<p>${tmpl_context.pic_form()}</p>
<!-- :-( ImportError on module pic ...?! -->
Module tw.core.base:535 in __call__ view
<< def __call__(self, value=None, **kw):
return self.display(value, **kw)
def get_default(self):
Module tw.core.base:532 in display view
<< kw = self.prepare_dict(value, kw)
self.register_resources()
return super(Widget, self).display(**kw)
def __call__(self, value=None, **kw):
Module tw.core.view:217 in display view
>> return tw.framework.engines.display(self, **kw)
Module tw.core.view:33 in _renderer view
>> template = self.load_template(template, origin)
Module tw.core.view:133 in load_template view
<< elif isinstance(template, basestring):
# Assume template path
output = self[engine_name].load_template(template)
else:
# Assume compiled template
Module genshi.template.plugin:95 in load_template view
Module pkg_resources:840 in resource_filename view
<< def resource_filename(self, package_or_requirement,
resource_name):
"""Return a true filesystem path for specified
resource"""
return get_provider
(package_or_requirement).get_resource_filename(
self, resource_name
)
Module pkg_resources:160 in get_provider view
>> __import__(moduleOrReq)
ImportError: No module named pic
======================================================
This import error seems to be caused by tmpl_context.pic_form auto-
generating some expectation for a module named pic although how and
where this occurs is not clear to me. I've still not developed an
intuition re. the stack trace and I'm stuck again. I already have a
pic.py module in my model folder and this defines a simple table [id,
title, img] which has otherwise worked fine before. Apologies in
advance if this post is a little long... :-{
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---