Yeah the widget docs are pretty bad and sometimes non-existant. I am
still trying to figure out how they work for the most part or else I
would be writing more docs. As for your original question. You don't
want to modify data in a widget class because it isn't safe across
threads. You want to make a widget outside the controller and then
only change the data at display time. Something to this effect:
sh = SyntaxHighlighter()
form = TableForm(
fields = [TextArea(name='code', attrs={'class':'py'})],
hidden_fields=[],
submit_text = 'Save')
class Root(controllers.RootController):
@expose(template='tgplayground.templates.sh')
def view(self):
sh = sh #Pulled from outside the class
form = form #Pulled from outside the class
data = dict(
value=dict(
code='''
class XYZ:
x = 4
''')) #Data to be passed in at display time, does not permanantly
effect the form
return dict(form=form, data=data, sh=sh)
And then put this in your kid file(sh.kid for me):
${form(**data)}
When including widgets with a lot of css and JS only you need to just
pass them into the template and turbogears automatically retrieves the
needed CSS and JS and puts it into the page. So I don't use sh in the
template but I do pass it in the dict to the template.
On 11/9/06, JM <[EMAIL PROTECTED]> wrote:
>
> Yeh you make a good point, however this does not solve my initial
> question;-)
>
> I am spending a lot of time trying things out, but as you know, when
> you begin, the simplest things can take stupidly long time to figure
> out, until you realize you totally missed the point and it suddenly it
> all makes sense...
>
> So, I spent some time sorting my issue with SO+Sqlite and wrote a
> little test case for a critical ticket
> (http://trac.turbogears.org/turbogears/ticket/1154) that was on hold,
> but for other things like widgets I do not have time to spend too many
> hours figuring it out, I would rather have a few more examples to work
> from. I read all the tutorials and doc I found, including simplewidget
> etc... but once you've done the simple examples, where do you go?
>
> I think the beginning steps are pretty well documented by now, and what
> this project now needs is some more advanced how-to's, some cool
> turbogears design patterns to inspire intermediate users and help them
> implement well designed web apps!
>
> Of course I will do my best to contribute.
>
> JM
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---