Re: [TurboGears] TG2, mako, webhelpers

5 views
Skip to first unread message
Message has been deleted

Mark Ramm

unread,
Jul 23, 2008, 12:18:03 AM7/23/08
to turbo...@googlegroups.com
> I have a few questions about TG2 :
> - How can I use mako instead of genshi ?

Right now you pretty much have to use strings like
"mako:myproject.templates.index" for your expose methods.

You can manipulate the pylons buffet template object to set mako as
the default rendering engine, but it's a bit complex.

As soon as Pylons releases a new version which adds the hooks we need,
we'll do a release of TG2 where you can set the default renderer with
a simple config option in app_conf.py.

> - how can I configure the application to use webhelpers, to expose it
> as a global "h" ? (I've looked into app_globals.py but I did not seem
> to pick things up. and can webhelpers and toscawidgets be mixed
> together ?

it's setup in the load_environent by getting stuff from helpers.py
inside you application's lib directory.

> - what should I know about using TG2 (1.9.7) in a production
> environment ?

Well, TG2 is being used by a few people in production, and there are
two major schools. The mod_wsgi school and the nginx proxy school.
Both provide good performance, and are great ways to deploy your app.
And you can use any wsgi server, so there are lots and lots of
options.

Tg2 is a pretty thin layer over the top of some well tested
components, so I personaly would not be very hesitant to deploy TG2 in
production at the moment, but I would say that it depends more on your
app and your specific requirements than anything else.


> - is there a list of the availalble function decorators ?

The ones provided by TG are here:

http://www.turbogears.org/2.0/docs/modules/tgdecorators.html

Other API docs can be found linked from here:

http://www.turbogears.org/2.0/docs/modindex.html

> Cheers,
> >
>

--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

django_pylons

unread,
Jul 23, 2008, 11:05:45 AM7/23/08
to TurboGears
Thanks for the quick reply!
expose decorators do work as I suspected which is great! more code
reuse:

@expose('json', exclude_names='d')
@expose('kid:blogtutorial.templates.test_form',
content_type='text/html')
def my_exposed_method(self):
return dict(a=1, b=2, d="username")


now for the webhelpers ... I did create a project and found the
helpers.py file but it was empty ? So I modify helpers.py by adding :
from webhelpers import *

then what do I add in app_cfg.py to have the helpers bound to a global
variable ? Also I do I set mako in app_cfg.py or will
"mako:myproject.templates.index" suffice ?

Cheers,

Mark Ramm

unread,
Jul 24, 2008, 12:06:19 PM7/24/08
to turbo...@googlegroups.com
On Wed, Jul 23, 2008 at 11:05 AM, django_pylons <s.jol...@gmail.com> wrote:

Thanks for the quick reply!
expose decorators do work as I suspected which is great! more code
reuse:

@expose('json', exclude_names='d')
@expose('kid:blogtutorial.templates.test_form',
       content_type='text/html')
def my_exposed_method(self):
   return dict(a=1, b=2, d="username")


Yea, we've tried to be very backwards compatible with TG1.  ;) 
 

now for the webhelpers ... I did create a project and found the
helpers.py file but it was empty ? So I modify helpers.py by adding :
from webhelpers import *

Whatever's imported there *should* just be added to h by the load_environment function automatically.   If that's not happening, let me know and we can troubleshoot it. 

Also I do I set mako in app_cfg.py or will
"mako:myproject.templates.index"  suffice ?

I think that should suffice for now.   Really looking forward to the next plyons release so that I can make changing default templates super-easy. 

--Mark Ramm

django_pylons

unread,
Jul 24, 2008, 5:42:32 PM7/24/08
to TurboGears

>
> > now for the webhelpers ... I did create a project and found the
> > helpers.py file but it was empty ? So I modify helpers.py by adding :
> > from webhelpers import *
>
> Whatever's imported there *should* just be added to h by the
> load_environment function automatically.   If that's not happening, let me
> know and we can troubleshoot it.

No I get "UndefinedError: "h" not defined" when calling : "$
{h.html.tags.checkbox("hi")}". is there somewhere I can set "h"
pylons seems to set it in app_cfg.py

thanks,
Reply all
Reply to author
Forward
0 new messages