[jifty-devel] Using Authentication::Password and Template::Declare

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Tue Aug 7 22:57:07 EDT 2007


Erm... I only new that answer because I added the basic POD there recently
rather than having actually tried it. ;)

Digging into how use_mason_wrapper() works and then the errors, it looks
like you've tripped on a couple bugs. I'm not an authority on these
particular parts of Jifty, but it looks like the first problem is that the
wrapper method defined in use_mason_wrapper() can't actually work unless the
share/web/templates/autohandler is tweaked, but may not need any changes in
and of itself.

The share/web/templates/autohandler does need at least one update and that

if ($m->base_comp->path =~ m|/_elements/|) {
    # Requesting an internal component by hand -- naughty

This path "/errors/requested_private_component" may have been a good path at
some point in the past, but there's no there there now. This probably needs
to be changed to /__jifty/error/requested_private_component or something
similar and then a component added there to handle the issue (or maybe it
just needs to die here).

The other update here needs to be that either the request made by calling
Jifty::View::Mason::Handler::handle_comp() needs to fix it up so that
base_comp is set correctly to the path of the page being handled by
Jifty::View, or needs to set a flag or something to keep the error redirect
from happening.

I don't know what's best in this particular case. I'll see if I can get a
test case put together sometime tomorrow though (unless someone wants to
beat me to it or I don't have time or forget, etc.).

In the meantime, EdF, I suggest either implementing your wrapper in T-D
without Mason (which can be done by overriding various render_* methods),
remove your App::View class altogether (which is working on our Metrics
application just fine) or doing the following as a hack work-around:

bin/jifty adopt web/templates/autohandler

and modify share/web/templates/autohandler (which was just created in your
local application) and modify it so that /_elements/wrapper is let through
that if-statement. For development purposes, I don't imagine that's too
heinous and it might not hurt you in a production environment, but I'd still
want the real fix before I published my app.

Anyway, that's my thoughts.


On 8/7/07, Edward Funnekotter <efunneko at gmail.com> wrote:
> Thanks for your quick response Andrew.  I am working off the latest T::D,
> so the use_mason_wrapper() method is available.
> This did change my output a bit.  Now my page gets redirected to
> errors/requested_private_component, which it complains about since it seems
> that it doesn't exist for me.  Do I have to declare wrapper to be publicly
> available?  I will keep digging myself, but if you happen to know the answer
> it would be appreciated.
> On 8/7/07, Andrew Sterling Hanenkamp <sterling at hanenkamp.com> wrote:
> >
> > EdF,
> >
> > I think we need to clean up some of the remarks regarding the usability
> > of the Template::Declare stuff. It does not have the maturity of Mason, but
> > I wouldn't say there are bugs crawling all over anymore. (At least not the
> > latest repository version, I'm not sure what state the latest CPAN release
> > is in.) I'd say it's certainly suitable for production use. The big problems
> > now tend to be those that are resolved with more time investment in
> > development.
> >
> > An /_elements/wrapper in Mason ought to work. I'm doing it on one of my
> > applications which was started prior to the TD views being added to Jifty
> > and I've never converted it.
> >
> > Do you have a View class defined? If you do, that might be the source of
> > some of the trouble. Since the TD docs are spread across several classes, it
> > might not be clear (and there's no example in this particular case either),
> > but you should be able to call:
> >
> > __PACKAGE__->use_mason_wrapper();
> >
> > in your View class to switch it over to requesting /_elements/wrapper
> > from Mason. That's defined in Jifty::View::Declare::BaseClass.
> >
> > Again, this is all based on using Jifty from a recent fetch from the
> > Subversion repository. I don't know how different the CPAN release is.
> >
> > Cheers,
> > Andrew
> >
> > On 8/7/07, Edward Funnekotter < efunneko at gmail.com> wrote:
> >
> > > Hi all,
> > >
> > > I have been building an app recently and decided to try to use the
> > > Authentication::Password plugin to handle my user authentication.  Since the
> > > Template::Declare stuff still looked fairly new ('BUGS: Crawling all over,
> > > baby. Be very, very careful.") I figured I would stick to Mason templates.
> > > My problem is that I have a _elements/wrapper that controls the main
> > > elements of each page, except for the views that are inherited from the
> > > Authentication::Password plugin.  They seem to not get any wrapper that I
> > > can see.
> > >
> > > Some digging shows that they are using the Template::Declare
> > > paradigm.  My question is, how do I get those pages to use my wrapper.  If I
> > > can't do that, how do I make a Template::Declare copy of my wrapper and get
> > > those pages to use it?  I did read through the documentation, but that
> > > didn't really clarify anything.  If there is a tutorial somewhere for
> > > Template::Declare, please just point me to it or point me to some example
> > > code.
> > >
> > > Thanks,
> > > EdF
> > >
> > > _______________________________________________
> > > jifty-devel mailing list
> > > jifty-devel at lists.jifty.org
> > > http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
> > >
> > >
> >
> > _______________________________________________
> > jifty-devel mailing list
> > jifty-devel at lists.jifty.org
> > http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
> >
> >
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070807/fa164577/attachment-0001.htm

More information about the jifty-devel mailing list