Re: [Catalyst] hostname
On Thursday 10 January 2008 21:15:25 Octavian Rasnita wrote: From: Ash Berlin [EMAIL PROTECTED] How did you get to a function in MyApp.pm during a request # in MyApp.pm sub foobarbaz { my ($c) = @_; } # In controller code. $c-foobarbaz(); Make sense? Not really. I've tried (in MyApp.pm): sub the_host { my ($c) = @_; return $c-req-hostname; } and then I've tried to use cookie_domain = the_host() in the MyApp config, but when I try to start the server it gives an error telling that I can't use the method req because $c is undefined. You could use MyApp::Root::auto to lookup the hostname from the request and set it in config as you wish. Example: # MyApp::Root; sub auto : Private { my ( $self, $c ) = @_; $c-config-{cookie_domain} = $c-req-hostname; } But anyway, what I need is working because I can avoid setting a domain name for the cookie. Octavian ___ List: Catalyst@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/ -- Knut-Olav Hoven Systemutvikler mob: +47 986 71 700 Linpro AShttp://www.linpro.no/ signature.asc Description: This is a digitally signed message part. ___ List: Catalyst@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/
Re: [Catalyst] hostname
cookie_domain = the_host() in the MyApp config, but when I try to start the server it gives an error telling that I can't use the method req because $c is undefined. I'd be curious about why you wanted the cookie domain in the config anyway! I presume you've got a bit of code like: $c-response-cookies-{'foo'} = { domain = $c-config('cookie_domain') }; In which case why couldn't you just do $c-response-cookies-{'foo'} = { domain = $c-req-hostname }; But anyway, what I need is working because I can avoid setting a domain name for the cookie. Yeah exactly, setting the domain in the cookie to match the domain requested is pretty pointless anyway as that's what browsers do by default. About the only time you need to send a domain back is when you want to set a cookie across all subdomains or similar. Eg: { domain = '.example.com' } Carl ___ List: Catalyst@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/
RE: [Catalyst] POD viewer
Hello! I've got an error: [error] Caught exception in CatalystAdvent-begin Can't locate object method now via package DateTime (perhaps you forgot to load DateTime?) at /tmp/test/Script/../lib/CatalystAdvent.pm line 57. I've fixed it adding use DateTime; Then i've stopped at: [error] Couldn't forward to command /calendar/index: Invalid action or component. What could it be? On Fri, 2008-01-11 at 00:59 -0600, Jonathan Rockway wrote: Silly quoting below, so I'm top posting. Take that! Anyway, the Catalyst Advent Calendar is basically a POD server. Is it pretty? No... but it is something you can cargo cult if you want. http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/CatalystAdvent/ Regards, Jonathan Rockway On Wed, 2008-01-09 at 08:19 +0100, Dami Laurent (PJ) wrote: -Message d'origine- De : Ashley [mailto:[EMAIL PROTECTED] Envoyé : mercredi, 9. janvier 2008 04:05 À : The elegant MVC web framework Objet : [Catalyst] POD viewer Through a somewhat shallow search (difficult terms to search out effectively) of the archives and search.CPAN I can't find if anyone has hacked up a Cat based POD viewer/Controller; like the modperl Apache one but, one hopes, without the (early?) security issues. I want to be able to share internal POD at work to encourage both its reading and writing. Thanks! -Ashley The lack of a one-line attribution makes it impossible to cleanly reply to this message (while keeping fragments from both your reply and the original question). Try to avoid this kthx. Hi Ashley, I've hacked up a pod viewing app : see Pod::POM::Web. It's not a Catalyst app, but it's a web app, sitting in mod_perl or cgi-bin or its own Http server, and serving all pod installed in your @INC. Enjoy, Laurent Dami ___ List: Catalyst@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/ ___ List: Catalyst@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/ ___ List: Catalyst@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/
Re: [Catalyst] hostname
From: Carl Johnstone [EMAIL PROTECTED] cookie_domain = the_host() in the MyApp config, but when I try to start the server it gives an error telling that I can't use the method req because $c is undefined. I'd be curious about why you wanted the cookie domain in the config anyway! I presume you've got a bit of code like: $c-response-cookies-{'foo'} = { domain = $c-config('cookie_domain') }; In which case why couldn't you just do $c-response-cookies-{'foo'} = { domain = $c-req-hostname }; I needed the domain name for setting the session in MyApp.pm. Octavian ___ List: Catalyst@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/
Re: [Catalyst] hostname
On Jan 11, 2008, at 5:29 AM, Carl Johnstone wrote: cookie_domain = the_host() in the MyApp config, but when I try to start the server it gives an error telling that I can't use the method req because $c is undefined. I'd be curious about why you wanted the cookie domain in the config anyway! I think the idea was something along the lines of... MyApp-config-{ 'session' }-{ 'cookie_domain' } = MyApp-request- header-( 'host' ); I presume you've got a bit of code like: $c-response-cookies-{'foo'} = { domain = $c- config('cookie_domain') }; In which case why couldn't you just do $c-response-cookies-{'foo'} = { domain = $c-req-hostname }; But anyway, what I need is working because I can avoid setting a domain name for the cookie. Yeah exactly, setting the domain in the cookie to match the domain requested is pretty pointless anyway as that's what browsers do by default. About the only time you need to send a domain back is when you want to set a cookie across all subdomains or similar. Eg: { domain = '.example.com' } In which case you could still do something in Root/auto if you wanted to modify it... my $domain_re = join( '|', qw( mydomain.com myotherdomain.com foo.com example.com ) ); sub auto : Private { my ( $self, $c ) = @_; if ( $c-request-header( 'host' ) =~ /(\.(?:$domain_re))$/ ) { $c-config-{ 'session' }-{ 'cookie_domain' } = $1; } return 1; } -- Jason Kohles, RHCA RHCDS RHCE [EMAIL PROTECTED] - http://www.jasonkohles.com/ A witty saying proves nothing. -- Voltaire ___ List: Catalyst@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/
[Catalyst] Re-enable digest mode?
Up until this week I was receiving the Catalyst list e-mails in digest form. This week I'm getting individual e-mails. When I checked the list server options it told me digest mode had been disabled by the administrator. It's hard for me to process multiple individual e-mails from the Catalyst list along with my other e-mail; is there any way digest mode could be re-enabled? Thanks! Hugh Lampert IT Specialist Information Technology (3261) Landesbank Baden-Württemberg New York Branch 280 Park Avenue, 31st Floor - West Building New York, NY 10017 Phone: (212) 584-1775 Fax: (212) 584-1799 Email: [EMAIL PROTECTED] Web: www.LBBW.com -Original Message- From: Emmanuel Quevillon [mailto:[EMAIL PROTECTED] Sent: Friday, January 11, 2008 8:38 AM To: The elegant MVC web framework Subject: [Catalyst] Serving html pages Hi, I am quite new with catalyst and I'd like to know how I could serve some html pages (actually documentation) e.g.: www.myapp.com/docs/index.html ? When I try to integrate such link in my template page, Pages are not served and as mentioned in the C::P::Static::Simple it does not serve .html file. Is there any magic thing to do without changing MyApp-config-{static}-{ignore_extensions} ? Thanks a lot Regards -- - Emmanuel Quevillon Biological Software and Databases Group Institut Pasteur +33 1 44 38 95 98 tuco at_ pasteur dot fr - ___ List: Catalyst@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/ Disclaimer: This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. The above information has been prepared for information purposes only. The above does not constitute an offer, recommendation or solicitation to buy or sell, nor is it an official confirmation of terms. While the information herein has been obtained from sources believed to be reliable, Landesbank Baden-Württemberg makes no representation that it is accurate or complete and it should not be relied upon as such. Neither Landesbank Baden-Württemberg nor any employee herein guarantees the information contained in this message. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You are not entitled to, directly or indirectly, use, disclose, distribute,print, or copy any part of this message if you are not the intended recipient.Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Landesbank Baden-Wurttemberg. ___ List: Catalyst@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/
Re: [Catalyst] Serving html pages
I have a similar problem, but I am on shared hosting and I do not have access to httpd.conf, only to the local .htaccess files. I have the static plugin set up so we are delivering HTML, image files and other static pages via Catalyst, but similarly to Alejandro I would like to serve up the pages directly from Apache. I have tried using mod_rewrite but it seems to be an invention of the Adversary designed to lead us into despair. Has anyone managed to serve static files directly using just .htaccess? On 12/01/2008, Alejandro Imass [EMAIL PROTECTED] wrote: Usually you would try to serve your static content directly with your Web Server and let only the dynamic part with Catalyst. For example you could have a configuration in your apache vhost as such: Suppose your app's name is vdc... VirtualHost * [...] # root of your app DocumentRoot /var/www/vdc/root # Aliases Alias /static /var/www/vdc/root/static Alias /other-static-files /var/vdc/whatever Alias / /var/www/vdc/script/vdc_cgi.pl # The Catalyst part is via mod_perl Location / SetHandler modperl PerlResponseHandler vdc /Location # The static content is served by apache directly Location /static SetHandler default-handler /Location Location /other-static-files SetHandler default-handler /Location # main app directory conf Directory /var/www/vdc DefaultLanguage es AddHandler cgi-script .pl AllowOverride None Options ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all /Directory # personal error file ErrorLog /var/log/apache2/vdc-error.log # personal log file LogLevel warn CustomLog /var/log/apache2/vdc-access.log combined ServerSignature On /VirtualHost On Jan 11, 2008 10:27 AM, Marcello Romani [EMAIL PROTECTED] wrote: Emmanuel Quevillon ha scritto: Hi, I am quite new with catalyst and I'd like to know how I could serve some html pages (actually documentation) e.g.: www.myapp.com/docs/index.html ? When I try to integrate such link in my template page, Pages are not served and as mentioned in the C::P::Static::Simple it does not serve .html file. Is there any magic thing to do without changing MyApp-config-{static}-{ignore_extensions} ? Thanks a lot Regards If I recall correctly, the default is to serve as static files only the ones under root/static, so try to put doc/ there. P.S.: Please don't start a new thread under an existing one. HTH -- Marcello Romani Responsabile IT Ottotecnica s.r.l. http://www.ottotecnica.com ___ List: Catalyst@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/ ___ List: Catalyst@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/ -- Regards, Martin ([EMAIL PROTECTED]) IT: http://methodsupport.com Personal: http://thereisnoend.org ___ List: Catalyst@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/
[Catalyst] looking for suggestion on both cron and pm
generally I do have several corn scripts. so I want to get $user both in MyApp and cron scripts. what I tried to do is soemthing like that: the first is a base module which contains schema cache and tt2 and others. package Foorum::Adaptor::Base; sub new { my $self = shift; my $params = {}; return bless $params = $self; } sub config { my $self = shift; return $self-{config} if ($self-{config}); my $config = LoadFile($path/../../../foorum.yml); my $extra_config = LoadFile($path/../../../foorum_local.yml); $config = { %$config, %$extra_config }; $self-{config} = $config; return $self-{config}; } sub schema { my $self = shift; return $self-{schema} if ($self-{schema}); my $config = $self-config(); $self-{schema} = Foorum::Schema-connect( $config-{dsn}, $config-{dsn_user}, $config-{dsn_pwd}, { AutoCommit = 1, RaiseError = 1, PrintError = 1 }, ); return $self-{schema}; } ... Check Attachment for more details. then a User adaptor module: package Foorum::Adaptor::User; use strict; use warnings; use base 'Foorum::Adaptor::Base'; sub get { my ( $c, $cond ) = @_; my $cache_key = 'user|' . Object::Signature::signature($cond); my $cache_val = $c-cache-get($cache_key); if ($cache_val) { return $cache_val; } $cache_val = get_user_from_db( $c, $cond ); return unless ($cache_val); $c-cache-set( $cache_key, $cache_val, 7200 );# two hours return $cache_val; } and others. more see attachment. at last: package Foorum::Model::User; use strict; use warnings; use base 'Catalyst::Model::Adaptor'; __PACKAGE__-config( class = 'Foorum::Adaptor::User' ); 1; so that we can do in MyApp: my $user = $c-model('User')-get( { username = $username } ); or cron script: use Foorum::Adaptor::User; my $user_model = new Foorum::Adaptor::User(); my $user = $user_model-get( { user_id = 1 } ); is those code correct? or there is another way to do it? Thanks. -- Fayland Lam // http://www.fayland.org/ Foorum based on Catalyst // http://www.foorumbbs.com/ package Foorum::Adaptor::Base; use strict; use warnings; use YAML qw/LoadFile/;# config use Foorum::Schema; # schema use TheSchwartz; # theschwartz use Template; # template use Template::Stash::XS; use File::Spec; use Cwd qw/abs_path/; my ( undef, $path ) = File::Spec-splitpath(__FILE__); sub new { my $self = shift; my $params = {}; return bless $params = $self; } sub base_path { my $self = shift; return $self-{path} if ( $self-{path} ); $self-{path} = abs_path($path/../../../); return $self-{path}; } sub config { my $self = shift; return $self-{config} if ($self-{config}); my $config = LoadFile($path/../../../foorum.yml); my $extra_config = LoadFile($path/../../../foorum_local.yml); $config = { %$config, %$extra_config }; $self-{config} = $config; return $self-{config}; } sub schema { my $self = shift; return $self-{schema} if ($self-{schema}); my $config = $self-config(); $self-{schema} = Foorum::Schema-connect( $config-{dsn}, $config-{dsn_user}, $config-{dsn_pwd}, { AutoCommit = 1, RaiseError = 1, PrintError = 1 }, ); return $self-{schema}; } *default_cache_backend = \cache; sub cache { my $self = shift; return $self-{cache} if ($self-{cache}); my $config = $self-config(); my %params = %{ $config-{cache}{backends}{default} }; my $class = delete $params{class}; eval(use $class;);## no critic (ProhibitStringyEval) unless ($@) { $self-{cache} = $class-new( \%params ); } return $self-{cache}; } sub theschwartz { my $self = shift; return $self-{theschwartz} if ($self-{theschwartz}); my $config = $self-config(); $self-{theschwartz} = TheSchwartz-new( databases = [ { dsn = $config-{theschwartz_dsn}, user = $config-{theschwartz_user} || $config-{dsn_user}, pass = $config-{theschwartz_pwd} || $config-{dsn_pwd}, } ], verbose = 0, ); return $self-{theschwartz}; } sub tt2 { my $self = shift; return $self-{tt2} if ($self-{tt2}); my $config = $self-config(); $self-{tt2} = Template-new( { INCLUDE_PATH = [$path/../../../templates], PRE_CHOMP= 1, POST_CHOMP = 1, STASH= Template::Stash::XS-new, } ); return $self-{tt2}; } sub error_log { my ( $self, $level, $text ) = @_; return unless ($text); my $schema = $self-schema(); $schema-resultset('LogError')-create( { level = $level || 'debug', text = $text, time = \'NOW()',#' } ); } 1; __END__ =pod =head1 NAME Foorum::Adaptor::Base - base module =head2 AUTHOR Fayland Lam fayland at gmail.com =cut package Foorum::Adaptor::User; use strict; use