Hi Alessandro,
Thanks a lot.

Besides the bug of TG, it's my fault. This morning I have updated TG2 to the
latest version, but when I tried the web again, Paster was serving with the
old version. I try it again against the new version and it's ok now.

Best regards,
León Domingo

*ender*
*LA FACTORÍA DE SOFTWARE*

Av. Cerro del Águila 7, 2ª planta - S23
28703 S.S. de los Reyes
Madrid

tlf. y fax: 902 01 44 01
*www.ender.es*


On 11 July 2011 14:58, Alessandro Molina <[email protected]>wrote:

> Hi Leòn,
> I'm responding also on the ML so that it keeps track of the answer
> which might be helpful to other people.
>
> The error you are facing is due to a bug in TG2.1 which wrongly
> registered the helpers resulting in always empty helpers.
> You have two solutions to this problem:
>
> 1) Upgrade to TG2.1.1 which resolves this issue, pay attention that it
> is possible that you have multiple versions of TG installed (if you
> used easy_install instead of pip) and you are still running on the old
> one. Always upgrade with -U if you use easy_install. Or start with a
> fresh virtual environment.
>
> 2) Add this patch http://blog.axant.it/archives/348 to your
> application to solve the issue. You have to do this only with TG2.1,
> not 2.0 or 2.1.1, so you have to check if tg.version is 2.1 and only
> in that case you have to perform the monkeypatch.
>
> On Mon, Jul 11, 2011 at 11:38 AM, León Domingo <[email protected]>
> wrote:
> > Hi Alessandro,
> > Is there anything to be aware of when using this technique? I'm
> > getting a weird thing. One instalation (at my home) works fine and
> > another (at my job) fails. In the second one, it seems that h. is
> > empty when I try to access it.
> >
> > I've included *predicates* and *authorize* in *lib.helpers*:
> >
> > from repoze.what import predicates, authorize
> >
> > and then, in the template (jinja2), i use them
> >
> > {% if h.authorize.has_permission('foo', 'bar') %}
> > ...
> > {% endif %}
> >
> > This works ok in one installation. I've updated TG2 in the failing one
> > to be sure and it fails in the same way.
> >
> > Thanks
> >
> > León
> >
> > On 9 mayo, 09:02, Alessandro Molina <[email protected]>
> > wrote:
> >> Import your predicate inside the myapp.lib.helpers module, you will be
> able
> >> to access it as h.predicate inside all the templates.
> >>
> >> As predicates raise exceptions I would also create an helper to make
> eadier
> >> to use it in py:if clauses
> >> On May 9, 2011 6:50 AM, "Rodrigo Parra" <[email protected]> wrote:
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> > Hi all,
> >>
> >> > I want to check for permissions in a template because I want the page
> >> > displayed to be slightly different according to them. (For example, a
> >> > link being displayed only if the user is a manager).
> >>
> >> > However, the authorization method for my application is a bit more
> >> > complex than repoze.what standard one, so I had to define new
> >> > predicate checkers in order to implement it.
> >>
> >> > I defined my own predicate checkers at myproject.lib.mypredchecks.py
> >> > (just an example). I had no trouble importing that to my controllers,
> >> > but I don't know how to use them on Genshi templates.
> >>
> >> > I found this old thread about a similar issue, but the thread is about
> >> > repoze.what built-in predicate checkers:
> >>
> >> https://groups.google.com/group/turbogears/browse_thread/thread/ce6fc.
> ..
> >>
> >> > Is there a way to do what I need, preferably without passing other
> >> > object through the controller?
> >>
> >> > Thanks in advance.
> >>
> >> > --
> >> > 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.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >
>

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

Reply via email to