Re: [Catalyst] "Unknown column 'me.role'" error
On Sep 7, 2007, at 3:22 PM, Dustin Suchter wrote: Unfortunately I thought of that one already, and the two do match. Here's the useful YAML and below is the useful SQL just to double check. I believe the underlying MySQL engine is 4.1. # cat adblue.yml | grep -v "\s*#" --- name: AdBlue authentication: dbic: user_class: AdBlueDB::User user_field: username password_field: password authorization: dbic: role_class: AdBlueDB::User I think you meant AdBlueDB::Role for the role_class... role_field: role role_rel: map_user_role user_role_user_field: user_id -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] SMTP vs sendmail
On Aug 31, 2007, at 7:23 AM, Carl Johnstone wrote: SMTPing to localhost usually doesn't make much sence - it is slow and as you mentioned already it causes trouble when the daemon is down or slow. So either you want to do queueing overhead, dns resolving and SMTPing to the *remote* host yourself or you simply open(MAILER,"|sendmail @args"). Using |sendmail means you've got the overhead of forking a separate process, SMTP to localhost the overhead is making the socket connection. Once it gets to your MTA it'll pretty much do the same in either case. Except by piping to sendmail, you can also specify -odq, which says to sendmail 'dump this into the mail queue and return immediately, I don't want to wait for delivery to work' which can make the application much faster and leave the mail delivering to sendmail. Piping to sendmail also has the disadvantage that in many cases it'll leave [EMAIL PROTECTED] in the headers, using SMTP means your message doesn't get mangled. Not necessarily, if you don't manage the mail server you are connecting to, then your headers might get mangled anyway, if you do manage the mail server, then you can easily correct the configuration to not leave [EMAIL PROTECTED] in the headers. To be honest the best solution to to make use of your ISPs outgoing mail gateway/smarthost. It'll be the most reliable mail server on their network, and you've only got the overhead of an outgoing socket connect. The best solution would be to do both, use sendmail on the web server to deliver into a local mail queue which is forwarded to the smarthost for delivery. That way you get the advantage of having the mail server handle the mail, while freeing you from having to write your own version of sendmail to deal with these situations: * What does your application do if the smarthost is getting pounded by spammers and that outgoing socket connect fails? * What does your applicaiton do if the smarthost is down for maintenance or hardware failure? In both of these cases, if you were piping to sendmail and letting the local MTA handle the relay to the smarthost, then the mail would simply be queued until the mail server was available again. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] About output in a browser
On Aug 28, 2007, at 6:52 PM, lanas wrote: Can someone tell me why the output of the directory listing is not the same due to, apparently, the poresence of a print statement ? The print statement is being output before the document headers are. Without the print statement, you are getting a content-type of text/ html, which causes everything to run together since the lines are separated with newlines instead of tags. When you add the print statement, you are preventing the headers from being delivered correctly to the browser, and either the web server or the browser is deciding that since you didn't specify a content-type, it's going to default to text/plain. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] access stash outside methods
On Aug 21, 2007, at 3:48 PM, Aditya Verma wrote: Hi All, I want all of my controllers to register there respective URLs with description. this data will be used in template to create dynamic HTML pages. controllers will register URLs at catalyst startup. I have to store this data into variable (not in any file or database) which will be accessible in all the controllers. To get the registration work I have to write statement outside of all controller methods to execute the same at the time of catalyst startup. hope you guys can understand my requirement. Data that only gets registered at startup like this doesn't belong in the stash anyway, I usually do this with class data... package MyApp::Controller; use base qw( Catalyst::Controller ); __PACKAGE__->mk_classdata( 'url_descriptions' => {} ); sub describe_url { my ( $self, $url, $description ) = @_; my $class = ref( $self ) || $self; $class->url_descriptions->{ $url } = $description; } package MyApp::Controller::Root; use base qw( MyApp::Controller ); __PACKAGE__->describe_url( '/' => 'The Main Page' ); package MyApp::Controller::PageListing; use base qw( MyApp::Controller ); use Class::Inspector; sub assemble_url_descriptions { my ( $self ) = @_; my %descriptions = (); for my $class ( Class::Inspector->subclasses( 'MyApp::Controller' ) ) { while ( my ( $url, $desc ) = each %{ $class->url_descriptions } ) { $descriptions{ $url } = $desc; } } return \%descriptions; } -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] RFC: Multiple :Chained and/or :PathPart attributes?
7;) Args (0) { my ( $self, $c ) = @_; if ( $c->stash->{ 'matches' } ) { $c->stash->{ 'template' } = 'select_revision.tt'; } elsif ( $c->stash->{ 'page' } ) { $c->stash->{ 'template' } = 'display_page.tt'; } else { $c->stash->{ 'template' } = 'not_found.tt'; } } I tried to put together a patch that could do this, but this is my first trip into the innards of the dispatcher, and it looks like it's going to take a while to wrap my brain around it, so if anyone has suggestions on how to implement this (or reasons that it's a very bad idea) I'd love to hear them... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Rate limiting password attacks
On Aug 17, 2007, at 10:56 AM, Carl Johnstone wrote: Anyone doing something like this already? Suggestions? Caveats? You'll almost certainly have to log it per-IP address rather than an a cookie or session or anything like that. Any real password- cracking bot is unlikely to honour your cookies or session identifiers. Real password cracking bots tend to use gigantic lists of open proxies, which defeats the IP logging as well. Which in return means you'll need to be careful, you don't want to block AOL users from logging in, just because a few of them all forgot their passwords within a few minutes of each other. One way to try and avoid this problem, is to key it by IP and username, password cracking bots usually try one username with a dictionary of passwords, rather than one password with a dictionary of usernames. As an idea, how about adding an (increasing) artificial delay into the response when the clients send an invalid username/password. It would make things increasingly awkward for crackers, whilst still letting good users through. A suggestion though it wouldn't work very well in mod_perl or similar setups where you can't afford to tie up system resources holding onto client connections. Instead of delaying the response, one possibility is to send a complete response without a login form, just a note that says 'too many attempts, try again in X seconds', possibly with a refresh to reload the page once the timer expires. This way you don't hold the client connections open while waiting for the timer to expire, although then it means you have to track on the server side when that timer will expire so you can start delivering the form again. Adding a delay is useful for console applications, where the user is forced to wait for the delay before trying again, but not so useful for web applications, where a cracker can just hold a few thousand connections open while waiting for the delay to expire. I've been contemplating the best way to address this problem on some of my own sites, and unfortunately I always end up back at the CAPTCHA approach. I don't really like forcing users to solve a CAPTCHA every time they log in, but so far it's the only solution that I've come up with that doesn't also turn into a massive denial of service potential when people start intentionally sending bad passwords for people they don't like. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] t directory hierarchy
On Aug 15, 2007, at 11:43 AM, Matt S Trout wrote: On Wed, Aug 15, 2007 at 11:27:14AM +0100, Ian Docherty wrote: Hi I have been using Catalyst for some time with a 'flat' test directory, with all test scripts in the same directory. The main reason for this is that when I do $ make test It does not recurse into the sub-directories and only runs test scripts in the 't' directory. That's the default behaviour. To add subdirs, put tests('t/*.t t/*/*.t'); in your Makefile.PL Or, if you have a recent version of Module::Install, just use: tests_recursive; -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Test server as a child process
On Jul 31, 2007, at 7:15 AM, Ivan Fomichev wrote: 2007/7/31, Peter Edwards <[EMAIL PROTECTED]>: Try using IPC::Run. I can see the "You can connect" message when using it to run scripts/myapp_server.pl (I guess it goes through ptys?) I've found the root of the evil. IPC::Run won't help here :-( The pipe is not autoflushed. If you put '$|++' in script/myapp_server.pl, everything works all right. BTW, is there a way to force autoflush for a Perl script executed in a child process, e. g. through environment variables, command line options or whatever? Actually, IPC::Run will help, if you tell it to use pseudo-ttys instead of pipes for the communication. If perl belives it's output is going to a tty, then it won't buffer as it would if the output is a pipe. Using Expect or IO::Pty directly, or something else that makes the subprocess believe it is connected to a terminal will have the same effect... use IPC::Run qw( run ); run( "script/myapp_server.pl", 'pty>', $out_and_err ); -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Running MyAppB under MyAppA (only for developers)
On Jul 25, 2007, at 3:23 PM, Oleg Pronin wrote: I need to plug in application B in A, so it could extend A's actions under some namespace. I understand this is not so simple, but i have no other way. I write a dynamic admin interface (Uniadm) that will be plugged in to various projects. It will extend functionallity of a project it was plugged in to. Admin interface will be available under www.myappA_site/uniadm/. Both Uniadm and MyApp are catalyst projects itselves. Is there a better (easier) way to solve my problem? Not making the uniadm it's own project would make it much easier, instead just make it a controller base class you can inherit in each application that needs it. I have a similar "universal admin" controller that is built this way... package Admin::Base; use strict; use warnings; use base qw( Catalyst::Controller ); sub main : Chained( 'base' ) PathPart('') Args(0) { my ( $self, $c ) = @_; $c->stash->{ 'template' } = 'admin/index.tt2'; } sub list_objects : Chained('base') PathPart('list') Args(0) { ... } # more admin functions follow, all using chained dispatch methods... 1; Then in the project that needs an admin interface... package MyApp::Controller::Admin; use strict; use warnings; use base qw( Admin::Base ); sub base : Chained('/') PathPart('admin') Args(0) {} 1; -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [catalyst] conditional loading of Controllers and Models
On Jul 16, 2007, at 9:26 AM, Christopher H. Laco wrote: Matt S Trout wrote: On Mon, Jul 16, 2007 at 02:48:50PM +0200, Daniel McBrearty wrote: is there a way to have some C's and M's load into catalyst conditionally? for example, if some config variable is set? Exclude some of them with setup_components config. Or just do it via @INC manipulation - I use this a fair bit for testing. Depends what you're trying to achieve really, and you haven't told us :) Actually, this has me curious as well. In my case, I'd like to load "Setup" controllers only when someone passes a --setup arg...so they can use the web based config once, deliberately. After that, just loading the app wouldn't expose those controllers to the world accidentally. This is one technique that I've used for having controllers that are only enabled while in debug mode, seems simple enough to change the condition that disables it. Just put this in the controller class... sub register_actions { my ( $self, $c ) = @_; if ( ! $c->debug ) { return } return $self->SUPER::register_actions( $c ); } -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html::prototype syntax in new Cat version
On Jul 10, 2007, at 12:35 PM, John Wang wrote: I think one reason prototype keeps coming up is because HTML::Prototype exists and is the only wrapper providing Perl access to JS effects. HTML::Prototype doesn't seem to have a lot of functionality in it but it can get some small things going fast. If a HTML::$other_js_lib was created, especially with the same API, Prototype usage would probably stop. A HTML::JQuery might be useful. Just a thought. http://search.cpan.org/~peterg/JQuery-1.06/ http://search.cpan.org/~cfranks/HTML-Dojo-0.0403.0/ http://search.cpan.org/~bct/CGI-Ajax-0.701/ -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anyone using ProxyPass?
On Jul 3, 2007, at 11:21 AM, Bill Moseley wrote: On Tue, Jul 03, 2007 at 11:24:34AM +0100, Richard Jones wrote: 1) There is definitely no $c->request->header('X-Forwarded-Host') Check if you have X-Forwarded-For. Also check the version of Apache if you are running 1.3, this wasn't added until 1.3.25. Let's see, I have not looked at this in a while but in apache2 I have: LoadModule proxy_module /usr/lib/apache2/modules/ mod_proxy.so LoadModule proxy_http_module/usr/lib/apache2/modules/ mod_proxy_http.so ProxyViaOn ProxyReceiveBufferSize 16384 I guess I'm using mod_rewrite to figure out what does or doesn't need to be sent to the back end -- so after all my rewrite rules and conditions I have: # Proxy everything else RewriteRule (.+) http://127.0.0.1:10085$1 [proxy] After that I guess you are stuck figuring out why you are not getting that header. 2) In Catalyst::Engine::Apache::prepare_path, $host = the IP address of the server (not localhost or 127.0.0.1), and $port = 81. Did you see this code? PROXY_CHECK: { my $headers = $self->apache->headers_in; unless ( $c->config->{using_frontend_proxy} ) { last PROXY_CHECK if $c->request->address ne '127.0.0.1'; last PROXY_CHECK if $c->config->{ignore_frontend_proxy}; } last PROXY_CHECK unless $headers->{'X-Forwarded-For'}; # If we are running as a backend server, the user will always appear # as 127.0.0.1. Select the most recent upstream IP (last in the list) my ($ip) = $headers->{'X-Forwarded-For'} =~ /([^,\s]+)$/; $c->request->address( $ip ); } If your address isn't 127.0.0.1 then it's not going to check for a proxy unless "using_frontend_proxy" is set. -- Bill Moseley [EMAIL PROTECTED] ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/ catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Template rendering error under mod_perl
On Jun 29, 2007, at 5:47 AM, Richard Jones wrote: Having developed my application sufficiently to see it working well so far, I though I should configure it to run under mod_perl. I have used the TTSite helper to generate the templates. The app runs fine using myapp_server.pl, but under mod_perl I get the following: Depending on how you installed it under mod_perl, you may find that you need to set 'home' in your configuration for path_to to work, if you don't explicitly set the path to the home directory, Catalyst will try to figure it out by looking for your Makefile.PL/Build.PL or by figuring out where the libraries are installed, but that may not be the correct location for your root directory. Take a look at Catalyst::Utils for the home method to see how it figures it out... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Custom error
On Jun 26, 2007, at 12:45 PM, Brian Kirkbride wrote: Jason Kohles wrote: On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote: Yes, that's what I meant, thanks Brian. Please provide a code example using RenderView action. I think it would also make sense to incorporate that example into the Catalyst cookbook instead of existing one since that one's incomplete. Something like this... sub render : ActionClass('RenderView') { } sub end : Private { Or even this: sub render : ActionClass('RenderView') {} sub end : Private { my ($self,$c) = @_; $c->forward('render'); if (my @errors = @{$c->errors}) { $c->errors(0); $c->stash->{template} = 'error.tt'; $c->stash->{errors} = [EMAIL PROTECTED]; $c->forward($c->view('TT')); } } To allow for a templated error page. The original question was how to deal with the view failing. If your view is broken, you probably don't want to try and use it to render the error... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Custom error
On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote: Yes, that's what I meant, thanks Brian. Please provide a code example using RenderView action. I think it would also make sense to incorporate that example into the Catalyst cookbook instead of existing one since that one's incomplete. Something like this... sub render : ActionClass('RenderView') { } sub end : Private { my ( $self, $c ) = @_; $c->forward( 'render' ); if ( my @errors = @{ $c->errors } ) { $c->response->content_type( 'text/html' ); $c->response->status( 500 ); $c->response->body( qq{ Error! Oh no! An Error! } . ( map { "$_" } @errors ) . qq{ } ); } } I think what Evaldas means is that an error (template not found, etc) in the View rendering stage will not be caught by the method in the Cookbook. I am away from my code at the moment, but IIRC the trick is to check $c->error AFTER you forward to MyApp::V::TT (or after the RenderView action) and then setup your error.tt template and forward to the view again. If that doesn't make sense I can provide a code example later. -- - Evaldas Imbrasas http://www.imbrasas.com ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/ catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] test server with -host
On Jun 18, 2007, at 6:38 PM, Daniel McBrearty wrote: Hi trying to run the test server and see it on another machine. ./script/myapp_server.pl -help tells me it should bind to all by default, but when I run it with no host option, I can only see it at localhost, not at the ip for the machine (I can see other webservers on this machine). It does bind everything by default, if you can't access it from another host I'd start by looking at things like hostbased-firewalls on your development machine... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Template creates objects via belongs_to autovivification
On Jun 13, 2007, at 8:17 AM, Matt Rosin wrote: The thing is, then I decided to let admins add new transactions without an associated customer, to record in the database transactions that were made offline. Instead of assigning r.customer to the id of the company running the system I just say 0 (not using nulls). What happens is, somehow the template forces Catalyst (DBIx::Class) to create a NEW CUSTOMER if there wasn't one already. This is bad, bad, bad. Every time an admin views the list of transactions, it seems I get 4 blank customer records silently added simultaneously, or maybe even more, depending on what kind of records are shown on the current page it seems. I discovered this by matching the FastCGI error log (which is where the -Debug output goes.. all 300MB of it...) against the modification date of the new customer records. The relationship docs imply that belongs_to will do the right thing if the relationship is optional, but also indicates that it determines if the relationship is optional by whether the foreign key can be NULL or not, if you have defined that column as NOT NULL, you may be running into problems If the relationship is optional -- i.e. the column containing the foreign key can be NULL -- then the belongs_to relationship does the right thing. Thus, in the example above "$obj->author" would return "undef". However in this case you would probably want to set the "join_type" attribute so that a "LEFT JOIN" is done, which makes complex resultsets involving "join" or "prefetch" operations work correctly. The modified declaration is shown below: # in a Book class (where Author has_many Books) __PACKAGE__->belongs_to(author => 'My::DBIC::Schema::Author', 'author', {join_type => 'left'}); -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] syntax
On Apr 16, 2007, at 4:24 PM, Will Smith wrote: Hi, I want to do a search on a table which contains a where clause greater than, and tried what I can think of but none work. This might not a place for this type of question, but I hope that some of you could spend a minute to help me out. Just a simple search: select * from books where id > '3'; $c->stash->{book} = [$c->model('myAppDB::Book')->search( ... ?? $c->model( 'myAppDB::Book' )->search( id => { '>' => 3 } ); -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] HOWTO reference config settings from template
On Apr 12, 2007, at 1:01 PM, Jeff Chimene wrote: The config is called in the View package (fori::View::Menu) I was hoping to set TT2 values /per package/ via the config as created by the TT2 helper. It looks like (after DEBUG => 'all') that TT2 only references the stash when it resolves variables. What is the problem you are trying to solve? Changing the template processor configuration from within a template that it is currently processing doesn't seem wise to me. That being said, the reason that only the stash variables are accessible is because they are all that are provided to TT by default... package MyApp::View::TT; sub template_vars { my ( $self, $c ) = @_; my %vars = $self->SUPER::template_vars( $c ); $vars{ 'ttconfig' } = $self->config; return %vars; } -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: [EMAIL PROTECTED] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Custom finalize_error
On Apr 2, 2007, at 5:39 PM, Jim Spath wrote: Jim Spath wrote: Jason Kohles wrote: On Apr 2, 2007, at 4:13 PM, Jim Spath wrote: I wanted to get rid of the "Please come back later" error page, so I defined my own finalize_error() in MyApp.pm as mentioned in this post: http://www.mail-archive.com/catalyst@lists.rawmode.org/ msg04542.html It looks like: sub finalize_error { my ($self, $c) = @_; $c->stash->{'template'} = 'error.tt2'; } The "Please come back later" page no longer appears, but now the page is simply blank. I've double checked to make sure the error.tt2 template is accessible via Catalyst and it is, so I'm unsure where to go from here. finalize_error is called long after the view processing has already been done, if you want to use a template to put a page there, you have to build your own Template object and process the template yourself. Ah. Great, thanks! I got it to work with the following code: sub finalize_error { my ($c) = @_; $c->response->content_type('text/html; charset=utf-8'); $c->response->body($c->view('Website')->render($c, 'error.tt2')); $c->response->status(500); } As an aside, what are the advantages/disadvantages of defining my own finalize_error() instead of handling errors in end() as described in the Catalyst Cookbook: http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/ Cookbook.pod#Delivering_a_Custom_Error_Page Dealing with errors in finalize_end allows you a chance to get at errors you might not otherwise have been able to handle (such as dispatch failures that prevent your end method from being called, problems in the end method itself, problems in the View, etc). In your case you negate some of this benefit by using the view to render your error page, which means your error handler can't handle any problems that may occur with the view. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Custom finalize_error
On Apr 2, 2007, at 4:13 PM, Jim Spath wrote: I wanted to get rid of the "Please come back later" error page, so I defined my own finalize_error() in MyApp.pm as mentioned in this post: http://www.mail-archive.com/catalyst@lists.rawmode.org/msg04542.html It looks like: sub finalize_error { my ($self, $c) = @_; $c->stash->{'template'} = 'error.tt2'; } The "Please come back later" page no longer appears, but now the page is simply blank. I've double checked to make sure the error.tt2 template is accessible via Catalyst and it is, so I'm unsure where to go from here. finalize_error is called long after the view processing has already been done, if you want to use a template to put a page there, you have to build your own Template object and process the template yourself. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Sending email
On Apr 2, 2007, at 6:10 AM, Dave Richards wrote: Hi all, To get the first obvious point out of the way, yes, I'm a newbie to Catalyst... I have developed a good little app, on the way to a much larger app using Catalyst, and it is all going along greatthen, I decided to add email notifications to the system, that's when I have come unstuck. I really am still getting my head around Catalyst, so I apologise if this is a really dumb question. I need to send an email from within a function, here is the code snippet: $c->email( header => [ To => $result->params->{email}, Subject => 'User Registration' ], body => $c->view('TT')->render($c,'email/registered'), ); And here is the error message: Caught exception in Arkadia::Controller::Users->register_do "Not a SCALAR reference at /Library/Perl/5.8.6/Email/Simple.pm line 195." I would suspect that render is returning a Template::Exception object, and since you aren't checking the return value, you are passing that on to Email::Simple, which doesn't know what to do with it... my $body = $c->view( 'TT' )->render( $c, 'email/registered' ); if ( ref $body && $body->isa( 'Template::Exception' ) ) { die "Rendering template failed! ($body)"; } $c->email( header => [ To => $result->params->{email}, Subject => 'User Registration', ], body => $body, ); -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Where and how to access database
On Mar 21, 2007, at 7:43 AM, Mario Minati wrote: Am Mittwoch 21 März 2007 11:39 schrieb Stephan Austermühle: The database tables are being loaded dynamically by Catalyst::Model::DBIC::Schema/ DBIx::Class::Schema::Loader. I read that I can get the DBH via $schema->storage->dbh -- but where do I get $schema from? my $dbh = $c->model( 'MyModel' )->schema->storage->dbh; Just be sure you don't hold onto the handle for too long, or strange things can happen (especially in a persistent environment). In the table class I can create custom functions to alter or get the resultsets. How complex can a query be that you want the DBI handle? With DBIC you can do almost everything, e.g. multi table joins, creating aliases with user defined functions and procedures. At least for me that's all I want :) There is at least one thing that I've used this for that DBIx::Class can't do (or at least I couldn't figure out how at the time I needed to do it)... $c->model( 'MyModel' )->schema->storage->dbh->do( "NOTIFY update_listener" ); -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] YAML config embedded path_to mysql_read_default_file
On Mar 18, 2007, at 7:26 PM, apv wrote: So, I would like to use a mysql connection file instead of putting the password and user in the config file. Can I get a path_to to work with this? I did Google and check the lists but couldn't find an answer. Where the "__HERE__" is is where the mysql_read_default_file=(path_to) goes. Model::DBIC: schema_class: MyApp::Schema::DBIC connect_info: - "dbi:mysql:opendevil;__HERE__;" - ~ - ~ If you are using Catalyst::Plugin::ConfigLoader to load your configuration (if you aren't sure then you probably are, it's the default), then you can do this... Model::DBIC: schema_class: MyApp::Schema::DBIC connect_info: - dbi:mysql:opendevil;mysql_read_default_file=__path_to (configfile.cfg)__ -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Catalyst::Manual::Tutorial::CatalystBasics [error]Couldn't render template "undef error - status_msg is undefined
On Mar 15, 2007, at 7:49 AM, [EMAIL PROTECTED] wrote: It was my hope that this warning would help people remember to turn it off: NOTE: Please be sure to disable TT debug options before continuing the tutorial (especially the 'undef' option -- leaving this enabled will conflict with several of the conventions used by this tutorial and TTSite to leave some variables undefined on purpose). Let me know if anyone has a suggestion on how to improve the wording. Maybe I will change "TIP: When troubleshooting TT it can be helpful to enable variable DEBUG options." to "TIP: When troubleshooting TT it can be helpful to enable variable DEBUG options (you can experiment now, but please remove these options before continuing the tutorial)." to essentially create a "warning sandwich" before and after the example. Maybe using an example other than 'undef' would cause fewer problems. # This might be a good option for a debugging example... DEBUG => 'dirs', DEBUG_FORMAT => '', -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Catalyst::Manual::Tutorial::CatalystBasics [error] Couldn't render template "undef error - status_msg is undefined
On Mar 14, 2007, at 12:51 AM, David Christensen wrote: I'm now on tutorial 2 of 9, and have run the various scripts, entered modules and templates, etc., as directed for the books database example. When I fire up the development server and browse to: http://p3800.holgerdanske.com:3000/books/list The server says: [error] Couldn't render template "undef error - status_msg is undefined It looks like you've turned on debugging in Template, either DEBUG_UNDEF or DEBUG_ALL (which gets you all the debugging options, including UNDEF.) DEBUG_UNDEF is helpful if you want to make sure you don't have any undefined variable values in your templates, but the way most people use templates is to just leave anything they don't need filled in empty. One option if you want to keep DEBUG_UNDEF enabled, but not have it throw an error for things like status_msg and error_msg that might reasonably be blank is to do something like this in your view... my @dont_leave_blank = qw( status_msg error_msg ); sub template_vars { my ( $self, $c ) = @_; my %vars = $self->NEXT::template_vars( $c ); foreach my $x ( @dont_leave_blank ) { if ( ! defined $vars{ $x } ) { $vars{ $x } = q{} } } return %vars; } -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anybody using Chained('.') ?
On Mar 13, 2007, at 10:41 AM, Robert 'phaylon' Sedlacek wrote: Jason Kohles wrote: I'm trying to use Chained('.') to create a controller base class that binds to the namespace of whatever controller class inherits it, but despite the documentation specifically mentioning this use, I can't seem to get it to work. Where does the documentation say that? In Catalyst::DispatchType::Chained it says Another interesting possibility gives :Chained('.'), which chains itself to an action with the path of the current controller's namespace. Apparently I misunderstood the relationship between Chained and PathPart, and therefore misunderstood what the documentation was saying here. So now the way I understand it is that Chained('.') means to setup a chain segment that has as it's parent the chain segment that matches the current controller's namespace. Apparently what I'm actually looking for is the equivalent of Chained('/') PathPart('.'), meaning I want to build chains that originate in the current namespace. What I'm actually trying to accomplish is something like this: package MyApp::CRUDController; use strict; use warnings; use base 'Catalyst::Controller'; # sub base : Chained(???) PathPart(???) CaptureArgs(0) { } sub id : Chained('base') PathPart('id') CaptureArgs(0) { } sub list : Chained('base') PathPart('') Args(0) { } sub view : Chained('id') PathPart('view') Args(0) { } sub edit : Chained('id') PathPart('edit') Args(0) { } sub delete : Chained('id') PathPart('delete') Args(0) { } 1; package MyApp::Controller::Foo; use strict; use warnings; use base 'MyApp::CRUDController'; # So here I would like to get these chained actions: # /foo/list # /foo/id/*/view # /foo/id/*/edit # /foo/id/*/delete 1; But the only way I can find to do this with Chained is by putting something like this in each controller subclass: sub base : Chained('/') PathPart('foo') CaptureArgs(0) { } And I would rather not do that if I can avoid it, I'd rather have it automatic, based on the namespace of the class that is inheriting the superclass. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Anybody using Chained('.') ?
I'm trying to use Chained('.') to create a controller base class that binds to the namespace of whatever controller class inherits it, but despite the documentation specifically mentioning this use, I can't seem to get it to work. I minimized the problem down to this simplest of examples... % catalyst.pl Test % cd Test % cat < lib/Test/Controller/Foo.pm package Test::Controller::Foo; use strict; use warnings; use base 'Catalyst::Controller'; # This doesn't work sub base : Chained('.') PathPart('') CaptureArgs(0) { } sub arghhh : Chained('base') PathPart('') Args(0) { } # This doesn't work either sub foo : Chained('.') PathPart('foo') Args(1) { } 1; END % script/test_server.pl When it starts up, I get this... [debug] Loaded Private actions: .--+-- +--. | Private | Class| Method | +--+-- +--+ | /default | Test::Controller::Root | default | | /end | Test::Controller::Root | end | | /foo/base| Test::Controller::Foo| base | | /foo/arghhh | Test::Controller::Foo| arghhh | | /foo/foo | Test::Controller::Foo| foo | '--+-- +--' [debug] Loaded Chained actions: .- +--. | Path Spec | Private | +- +--+ '- +--' And I don't seem to be able to get any chained actions working unless they are chained to a specific path... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Performance
On Mar 9, 2007, at 10:04 AM, Robert 'phaylon' Sedlacek wrote: Christopher H. Laco wrote: Sure, it they're that different. The goal still stands, don't use uri_for everywhere. Only use it when you really need it. Jep. But this is not getting easier if you start to have captures in your chains. I'm still having high hopes to build something fast (er) with URI::Template. I actually built something to do this just this weekend, because I had some big tables that were calling uri_for more than once for every row of the table. I ended up doing something like this... In the controller... $c->stash->{ 'uri_templates' }->{ 'id' } = $c->req->uri_with ( { object_id => '[*id*]' } )->as_string; In the template [% WHILE ( row = resultset.next ) %] [% FOR col IN columns %] [% IF uri_templates.$col %] [% action_link( uri_templates.$col, row ) %] [% ELSE %] [% row.$col %] [% END %] [% END %] [% END %] Elsewhere... sub action_link { my ( $template, $object ) = @_; while ( $template =~ /\[\*(\w+)\*\]/ ) { my $i = $1; my $rep = $object->$i(); $template =~ s/\[\*$i\*\]/$rep/g; } return $template; } I actually looked at URI::Template, and the one major issue I had with it was the choice of { and } as the template indicator characters, you can't do $c->req->uri_with( { foo => '{bar}' } ), since URI will escape the { and }, and your template will end up saying %7Bbar%7D instead of {bar}. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Catalyst::Plugin::DateTime
On Mar 10, 2007, at 12:14 AM, Bill Moseley wrote: On Sat, Mar 10, 2007 at 06:33:22AM +0200, Octavian Rasnita wrote: Hi, I have tried to install Catalyst::Plugin::DateTime under Windows using the cpan shell, but I have recieved the error below. I have also previously set the environment variable TZ=+02:00 but it still can't find the time zone. Is there anything I can do to install this Catalyst Plugin under Windows? What does that plugin offer over the standard DateTime module? Nothing except the ability to say $c->datetime or $c->dt. In fact, this is the entirety of the code of the module sub datetime { my $c = shift; my %params = @_; my $tz = delete $params{time_zone} || 'local'; # use params if argued if (%params) { return DateTime->new(\%params)->set_time_zone($tz); } else { # otherwise use now return DateTime->now(time_zone => $tz); } } # alias $c->dt *dt = \&datetime; -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html mail (was: reserved words)
On Mar 8, 2007, at 5:09 AM, Goetz Bock wrote: Dear subscribers, while totally of topic, could you please _try_ to write mails that can be read with a good old text (as in text/plain) only mail reader? [snip] I've intentionally placed my part on top, as it's unrelated to the thread. And I've kept an edited and annotated version of the mail I replied to underneath to illustrate how it looks in my MUA (mutt). Ok, so you don't like the way this mail is displayed by your mail reader, and therefore in order to get mail displayed in your mail reader the way you want it, the rest of the world must change? -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] reserved words
On Mar 6, 2007, at 12:02 PM, Octavian Rasnita wrote: Hi, Please tell me how can I find the list of reserved words that cannot be used as names for views, controllers, models, $c->stash elements... For example I have seen that the name of the application is also found in $c->stash->{name}. $c->stash->{template} is also special. I have also tried to create a view with the name "Show", and I have received the following error in the browser: Caught exception in TranzactiiBursiere::View::Show->process "TranzactiiBursiere::View::Show directly inherits from Catalyst::View. You need to inherit from a subclass like Catalyst::View::TT instead. If I changed the name of that view to "Html", it worked fine, with no errors... This is the error message you get if you create a subclass of Catalyst::View that doesn't implement a process() method. It probably doesn't have anything to do with the name of the module... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Accessing $c from Model
On Mar 5, 2007, at 7:02 AM, Scott Thomson wrote: Ok, I think I'm close... My main schema class: package DB; use base qw/DBIx::Class::Schema DBIx::Class::AccessorGroup/; __PACKAGE__->mk_group_accessors(simple => 'context'); __PACKAGE__->load_classes(qw//); 1; Very Bad Things are likely to happen if you ever attempt to run your application under the debugger when you have a package named 'DB'. I'd recommend using a different name... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Role problem
On Feb 25, 2007, at 9:32 PM, Ivan Wills wrote: Hi, I'm trying to use Roles with DBIC user storage. When I try to use $c->assert_user_roles('Admin'); I get the following error message: Caught exception in App::JumboRewards::Controller::MyAccount->test "DBIx::Class::ResultSet::all(): Error executing 'SELECT me.role FROM role me LEFT JOIN member_role map_member_role ON ( map_member_role.role_id = me.role_id ) WHERE ( map_member_role.member_alias = ? AND me.role IN ( ? ) )': ERROR: column map_member_role.member_alias does not exist" It looks like to me something is not joining to the member table when it should but I am not sure where to look. My setup is fairly similar to the example given at the end of Catalyst::Plugin::Authentication::Store::DBIC, with table and column names changed to match my companies coding standards. Any suggestions on what I have done wrong? Your configuration says the userid field in the mapping class is called 'member_alias', but your MemberRole class doesn't have a field with that name. I suspect you wanted __PACKAGE__->config-> {authorization}->{dbic}->{user_role_user_field} = 'memeber_id'; package App::JumboRewards::Schema::MemberRole; __PACKAGE__->add_columns( qw/member_role_id member_role_created member_id role_id/ ); __PACKAGE__->config( authorization => { dbic => { user_role_user_field => 'member_alias', }, }, ); -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Date::Calc and Date::Calendar with Catalyst?
On Feb 24, 2007, at 6:22 PM, Dave Morriss wrote: On 23/02/07, Jonathan Rockway <[EMAIL PROTECTED]> wrote: Dave Morriss wrote: > Question 1: Will I need to build my own plugin to achieve what I want, > or is there another way? It's unlikely that you'll want to use a plugin. Plugins should be reserved for things that modify Catalyst's usual request cycle. Pagecache, Static::Simple, and ConfigLoader are good examples of plugins; Prototype is a bad example. I thought, based on the way C::P::DateTime is put together, that plugins are also used as a way of making non-Catalyst modules available in the Catalyst namespace. From the way I interpret the documentation you referred to I reckon I _could_ do something like that. You seem to be recommending against it. Catalyst::Plugin::DateTime is a very good example of something that has no business being a plugin. It pollutes the namespace with not one, but two useless methods (that do the exact same thing, no less) and gains nothing from being a plugin, it could very easily have been a module (in fact, take a look at the source, it does almost nothing anyway). -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Foreign keys and DBIC
On Feb 22, 2007, at 5:29 PM, RA Jones wrote: Hi folks, I'm not getting it with foreign keys in DBIC. For example, table users has a column called location_id, which pulls the location from the locations table like so: select u.user, l.location from users u, locations l where u.location_id = l.location_id A location has many users, so in DB::Location : __PACKAGE__->has_many(users => 'DB::User', 'location_id'); No has_many/belongs_to mappings specified in DB::Users. Then, in a method in MyApp::Controller::Users : $c->stash->{user} = $c->model('DB::User')->find($id); $c->stash->{template} = 'users/view.tt2'; But the rendered view just shows location_id, not location. I obviously don't quite get it and have missed something here. Do I have to manually map location_id to location in either M, V or C? You have setup your relationships so that a location has_many users, and that is it, the relationship only goes one way. If you want the field in DB::User to refer back to the location, you also need a belongs_to relationship in your user class. Then I read in an article called 'Catalyst vs Rails vs Django Cook off' that "Catalyst's DBIC ORM supports multi-column primary keys and can do relationship mapping just by reading the schema! You don't even have to bother writing any has_many belongs_to definitions!" Exactly what I would like to do (like CDBI::Loader::Relationship? eg "a brewery produces beers"), but how so with DBIC? See DBIx::Class::Schema::Loader -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] unicode best practices
On Feb 16, 2007, at 6:19 AM, Dave Howorth wrote: Jonathan Rockway wrote: Also, read http://www.catalystframework.org/calendar/2006/21 for unicode details. Nice page, thanks. I'm puzzled by one sentence: $1, in this example, will contain the first character in the string. This intuitive if the string is something like "abcde", but it also holds true for a string like ???. Is '???' supposed to appear like that? If so, I don't understand the point. If not, is something broken on my end or the server end? I wondered the same thing, so I pulled the advent calendar sources from subversion, and in the .pod it's literally C, so it appears it is supposed to be like that, and I don't get the point either... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: looping
On Feb 14, 2007, at 12:21 PM, A. Pagaltzis wrote: Hi Ian, * Ian Docherty <[EMAIL PROTECTED]> [2007-02-14 16:40]: A. Pagaltzis wrote: * Will Smith <[EMAIL PROTECTED]> [2007-02-12 21:25]: my $column = $c->model("myDB::Author")->get_column('last_name'); while(my $name = $column->next){ $lname[$i] = $name; $i = $i + 1; } Ugh. Use `push`; this isn’t C. Or 'map' That won’t work here, since there’s no list to process, just an iterator. (I always thought List::Util should supply `unfold`…) Of course map, push, and everything else is kind of pointless anyway... my @name = $c->model( 'myDB::Author' )->get_column( 'last_name' )->all; -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Using C::P::A::ACL and C::M::FormBuilder together?
On Feb 12, 2007, at 4:36 PM, Troy Davis wrote: Changing from Private to Action allows the forward to work, but now the ACL is no longer enforced (although I can see the rule being loaded in the debug output). This isn't unexpected, the C::P::A::ACL docs say it only works with Private. You've misunderstood what it means when it says it 'only works with Private', it means that if you have a sub like this: sub foo : Path('bar') { } Then the ACL can only be addressed by the name 'foo', not 'bar'. There is no reason to split your functions up like this. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Chained action confusion...
I've been converting a big chunk of my next Catalyst application to Reaction, and have run into an issue with :Chained that seems strange to me, after working with it for a while I've managed to turn it into a tiny little example, hopefully small enough that someone can spot what I'm doing wrong... I've got a basic catalyst application right from the helper (catalyst.pl Test), and the only thing I modified is the root controller: package Test::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub base : Chained('/') PathPart('') CaptureArgs(0) { my ( $self, $c ) = @_; push( @{ $c->stash->{ 'path' } }, 'base' ); } sub index : Chained('base') PathPart('') Args(0) { my ( $self, $c ) = @_; push( @{ $c->stash->{ 'path' } }, 'index' ); } sub foo : Chained('base') PathPart('foo') Args(0) { my ( $self, $c ) = @_; push( @{ $c->stash->{ 'path' } }, 'foo' ); } sub end : ActionClass('RenderView') { my ( $self, $c ) = @_; $c->response->body( join( ' / ', @{ $c->stash->{ 'path' } } ) ); } 1; When Catalyst starts up, it shows me these chained actions: [debug] Loaded Chained actions: .- +--. | Path Spec | Private | +- +--+ | /foo| /base (0)| | | => / foo | | | /base (0)| | | => / index| '- +--' Which is as it should be, calls to http://myapp/ should go through "/ base(0) => /index" and calls to http://myapp/foo should go through "/ base(0) => /foo". When I load up /foo in a browser, I get the expected response: [info] *** Request 2 (0.333/s) [17853] [Sat Feb 10 08:23:51 2007] *** [debug] "GET" request for "foo" from "127.0.0.1" [debug] Path is "/foo" [info] Request took 0.007484s (133.618/s) . +---. | Action | Time | + +---+ | /base | 0.52s | | /foo | 0.31s | | /end | 0.000173s | ' +---' And the output in the browser is "base / foo", just like I wanted. However, when I hit the index, it skips right over the base action: [info] *** Request 3 (0.375/s) [17853] [Sat Feb 10 08:23:53 2007] *** [debug] "GET" request for "/" from "127.0.0.1" [info] Request took 0.005970s (167.504/s) . +---. | Action | Time | + +---+ | /index | 0.33s | | /end | 0.000152s | ' +---' And the output to the browser is just "index". This seems to happen with any chained action where the pathpart is '', in the full application I have other -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Chained action confusion...
I've been converting a big chunk of my next Catalyst application to Reaction, and have run into an issue with :Chained that seems strange to me, after working with it for a while I've managed to turn it into a tiny little example, hopefully small enough that someone can spot what I'm doing wrong... I've got a basic catalyst application right from the helper (catalyst.pl Test), and the only thing I modified is the root controller: package Test::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub base : Chained('/') PathPart('') CaptureArgs(0) { my ( $self, $c ) = @_; push( @{ $c->stash->{ 'path' } }, 'base' ); } sub index : Chained('base') PathPart('') Args(0) { my ( $self, $c ) = @_; push( @{ $c->stash->{ 'path' } }, 'index' ); } sub foo : Chained('base') PathPart('foo') Args(0) { my ( $self, $c ) = @_; push( @{ $c->stash->{ 'path' } }, 'foo' ); } sub end : ActionClass('RenderView') { my ( $self, $c ) = @_; $c->response->body( join( ' / ', @{ $c->stash->{ 'path' } } ) ); } 1; When Catalyst starts up, it shows me these chained actions: [debug] Loaded Chained actions: .- +--. | Path Spec | Private | +- +--+ | /foo| /base (0)| | | => / foo | | | /base (0)| | | => / index| '- +--' Which is as it should be, calls to http://myapp/ should go through "/ base(0) => /index" and calls to http://myapp/foo should go through "/ base(0) => /foo". When I load up /foo in a browser, I get the expected response: [info] *** Request 2 (0.333/s) [17853] [Sat Feb 10 08:23:51 2007] *** [debug] "GET" request for "foo" from "127.0.0.1" [debug] Path is "/foo" [info] Request took 0.007484s (133.618/s) . +---. | Action | Time | + +---+ | /base | 0.52s | | /foo | 0.31s | | /end | 0.000173s | ' +---' And the output in the browser is "base / foo", just like I wanted. However, when I hit the index, it skips right over the base action: [info] *** Request 3 (0.375/s) [17853] [Sat Feb 10 08:23:53 2007] *** [debug] "GET" request for "/" from "127.0.0.1" [info] Request took 0.005970s (167.504/s) . +---. | Action | Time | +-------- +---+ | /index | 0.33s | | /end | 0.000152s | ' +---' And the output to the browser is just "index". -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] MyAction for locally namespaced ActionClasses?
On Feb 8, 2007, at 1:58 PM, John Napiorkowski wrote: Hi, The manual file for Actions at http://search.cpan.org/~jrockway/Catalyst-Manual-5.700501/lib/ Catalyst/Manual/Actions.pod mentions that when you are adding Action classes to an action, you can use "MyAction" instead of "ActionClass" if the Action class is in the local namespace. I can't seem to make this work no matter what I try and grepping the source code doesn't turn up any responses for MyAction. Is this an error in the docs, or maybe the docs being too prescient? Or am I just not using it correctly? IF anyone has a working example of this, please let me know. I tried using it without success too, and came to the conclusion that it doesn't seem to have actually been implemented. When I ran across this issue I tried grepping the entire subversion repository for 'MyAction', and only found it in Catalyst-Manual. I didn't have time to look into it any deeper than that though... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Bread crumb
On Feb 7, 2007, at 11:30 AM, Peter Karman wrote: Jason Kohles scribbled on 2/6/07 8:33 AM: It still feels a little kludgy, but this is how I'm doing it currently... [...] fwiw, that is pretty close to how http://search.cpan.org/~tigris/Catalyst-Plugin-Breadcrumbs-5/lib/ Catalyst/Plugin/Breadcrumbs.pm does it. After looking at that I suspect that I simply stole the code from there and made a few modifications over time. I still don't much like the way that it is working especially now that I'm starting to get into Reaction and my breadcrumb code is generating a trail that links to invalid URLs. Since I've switched to using almost entirely :Chained paths, I'm considering an approach like Reactions - >push_controller, where each step in the chain can have the option to push a breadcrumb entry onto a stack... I have been using a (modified) version of C::P::Breadcrumbs for a while and it works ok. I haven't had any major complaints about it, I think the only reason I stole the code instead of using the module was that I didn't like that it built the breadcrumb trail from join('/', $c->namespace, $action), so I modified it to use $c->req->path instead.. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Bread crumb
On Feb 6, 2007, at 5:26 AM, Gert Burger wrote: Hi Can someone who has implemented "bread crumbs" using catalyst please share their methods/problems etc. I need to implement it but I stuck between different implementation techniques and would like to learn from other people's experience. It still feels a little kludgy, but this is how I'm doing it currently... package MyApp::View::TT; sub template_vars { my ( $self, $c ) = @_; my %vars = $self->SUPER::template_vars( $c ); $vars{ 'site' }->{ 'breadcrumbs' } = $self->breadcrumbs( $c ); return %vars; } sub breadcrumbs { my ( $self, $c ) = @_; my @breadcrumbs = (); my @paths = split( '/', $c->req->path ); while ( my $label = pop( @paths ) ) { next if $label eq 'index'; my $path = join( '/', @paths, $label ); $path = "/$path" unless $path =~ m#^/#; $label = $self->label_for( $c, $path, $label ); unshift( @breadcrumbs, { path => $path, label => $label, uri => $c->uri_for( $path ), } ); } unshift( @breadcrumbs, { path => '/', label => 'My Application', uri => $c->uri_for( '/' ), } ); return [EMAIL PROTECTED]; } sub label_for { my ( $self, $c, $path, $label ) = @_; if ( my $x = $c->config->{ 'breadcrumbs' }->{ $path } ) { return $x; } $label = join( ' ', map { ucfirst } split( /[_-]/, $label ) ); return $label; } 1; [% FOREACH item IN site.breadcrumbs %] [% IF loop.last %] [% title or template.title or item.label %] [% ELSE %] [% item.label %] >> [% END %] [% END %] -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Reaction Development?
On Feb 5, 2007, at 5:58 PM, John Napiorkowski wrote: Hi, Is there a test suite for Reaction other than the sample application at the source control site? Because I have a patch to fix a problem with the DBIC action reflector not properly creating actions for DBIC classes in a deep hierarchy (like myschema::membership::members) but since I could never get the sample app to run I can't write a test for the problem (and I know a patch without a test won't be accepted). Any chance you could share the patch even though it doesn't have tests yet? I've been looking for this bug off and on for the last three or four days, it's been driving me crazy... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] getting the role id
On Feb 4, 2007, at 6:52 AM, Octavian Rasnita wrote: Hi, Is it possible to get the id of the roles of the current user from $c->user? I found that I can get the role names using $c->user->roles, but I need the id of those roles. Do I need to make another query to the database for finding this? If you are using the normal many-to-many method for mapping roles, something like this: User->has_many( 'map_user_role', 'User::Role', 'user_id' ); User->many_to_many( 'roles', 'map_user_role', 'role' ); Then you can get the roles objects with $c->user->roles, and the User::Role objects with $c->user->map_user_role. -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can we use both TT and TTsite at the same time
On Nov 8, 2006, at 10:10 AM, Bill Moseley wrote: On Wed, Nov 08, 2006 at 08:18:49AM -0500, Jason Kohles wrote: site/wrapper: [% IF template.name.match('\.(css|js|txt)') OR nowrap OR template.nowrap; debug("Passing page through as text: $template.name"); content; Is your css and javascript dynamically generated? Some of it is, although I tend to include $stash->{ nowrap } = 1 for those, so the template name matching is somewhat redundant... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can we use both TT and TTsite at the same time
On Nov 8, 2006, at 12:03 AM, Mao DengFeng-e13751 wrote: Hi, TTsite view is more conenience at most time when create a new page. But TT view is needed in some case. For example, I try to update some part of a page using AJAX. This part is also rendered from a template. If we use TTsite, the header and footer are included when the template is rendered. I try to use TTsite for most of the pages but I want to use TT (without header and footer wrapped)for some special page. Is there a way to do that I use a view based on TTsite, but heavily modified, that among other things allows you to control whether the page is wrapped with headers and footers or not. This is the way I prefer to deal with it:site/wrapper:[% IF template.name.match('\.(css|js|txt)') OR nowrap OR template.nowrap; debug("Passing page through as text: $template.name"); content; ELSE; debug("Applying HTML page layout wrappers to $template.name\n"); content WRAPPER site/html + site/layout; END;-%] This way headers are automatically left off files with .css .js or .txt extensions, and you can manually cause the headers to be left off other templates by using $c->{ 'stash' }->{ 'nowrap' } = 1 in your controller method, or by putting [% META nowrap = 1 %] in the template itself. -- Jason Kohles[EMAIL PROTECTED]http://www.jasonkohles.com/"A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] problem with FormBuilder + TT2
On Sep 19, 2006, at 1:37 AM, Moritz Sisenop wrote:When I try$c->path_to(qw/root customers signup.tt2/)there is no Catalyst error message anymore. Just a TT one: "Not a GLOB reference at /usr/local/lib/perl/5.8.7/Template/Provider.pm line 647." Template Toolkit doesn't know what to do with the Path::Class::File object that path_to is going to return,use $c->path_to(qw/root customer signup.tt2/)->stringify instead.-- Jason Kohles[EMAIL PROTECTED]http://www.jasonkohles.com/"A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Post deployment application management
On 9/14/06, Bill Moseley <[EMAIL PROTECTED]> wrote: > > Another "deployment" question: I have a staging server (well, it's on > the same machine) where they can view and test changes. I'd like to > have that server get automatically updated with changes quickly after > checkins. Any ideas other than having cron run svn update every few > minutes (e.g. perhaps a post-commit script)? > That's how I do it, my post-commit script looks something like this... #!/bin/sh REPO="$1" REV="$2" AUTHOR=`svnlook author -r$REV $REPO` DATE=`svnlook date -r$REV $REPO` ( echo "To: [EMAIL PROTECTED]" echo "From: [EMAIL PROTECTED]" echo "Subject: Commit to $REPO by $AUTHOR (rev $REV)" echo echo "Author: $AUTHOR" echo "Date: $DATE" echo "Repository: $REPO" echo "Revision: $REV" echo echo " *** Changelog ***" svnlook log -r$REV $REPO echo '--' echo " *** Changed Files ***" svnlook changed -r$REV $REPO echo '--' echo " *** Staging Update ***" cd /var/staging svn update -r$REV echo '--' echo " *** Test Results ***" perl Makefile.PL make test echo '--' echo " *** Build Results ***" make tardist echo '--' ) | /usr/lib/sendmail -t -oi -oem -- Jason Kohles [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Catalyst::View::TT - strange caching annoyance
On 9/13/06, Einon <[EMAIL PROTECTED]> wrote: > Hi! > > I found an interesting bug in Catalyst::View::TT. Catalyst caches wrong > templates even if I do not use caching. > Regardless of whether you have Catalyst configured to do caching, Template Toolkit does it's own in-memory caching by default. >From 'perldoc Template': Caching and Compiling Options CACHE_SIZE Maximum number of compiled templates to cache in memory (default: undef - cache all) -- Jason Kohles [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] HTML::Widget, callback constraint, and multiple records per form
On 9/1/06, Ben Hopkins <[EMAIL PROTECTED]> wrote: > Boy is my face red! > > What a stupid mistake! Thanks for noticing it. > > Hmmm. Makes me think now. The see_if_exists subroutine now gets the value > in the form, but doesn't have any context (to do a > $c->model('electionsDB::County')->find... call). If I made > a subroutine that returns a coderef to a snippet that has the context in it > ... > > You can work around that pretty easily, by making the callback an inline sub ref... sub make_counties_widget { my ($self, $c) = @_; my $w = $c->widget('county_form')->method('post'); for my $f (1..10) { $w->element('Textfield', "name$f")->label('County Name:'); $w->constraint('Callback', "name$f")->callback(sub { my ( $value ) = @_; return see_if_exists( $value, $c ); }); } $w->element('Submit', 'Submit')->value('Submit'); $w->element('Reset'); return $w; } -- Jason Kohles [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] HTML::Widget, callback constraint, and multiple records per form
On 8/31/06, Ben Hopkins <[EMAIL PROTECTED]> wrote: > Here's what I have: a table (counties) that has county names in it. I want > to be able to add counties. Just one county per screen seems pretty dumb, > so I want a bunch of counties. The sole constraint is that a county cannot > already be in the database, and I figured the Widgets' constraint method > would be perfect for that. > > Here I make the widget: > > sub make_counties_widget { > my ($self, $c) = @_; > > my $w = $c->widget('county_form')->method('post'); > > for my $f (1..10) { > $w->element('Textfield', "name$f")->label('County Name:'); > $w->constraint('Callback', > "name$f")->callback(&see_if_exists); > } > > $w->element('Submit', 'Submit')->value('Submit'); > $w->element('Reset'); > return $w; > } > > Already, I'm wondering where the error message will go. Anyhow, I got > completely lost when writing 'see_if_exists' because the args are > unintelligible. It looks like the second arg is the Catalyst context, and > within there I can find the form results, but if that's the case, why does > it have to be called once for each field? It stops being a field validation > and becomes a form validation called once for each field!?! > > Does anybody use callback? Does anybody do multiple create/delete/updates > per form? > You are missing one critical character in your code. Because you left off the backslash before the function call, your callback isn't a callback, what is happening is that the function is being run at the time you create the widget, and is running 10 times because it's inside a loop. What is actually getting set as the callback is whatever &see_if_exists returns. And because you are calling the function with the &, but without parens, it is getting passed the same arguments that were passed to make_counties_widget, which is why they don't make any sense, and why the context is being passed as a second argument. -- Jason Kohles [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anyone actually using FastCGI with Apache (or even lighttpd)?
On 8/30/06, Matt S Trout <[EMAIL PROTECTED]> wrote: On 30/08/06, Jason Kohles <[EMAIL PROTECTED]> wrote: > On 8/29/06, Matt S Trout <[EMAIL PROTECTED]> wrote: > > > If somebody could write this up for Engine::FastCGI in the form of a > > patch I'm sure it could ship in 5.7002 > > I started to, but the workaround involves changing some environment > variables in ways that (for Apache at least) require knowledge of the > Apache configuration that FastCGI doesn't make available to the OK, how about a *documentation* patch outlining the issue and possible workarounds then please? Fair enough, see attachment... -- Jason Kohles [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire FastCGI.diff Description: Binary data ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anyone actually using FastCGI with Apache (or even lighttpd)?
On 8/29/06, Matt S Trout <[EMAIL PROTECTED]> wrote: > Andreas Marienborg wrote: > > I have had this problem since 5.33 I think. > > > > just wrote it off as a configuration problem and PEBKAC:) > > If somebody could write this up for Engine::FastCGI in the form of a patch I'm > sure it could ship in 5.7002 > I started to, but the workaround involves changing some environment variables in ways that (for Apache at least) require knowledge of the Apache configuration that FastCGI doesn't make available to the application. I considered doing something funky with having Apache set an environment variable to pass that information into the App, or putting it in the configuration file, but that just feels dirty, and introduces it's own problems if you change those portions of the Apache config and forget to change the environment or configuration. The other problem is that it doesn't seem to affect some people, which leads me to believe that there are only certain configurations where it breaks, or only certain things you might attempt in Catalyst that run afoul of it. I ran into it because I was using $c->request->path and $c->request->arguments from a default sub to return files if they existed, and it wasn't working because path and arguments were both wrong. I also didn't have a test environment with an application that wasn't in the root that I could test on to make sure my changes didn't break there, so in the end I decided I was probably better off spending that time trying to track down the FastCGI bug itself, which would seem to be a bigger win given the number of things besides Catalyst that I found that were affected by it... -- Jason Kohles [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Anyone actually using FastCGI with Apache (or even lighttpd)?
On 8/28/06, Mark Blythe <[EMAIL PROTECTED]> wrote: > Hey Jason, > > I think you're having the same problem I had back in June. I was > amazed that nobody else seemed to have been having this issue. I > guess it just took a few months. :-) > > Anyway, here's the solution message I posted, which has been working > fine for me since then. Take a look and see if it will work for you: > > http://lists.rawmode.org/pipermail/catalyst/2006-June/008361.html > That does seem to have pointed in the right direction anyway, though Apache needed a little more help to get going. I ended up subclassing Catalyst::Engine::FastCGI to provide an engine that works specifically for FastCGI applications that are hosted at the root of the domain (which seems to be the cause of the problem), though this could probably be a plugin as well... package Catalyst::Engine::RootFastCGI; use base qw( Catalyst::Engine::FastCGI ); use strict; use warnings; use NEXT; sub prepare_request { my ( $self, $c, %args ) = @_; $self->NEXT::prepare_request( $c, %args ); my $env = $self->env; my $name = $env->{ 'SCRIPT_NAME' }; $env->{ 'SCRIPT_FILENAME' } =~ s/$name$//; $env->{ 'PATH_INFO' } = $name.$env->{ 'PATH_INFO' }; $env->{ 'PATH_TRANSLATED' } = $env->{ 'SCRIPT_FILENAME' }.$env->{ 'PATH_INFO' }; $env->{ 'SCRIPT_NAME' } = '/'; } > I have this in my app as a Catalyst plugin. > > Mark > > On 8/28/06, Jason Kohles <[EMAIL PROTECTED]> wrote: > > I've been struggling for a while now to get an app working under > > FastCGI, mostly under Apache, although I did briefly experiment with > > lighttpd, it gave me the same results. > > > > In a nutshell, the problem is this, I setup an application using this > > configuration (which I found in the documentation): > > > > FastCgiExternalServer /tmp/test -socket /tmp/test.socket > > > > ServerName test.domain.com > > ServerAdmin [EMAIL PROTECTED] > > DocumentRoot /var/www/html > > > > Alias / /tmp/test/ > > > > > > When running a Catalyst app with this configuration, what happens is > > that any URL that is one level off the root, and ends with a / ends up > > at the main controllers index method. You can demonstrate this with a > > very basic modification of a generic application, just use > > 'catalyst.pl Test' to create a test app, then put these two methods in > > Controller::Root: > > > > sub default : Private { > > my ( $self, $c ) = @_; > > $c->response->body( "This is default" ); > > } > > sub index : Private { > > my ( $self, $c ) = @_; > > $c->response->body( "This is index" ); > > } > > > > Loading this application as http://test.domain.com/ should return > > 'This is index', while any other url on the server should say 'This is > > default'. What happens however, is that if you request a URL such as > > http://test.domain.com/foo/, you also get 'This is index'. > > > > The reason for this is that Catalyst::Engine::FastCGI inherits from > > Catalyst::Engine::CGI. Catalyst::Engine::CGI::prepare_path() has this > > code: > > > > $base_path = $ENV{SCRIPT_NAME} || '/'; > > > > When using the CGI interface, this works fine, and most of the time > > this seems to work fine for FastCGI as well, except when you use URL > > such as http://test.domain.com/foo/, what happens is that Apache (or > > mod_fastcgi) sets up these environment variables as: > > > > SCRIPT_NAME = '/foo' > > PATH_INFO = '/' > > > > Rather than the values you would expect them to have, which should be: > > > > SCRIPT_NAME = '/' > > PATH_INFO = '/foo' > > > > This seems to be a fairly common problem (there are bugs that mention > > similar behaviour in the bug tracking queues for lighttpd, rt, trac, > > zope, and several others), although I haven't been able to find a > > solution anywhere. > > > > I'm trying to use fastcgi with the external server so that I can have > > different apps using different perl installs for deployment purposes, > > which is a lot trickier with mod_perl, although if I can't get this > > working, I may have to bite the bullet and see about doing something > > ugly with mod_perl to make it happen. > > > > -- > > Jason Kohles > > [EMAIL PROTECTED
[Catalyst] Anyone actually using FastCGI with Apache (or even lighttpd)?
I've been struggling for a while now to get an app working under FastCGI, mostly under Apache, although I did briefly experiment with lighttpd, it gave me the same results. In a nutshell, the problem is this, I setup an application using this configuration (which I found in the documentation): FastCgiExternalServer /tmp/test -socket /tmp/test.socket ServerName test.domain.com ServerAdmin [EMAIL PROTECTED] DocumentRoot /var/www/html Alias / /tmp/test/ When running a Catalyst app with this configuration, what happens is that any URL that is one level off the root, and ends with a / ends up at the main controllers index method. You can demonstrate this with a very basic modification of a generic application, just use 'catalyst.pl Test' to create a test app, then put these two methods in Controller::Root: sub default : Private { my ( $self, $c ) = @_; $c->response->body( "This is default" ); } sub index : Private { my ( $self, $c ) = @_; $c->response->body( "This is index" ); } Loading this application as http://test.domain.com/ should return 'This is index', while any other url on the server should say 'This is default'. What happens however, is that if you request a URL such as http://test.domain.com/foo/, you also get 'This is index'. The reason for this is that Catalyst::Engine::FastCGI inherits from Catalyst::Engine::CGI. Catalyst::Engine::CGI::prepare_path() has this code: $base_path = $ENV{SCRIPT_NAME} || '/'; When using the CGI interface, this works fine, and most of the time this seems to work fine for FastCGI as well, except when you use URL such as http://test.domain.com/foo/, what happens is that Apache (or mod_fastcgi) sets up these environment variables as: SCRIPT_NAME = '/foo' PATH_INFO = '/' Rather than the values you would expect them to have, which should be: SCRIPT_NAME = '/' PATH_INFO = '/foo' This seems to be a fairly common problem (there are bugs that mention similar behaviour in the bug tracking queues for lighttpd, rt, trac, zope, and several others), although I haven't been able to find a solution anywhere. I'm trying to use fastcgi with the external server so that I can have different apps using different perl installs for deployment purposes, which is a lot trickier with mod_perl, although if I can't get this working, I may have to bite the bullet and see about doing something ugly with mod_perl to make it happen. -- Jason Kohles [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Bypass TT wrapper
On 8/21/06, Tobias Kremer <[EMAIL PROTECTED]> wrote: Hi list,I have set up a site which utilizes the TTSite defaults for providing a commonheader/footer using TTs wrapper mechanism. What if I want to bypass theheader/footer for certain URLs (specifically, I've forms which are injected into DIVs via AJAX and those forms are not supposed to have the commonheader/footer around 'em)? Is that possible? Something like Mason'sI handle this by changing the css/js/txt line in the wrapper, to look like this: IF template.name.match('\.(css|js|txt)') OR nowrap OR template.nowrap;This way you can disable the wrapping either in the template, by putting [% META nowrap = 1 %], or in the controller, using $c->stash->{ 'nowrap' } = 1. -- Jason Kohles[EMAIL PROTECTED] - http://www.jasonkohles.com/"A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/