[Catalyst] Unable to output anything in Root.pm -> 'auto'
Lukas Thiemeier
spamcatcher at thiemeier.net
Mon Oct 29 15:39:20 GMT 2012
Hi again,
about the missing sessionid:
I don't know much about the internals of Catalyst::Plugin::Session, but
I guess that the session is a lazy attribute, and only created if used.
This means: unless you put something in the session, you will not have
one, and therefore have no session-id.
This is very handy, because the overhead related to creating and
restoring a session is only executed if the session is really needed.
If your app has a session-less interface without authentication, and
extra functionality for authenticated users, the session will only be
created for authenticated users.
If you touch your session object before fetching the session-id, it will
work:
$c->session;
$c->res->body("SESSIONID " . $c->sessionid);
As soon as you implemented authentication, the session will be used and
the session-id will be set.
By the way, what do you need the session-id for? Catalyst handles
sessions in a transparent way. In most cases, you don't need to access
the session-id in your code. And if it is only for debugging: The
session plugin writes the session-id to $c->log when a session is
created or restored. This means: the code showed above will result in
the session-id being printed twice :)
Lukas
On 10/29/2012 04:04 PM, Craig Chant wrote:
> Oh I also tried changing it to ‘begin’ instead of ‘auto’, still doesn’t
> work?
>
>
>
> I also thought that all calls to ANY method / sub will always be passed
> $self & $c , only it doesn’t seem to be passing in $c and I’ve had to
> manually do it?
>
>
>
> I’ve tried…
>
>
>
> # always runs first!
>
> sub begin :Private {
>
> my ( $self, $c ) = @_;
>
>
>
> # Authenticate
>
> $self->AuthenticateUser($c);
>
> return 1;
>
>
>
> }
>
>
>
> sub AuthenticateUser {
>
>
>
> my ( $self, $c ) = @_;
>
>
>
> die 'Session ID = ' . $c->sessionid;
>
>
>
> }
>
>
>
> But there is no session ID.
>
>
>
> I am still getting the “Use of uninitialized value in concatenation (.)
> or string” error.
>
>
>
> I’ve read
> http://search.cpan.org/~mramberg/Catalyst-Plugin-Session-0.14/lib/Catalyst/Plugin/Session/Tutorial.pod
>
>
>
> Where it states : These plugins will automatically set
> |$c->sessionid|at the begining of the request, and automatically cause
> |$c->sessionid|to be saved by the client at the end of the request.
>
> So why is $c->sessionid uninitialized?
>
>
>
> Any ideas where my session info is?
>
>
>
> Thanks,
>
>
>
> Craig
>
>
>
> *From:*Craig Chant [mailto:craig at homeloanpartnership.com]
> *Sent:* 29 October 2012 14:54
> *To:* The elegant MVC web framework
> *Subject:* RE: [Catalyst] Unable to output anything in Root.pm -> 'auto'
>
>
>
> Nope, no change; same warning in the devel output and all that happens
> is the welcome screen loads?
>
>
>
> *From:*Ben Vinnerd [mailto:ben+catalyst at vinnerd.com]
> <mailto:[mailto:ben+catalyst at vinnerd.com]>
> *Sent:* 29 October 2012 14:48
> *To:* The elegant MVC web framework
> *Subject:* Re: [Catalyst] Unable to output anything in Root.pm -> 'auto'
>
>
>
> Private methods have to return a true value to continue processing.
>
> Try adding "return 1" at the end of the method.
>
> Ben
>
> On 29 October 2012 14:23, Craig Chant <craig at homeloanpartnership.com
> <mailto:craig at homeloanpartnership.com>> wrote:
>
> Hi,
>
>
>
> I seem to be going round in circles unable to get Catalyst to output
> anything via ‘auto’?
>
>
>
> I made a change to the Root.pm to try to add authentication via the
> ‘auto’ method, but it does nothing?
>
>
>
> # always runs first!
>
> sub auto :Private {
>
> my ( $self, $c ) = @_;
>
>
>
> # Authenticate
>
> $c->response->body('Matched Members::Controller::Auto in Root.' .
> $c->sessionid);
>
>
>
> }
>
>
>
> This doesn’t output anything and I simply get the welcome screen, plus
> there is a warning in the devel server output of
>
>
>
> “Use of uninitialized value in concatenation (.) or string”
>
>
>
> I have ..
>
>
>
> use Catalyst qw/
>
> -Debug
>
> ConfigLoader
>
> Static::Simple
>
> StackTrace
>
> Session
>
> Session::Store::FastMmap
>
> Session::State::Cookie
>
> /;
>
>
>
> In my main MyApp.pm
>
>
>
> Why is $c->response->body not working and why is the sessionid empty?
>
>
>
> Thanks
>
>
>
> */Craig Chant/*
>
> I.T. Manager
>
> Description: cid:image001.png at 01CD5F4A.17E848D0
>
> Main Line 01903 602664 <tel:01903%20602664>
>
> Direct Line 01903 227753 <tel:01903%20227753>
>
> Visit our website http://www.homeloanpartnership.com
>
> *HomeLoan Partnership have been named the Best Mortgage Network, 2012,
> at the myintroducer.com <http://myintroducer.com> Industry Awards*
>
>
>
> This Email and any attachments contain confidential information and is
> intended solely for the individual to whom it is addressed. If this
> Email has been misdirected, please notify the author as soon as
> possible. If you are not the intended recipient you must not disclose,
> distribute, copy, print or rely on any of the information contained, and
> all copies must be deleted immediately. Whilst we take reasonable steps
> to try to identify any software viruses, any attachments to this e-mail
> may nevertheless contain viruses, which our anti-virus software has
> failed to identify. You should therefore carry out your own anti-virus
> checks before opening any documents. HomeLoan Partnership will not
> accept any liability for damage caused by computer viruses emanating
> from any attachment or other document supplied with this e-mail.
> HomeLoan Partnership reserves the right to monitor and archive all
> e-mail communications through its network. No representative or employee
> of HomeLoan Partnership has the authority to enter into any contract on
> behalf of HomeLoan Partnership by email. HomeLoan Partnership is a
> trading name of H L Partnership Limited, registered in England and Wales
> with Registration Number 5011722. Registered office: 26-34 Old Street,
> London, EC1V 9QQ. H L Partnership Limited is authorised and regulated by
> the Financial Services Authority.
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk <mailto:Catalyst at lists.scsys.co.uk>
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
> This Email and any attachments contain confidential information and is
> intended solely for the individual to whom it is addressed. If this
> Email has been misdirected, please notify the author as soon as
> possible. If you are not the intended recipient you must not disclose,
> distribute, copy, print or rely on any of the information contained, and
> all copies must be deleted immediately. Whilst we take reasonable steps
> to try to identify any software viruses, any attachments to this e-mail
> may nevertheless contain viruses, which our anti-virus software has
> failed to identify. You should therefore carry out your own anti-virus
> checks before opening any documents. HomeLoan Partnership will not
> accept any liability for damage caused by computer viruses emanating
> from any attachment or other document supplied with this e-mail.
> HomeLoan Partnership reserves the right to monitor and archive all
> e-mail communications through its network. No representative or employee
> of HomeLoan Partnership has the authority to enter into any contract on
> behalf of HomeLoan Partnership by email. HomeLoan Partnership is a
> trading name of H L Partnership Limited, registered in England and Wales
> with Registration Number 5011722. Registered office: 26-34 Old Street,
> London, EC1V 9QQ. H L Partnership Limited is authorised and regulated by
> the Financial Services Authority.
>
> This Email and any attachments contain confidential information and is
> intended solely for the individual to whom it is addressed. If this
> Email has been misdirected, please notify the author as soon as
> possible. If you are not the intended recipient you must not disclose,
> distribute, copy, print or rely on any of the information contained, and
> all copies must be deleted immediately. Whilst we take reasonable steps
> to try to identify any software viruses, any attachments to this e-mail
> may nevertheless contain viruses, which our anti-virus software has
> failed to identify. You should therefore carry out your own anti-virus
> checks before opening any documents. HomeLoan Partnership will not
> accept any liability for damage caused by computer viruses emanating
> from any attachment or other document supplied with this e-mail.
> HomeLoan Partnership reserves the right to monitor and archive all
> e-mail communications through its network. No representative or employee
> of HomeLoan Partnership has the authority to enter into any contract on
> behalf of HomeLoan Partnership by email. HomeLoan Partnership is a
> trading name of H L Partnership Limited, registered in England and Wales
> with Registration Number 5011722. Registered office: 26-34 Old Street,
> London, EC1V 9QQ. H L Partnership Limited is authorised and regulated by
> the Financial Services Authority.
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
More information about the Catalyst
mailing list