Re: [Catalyst] Attribute::Handlers wont work in own classes under catalyst

2007-08-30 Thread John Napiorkowski

--- Nilson Santos Figueiredo Junior <[EMAIL PROTECTED]>
wrote:

> On 8/29/07, Felix Antonius Wilhelm Ostmann
> <[EMAIL PROTECTED]> wrote:
> > after a few tests we gone use this classes under
> catalyst ... and ...
> > dont work :-/ under catalyst our classes dont use
> Attribute::Handlers
> > :-/ we declare UNIVERSAL::Property and then use
> "sub nondigit : Property
> > { defined && !m{[0-9]} }" (see the code)
> 
> Catalyst breaks regular subroutine attributes.
> Apparently, it tries to
> parse them all so other code never gets the chance
> to parse them. I've
> seen this problem before while using a module (which
> used subroutine
> attributes) along with Catalyst and I decided to
> work around it
> instead of looking for a proper fix.
> 
> Good luck. Hopefully someone else can come up with
> solution other than
> using Catalyst's own attribute handling framework.
> 
> -Nilson Santos F. Jr.

Do we have the same problem with non action
subroutines in a Controller?  Because we have to
remember that an action declared in a controller is
being wrapped into it's own class, so we have to
expect that sub won't work quite the same way as plain
old Perl packages.  However 'normal' subs should work
fine.  I'm not so familiar with the attribute handling
module you've talked about, so I can't really be sure,
but I'd be curious if someone could try:

sub my_action :Local {
 my ($self, $c) = @_;
}

sub not_an_action :CustomAttribute {
 my $self = shift @_;
}

This trick might also work in a custom action class.

Try to think of Catalyst Components as wrappers to
other stuff and it will help.  Definitely it's great
practice to design stuff that works as a plain old
perl object and then bring it into Cat using action
classes, models, etc.




   

Choose the right car based on your needs.  Check out Yahoo! Autos new Car 
Finder tool.
http://autos.yahoo.com/carfinder/

___
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] Attribute::Handlers wont work in own classes under catalyst

2007-08-29 Thread John Napiorkowski

--- Felix Antonius Wilhelm Ostmann
<[EMAIL PROTECTED]> wrote:

> OK, first the problem:
> 
> we have build some classes with Attribute::Handlers
> (was inspired from 
> Attribute::Property)
> 
> This works realy fine!
> 
> after a few tests we gone use this classes under
> catalyst ... and ... 
> dont work :-/ under catalyst our classes dont use
> Attribute::Handlers 
> :-/ we declare UNIVERSAL::Property and then use "sub
> nondigit : Property 
> { defined && !m{[0-9]} }" (see the code)
> 
> then you can call: $obj->nondigit(4) and it will
> croak or 
> $obj->nondigit("car") and it will set the
> object-property nondigit to "car".
> 
> under catalyst he ignore the redefined sub in
> UNIVERSAL::Property ... 
> no, he dont call UNIVERSAL::Property to redefine sub
> :-/
> 
> 
> MfG
> Felix Ostmann
> 
> 
> 
> OK, here the code, you can test it with (works):
> perl -d -MData::Dumper -MmyExample -e 'my $e =
> myExample->create(); 
> $e->nondigit("car"); print Dumper($e);'
> or
> perl -d -MData::Dumper -MmyExample -e 'my $e =
> myExample->create(); 
> $e->nondigit(4); print Dumper($e);'
> 
> 
> under catalyst (wont work):
> sub default : Private {
> my ($self, $c) = @_;
> use myExample;
> use Data::Dumper;
> my $e = myExample->create();
> $e->nondigit("car");
> $c->response->body( Dumper($e) );
> }
> 
> 
> 
> CODE:
> 
> package myExample;
> 
> use strict;
> use warnings;
> 
> use 5.006;
> use Attribute::Handlers;
> use Carp qw/carp croak/;
> 
> $Carp::Internal{q/Attribute::Handlers/}++;  # may we
> be forgiven for our 
> sins
> $Carp::Internal{+__PACKAGE__}++;
> 
> sub UNIVERSAL::Property : ATTR(CODE) {
> my (undef, $self_glob, $check_code) = @_;
> 
> ref($self_glob)
> or croak "Cannot use property attribute with
> anonymous sub";
> 
> my $property = *$self_glob{NAME};
> 
> defined(&$self_glob)
> or undef $check_code;
> 
> no warnings 'redefine';
> 
> *$self_glob = sub {
> (my $self, local $_) = @_;
> 
> if( @_ == 1 ) {
>
> exists($self->{_property}->{_current}->{$property})
> or croak "Property $property not
> loaded";
> 
> return
> $self->{_property}->{_current}->{$property};
> }
> 
> if( @_ == 2 ) {
> ref($_)
> and croak "Invalid value for
> $property property, no refs";
> 
> # Property wurde geladen, sonst Abbruch
> $self->{_in_storage} && 
> !exists($self->{_property}->{_storage}->{$property})
> and croak "Property $property not
> loaded";
> 
> my $value = $_;
> 
> # überprüfe neuen Wert auf Gültigkeit,
> sonst Abbruch
> defined($check_code) &&
> !$check_code->($self, $_)
> and croak "Invalid value for
> $property property";
> 
> if( !defined($self->{_in_storage}) ) {
> # status "schammig"es Objekt, dann
> alles laden als "from 
> storage"
> 
> # ist neuer Wert != alter Wert,
> warnung ausgeben
> if( defined($_) ^ defined($value) or
> defined($_) && $_ 
> ne $value ) {
> carp "Property $property from
> database are 
> inconsistent";
>
> $self->{_property}->{_storage}->{$property} =
> $value;
> }
> else {
>
> $self->{_property}->{_storage}->{$property} = $_;
> }
> 
> }
> # wenn Objekt in der Datenbank
> elsif( $self->{_in_storage} ) {
> # lösche dirty-Status, wird neu
> berechnet
>
> delete($self->{_property}->{_dirty}->{$property});
> 
> # ist neuer Wert != alter Wert,
> dirty-Status neu setzten
> defined($_) ^ 
> defined($self->{_property}->{_storage}->{$property})
> and
> $self->{_property}->{_dirty}->{$property} = undef;
> 
> # ist neuer Wert != alter Wert,
> dirty-Status neu setzten
> defined($_) && $_ ne 
> $self->{_property}->{_storage}->{$property}
> and
> $self->{_property}->{_dirty}->{$property} = undef;
> }
> # wenn nicht in der Datenbank
> else {
> # auf jeden Fall auf dirty setzten
>
> $self->{_property}->{_dirty}->{$property} = undef
> }
> 
> return
> $self->{_property}->{_current}->{$property} = $_;
> }
> 
> croak "Too many arguments for $property
> method";
> };
> }
> 
> sub new {
> my ($class, @args) = @_;
> 
> @args
> and croak q{Can't call method "new" with
> arguments};
> 
> my $self = {
> _property   => {
> _current   => {},
> _storage   => {},
> _dirty => {},
> },
> _in_storage => undef,
> };
> 
> bless($self, $class);
> 
> return $self;
> }
> 
> sub create {
> my ($class, @args) = @_;
> 
> @args % 2
> and

Re: [Catalyst] CMS

2007-08-25 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Sat, Aug 25, 2007 at 12:41:11AM +0900, Matt Rosin
> wrote:
> > Catalyst::Plugin::I18N::DBIC (and
> Mango::Catalyst::Plugin::I18N) is
> > maybe a crosscutting thing like Zbigniew mentions
> with some useful
> > concepts.
> > 
> > I'm not looking to build Drupal or a blog platform
> but I have nothing
> > against them per se. I was thinking more of a tool
> to reduce the
> > amount of Catalyst code I type by identifying
> patterns.
> > 
> > For example:
> > - A multiuser pattern in which a site is separated
> into public, admin
> > and registered user portals (of which the latter
> two need to edit lots
> > of pesky data like their profiles, their "virtual
> holdings" like
> > coupons/listings/catalogs/resumes/banners//video
> clips, etc.).
> > Currently I would do this with a formbuilder form,
> view and save subs,
> > and TT template for each page.
> 
> Reaction's action reflector plus the ActionForm
> viewport
> 
> > - Another pattern might be to get one or a list of
> objects a user
> > owns, make a list of them and create an interface
> allowing them to
> > edit and save the data. We all keep reinventing
> the wheel with this.
> 
> Reaction's action reflector plus the ListView,
> ActionForm and CRUDController
> classes.
> 
> > Currently I would look at similar subs I'd made
> and well reinvent the wheel...
> > 
> > I have 3 ideas at the moment.
> > 
> > 1a. A standard object editor with rich editor and
> maybe some widgets.
> > It would render a complex form as necessary, given
> the object to be
> > edited. I once wrote something like this that
> would just let you edit
> > object data fields with text input boxes, it's not
> rocket science.
> 
> Done.
> 
> > 1b. Online asset manager to CRUD them, with a file
> upload widget might
> > also be nice.
> 
> Mostly done.
> 
> > 2a. Reduce the set of all information assets a
> user owns into a single
> > tree that may span many tables, allowing each
> asset (object, data
> > field, etc.) to be called from templates by name
> (could use namespaces
> > and dot notation maybe). This is probably most
> useful in the context
> > of having a tree of all text snippets, etc. used
> in display of the
> > public site.
> 
> Doable using metaprotocol introspection. Right now
> you need to feed Moose the
> info by hand but in DBIC 09 it'll be baked in.
> 
> > 2b. This reduces templates to a list of assets
> (snippets) called by
> > name interspersed with HTML tags and TT
> directives. Text snippets
> > would reside in a database and could be edited in
> a CMS, at least like
> > the utility of 1a/b above. Image pathnames or a
> single DIV's HTML
> > could also all be stored in the db. The template
> would just pull the
> > snippets out with a simple $c method like loc in
> the above I18N
> > modules. A standard facility for editing these
> things (a module and TT
> > templates) would also be useful.
> 
> I'm mostly just using the i18n plugin plus a tree of
> files under svn for this
> but our designer learned svk shortly after wiping
> windows in favour of ubuntu
> in a fit of anger with it during LugRadio Live.
> 
> > 3. Beyond this, I see an awful lot of programming
> and design going
> > into solving similar basic interface problems over
> and over. It would
> > be useful to provide some basic TT layouts and
> scripted user
> > interactions (I don't mean write perl script, I
> mean just write the
> > basic plot, preferably as an interpreted string of
> text but even yaml
> > could be used).
> 
> Agreed. The new reaction widget model works towards
> the latout part, I was
> planning to hook Class::Workflow to handle the
> scripty bit.
> 
> >  Currently we sometimes reuse templates (for
> example I
> > have a general modal dialog), but we don't really
> have smart systems
> > that DWIM the user interaction for basic data
> editing. For one thing,
> > we all look at each other's public sites but not
> the admin or user
> > portal pages which could require more programming
> work. Contributing
> > to solving repeated patterns once well will make
> Catalyst even more
> > powerful I think. A repository of such interface
> snippets (combination
> > of TT code, perl code, etc.) could be run on the
> dev site maybe.  At
> > the risk of sounding like I'm all talk I'm willing
> to provide my
> > current admin and customer portals to the project,
> possibly the TT
> > templates would be useful. Anyway they do look a
> little like the
> > Catalyst startup page. :)
> 
> I'd love to see the code publically, even if it
> isn't re-used it's instructive
> to see how other people do it.
> 
> In the same spirit: http://trout.me.uk/scsite.tgz is
> the Shadowcat website
> code base running on svn reaction from
> http://code2.0beta.co.uk/reaction/svn
> and I intend to artistic license the site codebase
> (not sure what we'll do
> about the content and layout yet, but I don't
> imagine our website copy
> is of great re-use value to anybody el

Re: [Catalyst] XML RPC Server and RenderView

2007-08-25 Thread John Napiorkowski

--- Nicolas Raspail
<[EMAIL PROTECTED]> wrote:

> Matthieu Codron a écrit :
> > Hi,
> > 
> > 
> >> Nicolas Raspail wrote:
> >>
> >>> Hello,
> >>> when playing with
> Catalyst::Plugin::Server::XMLRPC following the 
> >>> documentation, I get the same behaviour as Joe.
> >>
> >> Hmmm I thought it was just me.
> >>
> >>> I have search the archive and found thie mail
> from Joe Landman , and 
> >>> he has the same problem, but unfortunately,
> nobody answer him.
> >>
> >> True.  I am guessing that this is due to few
> people using XMLRPC in 
> >> Catalyst.  This is a shame as it really looks
> like a nice module to 
> >> use , and is exactly what I want to do ...  I
> have since hacked what I 
> >> need to do into some controllers/display logic
> outside of XMLRPC, 
> >> though I would rather get XMLRPC going.
> >>
> > 
> > I'm using this Catalyst::Plugin::Server::XMLRPC
> alongside RenderView 
> > without problems. To avoid forwarding to
> RenderView, I'm just putting a 
> > value in the response body at the end of the
> action, e.g. 
> > $c->response->body(1);
> > Looks like a hack, but it works. The contents of
> the response body are 
> > overwritten by the plugin.
> > 
> Hi Matthieu,
> 
> yes, I'm doing the same thing, but as you said, that
> looks like a hack, 
> and I would like to be sure it is the right thing to
> do
> 
> Thanks
> 
> Nicolas

Hi,

If Iam creating a site with mixed content (HTML pages
and XMLRPC for interactive stuff) I usually create a
base controller called 'ServicesController.pm' or
something and then I put an end action in that
controller.  That way it doesn't get to RenderView in
your root controller.

RenderView is a great way to get started but don't let
that stop you from creating end actions or forwarding
to views as needed.  That's way the Controller will
look in itself for an end action first.

Some of the Catalyst defaults become less useful the
more you create complexity or have needs beyond
rendering simple templates from database data.

--john


   

Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.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/


Re: [Catalyst] access stash outside methods

2007-08-21 Thread John Napiorkowski

--- Aditya Verma <[EMAIL PROTECTED]> 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.
> 
> Thanks,
> Aditya

Aditya,

Since your actions can map URL's in different ways, it
may not be easy to dynamically create a sitemap object
in the way you are talking about.  Because if an
action accepts parameters than it can potentially map
to a large number of URLs.

If you just want to have some additional information
placed into the stash for all the actions in a given
controller, you can do that in a :begin action, which
is run for each request to a controller.

However if this information is presentation related
you might prefer to place it into a configuration file
for your view templates.  For example if you are using
Template Toolkit, you can include a template that just
defines some local information.  That way you can
modify the information without having to deal with the
controllers.

Not sure if I am helping.  Good luck!
John


> 
> On 8/21/07, John Napiorkowski <[EMAIL PROTECTED]>
> wrote:
> >
> >
> > --- Aditya Verma <[EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> > >
> > > I am running catalyst under apache configured
> with
> > > mod_perl.
> > >
> > > Can I somehow access stash out methods.
> > >
> > > I want to declare a global variable inside
> > > controller and outside methods
> > > which will be accessible in all controllers.
> > > stash could be a solution but outside methods
> > > context object is not
> > > available so i don't have access to stash.
> > >
> > > please help me solve the problem.
> > >
> > > Thanks,
> > > Aditya
> >
> > Hi,
> >
> > I may not fully understand your use case, but
> > typically the stash is used for a particular
> context,
> > not as a global thing.
> >
> > You can alway pass the context to methods that
> need
> > it.  I know it seems cumbersome, but the reason is
> to
> > make you really think if you need it, the idea
> being
> > that you should try to decouple your context as
> much
> > as possible.
> >
> > If you need some global information there are a
> few
> > ways I can think of:
> >
> > 1) put it into the configuration file.  This is
> great
> > for static stuff, like admin email address, etc.
> > 2) Create a model that provides the information
> you
> > need.  If this information is based on the current
> > context you can inherit from
> > "Catalyst::Component::ACCEPT_CONTEXT" to build it.
> > 3) Create a base controller with a method that
> gets
> > the information you need.  The have the
> controllers
> > that need this information inherit from that.
> >
> > You might get the suggestion to make this a
> catalyst
> > plugin, but that's no longer recommended best
> > practices.  Plugins should be reserved for when
> you
> > are trulying enhancing/extending the basic
> Catalyst
> > features.
> >
> > Please share with us the details of the use case
> and
> > maybe we can help.
> >
> > --John
> >
> >
> >
> >
> >
>

> > Choose the right car based on your needs.  Check
> out Yahoo! Autos new Car
> > Finder tool.
> > http://autos.yahoo.com/carfinder/
> >
> > ___
> > 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/
> >
> > ___
> 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/
> 



   

Be a better Heartthrob. Get better relationship answers from someone who knows. 
Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=list&sid=396545433

___
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

2007-08-21 Thread John Napiorkowski

--- Aditya Verma <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I am running catalyst under apache configured with
> mod_perl.
> 
> Can I somehow access stash out methods.
> 
> I want to declare a global variable inside
> controller and outside methods
> which will be accessible in all controllers.
> stash could be a solution but outside methods
> context object is not
> available so i don't have access to stash.
> 
> please help me solve the problem.
> 
> Thanks,
> Aditya

Hi,

I may not fully understand your use case, but
typically the stash is used for a particular context,
not as a global thing.

You can alway pass the context to methods that need
it.  I know it seems cumbersome, but the reason is to
make you really think if you need it, the idea being
that you should try to decouple your context as much
as possible.

If you need some global information there are a few
ways I can think of:

1) put it into the configuration file.  This is great
for static stuff, like admin email address, etc.
2) Create a model that provides the information you
need.  If this information is based on the current
context you can inherit from
"Catalyst::Component::ACCEPT_CONTEXT" to build it.
3) Create a base controller with a method that gets
the information you need.  The have the controllers
that need this information inherit from that.

You might get the suggestion to make this a catalyst
plugin, but that's no longer recommended best
practices.  Plugins should be reserved for when you
are trulying enhancing/extending the basic Catalyst
features.

Please share with us the details of the use case and
maybe we can help.

--John 


   

Choose the right car based on your needs.  Check out Yahoo! Autos new Car 
Finder tool.
http://autos.yahoo.com/carfinder/

___
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] RFC: Multiple :Chained and/or :PathPart attributes?

2007-08-20 Thread John Napiorkowski

--- Jason Kohles <[EMAIL PROTECTED]> wrote:

> Currently, attempting to pass multiple arguments to
> either Chained or  
> PathPart attributes in a controller simply results
> in an exception  
> being thrown indicating that you can't do that, I'm
> thinking it might  
> be useful to change that behavior to allow for
> multiple arguments to  
> simply build multiple chains that take the same
> path.  As an example,  
> here is the code that led me to this thinking...
> 
> I was working on an application that includes page
> revisioning, and  
> ended up with this code, which seems excessively
> verbose to me...
> 
> The requirements were:
>   * Wiki-like page structure
>   * /page/SomePage displays the current revision of
> SomePage
>   * /page/SomePage/revision/3 displays revision
> number 3 of SomePage
>   * /page/SomePage/rev/3 also displays revision
> number 3 of SomePage
>   * /page/SomePage/date/2007-01-01 displays whatever
> revision was  
> current on 2007-01-01 (or show a selector if there
> was more than one  
> change that day)
>   * /page/SomePage/datetime/2007-01-01T12:10:00
> displays whatever  
> revision was current at that time
>   * For ALL of the above URLs, the page should be
> displayed if there  
> are no other path parts, or if the URL ends with
> /view
> 
> These requirements led to this code...
> 
> sub page : Chained('/') PathPart('page')
> CaptureArgs(1) {
>   my ( $self, $c, $page ) = @_;
>   # load page data for the indicated page into the
> stash
> }
> 
> sub revision : Chained('page') PathPart('revision')
> CaptureArgs(1) {
>   my ( $self, $c, $rev ) = @_;
> 
>   $c->forward( 'handle_revision', [ $rev ] );
> }
> 
> sub rev : Chained('page') PathPart('rev')
> CaptureArgs(1) {
>   my ( $self, $c, $rev ) = @_;
> 
>   $c->forward( 'handle_revision', [ $rev ] );
> }
> 
> sub handle_revision : Private {
>   my ( $self, $c ) = @_;
>   # load the revision indicated in
> $c->request->args[0] into the stash
> }
> 
> sub date : Chained('page') PathPart('date')
> CaptureArgs(1) {
>   my ( $self, $c, $date ) = @_;
> 
>   $c->forward( 'handle_datetime', [ $date ] );
> }
> 
> sub datetime : Chained('page') PathPart('datetime')
> CaptureArgs(1) {
>   my ( $self, $c, $date ) = @_;
> 
>   $c->forward( 'handle_datetime', [ $date ] );
> }
> 
> sub handle_datetime : Private {
>   my ( $self, $c ) = @_;
>   # create a datetime object from
> $c->request->args->[0]
>   # load the appropriate revision into the stash
> }
> 
> sub view : Chained('page') PathPart('view') Args(0)
> {
>   my ( $self, $c ) = @_;
> 
>   $c->forward( 'process_view' );
> }
> 
> # All of these subs have the exact same body as
> 'view', which does  
> nothing but forward to 'process_view'
> sub view_default : Chained('page') PathPart('')
> Args(0) {
> sub view_revision : Chained('revision')
> PathPart('view') Args(0) {}
> sub view_revision_default : Chained('revision')
> PathPart('') Args(0) {}
> sub view_rev : Chained('rev') PathPart('view')
> Args(0) {}
> sub view_rev_default : Chained('rev') PathPart('')
> Args(0) {}
> sub view_date : Chained('date') PathPart('view')
> Args(0) {}
> sub view_date_default : Chained('date') PathPart('')
> Args(0) {}
> sub view_datetime : Chained('datetime')
> PathPart('view') Args(0) {}
> sub view_datetime_default : Chained('datetime')
> PathPart('') Args(0) {}
> 
> sub process_view : Private {
>   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';
>   }
> }
> 
> If the Chained and PathPart attributes could take
> multiple arguments  
> that would simply build multiple chains, then I
> could have  
> significantly reduced the amount of repetition, by
> doing something  
> along these lines instead...
> 
> sub page : Chained('/') PathPart('page')
> CaptureArgs(1) {
>   my ( $self, $c, $page ) = @_;
>   # load page data for the indicated page into the
> stash
> }
> 
> sub revision : Chained('page')
> PathPart('revision','rev') CaptureArgs 
> (1) {
>   my ( $self, $c, $rev ) = @_;
> 
>   # load the indicated revision into the stash
> }
> 
> sub date : Chained('page')
> PathPart('date','datetime') CaptureArgs(1) {
>   my ( $self, $c, $date ) = @_;
> 
>   # load the appropriate revision into the stash
> }
> 
> sub view : Chained('page','revision','date')
> PathPart('','view') 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';
>

Re: [Catalyst] How to execute controller at startup

2007-08-07 Thread John Napiorkowski

--- Aditya Verma <[EMAIL PROTECTED]> wrote:

> Hi All,
> 
> Thank you very much for all your valuable comments
> at appreciate your quick
> response.
> 
> I have one more query.
> I have implemented a Plugin. How can I call a plugin
> method from controller
> outside of the controller methods.
> 
> suppose i have a Plugin named
> "Catalyst::Plugin::MyPlugin" contains a method
> called "sub myFunc {}"
> 
> Now i want to call myFunc from controller but i dont
> have context object
> outside of methods so currently I am doing:
> Catalyst::Plugin::MyPlugin::myFunc();
> 
> which is a normal function call (not catalyst way of
> doing, not even object
> oriented).
> Could you please suggest me an efficient way to call
> that method.
> 
> Thanks,
> Aditya

Since I'm not sure what your use case is I can only
give you some vaguely general suggestions.

First of all, the community has lately pushed people
to look carefully at their plugins to see if they are
really plugins or something else.  There is a document
posted at:

http://search.cpan.org/~jrockway/Catalyst-Manual-5.700701/lib/Catalyst/Manual/ExtendingCatalyst.pod

which is a a MUST READ for all new developers.

If you have something locked up in a plugin that you
need elsewhere, like in a cron job, for example, that
probably belongs in a Plain old Perl class and brought
into Catalyst via a Model.  That way you can access
functionality outside of Catalyst.

For (very brief) example:

A Plain Old Perl module:

package Myapp::Somestuff;

use base 'Class::Accessor';

sub stuff {

  my ($self, $arg) = @_;

  return $arg x 2;
}

A Catalyst model to wrap this:

package Myapp::Web::Model::Somestuff;

use Class::C3;
use base 'Catalyst::Model';

__PACKAGE__->mk_accessors(qw/somestuff/);

sub new {
  my ($class, $c, $arguments) = @_;
  my $self = $class->next::method($c, $arguments);
  $self->somestuff(Myapp::Somestuff->new());
  return $self;
}

sub stuff {
  shift->somestuff->stuff(@_);
}

In a controller:

Package Myapp::Web::Controller::Something;

use base 'Catalyst::Controller';

sub testit :Local {

  my ($self, $c) = @_;

  $c->stash(
result => $c->model('Somestuff')->stuff('a'),
  );
}

And then in your template you have a stash key
'result' which is equal to 'aa'.  And you have code
you can use outside of catalyst.

The above can be improved.  For example you can use
AUTOLOAD to automatically map the wrapper methods in
your module:

(Lifted pretty much from Handle or Mango, I forgot)

sub AUTOLOAD
{
  my $self = shift @_;
  my @args = @_;
  my ($method) = (our $AUTOLOAD =~ /([^:]+)$/);
  return if $method =~ /(DESTROY|ACCEPT_CONTEXT)/;

  return $self->somestuff->$method(@args) if
 $self->somestuff->can($method);
}

Good luck!

-john

> 
> 
> On 8/6/07, John Napiorkowski <[EMAIL PROTECTED]>
> wrote:
> >
> >
> > --- Aditya Verma <[EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> > >
> > > I am new to catalyst.
> > > I have developed an application using Catalyst.
> > >
> > > I need all my controllers to execute at startup
> and
> > > register there method
> > > URLs.
> > > I am not getting how to execute controller at
> > > startup.
> > >
> > > Please help me.
> > >
> > > Thanks,
> > > Aditya
> >
> > Hi,
> >
> > Catalyst Controllers are subclasses of
> > Catalyst::Component so are automatically located a
> > registered by your primary Catalyst class at
> startup.
> > If you are finding that you don't see your
> controllers
> > and/or actions in the debug screen when you start
> the
> > development server then you must have some typos
> in
> > the controller package names or something similar.
> >
> > Please give us a little more detail about your
> trouble
> > and the actually need that you are trying to fill.
> >
> > --john
> >
> >
> >
> >
> >
> >
>

> > Be a better Heartthrob. Get better relationship
> answers from someone who
> > knows. Yahoo! Answers - Check it out.
> >
>
http://answers.yahoo.com/dir/?link=list&sid=396545433
> >
> > ___
> > 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] How to execute controller at startup

2007-08-06 Thread John Napiorkowski

--- Aditya Verma <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I am new to catalyst.
> I have developed an application using Catalyst.
> 
> I need all my controllers to execute at startup and
> register there method
> URLs.
> I am not getting how to execute controller at
> startup.
> 
> Please help me.
> 
> Thanks,
> Aditya

Hi,

Catalyst Controllers are subclasses of
Catalyst::Component so are automatically located a
registered by your primary Catalyst class at startup. 
If you are finding that you don't see your controllers
and/or actions in the debug screen when you start the
development server then you must have some typos in
the controller package names or something similar.

Please give us a little more detail about your trouble
and the actually need that you are trying to fill.

--john



   

Be a better Heartthrob. Get better relationship answers from someone who knows. 
Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=list&sid=396545433

___
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 Workflow with Catalyst (was Making Controllers thin and Models thick)

2007-07-24 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Tue, Jul 24, 2007 at 02:43:12PM +0100, Ian
> Docherty wrote:
> > Thanks for pointing out the workflow CPAN module.
> I am very interested 
> > in this for my current project and must spend some
> time looking at it.
> > 
> > Has anyone actually used workflow within a
> Catalyst application and can 
> > they give the list their opinion and experiences
> with it?
> 
> It's an awful horrible piece of shit.
> Class::Workflow was written by
> our very own Yuvla Kogman to replace it and works
> very nicely with Catalyst.

Matt,

I'd appreciate when you have a little time if you
could share some more detailed thoughts on this, since
I was literally just about to start typing code
related to workflow and your message stopped me in my
tracks. 

I originally thought to experiment with Workflow over
Class::Workflow because it seemed to have a little
more active development and examples as well as more
development in the persistence area.  Since I am a
newbie to the area I am likely to need to play with it
quite a bit before I am able to usefully contribute so
I am looking for the most feature complete and
supported system.  However I am very interested in
learning a system and hopefully contributing usefully
to it, particularly as it can relate to Catalyst
development.

Thanks!

--John

> 
> -- 
>   Matt S Trout   Need help with your
> Catalyst or DBIx::Class project?
>Technical DirectorWant a managed development
> or deployment platform?
>  Shadowcat Systems Ltd.  Contact mst (at)
> shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/
> http://www.shadowcatsystems.co.uk/ 
> 
> ___
> 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/
> 



  

Shape Yahoo! in your own image.  Join our Network Research Panel today!   
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



___
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] Making Controllers thin and Models thick

2007-07-18 Thread John Napiorkowski

--- Kee Hinckley <[EMAIL PROTECTED]> wrote:

> On Jul 18, 2007, at 10:49 AM, John Napiorkowski
> wrote:
> > validating types for your columns.  I do this for
> very
> > common things like email addresses.  Postgresql is
> > nice for this since you can create custom types
> and
> > domains using Perl as your procedural language.
> 
> 
> Please tell me you're either doing *real* email
> validation (e.g.  
> Mail::Address), or something overly lax..  Aside
> from sites that  
> won't let me enter valid email addresses (keep in
> mind that just  
> about the only character not legal in an email
> address is NUL).  I've  
> even had sites who "updated" their validation such
> that people who  
> previously had accounts could no longer login.  ("+"
> is the really  
> common one to get rejected, but I had a friend who
> had his email  
> rejected once because it had a "-" in the domain
> name!)
> 
> My rule of thumb on email validation is "don't
> bother".  Or rather,  
> if you really care, send mail to it and ask them to
> respond.  After  
> all, just because it's valid doesn't mean it
> *works*.  I think a lot  
> of sites do it "just because".  Originally it was
> done because people  
> kept "making mistakes."  Of course the most of the
> mistakes were  
> intentional attempts to avoid getting spammed
> (somewhere.com was  
> *real* popular for fake addresses).
> 
> If you're just checking for typos "/[EMAIL PROTECTED]/" is
> probably  
> sufficient.  (Assuming of course that you don't want
> me to enter  
> "somewhere.com!nazgul" as my email address, even
> though it might well  
> work, and is certainly "legal".)
> 

I use a standard perl module for this which is part of
a custom function and domain in Postgresql.  Since we
send the user an email with a validation token to
activate an account, doing strict email testing cuts
down on the number of bad emails that get bounced
back.

I also hate those forms that ask for an email for no
reason, other than they want you in their database.

> 
> > I end up mirroring a lot of this in DBIC using
> > DBIC::Validate since I'd rather catch syntactical
> > errors in my code instead of throwing a database
> > error.  For me that's the last line of defense.
> 
> Are you referring to DBIx::Class::Validation, or is
> there another  
> module.  I looked at that, but it didn't seem to
> make any use of the  
> actual schema data.

Doh, yeah, I always get the name wrong.  You'd think
I'd remember since I used it so much on my last
project.


> 
> > I tend to think of this as 'spell checking versus
> > grammar checking'.  Your domain code is the
> grammar
> > for a particular business activity.  At least I
> think
> > of it that way.
> 
> That's a good metaphor.
> 
> ___
> 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/
> 



  

Luggage? GPS? Comic books? 
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz

___
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] Making Controllers thin and Models thick

2007-07-18 Thread John Napiorkowski

--- Bill Moseley <[EMAIL PROTECTED]> wrote:

> On Wed, Jul 18, 2007 at 07:49:50AM -0700, John
> Napiorkowski wrote:
> > I've come to the reluctant conclusion that for
> > anything other than trivial applications you will
> need
> > to validate in a couple of places.  Obviously the
> > database should be properly designed to enforce
> > integrity rules.  If you are using a database that
> > let's you create custom types, like Postgresql,
> you
> > can take it a bit further and actually create self
> > validating types for your columns.  I do this for
> very
> > common things like email addresses.  Postgresql is
> > nice for this since you can create custom types
> and
> > domains using Perl as your procedural language.
> 
> Yes, validation is a bit generic of a term.
> 
> For me, the database should try and enforce a valid
> state of
> the application.  An order row better reference a
> customer row.
> An order status better reference a valid value in
> the status table or
> have a valid check constraint.
> 
> Doesn't mean a bit of raw DBI can't hose the
> application, of course.
> 
> For application state changes I try and abstract
> that into a method in
> the model.  I rarely have ORM specific code in the
> controller.
> 
> I tend to not validate things like email addresses
> or phone numbers at
> the RDBMS level -- it's not critical to the state of
> the application
> typically.  That's left to an I/O layer that is my
> user input
> validation code.  That code can be used outside of
> Catalyst -- and
> as I commented before, it's not tied to the
> model/ORM either.
> 
> Application state changes are typically caused by
> user input. And user
> input is often multiple fields.  So, it makes sense
> to defined
> forms for handling a set of fields all as one unit. 
> That validation
> is also not easily defined in a static configuration
> file (or by
> constraints on the database) so it also makes sense
> the forms are
> bundled with code.
> 
> I doubt there's any best approach.  But, if the idea
> is thin
> controllers then I like using one line of code. ;)
> 
> -- 
> Bill Moseley
> [EMAIL PROTECTED]

Considering that you can set actions and action
classes via the central configuration file for a
controller you could eventually get down to not
needing any code, just configuration declarations. 
Still need to write a stub for your controllers
though.

I'm going to trying using the Workflow module
(http://search.cpan.org/~jonasbn/Workflow-0.28/) on my
next project and see if that can fill a missing piece
for me conceptually.  I think it can help cover the
state issues you mentioned.  Plus it has a validation
framework as part of it.

I end up with more in the database because the
applications I'm writing will end up being used by
other systems and I can't count on the PHP people
validating their incoming stuff properly :)

--John
> 
> 
> ___
> 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/
> 



   

Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.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/


Re: [Catalyst] Making Controllers thin and Models thick

2007-07-18 Thread John Napiorkowski

--- Bill Moseley <[EMAIL PROTECTED]> wrote:

> On Wed, Jul 18, 2007 at 09:39:25AM +, Zbigniew
> Lukasiak wrote:
> > Hi there,
> > 
> > I am too working on a thick model component.  It's
> a ResultSet base
> > class with functions bearing (provisional?) names:
> build_create and
> > build_update.  They do params validation and
> update the database in a
> > transaction with data for both the individual
> record and related
> > stuff.
> 
> Sounds like both you and Ken are pushing the
> validation into the
> model -- or rather the ORM layer.  The model needs
> to do some
> validation, of course, and I like to push that into
> the RDBMS where
> possible.
> 
> I do wonder if that's not coupling the ORM and the
> validation too
> closely.  Not that it happens very often, but if you
> decided to change
> ORMs you would would still want the same validation
> of input data.
> 
> I tend to have a separate layer between the
> controller and the model
> for validation.
> 
> > In short the CRUD controller actions using it can
> be as simple as:
> > 
> > sub update : Local {
> >my ( $self, $c, $id ) = @_;
> >if ( $c->request->method eq 'POST' ){
> >my $update_result = $c->model( 'DB::Table'
> )->build_update(
> > $id, $c->request->params() );
> >if ( $update_result->{status} eq 'OK' ){
> >$c->res->redirect( $c->uri_for(
> "table/view", $id") );
> >}else{
> >$c->stash( update_result =>
> $update_result );
> >   }
> >}else{
> >$c->stash( item => $c->model( 'DB::Table'
> )->find( $id ) );
> >}
> > }
> 
> 
> I suspect you write that enough times and you will
> notice the common
> code.
> 
> My Create/Update controllers tend to look like this:
> 
> sub edit : Local {
> my ( $self, $c, $id ) = @_;
> 
> $c->post_redirect( 'list', 'Foo was updated'
> )
> if $c->update_from_from( $id );
> 
> }
> 
> Because update_from_form knows the action path and
> can therefore find
> the associated form.  It can also determine what the
> concept of a
> posted form is in a single place.  And the
> associated form knows what
> model class to update or create a row in.  And the
> model class knows
> how to validate ids.  And the form knows how to look
> at the model
> class and determine lookup values for one-to-many
> and many-to-many
> relationships.
> 
> I might validate $id a bit more to make sure the
> current user can
> access it, but that can also happen in a chain or
> auto method.  Or
> that might be considered part of the validation and
> the form module
> can validate that the user can access $id.  But, I
> kind of consider
> that more of a controller responsibility since an
> invalid $id in the
> path for a given user is an invalid path (and thus
> maybe a 404).
> 
> -- 
> Bill Moseley
> [EMAIL PROTECTED]
> 

I've come to the reluctant conclusion that for
anything other than trivial applications you will need
to validate in a couple of places.  Obviously the
database should be properly designed to enforce
integrity rules.  If you are using a database that
let's you create custom types, like Postgresql, you
can take it a bit further and actually create self
validating types for your columns.  I do this for very
common things like email addresses.  Postgresql is
nice for this since you can create custom types and
domains using Perl as your procedural language.

I end up mirroring a lot of this in DBIC using
DBIC::Validate since I'd rather catch syntactical
errors in my code instead of throwing a database
error.  For me that's the last line of defense.

Validation in the business logic is a different beast
since here you are enforcing not just types value but
actual business rules.  Although in theory you can do
all of this in the database or at the ORM level it's
usually best not to since your business logic is
actually trying to capture the full domain of activity
for your system, and this is hard to do with tables
and triggers.  Not impossible, just can be messy and
not too flexible.

I tend to think of this as 'spell checking versus
grammar checking'.  Your domain code is the grammar
for a particular business activity.  At least I think
of it that way.

At the User Interface level you also have checking
that has it's own needs.  For example you might have a
business process to create a new account for a user. 
At the UI level you ask for a new password and to
repeat the password in another field to verify that
you typed it correctly.  For me that is validation for
a user interface model and doesn't belong in the
domain logic, ORM or in the controller.  This is where
reading the code for the Reaction project has really
helped me to think about this.  

If this sounds like validation is scattered all over
your code, it doesn't have to be.  Because validation
tends to be a lot of configuration files stuff that
you can centralize if you want.  Data::Formvalidator
can cover a lot of this, since you can use it in DBIC
and 

Re: [Catalyst] Proper way to perform cleanups on server shutdown?

2007-07-11 Thread John Napiorkowski

--- Mark Zealey <[EMAIL PROTECTED]> wrote:

> Perhaps I'm missing something, but what's the
> problem with doing something 
> like:
> 
> package MyApp;
> 
> $SIG{INT} = sub {
>   graceful_shutdown();
>   exit(1);
> }
> 
> END { graceful_shutdown() }
> 
> sub graceful_shutdown {
>   # Code here...
> }
> 
> Note that a $SIG{INT} will not exit if you override
> it, which is why you need 
> the exit. This means that you could make it restart
> on a SIG{INT} (or perhaps 
> better, $SIG{HUP})

Hmm, I didn't know that (obviously).  That's probably
why when I do 

$SIG{INT} = sub {}

in my MyApp.pm file I get the proper cleanup, since
I'm capturing the call for an immediate interrupt.  I
guess the TERM signal must work the same way.

The main problem for me is not that I have shutdown
and cleanup in my custom code, but that some modules
I'm using (File::Temp) define END blocks to perform
their own cleanup chores.  Really I think this is the
best way, rather than to try and have one big uber
cleanup routine in my core module, let each module
that needs to do housekeeping handle it's own.

Thanks to you for pointing this out to me, and to
others who've responded and pointed out other useful
bits.

--john

> 
> Mark
> 



   
Ready
 for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.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/


Re: [Catalyst] Proper way to perform cleanups on server shutdown?

2007-07-11 Thread John Napiorkowski

--- "Jonathan T. Rockway" <[EMAIL PROTECTED]> wrote:

> On Wed, Jul 11, 2007 at 09:03:29AM -0700, John
> Napiorkowski wrote:
> > I can demonstrate this by placing an END block in
> my
> > root modules (the "MyApp.pm" module)
> > 
> > END {
> >   print "got END BLOCK!\n";
> > }
> > 
> > This will never run under the conditions I have
> > described.
> > 
> > HOWEVER, if I set SIG handlers manually like so:
> > 
> > $SIG{INT} = sub { print "got INT!\n" };
> > $SIG{TERM} = sub { print "got TERM!\n" };
> > 
> > END {
> >   print "got END BLOCK!\n";
> > }
> > 
> > Then the END block does run.
> 
> Is this different from what you would expect?
> 
> try:
> 
>   $ perl -e 'END { print "going away\n" }; sleep 1
> while(1);' 
>   ^C
>   $ _
> 
> compared to:
> 
>   $ perl -e 'END { print "going away\n" }'
>   going away
>   $ _ 
> 
> >From what I've observed, a signal won't trigger END
> blocks even
> outside of Catalyst.
> 
> Regards,
> Jonathan Rockway

To be honest I am not sure what should happen.  Your
example makes total sense, but I don't understand why
an INT|TERM signal doesn't always cause the
application to quit immediately and fail any END
blocks.  In the case I have I see that it fails the
END blocks unless I add some signal handlers in the
global space.  So I am at a lose to understand that.

I've spent a lot of spare time since I started this
threat more than 2 weeks ago trying to figure it out
but it seems that signal handling is quite arcane,
particularly if you need to worry about older Perls
and Perls on non Unix platforms.

Pressing Ctrl-C is how the tutorial tells me to exit
the development server (when running foregrounded). 
However this will definitely cause trouble with code
that uses END blocks, particularly for cleanup.  So
what I am trying to figure out is a good way to
canonically signal a catalyst application to
gracefully stop or restart.  This would be a way that
would respect any cleanup handling.

We have a run command for Catalyst::Engine, perhaps it
would be good to have a stop and restart here as well?
 Or maybe saying this displays too much ignorance on
my part, but I have to start somewhere :)

I guess I would like to help to try and clarify and
document the behavior.  I just could use some guidance
from people with more intimate understanding of the
system.  Maybe this is something more for the
development list?  

Thanks!

John

> ___
> 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/
> 



  

Park yourself in front of a world of choices in alternative vehicles. Visit the 
Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ 

___
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] Proper way to perform cleanups on server shutdown?

2007-07-11 Thread John Napiorkowski
--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Wed, Jun 27, 2007 at 02:38:34PM -0700, John
> Napiorkowski wrote:
> > Hi,
> > 
> > I'm finding that the way I usually catch shutdown
> > signals to perform cleanup is not working. 
> Setting
> > %SIG handlers doesn't seem to do it and I'm not
> > finding that DESTROY methods are getting fired off
> in
> > the expected way.
> > 
> > For example if I set a $SIG{INT} handler in the
> > application class (MyApp.pm) that get's called if
> I am
> > running the development server foregrounded and
> the
> > interrupt it with a 'ctrl-c', but it doesn't get
> > called if the development server is deamonized and
> I
> > kill the process.  $SIG{QUIT} doesn't seem to do
> it. 
> > DESTROY doesn't seem to every get called.
> 
> Add some better traces - I suspect this is either
> (a) a DBIC problem fixed
> in 0.08 or (b) a problem that isn't that you didn't
> give us a test case for
> yet :)

Okay, I've got something strange and could use some
advice about the best way to create a test case for
it.

Basically I am finding that END blocks anywhere in a
Catalyst application (even in END blocks from included
libraries) never get called when running the standard
development server and then shutting it down with
either an INT or TERM.

INT get's generated if you are running the development
server forgrounded and then press 'ctrl-c' to exit it,
while I get a TERM signal when running the server
backgrounded and then using kill $pid on it.

I can demonstrate this by placing an END block in my
root modules (the "MyApp.pm" module)

END {
  print "got END BLOCK!\n";
}

This will never run under the conditions I have
described.

HOWEVER, if I set SIG handlers manually like so:

$SIG{INT} = sub { print "got INT!\n" };
$SIG{TERM} = sub { print "got TERM!\n" };

END {
  print "got END BLOCK!\n";
}

Then the END block does run.  It also runs everywhere
in any Catalyst package or included module.

I'm not sure if this affects the other Catalyst
Engines.  I'll try to test it on Apache, for example. 
But I'm a little perplexed by this.  I am guessing
that these SIG handlers are being set someplace that
is causing trouble with the END blocks and that when I
set them myself it clears that trouble.  My suspicion
of this is increased because if I set the SIG handlers
as local the trouble behavior returns.

I'm not so sure how to create a test for this, since
I'm not sure how to capture  these Signals and could
use some advice for that.  I Could also use some
thoughts from the group as to what we'd like for this
to do.  Ignoring all END blocks is not good!

Thanks!

John


   

Moody friends. Drama queens. Your life? Nope! - their life, your story. Play 
Sims Stories at Yahoo! Games.
http://sims.yahoo.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/


Re: [Catalyst] html::prototype syntax in new Cat version

2007-07-11 Thread John Napiorkowski

--- John Wang <[EMAIL PROTECTED]> wrote:

> On 7/10/07, J. Shirley <[EMAIL PROTECTED]> wrote:
> >
> > On 7/10/07, John Napiorkowski <[EMAIL PROTECTED]>
> wrote:
> > >
> > > It's been said by others but I really prefer to
> do all
> > > this in my templates.  It would be easy to have
> this
> > > in a Template Toolkit plugin if you wanted, but
> I
> > > can't see the value of basically using perl as a
> code
> > > generator for Javascript.  I prefer to be closer
> to
> > > the original API.  But that's my choice :)
> > >
> > > --john
> > >
> > >
> >
> > Agreed, but I sometimes doubt the practicality of
> this when attracting
> > new users.  Folks who are comfortable with
> full-spectrum development
> > (setting up Apache, FastCGI/MP, Catalyst, their
> templating, DBs) are
> > the minority.  A significant number of users are
> copy'n'paste-based.
> > They take code that works, and include it in their
> own app and
> > continue until they get the product they want.
> >
> > Without helpers, we're going to be stuck with
> people asking about the
> > JS-toolkit that does have a helper.
> >
> > The only way I think we can help promote a "better
> path" is to make it
> > just as easy to use a better JS kit.  This means
> helpers, and TT
> > macros and all that.
> >
> > The problem is that everybody who has the
> knowledge to do this, simply
> > doesn't care to because they fundamentally view it
> as wrong or a waste
> > of time (which I do as well, but I see the
> "business" case for the
> > Catalyst project).
> 
> 
> I agree. I don't use Perl wrappers myself but think
> they would Catalyst more
> of a full solution and head off the Prototype.js
> questions we keep getting.

Maybe let has out what a wiki entry for this topic
could be like.  I have a little spare time to help
write it up.

suggested topics could be:

-- How do advanced JS libs integrate with Catalyst
-- What are the recommended libraries
-- What is the best place to turn for help
-- What is the Catalyst roadmap in regards to this.

What else do we think should be on there?

--john




 

Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 

___
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

2007-07-10 Thread John Napiorkowski

--- Daniel McBrearty <[EMAIL PROTECTED]>
wrote:

> > It's been said by others but I really prefer to do
> all
> > this in my templates.  It would be easy to have
> this
> > in a Template Toolkit plugin if you wanted, but I
> > can't see the value of basically using perl as a
> code
> > generator for Javascript.  I prefer to be closer
> to
> 
> my sentiments exactly. Even if your perl is way
> better than your js,
> it's harder to debug js wrapped in perl than
> straight js. You usually
> have to face the underlying library sooner or later.

In the case of toolkits like jquery or YUI, what you
end up with is a perl code generator that build JS
which is using another JS layer library to smooth over
browser compatibility issues...

--john

> 
> -- 
> Daniel McBrearty
> email : danielmcbrearty at gmail.com
> http://www.engoi.com
> http://danmcb.vox.com
> http://danmcb.blogger.com
> find me on linkedin and facebook
> BTW : 0873928131
> 
> ___
> 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/
> 



 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

___
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

2007-07-10 Thread John Napiorkowski

--- John Wang <[EMAIL PROTECTED]> wrote:

> On 7/10/07, J. Shirley <[EMAIL PROTECTED]> wrote:
> >
> >
> > prototype.js and friends (scriptaculous, openrico,
> etc) are rated the
> > lowest in those categories.  It fails the robust
> check by having
> > several things that don't play nice together, and
> also I've seen some
> > serious cross-browser compatibility issues. 
> Standardization is
> > probably the biggest gripe people have with
> prototype.js.  It doesn't
> > encapsulate and clobbers existing objects or adds
> on to them in weird
> > ways (like arrays).  As an example, if you use
> some effects in
> > scriptaculous, Google Maps fails to work because
> of their mouse
> > capturing code.
> 
> 
> Good to know. Do you know which Scriptaculous
> effects break Google Maps? It
> will be useful for planning for the future.
> 
> It's safe to say that inside of the Catalyst
> community, you will get
> > absolutely zero support if you chose to use
> Prototype.  You are free
> > to ask, but you will get flamed for your choice. 
> That's just the way
> > it goes.
> 
> 
> Some of the larger Catalyst-based sites use
> prototype (or parts of
> prototype) but the ones I've seen don't use Google
> Maps. Those projects also
> don't ask for prototype help from the Catalyst
> community. I think some of
> the flames given for prototype usage also prevent
> others from providing
> assistance. As you say, that's just the way it goes.
> 
> If you want alternatives, here are the more favored
> solutions that
> > have proven themselves to be of a quality
> Catalysters will bother
> > assisting with:
> > * Dojo - http://www.dojotoolkit.org/
> > * YUI - http://developer.yahoo.com/yui/
> > * jQuery - http://www.jquery.com/
> > * Mootools - http://mootools.net
> > * MochiKit - http://www.mochikit.com
> >
> > And, of course, there is Ext
> (http://www.extjs.com) which sits on top
> > of YUI and jQuery (and hopefully Dojo soon... and
> unfortunately
> > prototype.js, but it's a good way of getting your
> code away from
> > prototype and onto something higher quality.) and
> is more of a
> > "widget".
> >
> > Picking a quality JS lib is just as important as
> picking a quality
> > framework.
> 
> 
> 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.
> 

There is "http://search.cpan.org/~peterg/JQuery-1.06/";

which could meet those kinds of needs.

It's been said by others but I really prefer to do all
this in my templates.  It would be easy to have this
in a Template Toolkit plugin if you wanted, but I
can't see the value of basically using perl as a code
generator for Javascript.  I prefer to be closer to
the original API.  But that's my choice :)

--john


> -- 
> John Wang
> http://www.dev411.com/blog/
> > ___
> 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/
> 



 

We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

___
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 a persistent hash in a model

2007-07-07 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Sat, Jul 07, 2007 at 04:52:19PM +0200, Daniel
> McBrearty wrote:
> > Hi
> > 
> > I want to use a persistent hash in a model, using
> (I guess) Storable.
> > The hash would get inititalised in new, and
> modified in the model. I
> > would use lock_store to save any changes as data
> is modified in the
> > model class.
> > 
> > This would be OK in the test app, but as the app
> will get used under
> > fast_cgi, is this safe? Given that there can be a
> number of cat
> > instances running, presumably there will be as
> many model classes, and
> > therefore they will not be in sync as data is
> updated?
> > 
> > Is there any easy way to keep some ad-hoc
> persistent data out of the 
> > database?
> 
> For a single machine deployment I'd try DBM::Deep

++vote for DBM::Deep.  I'm using it very successfully
for adhoc stuff that I need persistence for but don't
need to keep or is not important enough for a table. 
It can even do an okay job of serializing your simple
objects. but buyer beware with that behavior.


> 
> -- 
>   Matt S Trout   Need help with your
> Catalyst or DBIx::Class project?
>Technical DirectorWant a managed development
> or deployment platform?
>  Shadowcat Systems Ltd.  Contact mst (at)
> shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/
> http://www.shadowcatsystems.co.uk/ 
> 
> ___
> 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/
> 



   

Sick sense of humor? Visit Yahoo! TV's 
Comedy with an Edge to see what's on, when. 
http://tv.yahoo.com/collections/222

___
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] Uniform treatment of all parameters (including file uploads)

2007-07-03 Thread John Napiorkowski

--- Zbigniew Lukasiak <[EMAIL PROTECTED]> wrote:

> I constantly bump into the mismatch in the treatment
> of 'normal'
> params and the file uploads.
> 
> Wouldn't life be simpler if
> 
> $c->request->param( 'file_field' )
> 
> would return a Catalyst::Request::Upload object (or
> an array of them)?
> 
> You can get the name of the uploaded file from a
> Catalyst::Request::Upload object.
> 
> -- 
> Zbigniew Lukasiak

I also think about this a lot since I'm working mostly
on applications with lots of file uploading.  You'd
still get a sort of mismatch though, but would be in
the type of thing that 'param' is returning.

In a way, with a POST everything is really an upload,
just that by convention if the type is urlencoded with
consider it a flat parameter list.  But I think we
will need a more evolved way of thinking about this. 
Work that's been done on the REST controllers suggest
a possible path.  This way we can convert any type of
incoming POST into some sort of Perl object or List of
lists.  Just need the correct de/inflators.

I like that Catalyst lets me easily separate
parameters extracted from a urlencoded body from
search query parameters.  I do really use then for
separate things.

You could probably write a quick plugin to push upload
objects into the param list, but messing with that
list will probably result in it not being widely
accepted.




   

Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469

___
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] IDE for use with Catalyst

2007-06-30 Thread John Napiorkowski

--- Fernan Aguero <[EMAIL PROTECTED]> wrote:

> 
> | Hi There,
> | 
> | I am taking a this week off of work and would
> really like to build an
> | application with catalyst.  Does anyone have an
> IDE that they can
> | recommend?  I have been developing perl apps for a
> while now but have
> | been using vi :). If anyone has any suggestions I
> wold love to hear
> | them.
> |
> 
> vim + omniperl
> 
> eclipse + epic
> 
> My $0.2
> 
> Fernan
> 

I also use Eclipse a lot, but find myself back with vi
time and time again.  I tend to have several xterms
open for stuff like psql prompt, log monitoring, etc.

--john


   

Moody friends. Drama queens. Your life? Nope! - their life, your story. Play 
Sims Stories at Yahoo! Games.
http://sims.yahoo.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/


Re: [Catalyst] Proper way to perform cleanups on server shutdown?

2007-06-27 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Wed, Jun 27, 2007 at 02:38:34PM -0700, John
> Napiorkowski wrote:
> > Hi,
> > 
> > I'm finding that the way I usually catch shutdown
> > signals to perform cleanup is not working. 
> Setting
> > %SIG handlers doesn't seem to do it and I'm not
> > finding that DESTROY methods are getting fired off
> in
> > the expected way.
> > 
> > For example if I set a $SIG{INT} handler in the
> > application class (MyApp.pm) that get's called if
> I am
> > running the development server foregrounded and
> the
> > interrupt it with a 'ctrl-c', but it doesn't get
> > called if the development server is deamonized and
> I
> > kill the process.  $SIG{QUIT} doesn't seem to do
> it. 
> > DESTROY doesn't seem to every get called.
> 
> Add some better traces - I suspect this is either
> (a) a DBIC problem fixed
> in 0.08 or (b) a problem that isn't that you didn't
> give us a test case for
> yet :)
> 

So you think this could be in DBIC?  I'll run the
whole thing in debug mode and see what I can find.

I guess I could use some help figuring out what we
would like the behavior to me.  For myself I'd like th
be able to respect SIGTERM (or whatever Apache sends
to modperl when it get's a stop command) and SIGHUP so
I can force a reload.

I got into this whole thing because I was writing some
code to create a tempdir for the template toolkit
cache files.  My admin want my application to kill up
more nicely after itself and I was tired of dealing
with permissions trouble in the /tmp directory when
several people are running the same instance of a
given catalyst application and all are trying to write
to the same tmp path.  I could handle this with local
config files for each developer but given the admin
request I figured it would be easier to just have TT
use a temporary directory.  Catalyst::Utils had a
nice, ready to go class2tempdir method but I just
found that when I killed the application the auto
cleanup just didn't seem to work.  So I ended up with
a bunch of tempdirs in /tmp which was the opposite
need.

That lead me to playing with this.  If we can work out
what we want I will offer a test for Catalyst::Utils
and a patch for the desired behavior.

Thoughts appreciated!

--John

> -- 
>   Matt S Trout   Need help with your
> Catalyst or DBIx::Class project?
>Technical DirectorWant a managed development
> or deployment platform?
>  Shadowcat Systems Ltd.  Contact mst (at)
> shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/
> http://www.shadowcatsystems.co.uk/ 
> 
> ___
> 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/
> 



   

Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.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/


[Catalyst] Proper way to perform cleanups on server shutdown?

2007-06-27 Thread John Napiorkowski
Hi,

I'm finding that the way I usually catch shutdown
signals to perform cleanup is not working.  Setting
%SIG handlers doesn't seem to do it and I'm not
finding that DESTROY methods are getting fired off in
the expected way.

For example if I set a $SIG{INT} handler in the
application class (MyApp.pm) that get's called if I am
running the development server foregrounded and the
interrupt it with a 'ctrl-c', but it doesn't get
called if the development server is deamonized and I
kill the process.  $SIG{QUIT} doesn't seem to do it. 
DESTROY doesn't seem to every get called.

So what I'm looking for is advice about the proper way
to shutdown the development server and Catalyst apps
running under Apache and how to trap those events both
globally (say in my MyAPP.pm module) and in
components.  I need this so I can do some
housekeeping, etc. 

Thanks!

--John


   

Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.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/


Re: [Catalyst] Custom error

2007-06-25 Thread John Napiorkowski

--- Evaldas Imbrasas <[EMAIL PROTECTED]> wrote:

> Actually, the example below doesn't work if there
> are any TT rendering errors.
> 
> Is there a catch-all solution, or does it have to be
> done on the Apache level?

I'm not sure what you mean.  If you are running in
mod_perl and set an error status (4xx or 5xx) Apache
will (in it's relatively default config) display a
standard template in various languages, depending on
the language setting for the client.  You can edit
these if you like.

If you want catalyst to handle all this, you need to
remove that apache stuff and catch all the error codes
and build templates as you like.  Catalyst doesn't
have this templates out of the box, you need to catch
errors codes and direct them to templates you made,
but it would be a really nice project for someone to
do.  Right now the non debug /debug message is just
inlined html in the Catalyst::Engine module.  It would
be cool to break this out and have some default
templates in TT, Mason, etc.

--john


> 
> 
> >
>
http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Cookbook.pod#Delivering_a_Custom_Error_Page
> >
> 
> 
> -- 
>
-
> 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/
> 



   

Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

___
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] iterating ResultSet in controller vs. template

2007-06-19 Thread John Napiorkowski

--- John Goulah <[EMAIL PROTECTED]> wrote:

> If I do something simple like this:
> 
>  my $myalums  = [
> $c->model('MyDB::Alumni')->search({}, { rows => 20
> })
> ] ;
> 
> and stash it:
> $c->stash->{alumni} = $myalums;
> 
> I am able to iterate in the template like:
> 
>[% FOREACH alum IN alumni -%]
>id: [% alum.alumni_id %]  
>[% END -%]
> 
> 
> But if I try to iterate this in the controller, I
> cannot do something like:
> 
> while (my $alum = $myalums->next) {
> $c->log->debug("id: ". $alum->alumni_id);
> }

Because ->next isn't a method on an array reference. 
You could try derefing via @$myalumns.

--john

> 
> unless I dont return an anonymous reference like:
> 
> my $myalums  =
> $c->model('MyDB::Alumni')->search({}, { rows => 20
> }) ;
> 
> then the while loop above works fine, but I dont get
> any output in the
> template.  I'd like to be able to use the iteraters,
> so what am I doing
> wrong here?


> 
> 
> Thanks!
> John
> > ___
> 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/
> 



   

Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz
 

___
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() Attribute

2007-06-18 Thread John Napiorkowski

--- Zbigniew Lukasiak <[EMAIL PROTECTED]> wrote:

> When we are at this View refactoring.  When changing
> the template you
> need to put the whole path on stash ( $c->stash(
> template =
> template_path/template.tt) ).  What I would propose
> is that the view
> automatically used the $c->action->namespace as the
> template_path - so
> that you would not need to specify the full path -
> only the template
> name.
> 
> This would mean less typing in most common case but
> also should be
> useful when inheriting from a base controller -
> since it would
> automatically adjust the template paths - and that
> is what you need in
> most cases as well.  The ideal would be if it would
> search the
> template directories of respective controller
> classes in the
> inheritance tree - but I have no idea how to
> accomplish that.

I'm not sure how far we want to go; do we want one
uber base class or a simple base with 'plugins' for
extra behavior?  Because I can think of lots of stuff
I'd like to use for some situations.  For example I
have cases where for all templates in a given
directory I want to set a particular WRAPPER for my
Template toolkit, etc.

--john

> 
> --
> Zbyszek
> 
> On 6/17/07, Jonathan Rockway <[EMAIL PROTECTED]> wrote:
> > On Sunday 17 June 2007 01:02:52 pm Christopher H.
> Laco wrote:
> > >
> > > Well, if we're throwing things in the ring...
> > >
> > > C::View::Templated
> > >
> > > ->template()
> > >
> > > And some forms of:
> > >
> > > ->template_paths(\@)
> > >
> >
> > I like this.  Should we put this in a separate
> package, or right in C-Runtime?
> >
> > Incidentally, you could do
> $c->view->template('...')* instead of
> > $c->stash->{template}, which looks pretty nice.
> >
> > * or $c->view('View::TT')->template('...') if you
> don't like default_view.
> >
> > --
> > package JAPH;use Catalyst
> qw/-Debug/;($;=JAPH)->config(name => do {
> > $,.=reverse qw[Jonathan tsu rehton lre rekca
> Rockway][$_].[split //,
> > ";$;"]->[$_].q; ;for
> 1..4;$,=~s;^.;;;$,});$;->setup;
> >
> > ___
> > 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/
> >
> 
> 
> -- 
> Zbigniew Lukasiak
> http://brudnopis.blogspot.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/
> 



   

Get the free Yahoo! toolbar and rest assured with the added security of spyware 
protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php

___
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() Attribute

2007-06-16 Thread John Napiorkowski

--- Jonathan Rockway <[EMAIL PROTECTED]> wrote:

> On Friday 15 June 2007 08:36:33 am Christopher H.
> Laco wrote:
> 
> > OPTION #2: View::TT, View::Mason, View::**
> > --
> >
> > PROS:
> >
> > Template() will be honored with the use of
> RenderView and the use of
> > forwarding to a view manually (like in REST or
> other controller code).
> >
> > CONS:
> >
> > This has to be implemented in each View::**
> package that wants to
> > support it.
> >
> > IF one changes from a view the support it, to one
> that doesn't,
> > controllers go boom.
> >
> 
> What we really need to do is add a utility method
> like template_name() to the 
> Catalyst::View base class.  Even without the
> :Template attribute, there is 
> code duplicated between every view that shouldn't
> be( $template = 
> $c->action || $c->stash->{template} ). 
> 
> Let's factor that out into to Catalyst::View, fix
> the views in svn, and then 
> you can add the :Template code there.  It needs to
> be done, and your feature 
> is the, uh, catalyst for change.
> 
> Thoughts?

This would make a great Moose Role.  I never liked
'template' being part of the stash and typically
avoided using it.  But it still got me a few times
when I had some database tables named 'Template' :)

I'd like to see this factored so that it would be a
role Role for controllers as well.  But I think we
need to think a little about how the Views get
dispatched to.  Right now most of use just have
something stuck in the Root controller.  Perhaps if
this is working for use we should canonicalize it as
something?

-john

> 
> -- 
> package JAPH;use Catalyst
> qw/-Debug/;($;=JAPH)->config(name => do {
> $,.=reverse qw[Jonathan tsu rehton lre rekca
> Rockway][$_].[split //,
> ";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;
> 
> ___
> 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/
> 



  

Park yourself in front of a world of choices in alternative vehicles. Visit the 
Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ 

___
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] How to show SQL in apache error_log?

2007-06-12 Thread John Napiorkowski

--- Cookie <[EMAIL PROTECTED]> wrote:

> It seems useless.The apache error_log still don't
> output the sql.
> Thanks for your reponse.
> 
> 
> 
> Date: Mon, 11 Jun 2007 09:41:04 +0300
> From: "Octavian Rasnita" <[EMAIL PROTECTED]>
> Subject: Re: [Catalyst] How to show SQL in apache
> error_log?
> To: "The elegant MVC web framework"
> 
> Message-ID:
> <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> You can put
> 
> $ENV{DBIC_TRACE}++;
> 
> in MyApp.pm
> 
> Octavian
> 
>  - Original Message - =
> 
>  From: Cookie =
> 
>  To: catalyst@lists.rawmode.org =
> 
>  Sent: Monday, June 11, 2007 7:01 AM
>  Subject: [Catalyst] How to show SQL in apache
> error_log?
> 
> 
>  As we know,if we use export DBIC_TRACE=3D1 and then
> we run the myapp_serv=
> er.pl,we can see the sql from the stander output.
>  I want to show the sql in the apache error_log.I
> modify the httpd.conf fi=
> le like this:
>  setenv DBIC_TRACE 1
>  But it seems useless.How can solve this problem?
>  Thanks.

If you are using DBIx::Class, you can enable debugging
mode, which output the SQL generated.  Also you can
enable DBI trace levels like so:

$schema->storage->debug(1);
$schema->storage->dbh->trace($x);

Where $x is range 1..15.  See:

http://search.cpan.org/~timb/DBI-1.56/DBI.pm#TRACING

For more.  Don't make the number too big or your logs
will explode.

I guess this all goes to STDOUT, but not sure what
Apache will do with that.  I don't have a lot of
experience with it because I usually log to a database
with log4perl for my webapps.  But give it a try.  You
might have to tweak the apache log configuration.  If
you are running the app in a virtual host you can
create a custom log handler just for it, so it's not
mixed up with your other hosts.

--john



 

Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

___
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 a function once on all requests

2007-06-04 Thread John Napiorkowski

--- Steve Francia <[EMAIL PROTECTED]> wrote:

> Eden Cardim wrote:
> > On 6/4/07, Steve Francia <[EMAIL PROTECTED]> wrote:
> >>  Anyone know of any good reason to do it
> differently, or has anyone used
> >> other strategies in the past?
> >
> > That looks like auto-chaining, you might want to
> take a look at "auto"
> > actions.
> >
> >
>
http://search.cpan.org/~jrockway/Catalyst-Manual-5.700701/lib/Catalyst/Manual/Intro.pod#Built-in_actions_in_controllers/autochaining
> >
> > http://dev.catalystframework.org/wiki/FlowChart
> >
> It does look like auto-chaining, so perhaps I should
> restate my original
> question.
> 
> What I want to do is a bit more specific.
> I am using chaining a decent amount, often chaining
> across different
> controllers.
> 
> The end result of what I want to do is pass into the
> template (TT) the
> top most level controller name IE the controller
> closest to root.
> This is accessed using $c->namespace, from within
> the controller.
> 
> If I use auto-chaining like:
> 
> sub auto : Private {
> my ( $self, $c ) = @_;
> $c->stash->{ controller } = $c->namespace;
> }
> 
> in the root controller (Root.pm). It works until I
> chain across more
> than one controller.
> Instead of the first, it gives me last controller in
> the chain, which
> leads me to believe that this method is either
> called once for each
> controller or called only once, but from the last
> controller in the chain.
> 
> Perhaps there is a different approach with
> autochaining I should try.

I've found similar things when using actions across
controllers with Chained actions.  If you have a
chained private path the spans more than one
controller it's the controller that owns the
terminating action that is associated with
$c->controller, not the root of the chain.  This
caused me trouble once as well; I guess for me it was
more intuitive that way always I can't rationally
defend it as better than the way it actually works.

At least the auto and chained action behavior is
consistent.

One thing that might bite you here is that to me it
sounds like you are tying the controller a bit too
tightly to your view logic.  Because it sounds like
you are performing some sort of logic in the view
based on the controller name.  I don't know your exact
need so I could be totally wrong here, but I thought
to mention it.  It could work better for you in the
end to decouple the view and controller and if you
need to access some logic or data in the view that
resides in the controller using an intermediary class
might be better.

Anyway, I'd be interested to here more about your
application!

Thanks,
John

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] running a function once on all requests

2007-06-04 Thread John Napiorkowski

--- Steve Francia <[EMAIL PROTECTED]> wrote:

> I have a routine I would like to run once for each
> request.
> 
> After reading through the docs, I think I have found
> a good approach and
> am wondering what others have done.
> 
> I created a base controller which uses base
> 'Catalyst::Controller' .
> Inside the base controller I create a begin
> function:
> 
> sub begin : Private {
> my ( $self, $c ) = @_;
> 
> $c->stash->{ controller } = $c->namespace;
> }
> 
> In all my other controllers I use this base class.
> 
> If I want to add a controller specific begin routine
> to a controller I
> place the following in that controller class:
> 
> sub begin : Private {
> my ( $self, $c ) = @_;
> 
> $self->SUPER::begin($c);
> # CONTROLLER SPECIFIC LOGIC HERE
> }
> 
> 
> Anyone know of any good reason to do it differently,
> or has anyone used
> other strategies in the past?
> 
> Thanks,
> Steve Francia


I think begin actions where created for exactly this
reason.  The only thing I do differently is to use
NEXT or C3 instead of SUPER.

--john


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Plugin HOWTO?

2007-06-04 Thread John Napiorkowski

--- Michele Beltrame <[EMAIL PROTECTED]> wrote:

> Hello Cristina!
> 
> > I would like to know if there's any HOWTO (or best
> practice) available
> > on writing Catalyst's plugins.
> 
> Try this:
> 
>
http://search.cpan.org/~jrockway/Catalyst-Manual-5.700701/lib/Catalyst/Manual/ExtendingCatalyst.pod
> 
> Michele.

Hi,

Cristina, perhaps you could share with us the what
task it is you are trying to do?  If you read the
posted link you will see that there are several ways
to extend or integrate catalyst with your project
depending on your goal or needs.  

--john


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] deploying a Catalyst app

2007-06-01 Thread John Napiorkowski

--- mla <[EMAIL PROTECTED]> wrote:

> Octavian Rasnita wrote:
> > Hi,
> > 
> > Please tell me where can I find more information
> about deploying a Catalyst
> > app.
> > I think there should be a way of creating a
> tarball with the whole app,
> > including the entire application.
> > 
> > When installing it on the target machine (with
> make, make install) it 
> > should
> > require all the necessary Catalyst and
> non-Catalyst modules.
> > 
> > It should be also nice if it would be a way of
> creating automaticly a 
> > tarball that contains all the necessary modules,
> and install them no 
> > matter if some of them are already installed on
> the target machine or 
> > not (including the entire Catalyst framework).
> 
> How do most of you deploy applications? I've seen
> several references
> to tarballs now. Do you do that even for very large
> sites?
> 
> I've always used cvs/svn for the app. Tagged it for
> staging/prod and
> pulled the changes to the appropriate servers.
> 
> Maurice

I do my best to have the application install as a
standard perl module, that way my admin can install it
with a well known procedure and I can have the
application prompt to download required modules, etc.

Right now there is still a bit of tweaking of env vars
to find the correct configuration files and so forth,
but I'm trying to learn how to prompt for that during
installation.

Ideally I'd like to use PAR and the PAR module for
apache.  That way I can just hand off a single file to
my admins.  But until I can learn to make that work
properly I think setting up to install like a regular
perl module is a good way to do it.  It also tends to
push me to make sure I wrote good tests and all that
as well :)

For an example of a catalyst application designed like
to install with CPAN you can check out Angerwhale at:

http://search.cpan.org/~jrockway/Angerwhale-0.05/lib/Angerwhale.pm

--john
--john


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] using REST within the app

2007-05-24 Thread John Napiorkowski

--- stephen joseph butler <[EMAIL PROTECTED]>
wrote:

> On 5/24/07, John Goulah <[EMAIL PROTECTED]> wrote:
> > What are some of the patterns people are using to
> implement this?  Any other
> > thoughts?
> 
> People are going to hate me for saying this... but
> I've started to
> adopt the Java bean paradigm for my Catalyst app. To
> the point where I
> even have a whole MyApp::Bean hierarchy (skip to the
> bottom if you're
> already gearing up for a big paradigm fight).
> 
> Why? I had this nice little CRUD app that did what I
> wanted. But then
> I started looking at adding XMLRPC support, and
> other things.
> Reviewing my code, I realized I couldn't just call
> my existing methods
> because they all assumed things like:
> 
> 1) Parameters would come in an HTML::Widget or some
> CGI like interface
> (param, params, parameters, etc). When dealing with
> XMLRPC this isn't
> true.
> 
> 2) Errors would just be stuffed into the stash.
> Which is fine if
> you're going to render them, but isn't as nice for
> other solutions.
> Suppose I needed to add SOAP support later. Errors
> should come via
> SOAP exceptions.
> 
> 3) That the context would be able to provide things
> like the current
> user. With XMLRPC, sometimes the external app would
> need to feed the
> user to my backend, so what's in the context would
> be wrong.
> 
> 4) The general assumption that the content in the
> stash was going to
> be rendered. Some methods would fetch several things
> from the database
> and stash them because that's what the templates
> would need. But with
> XMLRPC, it was a waste.
> 
> I happen to have done some work with JavaEE and am
> familiar with the
> design pattern, so that's the solution I reached
> for. It's still MVC,
> but the controller has two parts.
> 
> A) The servlet, which corresponds to Catalyst
> controllers. But the
> servlets don't do any of the actual work; they just
> marshal the data
> between the HTTP interface and your beans...
> 
> B) The beans, which contain all the business logic.
> These interact
> with the model, manipulate it, and then return the
> results to the
> servlets. Beans should never be written with the
> transport (HTTP,
> SOAP, XMLRPC) or view in mind: all that's the job of
> the servlet. If
> the view needs extra data from the model for this
> transport, then it's
> the job of the servlet to fetch that.
> 
> This might or might not work for you. I'm not
> interested in starting a
> design paradigm war; I understand they all have
> their own strengths
> and weaknesses. Just thought I'd throw this out
> there

I don't think this should start a flame war; I think
the general consensus on best practices is that the
controller should be very thin, ideally you should be
able to simple set up your controllers with
declaration s in the config files and then you have
action classes that link up with domain model through
some interface logic, which are separate from
Catalyst.  This way you can use the same underlying
stuff for cron jobs or other needs, such as RPC.

So I think we are starting to come to that point, just
maybe we all don't have a canonical example of the
best way to approach building that layer.  The Mango
project has something like that and looking at the
source for that has given me a lot of things to think
about.  Reaction is a project that is one step up from
the domain model and sits between it and Catalyst to
offer a clear means of linking the two (Someone PLEASE
correct me if I'm wrong about Reaction).

--john

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Lightweight error/messages reporting to templates

2007-05-24 Thread John Napiorkowski

--- Paul Makepeace <[EMAIL PROTECTED]> wrote:

> I'm hoping there's a 'best practice' or common
> pattern for reporting
> errors and messages to templates (not necessarily
> just forms).
> 
> I find myself doing stuff like,
> 
>  my @errors; my @messages;
>  # ...
>  if ($some_err_condition) {
>push @errors, "whoops";
>  } else {
>$obj->update;
>push @messages, $obj->name . " updated!";
>  }
>  # ...
>  $c->stash(messages => join "", @messages);
>  $c->stash(errors => join "", @errors);
> 
> Which is then tediously copy & pasted amongst
> controllers that do that
> reporting.
> 
> And then my template says something like,
> 
>   [% IF errors %]
> [% errors %]
>   [% END %]
>   [% IF messages %]
> [% messages %]
>   [% END %]
> 
> At least with the template I have that as a MACRO I
> can call variously
> but I'd at least like a way to have some kind of
> context/controller-wide way of dealing with these
> errors & messages. I
> don't quite understand Cat's object model well
> enough to do this
> globally myself yet.
> 
> P
> 
Hi,

This doesn't cover communicating errors to templates
but this journal at
"http://bricas.vox.com/library/post/catalyst-exceptionclass.html";
gives an example for creating custom Exception objects
that Catalyst can use.  Might be something here to
give you ideas (I know it did for me) but probably
doesn't qualify as lightweight.

--john


--John

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] using REST within the app

2007-05-24 Thread John Napiorkowski

--- John Goulah <[EMAIL PROTECTED]> wrote:

> What are peoples thoughts on using REST not only as
> a web service, but also
> within the application itself as another layer of
> abstraction?  I would
> assume in this way all the DB related calls would go
> through the REST layer,
> and this way they can be invoked as services or
> locally through the app.  Is
> this too much overhead since the model itself is a
> layer?
> 
> What are the best ways to deal with this from a
> security aspect (such as
> making sure people dont call some DELETE action on
> senstive data)? Is this
> handled with authorization or some other such way? 
> I wouldn't want an
> "authorized" user to delete content they aren't
> authorized to delete of
> course.
> 
> What are some of the patterns people are using to
> implement this?  Any other
> thoughts?
> 
> 
> Thanks!
> John

I've been trying to build an application around this
idea but it's not trivial to model all your business
interactions in terms of CRUD like behaviors against
resources.  For me that was the number one issue.

For example, I'm designing a tagging system for
internal applications at this bank.  We are applying
tags to several different types of entities, such as
calenders, news items and blogs.  We want a global tag
system for this so we can build feeds for mixed
content based on the tag.

You'd think it would be very straightforward since
tagging is common and examples abound.  But when you
actually go to design the URI space you have to make a
lot of calls which will profoundly affect how a system
is used.  Things get complex quickly!  For example do
you let the API update and add tags via a given
resource with UPDATE, like:


 ...inline news content
 
   
   


Or follow the more RESTful:


 ...inline news content
 
   
   


Or should the content no be inlined:


 
 
 
   
   


Some examples above are more RESTful, but makes it
harder for your API consumers.

I'm far from an expert on the matter but I have tried
this and found it's not a cure all.  I have noticed
all the most successful REST and RESTlike APIs have
all been for straightforward and simple services. 
Building an enterprise API on this may not be easy.

In general I've been trying to use the Atom API as my
exchange and publishing model.  For my custom content
I try to use RDF and not invent my own XML each time. 
Or I find something already existing, such as iCal for
calendars.  

The Atom community for this is very active and can
give suggestions.  However I also try to make
everything viewable as JSON as well, which makes it
easier to use some of the available Ajax toolkits for
building my management forms.

Security wise you should stick with the standard HTTP
error codes.  For example if a user is not permitted
to DELETE than that would return a Method not allowed
style error.

Overhead is of course an issue but since in theory a
properly designed REST system would scale massively it
should just be a matter of designing your network
properly.

Sure I've created more questions than I've answered :0
 Good luck! --john

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] includes in catalyst

2007-05-22 Thread John Napiorkowski
--- John Goulah <[EMAIL PROTECTED]> wrote:

> Is it better to put module "use" statements within
> each controller class
> they are used in, or at some more global level , and
> if so where is
> suggested?
> 
> 
> Thanks!
> John

The general consensus is that you should use a module
where it's needed, not in a global area.  You can
however create your own base controller, inheriting
from Catalyst::Controller, that uses everything for a
particular task that you reuse in multiple
controllers.

If the package you are including is very data oriented
you can consider wrapping it in a model class.

Not recommended is creating a plugin just to expose
some common functionality.

--John

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


RE: [Catalyst] ActiveRecord for Perl

2007-05-22 Thread John Napiorkowski

--- Eduard Giménez <[EMAIL PROTECTED]> wrote:

> > I'm considering trying to port Ruby's ActiveRecord
> to Perl as 
> > a lightweight ORM option (with some small changes
> maybe, like 
> > composite PKs). If anyone's interested, toss me a
> message 
> > privately and we'll coordinate.
> 
> Why not simply colaborate to extend DBIx?

Just as a followup to that, you should really try to
write a list of everything you think is missing from
DBIx and discuss it over on the project mailing list. 
The framework is designed around a component
architecture so it's straightforward to add or alter
features.  I find it unlikely you will be able to
match it's features without more than a year of
consistent effort.

Some of the validation stuff that AR does for you
could be handled by some hacking on DBIC::Validation
although to be honest good design would preclude
wanted to put all your validation in the physical
model class.

--John

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


[Catalyst] Creating Good Adaptor or Bridge Models (WAS: Creating a thin Model)

2007-05-22 Thread John Napiorkowski
--- Jamie Neil <[EMAIL PROTECTED]> wrote:

> Matt S Trout wrote:
> > If you get stuck, could you start a fresh thread,
> please? I think this one
> > has officially got confused now :)
> 
> Ok. Just for the record though, this seems to be
> working fine so far:
> 
> 
> package MySite::Model::Widget;
> 
> use strict;
> use warnings;
> use base qw/Catalyst::Model/;
> use MySite::Widget;
> 
> __PACKAGE__->config(
>  connect_info => [
>  'dbi:Pg:mysite', 'username',
>  'password', { AutoCommit => 1 },
>  ],
> );
> 
> sub new {
>  my ( $class, $c, $args ) = @_;
>  return MySite::Widget->new(
>  Catalyst::Utils::merge_hashes( $args,
> $class->config ) );
> }
> 
> 1;

[CUT]

Hey,

Maybe we could summarize the best practice lessons
from this thread?  If so I'll be happy to put them on
the wiki someplace suitable.

So we are saying it's better to override new instead
of COMPONENT and that it's okay to return your class
directly in new and not have to create an accessor and
then use AUTOLOAD to dispatch method calls?

So when you just want to make the object available via
$c->model(...)->method you can do (in the catalist
model):

sub new {
  my ($class, $c, $args) = @_;

  return ExternalModule->new(
Catalyst::Utils::merge_hashes( $args,
$class->config )
  );
}

But if you are adapting and/or altering the method
calls it would be better to:

__PACKAGE__->mk_accessors(qw/some_object/);

sub new {
  my ($class, $c, $args) = @_;
  my $self = $class->NEXT::new($c, $args);

  $self->some_object(Someobject->new(
Catalyst::Utils::merge_hashes( $args,
$class->config )

  return $self;
}

sub adapted_method
{
  my $result = shift->some_object->internal_method;
  ## Do something to $result
  return $result;
}

The reason I ask is because there have been several
ways of doing this very basic type of thing floating
around CPAN and I'm sure I'm not the only one
confused.

Maybe we could try to generate a concise list of cases
and then try to work out a best practices example for
each?  I'm sure that would be a good thing for a wiki
entry or even as part of the POD docs.

--john

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Creating a thin Model

2007-05-18 Thread John Napiorkowski

--- "Christopher H. Laco" <[EMAIL PROTECTED]> wrote:

> Christopher H. Laco wrote:
> > Jamie Neil wrote:
> >> Can anyone tell me the best way of wrapping a non
> catalyst perl module
> >> in a Catalyst Model?
> >>
> >> I'm trying to setup the following stack:
> >>
> >> MyApp::Controller::Widget
> >> MyApp::Model::Widget
> >> MyApp::Logic::Widget
> >> MyApp::Schema::DB
> >>
> >> where MyApp::Model::Widget is based on
> Catalyst::Model, contains the
> >> configuration information for
> MyApp::Logic::Widget, and makes the
> >> methods in MyApp::Logic::Widget available in
> MyApp::Controller::Widget
> >> as $c->Model('Widget')->mymethod(...);
> >>
> >> MyApp::Schema::DB is a DBIC Schema which I want
> MyApp::Logic::Widget to
> >> use for storage, but not just passed through to
> the Model in the same
> >> way that Catalyst::Model::DBIC::Schema does.
> >>
> >> There is obviously more than one way to do this
> from looking at all the
> >> other models on CPAN, but is there some kind of
> best practice? Should I
> >> use AUTOLOAD, ACCEPT_CONTEXT, COMPONENT, override
> new or something else?
> >>
> >> I did see a very promising thread on this issue a
> few months ago, but
> >> this question
> >>
>
(http://lists.scsys.co.uk/pipermail/dbix-class/2007-January/003289.html)
> >> was never really answered. I've been going round
> and round in circles on
> >> this for a couple of weeks now, so some pointers
> (or even better example
> >> code) would be most welcome.
> >>
> > 
> > You're right. It depends on a few things.
> > Does the module you're wrapping have a new? Is it
> statefull? stateless?
> > Is it self creating, or is it a factory that
> creates other things.
> > 
> > Those are all factors.
> > 
> > Personally, I almost always do:
> > 
> > sub COMPONENT {
> >my $self = NEXT::new
> > 
> >  diddle config...return $self
> > }
> > 
> 
> Sorry...that pseudo code was too vague:
> 
> 
> sub COMPONENT {
>   my $self = shift->NEW::new(@_);
>   $self->{'noncatclass'} = NonCatClass->new
>   return $self
> }
> 
> Then, delegate via autoload, or use real methods to
> forward request to
> the instance of the real class...
> 
> -=Chris

Any comments on why it's better to override
'COMPONENT' as opposed to 'new'?  I could never really
figure out the advantages or disadvantages for either.
 Of course if you are going to subclass a model that
might use 'ACCEPT_CONTEXT' then new is the only way to
go.

--john


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Application design best practice

2007-05-18 Thread John Napiorkowski

--- Richard Jones <[EMAIL PROTECTED]> wrote:

> Having struggled to get my actions to match my urls
> the way I (think) I 
> want, it was suggested in another thread that I put
> one or more action 
> methods in the Root controller. I would be
> interested in opinions about 
> what should/should not go in the Root C. At the
> moment I just have login 
> logic in the auto sub (a la Tutorial), and a
> query_log routine.
> 
> I know Catalyst is flexible, and will work OK
> whatever, but there might 
> already be some good ground rules covering this. I
> am anxious to avoid 
> generating an app with a large collection of methods
> in Root and not 
> much elsewhere.
> -- 
> Richard Jones

Hi,

That was me that mentioned the Root controller option.
 It's not at all best practice to simple chuck
everything into root; I only suggested it as a way to
get you past the initial learning curve where you are
now frustrated because things are just acting strange
and you don't know why.  I promise you with a little
effort and time it will become more clear, just if you
can't get anything at all to work you will get very
frustrated.

Typically I have in my Root.pm a default action to
catch anything not caught, auto for centralizing my
authorization and a catchall end controller.  I also
tend to chuck ideas I am playing with there, since
it's easy.

--john


> 
> 
> ___
> 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/
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Re: Catalyst without template

2007-05-17 Thread John Napiorkowski

--- "A. Pagaltzis" <[EMAIL PROTECTED]> wrote:

> * Dmitri Pissarenko <[EMAIL PROTECTED]>
> [2007-05-17 17:00]:
> > sub buttonPressed : Local {
> >my ( $self, $c ) = @_;
> > 
> >my $name = $c->request->params->{name};
> > 
> >$c->res->write("Hello " . $name . ", welcome to
> the world of Dojo!\n");
> > }
> 
> Don’t do that, it leads to spaghetti. Write your
> own View class
> and generate the output from there.
> 
> Regards,
> -- 
> Aristotle Pagaltzis // 

Might want to check out the Catalyst view for Template
Declare mentioned earlier on this list at:
http://www.mail-archive.com/catalyst@lists.rawmode.org/msg05252.html

Good for when you you want to quickly put together
screens for debugging or for simply stuff.  That way
you can avoid the effort of getting TT setup and
hacking templates.  I've also used HTML::Tree for this
in the past, when I didn't want all the power of TT. 
Not sure if I'm convinced about using it for lots of
pages, but choice of Templating is pretty personal so
I won't try to start a flame war.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Catalyst actions

2007-05-17 Thread John Napiorkowski

--- Richard Jones <[EMAIL PROTECTED]> wrote:

> Help - I'm going round in circles with Catalyst
> actions. I want
> http://localhost:3000/search to map to the method
> search() in
> MyApp::Controller::Search, so I defined the method
> as:
> 
> sub search : Path Form('/search') { # a formbuilder
> method
>   if ( $form->submitted && $form->validate ) {
> $c->detach('retrieve');
>   }
>   # etc;
> }
> 
> sub retrieve : Private {
>   # performs db lookup, results in $rs, then:
> 
>   if (! $rs->pager->total_entries ||
> $rs->pager->total_entries > 1000) {
> $c->stash->{error_msg} = sprintf 'Total records
> matched = %s, please
> refine search', $rs->pager->total_entries;
> $c->detach('search'); # re-load search form with
> message
>   }
>   else {
> # display results in template
>   }
> }
> 
> Now, if the $rs->pager->total_entries value triggers
> $c->detach('search'), then the following error is
> generated:
> 
> Couldn't render template "file error -
> search/search: not found"
> 
> I also sometime see [% Catalyst.uri_for('search') %]
> translating to
> 'base_url/search/search' in the template, and though
> ugly, it does work.
> 
> It's probably got something to do with the
> definition of search() as an
> empty Path, but that's the only way I could get the
> the address to read
> http://localhost:3000/search as opposed to something
> ugly like
> http://localhost:3000/search/search, as it does if I
> define search() as
> a Local action, ie 'sub search : Local'.
> 
> I've also tried playing with calling the default
> method 'index' and
> 'default', and various attributes Local, Path,
> Global (I know that one's
> wrong) but ran into problems with all of those. I
> can't do a
> $c->res->redirect to the url '/search' as I need the
> original search
> params reloading. Can anyone see an obvious solution
> to this? Probably
> to do it the correct way!
> 
> -- 
> Richard Jones

Hi,

your search action is being mapped to the
/search/search namespace because when you use the Path
attribute without a value it defaults to whatever the
sub name is, in this case what you are doing is like
Path('search').  This gets scoped under the
controllers namespace (in this case the action
namespace for your controller is /search, so the
search method that you define get's put as
/search/search.)

The error you are getting is because by default TT
View looks for a template at a path based on the
action's namespace, so you want a file called search
under root/search path.

If you want your search method to be at url /search
try defining it with a Path('') attribute (explicitly
setting to empty).  Or put this stuff in your Root.pm
controller, which defines it's action namespace to
'/'.

BTW, you can spot all the private and public
namespaces for you application when it starts up.  It
gives a long debug info screen which is very helpful.

I know when you first start this can be difficult and
confusing.  I think it's a bit harder now because as
time has gone on Catalyst has added more and more ways
to map actions, mostly because as we've all used
Catalyst we've come up with more needs.  So some ways
of mapping are somewhat deprecated.  I tend to use
action chains mostly now, and sometimes Path.  Default
I tend to use in the root controller to capture an
ultimate not found response.

If this is too confusing then you can just put
everything into the Root.pm controller. Then it's like
building a CGI::Application webapp, which might be
easier to get.  The main advantage to breaking out
into multiply controllers is in easy of understanding
and when you make base controllers for different kinds
of activities.

--john

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


RE: [Catalyst] Form validation in insert() and update()?

2007-05-16 Thread John Napiorkowski

--- Jason Gottshall <[EMAIL PROTECTED]> wrote:

> Chris Laco wrote:
> > Off Topic. Making a note for myself and
> DBIC::Validation
> > 
> > 100 can be validated because we have %colinfo
> {size => 100}
> > Patterns could be covered in validation_profiles
> at the source
> > level...but maybe this would be nice as well:
> > 
> >   {
> > type => 'VARCHAR',
> > size => 100,
> > validation => qr/[EMAIL PROTECTED]/
> > #validation => sub{}
> >   }
> > 
> > 
> > /me urns for better validaiton profiles created
> from DBIC %colinfo
> 
> This gets at precisely the issue I've been wrestling
> with lately.
> Validation constraints at all levels (db, model,
> controller, form, etc.)
> seem to sort themselves into two general categories:
> field-specific
> questions ("Is it required/unique?", "Does it match
> a given pattern?",
> etc.) and broader domain-level interdependencies
> ("Require at least one
> of the following...", "If A is 'foo' then B must
> match /^bar|baz|qux$/",
> etc.) This leads me to want to define those
> constraints in different
> places. 
> 
> For example, I'd love to be able to define
> per-column validation
> patterns/subs at the DBIC level as Chris describes
> above, and then
> utilize that meta info to validate input at higher
> levels (model,
> controller, form) as MST described in another post
> on this thread. But
> I'd also need a way to create a profile for, let's
> say, form field
> validation interdependencies (which can be
> independent of
> domain/model/db-level interdependencies, as
> previously noted). But how
> do I implement a concise way of accomplishing all
> these things?
> 
> Or is the fact that I have so many things to worry
> about an indicator
> that this isn't going to be concise?
> 
> If Chris were to implement a per-column profile
> option for
> DBIx::Class::Validation, I'd be inclined to look for
> a way to use
> Data::FormValidator at several levels. Would it make
> sense to have a
> method that would compile everything from %colinfo
> and
> validation_profile() into a single profile that
> could then be utilized
> (and modified/extended) at the model/controller
> level?

I was thinking something similar.  We could have an
optional DBIC::Validation::Auto that would create a
base profile based on the columnn metadata, like
required, unique, must be FK, etc.  Then your custom
profile would be automatically merged in.  Would be
useful to help CYA at the physical model level. 
However you still need to do checking at your business
model level and possible at the form level, depending
on how you are doing forms.  Since I've been writing
my most recent business logic stuff with Moose, I've
been trying to use Moose's built in type checking for
a lot of that.  Still have a lot to learn with that.

For the top most layer of validation, associated with
a particular form,  I don't think this belongs in the
controller, I think it's more a view thing.  Lately
I've been doing it as macros in template toolkit, for
the most top level, final validation.  This is a
combination of Ajax style callbacks and client-side
Javascript.  Maybe that's ugly.  Not sure yet, I need
to work with a bit more.  Jquery has some nice plugins
to help with this.

--john

> 
> And should this branch of the thread be moved to the
> DBIC list?
> 
> Jason
> 
> ___
> 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/
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] getting $c in model unit test

2007-05-15 Thread John Napiorkowski
--- Nathan Gray <[EMAIL PROTECTED]> wrote:

> I would like to test a model with a unit test. 
> Catalyst kindly
> generates stub unit tests for models, but it does
> not include a stub
> showing how to instantiate the context object.
> 
> I have looked at:
> 
>   -
>
http://dev.catalystframework.org/wiki/Testing#ModelTests
> (Examples of test for your model: STUB)
>   -
>
http://search.cpan.org/dist/Catalyst-Manual/lib/Catalyst/Manual/Tutorial/Testing.pod
> (TIP: For unit tests vs. the "full application
> tests" approach used
>   by Test::WWW::Mechanize::Catalyst, see
> Catalyst::Test.)
>   -
> http://search.cpan.org/perldoc?Catalyst%3A%3ATest
> (METHODS: get request local_request
> remote_request)
>   -
> http://search.cpan.org/perldoc?Catalyst%3A%3ADevel
> (The documentation remains with
> Catalyst::Runtime.)
>   -
> http://search.cpan.org/perldoc?Catalyst%3A%3ARuntime
> ($c->prepare( @arguments ) Creates a Catalyst
> context from an engine-specific request (Apache,
> CGI, etc.).)
> 
> Does anyone have an example unit test that has
> access to $c?
> 
> Thanks so much!
> 
> -kolibrie

Hi,

I'm assuming that what you mean is that you want to
test the model without running catalyst as it's
container.  I'm not sure there is a good way to do
this.   What I usually do is make my model a stand
alone perl class that can be tested individually and
then have a thin Catalyst model that wraps and
provides it to my webapp.

For things that would normally go into the catalyst
context, like say $c->user, I try to not access this
in my model directly.  Instead I wrap it in an adapter
class, that gets generated via a factory interface. 
That way I can create versions of this class that can
live outside of catalyst.

So something like:

MyApp::User  is a base User Class
MyApp::CatalystUser  creates a User from $c->user
MyApp::StandaloneUser  creates a user from params

MyApp::UserFactory  returns a MyApp::User based on
what you have

MyApp::WelcomeEmailUser  Expects a User class and
sends a welcome email

MyApp::Web::Model::User  A catalylst model that wraps
the UserFactory for you.

So MyApp::Web::Model::User might do something like

__PACKAGE__->mk_accessors(qw/user/);

sub ACCEPT_CONTEXT
{
 my ( $self, $c ) = @_;
 my $user = MyApp::UserFactory->create($c->user);

 $self->user($user);
 return $self;
}

and in a catalyst controller you do:

my $user = $c->model('User')->user;
MyApp::WelcomeEmailUser->mail($user);

While in your unit test you can:

my $user = MyApp::UserFactory->create({
  name=>"x",
  email=>"[EMAIL PROTECTED]",
});

my $email_status =
MyApp::WelcomeEmailUser->mail($user);



There's probably an easier and more concise way to do
this but right this minute I'm still on my first
coffee of the day.  Hopefully some smarter people will
chime in and correct me.

--john

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] catalyst tutorial: MyAppDB/Book.pm vs. MyApp/Model/Book.pm

2007-05-15 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Tue, May 15, 2007 at 12:10:15AM -0700, mla wrote:
> > But I'm thinking a better layout would be:
> > 
> > /lib
> > ./lib/Try
> > ./lib/Try/Catalyst/Model
> > ./lib/Try/Catalyst/Model/DB.pm
> > ./lib/Try/Catalyst/View
> > ./lib/Try/Catalyst/View/TT.pm
> > ./lib/Try/Catalyst/Controller
> > ./lib/Try/Catalyst/Controller/Root.pm
> > ./lib/Try/Catalyst/Controller/Users.pm
> > ./lib/Try/DB.pm
> > ./lib/Try/User.pm
> > ./lib/Try.pm
> > 
> > That makes the relationship between M/V/C and
> Catalyst explicit, and
> > leaves the rest of the namespace available for
> generic use.
> 
> I tend to use MyApp::Web rather than ::Catalyst
> since then if I need a
> second web interface I can create MyApp::WebAdmin or
> whatever.

MyApp::Web is also the way I do it (now) for the same
reasons as above.  Although sometimes I make it more
project specific like MyApp::Portal and then
MyApp::Services if I'm exposing an API like on my
current project.  Vote++ for this as a best practice.

--John

> 
> -- 
>   Matt S Trout   Need help with your
> Catalyst or DBIx::Class project?
>Technical DirectorWant a managed development
> or deployment platform?
>  Shadowcat Systems Ltd.  Contact mst (at)
> shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/
> http://www.shadowcatsystems.co.uk/ 



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] catalyst tutorial: MyAppDB/Book.pm vs. MyApp/Model/Book.pm

2007-05-15 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Tue, May 15, 2007 at 03:47:57AM -0700, mla wrote:
> > I find the Rails ActiveRecord interface pretty
> appealing:
> > 
> >  
>
http://ar.rubyonrails.com/classes/ActiveRecord/Base.html
> 
> DBIC's interface is not dissimilar although it
> favours data structures
> for query descriptions rather than raw SQL.
>  
> > I like the notion of protected fields
> (attr_protected and
> > attr_accessible) to allow mass assignment directly
> from the
> > request parameters.
> 
> This is perl.
> 
> my @ok = qw(foo bar baz quux);
> 
> my %set; @[EMAIL PROTECTED] = @{$c->req->[EMAIL PROTECTED];
> 
> $dbic_obj->update(\%set); # but gods please validate
> first for production
> 
> > I like how if you fetch columns that don't exist
> in the table
> > the object becomes read-only by default.
> 
> That's neat, although I prefer tools that presume I
> know that I'm doing.
> 
> > And the find() interface seems nice, where
> basically the
> > select is just broken into its components (e.g.,
> condition,
> > order, group, limit, offset). I know they add a
> bunch of
> > helper fetch methods through their autoload
> mechanism.
> 
> Yeah, I find this kinda funny. Rails guys go "look,
> LOOK" about the equiv. of
> 
> find_by_login($login)
> 
> DBIC just handles
> 
> find({login => $login})
> 
> which saves autoload madness at the cost of ... TWO
> CHARACTERS ...

BTW, if this was something some people really wanted I
don't think it would be too hard to create as a DBIC
component.  You'd just be auto creating a bunch of
relationships via __PACKAGE__->add_relationship (I
think).  The biggest issue I have is that (from what I
understand) they assume all your unique constraints
are single key.  I sometimes have multikey uniques for
when it makes sense to me.  So I'm not sure what we'd
want to call it ->find_by_key1_and_key2?  Doing
->find({key1=>...,key2=>...}) seems more consistent to
me and has the benefit of being easy to work with if
you are writing a lot of common code that find stuff
via introspection of the data.  So I wouldn't find it
so useful.  --john


> 
> > So with that design you'd get the centralized
> validation, which
> > is most critical to me, but then you could use SQL
> freely
> > and get back a collection of read-only active
> record objects
> > if you did fancy stuff.
> 
> You -can- pass a custom chunk of SQL to DBIC for the
> where clause and have
> it Just Handle It. The fact that most people choose
> not to is, however, a
> hint as to where the better engineering practice
> lies :)
> 
> > I'll read through DBIx::Class some more. The thing
> where the
> > models are used through the schema seemed weird to
> me and I don't
> > fully understand it yet. I'd really like to be
> able to "use Try::User"
> > and be able to create and update it rather than
> going through an
> > explicit db schema layer. I guess I could create
> another object
> > that wraps around the DBIx::Class module or
> something.
> 
> Under Cat you'd just be doing $c->model('DB::User')
> and everything would work.
> 
> The reason for the explicit schema object is to
> handle multiple connections
> elegantly (see recent blog madness for the nasty
> hacks used to make AR sort
> of handle it if you change all your code to use a
> different syntax).
> 
> If you're sure you only need one connection, DBIC
> -will- let you set the
> connection at the class level. It's just kinda gross
> so people generally don't.
> 
> -- 
>   Matt S Trout   Need help with your
> Catalyst or DBIx::Class project?
>Technical DirectorWant a managed development
> or deployment platform?
>  Shadowcat Systems Ltd.  Contact mst (at)
> shadowcatsystems.co.uk for a quote
> http://chainsawblues.vox.com/
> http://www.shadowcatsystems.co.uk/ 
> 
> ___
> 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/
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Is it time for a Catalyst Conference yet?

2007-05-09 Thread John Napiorkowski

--- Thomas Klausner <[EMAIL PROTECTED]> wrote:

> Hi!
> 
> On Tue, May 08, 2007 at 05:13:03PM -0500, Dave
> Rolsky wrote:
> 
> > >Just a general question to the list to see if
> there is interest in 
> > >getting together a conference dedicated to
> Catalyst developers.  Or is 
> > >the feeling that the normal Perl conferences
> cover all our needs?
> > 
> > ..
> > 
> > One possibility might be to try to piggyback a
> "Catalyst day" before/after 
> > an existing Perl conference like YAPC or OSCON.
> That way you don't have to 
> > work as hard to get an audience.
> 
> BTW, this is basically what we try to achieve with
> the Hackathons at 
> YAPC::Europe: Give certain projects time and place
> to do a 
> "Mini-Conference / Workshop" embedded in the YAPC:
>   http://vienna.yapceurope.org/ye2007/cfh.html
> 

I was thinking something like this, something with a
hackthon feel and maybe one or two lightning talks and
some words from the Catalyst main developers about
future thoughts, etc.

I'll check the list of upcoming YAPCs.  Thanks for the
idea.  I just thought to float the idea on the list
and see if there is more than tepid interest.

--john

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


[Catalyst] Is it time for a Catalyst Conference yet?

2007-05-08 Thread John Napiorkowski
Hi,

Just a general question to the list to see if there is
interest in getting together a conference dedicated to
Catalyst developers.  Or is the feeling that the
normal Perl conferences cover all our needs?

_john

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] creating action classes for chained actions, trouble with overriding ->match

2007-05-08 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> On Tue, Mar 20, 2007 at 01:15:48PM -0700, John
> Napiorkowski wrote:
> > I may have answered my own question.  A peer
> pointed me to:
> > 
> >
>
http://search.cpan.org/src/MRAMBERG/Catalyst-Runtime-5.7007/lib/Catalyst/DispatchType/Chained.pm
> > 
> > and down in a method called 'recurse_match' it
> does indeed seem like match is only called against
> the endpoint in a chain.  So I guess I'd like to
> find out if anyone knows the reasoning behind this. 
> I think ideally if an action class can over ride
> match, this should be allowed for all types of
> actions.  Or I am just not smart enough to know why
> not :)
> 
> Because nobody's implemented match_captures yet
> which Chained and Regex could
> then both call. Should be pretty easy if you fancy a
> go.

Let me see if I understand what the scope of this and
the effect would be.

We'd want a new method on Catalyst::ActionChain called
match_captures which could look something like

sub match_captures
{
   my ( $self, $c, @cap_args ) = @_;
   return 1; ## or 0 to fail to match.
}

Where @cap_args would the actual capture specified via
the attribute 'CaptureArgs(x)'

We'd need to patch this into (I'm guessing) the
recurse_match method for chained dispatch type to make
sure we call this new match method.

Then if you wanted an actionclass for chained actions
that are not endpoints you'd inherit from
Catalyst::ActionChain instead of Catalyst::Action

I'm a bit confused about using this for Regex since
from the source it looks like that dispatch type is
calling the regular match.  Could you please enlighten
me as to your thinking here?

I can see this would work although I am concerned
(maybe for no good reason) that action classes with
match methods wouldn't work as expected if the action
is in the middle of a chain.  So this would reduce re
usability for those action classes.  However this may
not be a problem.  Any thoughts on that?

I have some test for the way I think I'd want this to
work floating around someplace.  I'll dig them up
since that's always a good place to start.

--John

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Catalyst MVC Best Pratices

2007-05-03 Thread John Napiorkowski
- Original Message 

From: Anthony Gardner <[EMAIL PROTECTED]>

To: catalyst@lists.rawmode.org

Sent: Thursday, May 3, 2007 6:22:12 PM

Subject: [Catalyst] Catalyst MVC Best Pratices



Greetings,



I've had a look at Catalyst and RoR from a basic point of view and like both. 
I'm also familiar with the concepts of MVC but again, from a basic point of 
view. I'm also busy learning design patterns etc. 



So, my head is full and maybe I can't see the wood for the trees in what I'm 
about to ask.



I'm 100% happy with what should go in the View part of MVC, 90% sure of what 
should go in the Controller and more than confused about what should go in the 
Model (not exactly true)



I searched the Catalyst mail archives about 'best practice' and came across 
this (amongst others) and read it in full



http://www.gossamer-threads.com/lists/catalyst/users/1081?search_string=best%20practice;#1081



. leaving me not confused but with lots of questions.



I've already started my new application and I've set it up like this ...



lib/P4C/Controller/SelectProduct.pm

/Model/Product.pm

   /P4CSchema/Product.pm (amongst others)

   /P4CSchema.pm

   /P4C.pm





Now, when selectproduct action is called, I want to select all products that 
match a criteria. In the Catalyst examples, this would be done simply as 




$c->stash()->{products} = [$c->model('P4CSchema::Product)->all()];



and all would be happy in the world.



But, I might want to do some work on those results before stashing them away 
so, I may decide to do this in the Controller ...



my $prod = Model::Product->new();

$c->stash()->{products} = [ $prod->get_all_products_that_like_me() ];



and in Model::Product I'd have something like this (maybe)...



sub get_all_products_that_like_me() {

  my $self = shift;



  ## what's the use of schema in this command when it works okay without?

   ##$self->schema()->resultset('P4CSchema::ProductGroup')->all();

  my $prods = $self->resultset('P4CSchema::ProductGroup')->all();



  return $self->do_you_like_him( $prods );



}



But, is this the right place to put this logic as, I have read on the mailing 
list that people would use Model::* as a wrapper to the business logic code 
that is elsewhere.



So, would this be better (haven't thought this through because as I said, my 
head is too full) ? .



lib/P4C/Controller/SelectProduct.pm

 /Model/Product.pm

   /P4CSchema/Product.pm (amongst others)

   /P4CSchema.pm

   /P4C.pm

   /Logic/Product.pm



and have in Model::Product one of.



use base qw|Logic::Product Catalyst::Model::DBIC::Schema|; 

use base qw|Catalyst::Model::DBIC::Schema Logic::Product|;



and let Logic::Product do the  ... 



sub get_all_products_that_like_me() {

  my $self = shift;



  ## what's the use of schema in this command when it works okay without?

  ##$self->schema()->resultset('P4CSchema::ProductGroup')->all();

  my $prods = $self->resultset('P4CSchema::ProductGroup')->all();



  return $self->do_you_like_him( $prods );



}



Is that's what meant by 'wrapper'?



Phew, okay, that's it for now. I have my flame pants on, so go ahead ;)



Many thanks



-Ants




Hi,

I think having a business logic and even an interface logic separate from the 
main catalyst application
is a good way to go.  I've been trying to keep the actually controllers really 
thin so that almost all of it
can be handled through action classes and configuration in the controller 
class.  That way the Models
are mostly a thin wrapper around business classes, maybe with some extra sugar 
or taking advantage
of the fact you can get the context for the few models that might actually 
value having the context.  This
way makes it a lot easier to test.

I favored Perl over Ruby because there are a lot of already done things in CPAN 
that you can glue into
a Catalyst model.  I tend to use models for both accessing and mutating data, 
kicking off processes
and doing data transformations.  Maybe that last sounds a little like a view 
but I'm comfortable using the
model for things like the command (GoF) pattern, and similar.

I really like the way the Mango (http://mangoframework.com/) author has 
separated data access into
Schema, Providers and then Catalyst Models.  I've been looking at that for 
inspiration.  Also the
Angerwhale project 
(http://search.cpan.org/~jrockway/Angerwhale-0.04/lib/Angerwhale.pm) has given 
me
a lot to think about in terms of arranging for data, although that is not 
currently database driven, yet the
way the framework is written there is no reason you couldn't add one.

One that you might want to stash a reference to your Resultset object rather 
than getting all the rows
out.  That way if your interface logic needs to perform view oriented things 
(like paging results) it's
much easier.

Creating solid custom exceptions is another thing worth figuring out.  There 
was some discussion about
this on a blog

Re: [Catalyst] Catalyst::Model::DBIC::Schema or not?

2007-04-27 Thread John Napiorkowski


- Original Message 
From: Jason Gottshall <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Friday, April 27, 2007 12:54:39 PM
Subject: RE: [Catalyst] Catalyst::Model::DBIC::Schema or not?

Brian Kirkbride wrote:
> Jason Gottshall wrote:
> > Brian Kirkbride wrote:
> > > I usually have an architecture like this:
> > >
> > > Client -> Controller -> Model -> ORM -> Database
> > >
> > > The ORM is usually just vanilla (as you suggested), the Database 
> > > enforces simple 
> > > data constraints (foreign keys, etc) and the Model makes 
> > > sure that the complex 
> > > business logic constraints are met.  Some things are simply not 
> > > enforceable by a 
> > > stored procedure - this might involve validation of image files
for 
> > > example. 
> > > The beauty of Catalyst is that it's up to you how to 
> > > handle separation of 
> > > concerns and Catalyst is helpful no matter how you do.
> > 
> > Thanks, Brian. This is the exact structure I'm considering. So my 
> > question is this: If all the ORM interaction happens at the 
> > Model level, 
> > and DBIC isn't being treated as a "model" itself, is there 
> > any reason to 
> > use Catalyst::Model::DBIC::Schema to establish the db connections? I

> > guess my gut tells me "no", but I want to make sure I'm not missing 
> > something here.
> 
> No problem.  As I said in my earlier reply, I don't have DBIC 
> models in my 
> catalyst app because it encourages me to put ORM-related code 
> where it belongs, 
> in the Business Logic model(s).

Just a follow-up to this month-old thread: 

I tried eliminating Catalyst::Model::DBIC::Schema in favor of having my
true business Models do all the interfacing with DBIC. No problem with
those Models, but I did discover an unintended consequence:
Catalyst::PluginDBIC stuff stopped working! 

It was specifically the storage components for Authentication and
Session that choked. I couldn't figure out how to give either of them
the connection info they needed; they both expect to be configured with
the name of a schema/table class that is then used, via
C::M::DBIC::Schema, to get a resultset.

So I'm trying out a compromise. I've set up the appropriate
C::M::DBIC::Schema model, but don't intend to use it directly from
controllers or views. Instead, I've provided all my db-interactive
models with a schema()method; if the model is being used under Catalyst,
they get at the schema object via the already-connected Catalyst DBIC
model (thanks to ACCEPT_CONTEXT); otherwise, a new connection is
composed and returned. I had to do a little more refactoring so that
both C::M::DBIC::Schema and the independent models have access to the
same connection logic, but it seems to be working. Meanwhile, the Auth
and Session plugins are working again, and I should be able to use other
DBIC-dependent plugins without problem.

Now it's just a matter of resisting the temptation, as Brian mentioned,
of accessing DBIC directly outside of models. I'm pretty sure I have the
will power, so I just have to worry about indoctrinating the rest of the
programmers in my office. Wish me luck...

Jason

I hesitate to mention this because it's not my project but Mango has taken an 
approach that
seems similar to what you mentioned (and others have mentioned a few times in 
other recent
and older threats) by having DBIC based business model classes that are linked 
into the Model
via a base Provider class.  You can see:

http://svn.mangoframework.com/CPAN/Mango/trunk/lib/Mango/Catalyst/Model/

to check this out.  Seems like a clean and sane approach.  You can always have 
a model subclassing
C::M::DBIC::Schema in there for rapid prototyping or compatibility with plugins 
that expect to find it.

Peace,
John


___
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/




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: Redirects // Re: [Catalyst] Re: forwarding to chained actions

2007-04-27 Thread John Napiorkowski

- Original Message 
From: Michael Reece <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Friday, April 27, 2007 12:27:29 PM
Subject: Re: Redirects // Re: [Catalyst] Re: forwarding to chained actions

it would be nice if $c->res->redirect returned a 303 appropriately if  
$c->req->method eq 'POST'.

i have in the past trapped it in 'end' to fix up the $c->res->status  
if == 302 and $c->req->method eq 'POST', but lately i just don't bother.

You should be able to set the http status code with ->redirect(302) if I'm 
reading the source code correctly.

--John

On Apr 27, 2007, at 6:03 AM, Simon Wilcox wrote:

> On Tue, 24 Apr 2007, A. Pagaltzis wrote:
>
>> _ALL_ POSTs should be followed by a redirect, ALWAYS.
>
> This is really good advice but I was looking at the response code RFC
> today [1] for an unrelated matter and found the following:
>
>   If the 302 status code is received in response to a request other  
> than
>   GET or HEAD, the user agent MUST NOT automatically redirect the  
> request
>   unless it can be confirmed by the user, since this might change the
>   conditions under which the request was issued.
>
> It then goes on to say:
>
>   Note: RFC 1945 and RFC 2068 specify that the client is not  
> allowed to
>   change the method on the redirected request.  However, most existing
>   user agent implementations treat 302 as if it were a 303 response,
>   performing a GET on the Location field-value regardless of the  
> original
>   request method. The status codes 303 and 307 have been added for  
> servers
>   that wish to make unambiguously clear which kind of reaction is  
> expected
>   of the client.
>
> So, what do people do - do you send 303/307's "correctly" or just  
> default
> to 302 behaviour ?
>
> Simon Wilcox
> [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>
> -- 
> Digital Craftsmen Ltd
> Exmouth House, 3 Pine Street, London. EC1R 0JH
> t 020 7183 1410 f 020 7099 5140 m 07951 758698
> w http://www.digitalcraftsmen.net/
>
> ___
> 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/

---
michael reece :: software engineer :: [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/




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: Redirects // Re: [Catalyst] Re: forwarding to chained actions

2007-04-27 Thread John Napiorkowski


- Original Message 
From: Simon Wilcox <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Friday, April 27, 2007 9:03:23 AM
Subject: Redirects // Re: [Catalyst] Re: forwarding to chained actions

On Tue, 24 Apr 2007, A. Pagaltzis wrote:

> _ALL_ POSTs should be followed by a redirect, ALWAYS.

This is really good advice but I was looking at the response code RFC
today [1] for an unrelated matter and found the following:

  If the 302 status code is received in response to a request other than
  GET or HEAD, the user agent MUST NOT automatically redirect the request
  unless it can be confirmed by the user, since this might change the
  conditions under which the request was issued.

It then goes on to say:

  Note: RFC 1945 and RFC 2068 specify that the client is not allowed to
  change the method on the redirected request.  However, most existing
  user agent implementations treat 302 as if it were a 303 response,
  performing a GET on the Location field-value regardless of the original
  request method. The status codes 303 and 307 have been added for servers
  that wish to make unambiguously clear which kind of reaction is expected
  of the client.

So, what do people do - do you send 303/307's "correctly" or just default
to 302 behaviour ?

I do a 303 for when a post alters the system, such as when I add a new record 
to a CRUD style
interface and want to redirect back to the list view.  I use 302 when the post 
is merely sending me someplace after some processing, like after I successful 
login I redirect back to the requested page or to a default.

--john


Simon Wilcox
[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

-- 
Digital Craftsmen Ltd
Exmouth House, 3 Pine Street, London. EC1R 0JH
t 020 7183 1410 f 020 7099 5140 m 07951 758698
w http://www.digitalcraftsmen.net/

___
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/




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] query once per session?

2007-04-26 Thread John Napiorkowski


- Original Message 
From: Michael Higgins <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Thursday, April 26, 2007 5:35:09 PM
Subject: [Catalyst] query once per session? 

Hello, 

I'm wondering how I can get a query (that becomes a drop-down list for a
form field) set to execute only once and return the data from the client
side, or at least from memory, until the session ends.

I've set something up to filter results based on selection from a form, but
getting the list each and every time is too lengthy a process for a table
only updated once a day.

I've tried using Plugin::Catalyst::Cache, but the docs leave me clueless.

Anyone have a suggestion?

-- 
Michael Higgins

Hi,

If you are using the session plugins you can just assign some information to it 
in a similar way that you use the stash:

$c->session( some_stuff=>[qw/aaa bbb ccc/]);

If you are going to use this in lots of places you could write a model that 
accepted the current context to automatically do this for you.

--John


___
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/




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] How many models?

2007-04-26 Thread John Napiorkowski


- Original Message 
From: Jamie Neil <[EMAIL PROTECTED]>
To: catalyst@lists.rawmode.org
Sent: Thursday, April 26, 2007 5:02:24 PM
Subject: Re: [Catalyst] How many models?

John Napiorkowski wrote:
> I think the consensus is that it's best to create business logic type
> models outside of Catalyst and then build a simple wrapper model for
> it.  That way you can use it for stuff like cron jobs and anything
> that doesn't live inside of Catalyst.

That's exactly what we're trying to do.

> Now I isolated the business logic for creating an account into the
> MyApp::Logic::Accounts package because for my system creating a new
> user is much more than just inserting a row into the Users database.
> The logic would using the MyApp::Schema::Users Class and some other
> classes and wrap all that into a neat interface.

Again, this is the direction we are going, however what I was concerned 
about was that this way we would end up with a lot more database handles 
that was necessary (we may have three or four models). Whilst this is 
not a problem for a single application, we are planning on running many 
instances sharing the same database server.

Of course I may just be misunderstanding how DBIx::Class works :)

To be honest I'm not so sure what DBIx::Class does for this, although I haven't 
had any trouble with the above approach scaling when I do heavy testing.  I 
figure that you Catalyst application would create a database handle and then if 
you ran a cron job that would create it's own handle for it's lifetime.

If this was a problem you could probably override the DBIC connection class to 
first check to see how many open handles on a database exists before trying to 
create a new one.  I'd check the DBIC documentation (which is extensive) or 
mailing list archives (also extensive) and if you can't get a good answer post 
to the DBIx:Class mailing list.

DBIC searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/

Good luck! --John
-- 
Jamie Neil | <[EMAIL PROTECTED]> | 0870  454
Versado I.T. Services Ltd. | http://versado.net/ | 0845 450 1254

___
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/




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] How to pass vars to modules

2007-04-26 Thread John Napiorkowski

- Original Message 
From: Dave Rolsky <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Thursday, April 26, 2007 3:17:20 PM
Subject: Re: [Catalyst] How to pass vars to modules

On Thu, 26 Apr 2007, RA Jones wrote:

> So I'm declaring it in all my controllers that need to do sorts, which is 
> repetitive and probably not the best way to do it. Is there a standard way of 
> handling modules like this (Date::Calc is another)?

I'd say that declaring it where it is used _is_ the best way to do it.

It doesn't hurt to declare what prereqs a module has at the top of a 
module, and it'll make it clearer what it's using. This is doubly true 
when you're importing functions into a new namespace. It's really annoying 
to see some random function used in a module and then try to figure out 
where it might've come from.

-dave

Another way to help with this is to create a custom controller that declares 
the needed modules and have each controller that needs it inherit.  Or if you'd 
rather not use inheritance you can play with Moose and Roles.  I'm finding that 
Moose plays really nicely with Catalyst.

--John




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] How many models?

2007-04-26 Thread John Napiorkowski
 Original Message 
From: Jamie Neil <[EMAIL PROTECTED]>
To: catalyst@lists.rawmode.org
Sent: Thursday, April 26, 2007 10:47:46 AM
Subject: [Catalyst] How many models?

Hi All,

We're in the process of porting an existing CMS/Cart system to Catalyst, 
and trying to work out how to deal with the database modelling. While 
most of the tables will be accessed through a simple DBIx::Class::Schema 
setup, there are a few which have more complex relationships that we 
wish to hide behind custom methods.

We've come to the conclusion that this is best done by creating an 
external module, but we're not sure whether we should create two 
Catalyst models (one using DBIx::Class::Schema and one wrapping our 
external module), or have a single model and access the simple tables 
through the external module too. The first option seems simpler more 
straightforward, but we don't want to end up with multiple database 
connections (there is only one database) if we can help it.

Can anyone offer some advice?

Thanks,

-- 
Jamie Neil | <[EMAIL PROTECTED]> | 0870  454
Versado I.T. Services Ltd. | http://versado.net/ | 0845 450 1254

I think the consensus is that it's best to create business logic type models 
outside of Catalyst and then build a simple wrapper model for it.  That way you 
can use it for stuff like cron jobs and anything that doesn't live inside of 
Catalyst.

Whether you put those additional business logic methods inside the actual DBIC 
Schema class or in a separate class is your call.  Best practices suggest that 
it's best to kept the physical ORM cleanly separated from your business logic 
classes, but if you don't have a lot of logic or if your physical model is a 
very good representation of how the data is actually used then sometimes it's 
easier to add a few methods directly to your DBIC Schema classes.

Usually I create a tree structure similar to this for new applications:

[Under .../Myapp-Application or something similar]

/lib
  /MyApp
 Web.pm  (Catalyst Application package)
 Schema.pm (Your DBIx::Class::Schema)
 /Schema
Users.pm (a DBIx::Class)
 Tags.pm (another DBIx::Class)
(etc.)
 /Logic
Accounts.pm (A Plain Old Perl Module)
 /Web
   /Controller
  Join.pm
  Root.pm
  (etc.)
   /Model
  DBIC.pm   (Loads up Myapp::Schema)
  Accounts.pm  (A Wrapper for MyApp::Logic::Accounts)
   /View
  TT.pm
/root
/script
/t


Now I isolated the business logic for creating an account into the 
MyApp::Logic::Accounts package because for my system creating a new user is 
much more than just inserting a row into the Users database.  The logic would 
using the MyApp::Schema::Users Class and some other classes and wrap all that 
into a neat interface.  However you could probably put a lot of that logic into 
methods in the MyApp::Schema::User class if you wanted to.  I'd probably do 
this is there wasn't a lot going on in this process since I don't want class 
explosion like you get with Java development sometimes.  Also there is 
something to be said for putting stuff where you might expect to find it and I 
think I'd like in the User class first for stuff like that.

I've been putting all my catalyst components under a namespace like 
'MyApp::Web' or 'MyApp::Portal' etc rather than keep the directory structure 
flatter because this way it's easier for me to make multiple catalyst instances 
sharing a given set of libraries.  There are other ways you can do this but I 
find this way the most simple.  YRMV.

The only issue I have here is having to write all the wrapper classes for 
Catalyst Modules that instantiate a Logic Module.  However it probably wouldn't 
be too hard to write something to do this for you automatically, similar to the 
way the DBIC.pm creates Catalyst models for each DBIx::Class you have.  If 
anyone has some thoughts on this I'd enjoy hearing it.

Anyway, that's what I do, but I'm probably far from the expert Catalyst guy on 
the list.  Hopefully this will spawn some discussion.

Peace,
John

___
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/




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/


Re: [Catalyst] Componentised actions.

2007-03-30 Thread John Napiorkowski


- Original Message 
From: Nilson Santos Figueiredo Junior <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Thursday, March 29, 2007 11:46:48 PM
Subject: Re: [Catalyst] Componentised actions.

On 3/29/07, Oleg Pronin <[EMAIL PROTECTED]> wrote:
> I cannot forward to the list actions because they are not private actions
> (they have its own URLs). In docs 'forward' is for private actions.

If the docs state that, they're wrong. It's perfectly possible to
forward to public actions.

> For example you can create url-action which edits some objects and include
> it in many templates. This is not like
> ordinary template toolkit's include - this component can show itself, modify
> data, receive request params etc, like
> any web page. And this doesnt depend on whether this action is directly
> called from browser or included in some template.

You could have some thing like this:

  sub nice_page : Local {
my ($self, $c) = @_;
$c->forward('object1');
$c->forward('object2');
  }

I was always nervous about doing this because of my fear about Stash namespace 
collision.  To be honest I have a love hate relationship with the stash because 
I like the idea of  having a ready made messaging system but because it's hash 
based I feared the feeling I was making a very tightly coupled application.  
You need to know the base stash key for your stuff, right?  And then it needs 
to be different for each action that you think might be in an action chain or 
forwarded to as in the example above.

Have you run into this problem, found ways around it or just don't feel 
paranoid about it?

--John

Then, inside nice_page.tt:

  [% INCLUDE object1.tt %]
  [% INCLUDE object2.tt %]

Should do exactly what you want. And, well, if it doesn't you can
always use Catalyst::Plugin::SubRequest.

-Nilson Santos F. Jr.

___
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/





 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

___
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] Componentised actions.

2007-03-28 Thread John Napiorkowski


- Original Message 
From: Oleg Pronin <[EMAIL PROTECTED]>
To: catalyst@lists.rawmode.org
Sent: Wednesday, March 28, 2007 5:55:54 PM
Subject: [Catalyst] Componentised actions.

Greetings!

 

I'm developing a website based on catalyst and want it to be moduled and 
componentised the way like this:

 

site.com/object1/list 

   displays objects 1 in empty design.

 


site.com/object2/list 

   displays objects 2 in empty design.

 

site.com/nicepage

   displays a page in website design which contains result of processing 
actions 'site.com/object1/list' and 'site.com/object2/list
'.

 

The question one is how do i get the output of the actions inserted into 
another template ?

 

i mean something like 

 

page template page template

[% c.forward('/object1/list') %]

page template page template, 

 

just for example, this of course doesn't work.

 

 

The question two is how do i know while running in '/object2/list' action 

whether action is called from the browser or inserted into another template.

 

I.e. i want URL site.com/object1/list to display information in site design 
while the same action inserted into another template

( pseudo :) [% c.forward('/object1/list') %] )  to display information in empty 
desing (i.e. through another VIEW).

 

Any suggestions ?



  

Best regards, Pronin Oleg, Rambler Internet Holding.

Let me see if I understand what you are trying to do.  You want a portal like 
system where you have a parent page that contains units or regions that 
automatically dispatch to different actions and perform a full request cycle, 
including returning a response body suitable for including in the parent page.  
If so that sounds like something I was trying to do earlier this year.  There 
is a Catalyst subrequest plugin (both in CPAN and a newer, unreleased version 
in the source control repository) which could in theory be used to make portal 
like applications.  However I wasn't able to get this to perform satisfactorily 
since the CPAN plugin has known limitations in terms of it's ability to 
properly scope stuff and I couldn't get the repository version to work at all 
(although might just be my ignorance, your results may vary)

There is a branch in the repo that is supposedly to make this kind of this 
easier (or at least that was my understanding of it) called "app_context_split" 
(at least that is what I think it was called) but the repo doesn't show any 
work on that since January and since I don't know about the goal of that branch 
or the outstanding TODO list I'm not sure what to say about it.  Maybe the 
author can speak up?

You could write a custom action class or something to do a cold, hard LWP http 
request.  I tried that but found the performance to be bad and there was a lot 
of trouble to make sure everything work right such as if the parent page gets a 
POST what does your 'portlet' (for lack of a better work) get?  Does it get a 
post with all the posted params and posted attachments?  Get's very expensive 
and there's a lot of plumbing to do.

In the end I gave up trying to make my application this way since I couldn't 
find an elegant way to do it that didn't require a lot of plumbing work on my 
part and also performed well.  The direction I took was to 'componentize' my 
page using TT's ability to include bits of other templates.  That way I have 
something like what I want, but I admit it isn't so perfect since I have more 
coupling between logic and presentation than is usually considered good 
practice.

Why not tell us a little more about what your application is trying to do and 
we can maybe advice a way around this problem.

--John









 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail ___
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] Data::FormValidator Plugin

2007-03-24 Thread John Napiorkowski


- Original Message 
From: John Napiorkowski <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Saturday, March 24, 2007 12:12:29 PM
Subject: Re: [Catalyst] Data::FormValidator Plugin



- Original Message 
From: Tomohiro Teranishi <[EMAIL PROTECTED]>
To: catalyst@lists.rawmode.org
Sent: Saturday, March 24, 2007 10:33:13 AM
Subject: [Catalyst] Data::FormValidator Plugin

Hi,

I am a big fun of catalyst freamwork  and I made a plugin for
Data::FormValidator called 'C::P::FormValidator::Lazy' . I am
wonderling if this plugin should stay in my local or  publish to CPAN.
 Can I have any suggestion??

I attach source code and also below is  subversion repo url.

http://tomyhero-perl-module.googlecode.com/svn/trunk/Catalyst-Plugin-FormValidator-Lazy/

thanks,

[code snipped]


Hi,

To be honest I think this is the kind of thing that we'd prefer to see done as 
a actionclass or controller/actionclass rather than as a plugin.  The reasoning 
is that a plugin becomes global and too many plugins polute the global 
namespace.  

The best practices that we'd like to promulgate is that a plugin should be 
something that extends or enhances the catalyst global system, adds 
functionality to the existing hooks, etc.

Anyway, I think that this was explained better in a draft update to the 
documentation, I'll peek in the archives and try to point you to it.   But you 
can look at the way the formbuilder actionclass and controller was made.  This 
started life as a plugin but was migrated to support the new best practices and 
now it's probably the most popular form system for catalyst.

--john

The best practices doc I was talking about is being worked on at:

http://474.at/lab/ExtendingCatalyst.pod

and there's quite a discussion for it on the developer's mailing list at:

http://lists.scsys.co.uk/pipermail/catalyst-dev/2007-March/000608.html

It's a good place to start and also contribute what's lacking.

BTW, I hope my post is not discouraging to you in any way.  I know that there 
has been a lot of pain around the best way to extend catalyst, and there was an 
early plugin manual that encouraged people to use this method exclusively.  
Also it's so easy :)  Let me know if you have questions or want to bounce items 
off --john





 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

___
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/





 

We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

___
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] Data::FormValidator Plugin

2007-03-24 Thread John Napiorkowski


- Original Message 
From: Tomohiro Teranishi <[EMAIL PROTECTED]>
To: catalyst@lists.rawmode.org
Sent: Saturday, March 24, 2007 10:33:13 AM
Subject: [Catalyst] Data::FormValidator Plugin

Hi,

I am a big fun of catalyst freamwork  and I made a plugin for
Data::FormValidator called 'C::P::FormValidator::Lazy' . I am
wonderling if this plugin should stay in my local or  publish to CPAN.
 Can I have any suggestion??

I attach source code and also below is  subversion repo url.

http://tomyhero-perl-module.googlecode.com/svn/trunk/Catalyst-Plugin-FormValidator-Lazy/

thanks,

[code snipped]


Hi,

To be honest I think this is the kind of thing that we'd prefer to see done as 
a actionclass or controller/actionclass rather than as a plugin.  The reasoning 
is that a plugin becomes global and too many plugins polute the global 
namespace.  

The best practices that we'd like to promulgate is that a plugin should be 
something that extends or enhances the catalyst global system, adds 
functionality to the existing hooks, etc.

Anyway, I think that this was explained better in a draft update to the 
documentation, I'll peek in the archives and try to point you to it.   But you 
can look at the way the formbuilder actionclass and controller was made.  This 
started life as a plugin but was migrated to support the new best practices and 
now it's probably the most popular form system for catalyst.

--john





 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

___
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] creating action classes for chained actions, trouble with overriding ->match

2007-03-20 Thread John Napiorkowski


- Original Message 
From: John Napiorkowski <[EMAIL PROTECTED]>
To: catalyst@lists.rawmode.org
Sent: Tuesday, March 20, 2007 4:07:29 PM
Subject: [Catalyst] creating action classes for chained actions, trouble with 
overriding ->match

Hi,

I've been working on some action classes that are primarily used by chained 
actions (although they could be used otherwise) and running into some confusion 
about overriding the ->match method.

It seems like if you have an action chain with several actions that have action 
classes, the ->match method of the terminal action is the only one that gets 
run.  For example:

Does anyone know if this is correct?  Or am I just doing something wrong?  
Seems strange that I can hook into execute but not match but that just might be 
me.

Thanks!
--John

I may have answered my own question.  A peer pointed me to:

http://search.cpan.org/src/MRAMBERG/Catalyst-Runtime-5.7007/lib/Catalyst/DispatchType/Chained.pm

and down in a method called 'recurse_match' it does indeed seem like match is 
only called against the endpoint in a chain.  So I guess I'd like to find out 
if anyone knows the reasoning behind this.  I think ideally if an action class 
can over ride match, this should be allowed for all types of actions.  Or I am 
just not smart enough to know why not :)

Thanks!
John




 

We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

___
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/





 

Bored stiff? Loosen up... 
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front

___
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] creating action classes for chained actions, trouble with overriding ->match

2007-03-20 Thread John Napiorkowski
Hi,

I've been working on some action classes that are primarily used by chained 
actions (although they could be used otherwise) and running into some confusion 
about overriding the ->match method.

It seems like if you have an action chain with several actions that have action 
classes, the ->match method of the terminal action is the only one that gets 
run.  For example:

Does anyone know if this is correct?  Or am I just doing something wrong?  
Seems strange that I can hook into execute but not match but that just might be 
me.

Thanks!
--John




 

We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

___
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: Would this be useful to anyone?

2007-03-20 Thread John Napiorkowski
I have a version of Catalyst::Model::DBIC::Schema where I hacked in some code 
to automatically look at the query string and perform some limits and sorting.  
Basically if it sees a something like:

...?[table].page=1&[table].max-results=10&[table].order-by=[column].[direction]

It will automatically create a new resultset object with the correct limits.  
It can also do (very unoptimized) searches with something like

...?[table].search=[text to search in the table]

I'm adding in the ability to set a start and end range, as well with something 
like

...?[table].start-index=10&[table].end-index=100

I was wondering if the community thinks this could be useful, or if it would be 
more useful in some other state.  I know that this kind of resultset limiting 
is something I do all the time and I assume it's the case for others.

Right now I have this integrated with my Schema classes, as I mentioned above, 
but I am not sure it's the best thing to do.  Although it will DWIM when I do 
$c->Model('table') it doesn't help me if that resultset has one to many 
relationships that also need to be limited.  So I have this also as a DBIC 
component in order to handle this for me.

I was thinking perhaps we'd prefer to have this as a separate model that you'd 
pass a resultset and a $c->request to to get the limited resultset, instead of 
so much magic:

my $fullrs = $c->Model('Table');
$c->forward($c->Model('LimitResultSet'), [$fullrs, $c->request]);

## Now $fullrs has been limited as described above

I was thinking to use $c->forward because I tend to use forward when I am 
implementing a command or pipeline style design pattern, but this could also 
easily be:

my $fullrs = $c->Model('Table');

my $pagedrs = $c->Model('LimitResultSet')->build($fullrs, $c->request)


Or something similar If people preferred:

Then again maybe it would just be better to keep it as a raw DBIC component:

my $pagedrs = $fullrs->search_by_query($c->request);

This would have the benefit of working reasonally well will people using CGI.pm 
outside of Catalyst.  This is sort of what I am doing now, I have a component 
and my hacked Catalyst model calls it to save myself a bit of trouble.  The only


Any thoughts?

BTW, one thing that is making this hard for me to make cross database is that 
in the full text search Postgres requires ILIKE to make the search case 
insensitive, unlike ever other database.  Right now in my DBIC code I do:

foreach my $keyword ( split(/\s/, $value) ) 
{
my @keywords = split(',', $keyword);

push @array, [

-or => [ {$column => {'ILIKE' => [ map { '%'.$_.'%' } @keywords 
]} } ],
];
}

to build the correct data structure for searching.  Does anyone out there know 
if there is a neat cross database way to do this, or do I need to explicitly 
check for Postgres and use ILIKE instead of like?

--john





 

It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/

___
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] [Announce] Catalyst-Runtime 5.7007

2007-03-14 Thread John Napiorkowski
- Original Message 
From: Marcus Ramberg <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Wednesday, March 14, 2007 10:22:35 AM
Subject: [Catalyst] [Announce] Catalyst-Runtime 5.7007

Hi Gang.

There's been some time since our last release, as we're busy working
on the next major release of Catalyst. Meanwhile, here is a  release
new release to address minor issues that has come up in the past
months. All in all though, the development team is quite happy with
the stability of our current stable releases.

Marcus
-- catch and release monkey

Changelog Entry:

5.7007  2007-03-13 14:18:00
- Performance and stability improvements to the built-in HTTP server.
- Don't ignore file uploads if form contains a text field with the
  same name.  (Carl Franks)
- Support restart_delay of 0 (for use in the POE engine).
- Skip body processing if we don't have a Content-Length header.
  Results in about a 9% performance increase when handling GET/HEAD
  requests.
- Add a default body to redirect responses.
- MyApp->model/view now looks at MyApp->config->{default_view/model}
  (Bogdan Lucaciu)

-- 
With regards
Marcus Ramberg

I'll be installing this right away so that I can drop my content length hack to 
fix the long pause on redirects for Firefox.  The default view model thing will 
reduce boilerplate code in my base controllers for sure.  Thanks!

Would anyone care to comment about some of the potentially new things upcoming? 
 Peeking in the Catalyst repository branches area shows a lot of tantalizing 
and interesting things.  I know people are super busy but I can't help to 
wonder.

___
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/





 

Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097

___
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 Engine

2007-03-13 Thread John Napiorkowski
- Original Message 
From: "Mesdaq, Ali" <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Tuesday, March 13, 2007 3:00:14 PM
Subject: [Catalyst] Template Engine

I just wanted to get everyone's feedback on what they prefer as their
templating engine. I know there are a bunch of choices but wanted to see
what people think of certain ones. I am looking for something that
supports and promotes good practices and cutting edge techniques.

--
Ali Mesdaq
Security Researcher
Websense Security Labs
http://www.WebsenseSecurityLabs.com
--

I think the last time we polled we discovered most people are using template 
toolkit with Mason a distant second place.  I like TT because it's quite 
flexible and extendable; many people don't like it for that reason.

I originally choose it for practical reasons, I wanted to focus on developing 
skills for my team and decided to make some choices for development practices.  
I choose TT for templating because it's very popular and is simple enough for 
me to be able to assign the templating work to junior developers.  I considered 
Mason very seriously because if it's large comunity but when I chose Catalyst 
that settled it for TT, since most people here can assist with TT on the 
mailing list.

There is a great TT book out there as well.  If would buy it if you decide to 
go that way.

--john






 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail

___
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: PathPrefix (was: [Catalyst] Anybody using Chained('.') ?)

2007-03-13 Thread John Napiorkowski
There's a way you can mimic PathPrefix for now.  This worked for me:

http://use.perl.org/~LTjake/journal/31738

Looking forward to the swarm of tweaks and fixes that are part of the next 
Catalyst release :)  --John


- Original Message 
From: Robert 'phaylon' Sedlacek <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Tuesday, March 13, 2007 12:52:24 PM
Subject: PathPrefix (was: [Catalyst] Anybody using Chained('.') ?)

Jason Kohles wrote:

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

You can chain your action only to other actions or to the root, not to 
namespaces. The PathPart attribute controls how the path is built 
visibly. There is a :PathPrefix implementation that does what you want 
somewhere in Catalyst's SVN, but I don't know when it is expected to go 
to CPAN.

> But the only way I can find to do this with Chained is by putting 
> something like this in each controller subclass:

You can also put the base in the controller base class and configure it 
via your config file or application class:

   Controller::Foo:
 action:
   base:
 PathPart: 'foo/bar/baz'

(untested again, there is an example in the Advent Calendar for 2006)

-- 
# Robert 'phaylon' Sedlacek
# Perl 5/Catalyst Developer in Hamburg, Germany
{ EMail => ' [EMAIL PROTECTED] ', Web => ' http://474.at ' }

___
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/






 

Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091

___
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

2007-03-07 Thread John Napiorkowski



 
DIV {
MARGIN:0px;}



From: John Napiorkowski 


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

  
  
  
  
 

I have tried:

 

perl script/myapp_create.pl view 
Show

 

After restarting the application, it gives that 
error. If I do instead:

 


perl script/myapp_create.pl view 
Html

 


The application works fine after restarting it. 
Am I doing something wrong?

 

Thanks.

 

Octavian

 

  I'd personally be interested in seeing what the generated files look 
  like.  Could you attach them in your response (or post them someplace we 
  can see?)


  Hi,

   

  Here is the first one (Show.pm):

   

  package 
  TranzactiiBursiere::View::Show;

   

  use strict;
use warnings;
use base 
  'Catalyst::View';

   

  =head1 NAME

   

  TranzactiiBursiere::View::Show - Catalyst 
  View

   

  =head1 DESCRIPTION

   

  Catalyst View.

   

  =head1 AUTHOR

   

  A clever guy

   

  =head1 LICENSE

   

  This library is free software, you can 
  redistribute it and/or modify
it under the same terms as Perl 
  itself.

   

  =cut

   

  1;


  And here it is the second one that works 
  (Html.pm):

   

  package 
  TranzactiiBursiere::View::Html;

   

  use strict;
use warnings;
use base 
  'Catalyst::View';

   

  =head1 NAME

   

  TranzactiiBursiere::View::Html - Catalyst 
  View

   

  =head1 DESCRIPTION

   

  Catalyst View.

   

  =head1 AUTHOR

   

  A clever guy

   

  =head1 LICENSE

   

  This library is free software, you can 
  redistribute it and/or modify
it under the same terms as Perl 
  itself.

   

  =cut

   

  1;


   

  If I just delete the file Show.pm and restart the 
  server, the program works fine, but if I put it back and restart, it gives 
  that error.

  I have seen the same thing under Linux and 
  Windows.

   

  Thanks.

   





As others have pointed out, when you use $c->forward(...) that target needs a 
process method.  I try to think of modules that I forward to as being 
implementations of the "Command" design pattern, or part of a Pipeline pattern, 
instead of a module that is actually instantiated and consumed.  At least 
that's the way I try to make sense of all the different ways you can access 
Catalyst modules.

I'm guessing that the reason Html works is that you actually have a different 
Html modules or Action somewhere in the path that works correctly, and it is 
that module and not the new one you are creating that is getting called.

When I forward to a view I try to be very explicit like:

$c->forward($c->view('html')) || $c->log->error("Can't find the html view.");

I find this helps.  So try looking in your list of installed components to see 
if Html is being matched someplace else.  Also please let me know what you goal 
here is, that way maybe we can advise a bit better.  Good Luck

--John




 

Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html___
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

2007-03-07 Thread John Napiorkowski


- Original Message 
From: Octavian Rasnita <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Wednesday, March 7, 2007 12:05:35 PM
Subject: Re: [Catalyst] reserved words



 
 


From: Jason Kohles 


  


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

   

  I have tried:

   

  perl script/myapp_create.pl view 
Show

   

  After restarting the application, it gives that 
  error. If I do instead:

   

  
  perl script/myapp_create.pl view 
Html

   


  The application works fine after restarting it. 
  Am I doing something wrong?

   

  Thanks.

   

  Octavian

   
I'd personally be interested in seeing what the generated files look like.  
Could you attach them in your response (or post them someplace we can see?)

--John

_
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/







 

Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/___
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

2007-03-06 Thread John Napiorkowski


- Original Message 
From: Octavian Rasnita <[EMAIL PROTECTED]>
To: catalyst@lists.rawmode.org
Sent: Tuesday, March 6, 2007 12:02:39 PM
Subject: [Catalyst] reserved words

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

Thank you.

Octavian

I didn't know about the "Show" issue that you mentioned but AFAIK there are not 
really global reserved stuff.  'template' is used by the TT view to set the 
path to the template so you have to be careful with that.  I think the 
'template' think bit me once as well.  That's really the only stash key I can 
think of that's special, but if you use something other than TT you should 
check the docs.

--john


___
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/





 

Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html

___
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: AW: [Catalyst] IE6/7 HTTP POST form problems

2007-03-01 Thread John Napiorkowski
- Original Message 
From: Hartmaier Alexander <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Thursday, March 1, 2007 11:02:12 AM
Subject: AW: [Catalyst] IE6/7 HTTP POST form problems






 









Hi John!
 

  
 

I think it might be that
apache2.2 handles http post packets stricter than version 2.0…
 

As said before I see
the packets arriving at the web server, but they are just ignored.
 

The request isn’t even
logged in the access log of apache, that’s why I assume an apache problem.
 

I’ve already changed
the network card on one box and reinstalled the other on new hardware (HP DL320
G2).
 

  
 

I’m out of ideas…
 

  
 



-Alex
 



This probably isn't the best support list for this problem.  I'd recommend 
taking a look at: http://httpd.apache.org/lists.html and search the archives 
there to see if anyone else has a similar problem and got a solution.  Also you 
can look at the Apache bug report page 
(http://httpd.apache.org/bug_report.html) to see if there is something like it. 
 If not you can subscribe to one of the support lists or see if you can get 
onto IRC and see if someone is around (usually is).

I feel your pain with IE.  If I billed MS for all the time I've wasted with CSS 
or other related browser issues I could take a very nice vacation!  

--John

[Remainder of post snipped for clarity, see thread for details]






 

Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/___
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] IE6/7 HTTP POST form problems

2007-03-01 Thread John Napiorkowski
- Original Message 
From: Hartmaier Alexander <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Thursday, March 1, 2007 4:24:58 AM
Subject: [Catalyst] IE6/7 HTTP POST form problems




 
 








Hi!
 

  
 

Since about two month I’m fighting a
problem some IE users have: on send of a form they don’t receive an
answer from the web server.
 

Tcpdump shows that the packets arrive at
the web server but apache2.2 just ignores them.
 

I disabled https on the internal site to
make debugging easier but the problem still exists.
 

The time the error occurred first was about
the same as I upgraded from apache2 to 2.2 (debian etch).
 

I search for bug reports on apache2.2 but
didn’t find any.
 

  
 

Swapping mod_perl for fastcgi didn’t change
anything either.
 

It also makes no difference if the client
accesses the web server directly or over a proxy.
 

Strange is that the problem never occurs on
my workstation, neither with IE6 (MS virtual pc image) nor with IE7.
 

  
 

Has anyone experienced something similar or
has suggestions?
 

  
 

Thanks in advance!
 

  
 

With best regards
 

Alexander Hartmaier
 

 
 

T-Systems Austria GesmbH
 

Rennweg 97-99
 

A-1030 Vienna
 

  
 

phone: +43-(0)57057-4320
 

mobile: +43-(0)676-8642-4320


Sorry, I think you'll need to start adding a ton of debug output to see what's 
going on.  I'm not sure if this is a Catalyst issue or a networking issue.  IE 
tends to play a little rough with the rules, as I am sure you know.


If you are sure the problem is inside Catalyst you can try running Apache in 
debug with Apache::DB (http://search.cpan.org/~fwiles/Apache-DB-0.13/DB.pm) to 
see if you can spot where the requests are being ignored.


Or try a stripped down Apache with just mod_perl installed.  You can compile it 
very light.  I am actually doing with to make an version of apache that only 
does mod_perl, for example.


Since you don't have the problem I am guessing it could be trouble with the 
clients network connection or computer.  Do they have this problem with other 
applications.


Tell us a little more about your catalyst setup and why you suspect the trouble 
is inside of Cat and not in the network or configuration.   Good luck.


--john

 

  
 




*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be 
privileged.
If you are not the intended recipient, please notify the sender and then delete 
this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*___
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/







 

Food fight? Enjoy some healthy debate 
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367___
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] Resurrected: HTTP redirect - delayed Firefox

2007-02-23 Thread John Napiorkowski


- Original Message 
From: John Napiorkowski <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Friday, February 23, 2007 6:26:06 PM
Subject: Re: [Catalyst] Resurrected: HTTP redirect - delayed Firefox



- Original Message 
From: Andy Grundman <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Friday, February 23, 2007 5:40:29 PM
Subject: Re: [Catalyst] Resurrected: HTTP redirect - delayed Firefox


On Feb 23, 2007, at 5:27 PM, Andy Grundman wrote:

>
> On Feb 23, 2007, at 5:04 PM, Svilen Ivanov wrote:
>
>> But the Engine::HTTP doesn't provide the Content-Length. This can  
>> be fixed
>> by adding a few lines in finalize_headers (Engine/HTTP.pm, at line  
>> 53):
>>if ($self->_keep_alive) {
>>$c->response->headers->content_length( length($c->response- 
>> >body) );
>>}
>
> Hmm, Content-Length should already be set elsewhere in the code, in  
> Catalyst::finalize_headers.

Actually, redirects don't have any body or content-length (see  
Catalyst.pm line 1415), so according to the RFC, will cause the  
browser to not reuse the connection.

Not sure if this helps but according to the specification HTTP 302 should 
contain a body entity:

"The temporary URI SHOULD be given by the Location field in the
   response. Unless the request method was HEAD, the entity of the
   response SHOULD contain a short hypertext note with a hyperlink to
   the new URI(s)."

I can see that Catalyst is setting a Content_length for HTTP 303 (which has no 
delay issue for me) but doesn't set one for HTTP 302, which does.

I don't think this would be too hard to test, could just manually insert the 
content length in the view code, just to see

--john

Woot, looks like that fixed it!  Firefox seems to want a content length.  If I 
add a line to my end action to make sure that 302 has a content length header I 
don't get the delay anymore.

How do we want to go about fixing this?   Should we make sure that 302 follows 
the spec as outlined above (sets a body with the redirect link if one doesn't 
already exist), create a test patch etc?

--john

___
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/





 

Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.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/





 

Never Miss an Email
Stay connected with Yahoo! Mail on your mobile.  Get started!
http://mobile.yahoo.com/services?promote=mail

___
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] Resurrected: HTTP redirect - delayed Firefox

2007-02-23 Thread John Napiorkowski


- Original Message 
From: Andy Grundman <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Friday, February 23, 2007 5:40:29 PM
Subject: Re: [Catalyst] Resurrected: HTTP redirect - delayed Firefox


On Feb 23, 2007, at 5:27 PM, Andy Grundman wrote:

>
> On Feb 23, 2007, at 5:04 PM, Svilen Ivanov wrote:
>
>> But the Engine::HTTP doesn't provide the Content-Length. This can  
>> be fixed
>> by adding a few lines in finalize_headers (Engine/HTTP.pm, at line  
>> 53):
>>if ($self->_keep_alive) {
>>$c->response->headers->content_length( length($c->response- 
>> >body) );
>>}
>
> Hmm, Content-Length should already be set elsewhere in the code, in  
> Catalyst::finalize_headers.

Actually, redirects don't have any body or content-length (see  
Catalyst.pm line 1415), so according to the RFC, will cause the  
browser to not reuse the connection.

Not sure if this helps but according to the specification HTTP 302 should 
contain a body entity:

"The temporary URI SHOULD be given by the Location field in the
   response. Unless the request method was HEAD, the entity of the
   response SHOULD contain a short hypertext note with a hyperlink to
   the new URI(s)."

I can see that Catalyst is setting a Content_length for HTTP 303 (which has no 
delay issue for me) but doesn't set one for HTTP 302, which does.

I don't think this would be too hard to test, could just manually insert the 
content length in the view code, just to see

--john


___
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/





 

Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.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/


Re: [Catalyst] todo list for FormBuilders (was the l10n thread)

2007-02-20 Thread John Napiorkowski

- Original Message 
From: Jonathan Rockway <[EMAIL PROTECTED]>
To: The elegant MVC web framework 
Sent: Tuesday, February 20, 2007 11:04:34 AM
Subject: Re: [Catalyst] todo list for FormBuilders (was the l10n thread)

Christopher H. Laco wrote:
> FormBuilder is nice when it comes to localizing the messages via
> messages.$lang. It totally sucks when it comes to localizing the form
> labels themselves. It looks like I either have to manually loop through
> teh fields and localize the labels, or use a different .frm config for
> each language...which means duplicating major parts of the config.

This doesn't really answer your question, but raises another good point.
 FormBuilder's definition files are great.  The fact that they're
magically parsed by the secret internals FormBuilder isn't.  In your
case, you really want something like this:

Form:
  foo:
name: _[1]
  bar:
name: _[2]
...

and then you want to apply a filter that properly maps _[1] to the
localized string as expected.

The way this should work is that form definition files should be
retrieved from a Model.  The default model would parse the YAML and then
pass the result to FormBuilder.  This would give you the opportunity to
reuse an existing model (maybe you want your forms to come from a
database), and give you the opportunity to subclass the model to do
l10n, use XML instead of YAML, etc.  The idea is to use a Catalyst model
instead of a FormBuilder "model".  This would solve your problem, and
many others that people haven't had yet :)

Interestingly (now that I think about it) FormBuilder is really its own
MVC framework (its own filesystem model for reading config, its own
templating system as a view).  I guess what we need to do is get rid of
FormBuilder's model and view and use Catalyst's instead.  (Something I
dislike about FormBuilder is invoking TT twice per request; [% PROCESS
my_form.tt form=FormBuilder %] is much clener.)

Then you could read XML-formatted forms from memcached and render them
with ClearSilver -- without FormBuilder ever knowing or caring.  (The
flexibility of Catalyst we all love...)

Anyway, /me goes to look at how easy this is to do... but in the mean
time... comments?  Am I missing something?

I don't think you are missing anything.  Actually I was thinking something 
similar myself, but for a bunch of layout classes I've been working on.  I like 
the idea of a config type file for this, let's my authors declare what their 
page needs, but instead of having the controller perform this via a custom 
controller or an action class I want the action class to let a model do this 
for me.  So the model should be responsible to get the configuration in an 
expected format.  This would make it much easier if in the future I want to put 
stuff into the database instead of the filesystem.

--john

-- 
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;

___
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/





 

Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index

___
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: Redirect status codes (was: HTTP redirect - delayed Firefox)

2007-02-13 Thread John Napiorkowski

--- "A. Pagaltzis" <[EMAIL PROTECTED]> wrote:

> * Matt S Trout <[EMAIL PROTECTED]> [2007-02-12
> 11:45]:
> > On 10 Feb 2007, at 08:30, A. Pagaltzis wrote:
> > >Actually, 302 means “repeat the same request at
> this other
> > >URI” whereas 303 means “please retrieve this
> other URI using
> > >GET.” The difference is that strictly according
> to RFC, 302
> > >means the request should be repeated with the
> same method, so
> > >if you return a 302 to the browser in response to
> a POST, the
> > >browser would have to repeat the full POST at the
> redirect
> > >target address.
> > 
> > I've never seen anything except a GET sent after a
> 302 though.
> > 
> > Ain't browsers grand.
> 
> Yeah, for all intents and purposes the original
> meaning of 302 is
> pretty much lost now.
> 
> There was an excellent writeup of the issue by
> Andrew J. Flavell:
>
http://ppewww.physics.gla.ac.uk/~flavell/www/post-redirect.html
> 
> Unfortunately it’s 404 now. I found a link to a
> mirror on Google,
> but that too is 404. However, the Google cache still
> has a copy:
>
http://209.85.135.104/search?q=cache:www.notes.slim.summitmedia.co.uk/post-redirect/www/post-redirect.html
> 
> I better file this away somewhere before that too
> gets lost…

At this point I end up just making sure I am building
this in a way that works properly with my front end
squid cache.  I'd like to be able to use different
redirect status codes in a meaningful way, but I doubt
in the end it buys you anything meaningful.  Until all
the browers support this meaningfully it fails to have
much semantic meaning.

I think the Atom people are doing something with this,
for when you are retrieving info that needs to
redirect, but it will be a long time before whatever
standard they formalize is adopted.

--john

> 
> Regards,
> -- 
> Aristotle Pagaltzis // 
> 
> ___
> 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/
> 



 

It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/

___
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] Why I chose Perl and Catalyst

2007-02-13 Thread John Napiorkowski

--- "Hermida, Leandro" <[EMAIL PROTECTED]> wrote:

> 
> Hi everyone,
> 
> Do not want to start any kind of language war or
> anything - just need
> some concrete, objective opinions and advice.  We
> are starting a brand
> new web application + services + database project
> and my boss ("those
> who make the decisions") asked me as project lead
> why I am chosing the
> Perl/Catalyst/DBIx::Class/CPAN stack instead of
> Java/J2EE/Some Java
> framework or .NET/C#/Microsoft.  In the case of this
> project since we
> are starting from scratch there is no initially
> evident reason (like in
> the previous example where there was already
> existing code that would
> influence the decision).  From my experience with
> Java and C# we could
> do it using those languages.
> 
> Any insight or advice as to why would one prefer a
> Perl stack over a
> Java or .NET one?  It seems that a lot of people
> (including my boss)
> think that Perl cannot compete when one is trying to
> do "enterprise"
> applications.  In some ways (please tell me if I am
> wrong) it might be
> true because Perl exhibits very few rules and
> standards and very little
> built-in control over how you write your code when
> compared to the Java
> and C# paradigm, syntax and compilation rules.  This
> seems to make it
> much more difficult when writing very modular,
> reusable OO code in a
> distributed team of developers.
> 
> In general are there people out there using Perl for
> some things and
> then finding the need to step to a more controlled
> and standardized
> language like Java, C#, others??

One thing that I prefer about Perl is how it's let me
grow as a developer.  I was able to use it to do
useful and serious applications right from the start,
but as I've grown in my knowledge, I didn't outgrow
Perl.  Particularly today, with strong MVC frameworks
like Catalyst, Moose for OO development and a choice
of ORMs (I'm particular to DBIx, but others also get
good feedback and have communities) you can find that
Perl has most of the enterprise goodies.  So if you
need control and structure you can enforce that. 
Moose + Catalyst can give you that, if you use them
well and with best practices in mind.

CPAN will offer you a ton of modules for integrating
with just about any existing system.

Also we find Perl integrates well with enterprise
application management software.  We use doxygen
(http://www.stack.nl/~dimitri/doxygen/) for
documentation along with Jira
(http://www.atlassian.com/software/jira/) and SVN for
source control.  Those package play nice together. 
Some of out developers are using Eclipse with a Perl
plugin and find that works pretty well.  Personally
I'm still a VIM man.

For better or worse, we find that we can get Perl
developers with lots of experience for less than Java
developers of equivalent years, although that might
just be here in NYC where a lot of the Java folks work
in the highly lucrative financial industry.

There are disadvantages of course.  It will be easier
to find Java or .NET people, although the quality of
the talent is varied.  Perl is still more 'DIY' in a
lot of ways.  It appeals to a slightly wilder group of
developers, at least in my experience.  I think if I
was running a very large IT shop I'd seriously be
looking at Java with Struts or similar, because of the
staffing issue.  For small or medium shops, or
consulting groups that can set their own size goals,
this won't be a problem.

One last great thing about Perl is the community.  I
enjoy hanging with Perl people more than with any
other language developer groups.  That's highly
subjective of course :)

Good luck with your strategic planning.

--john



> 
> Thanks,
> 
> Leandro
> 
> 
> 
> > -Original Message-
> > From: Jon [mailto:[EMAIL PROTECTED] 
> > Sent: Tuesday, February 13, 2007 14:08
> > To: catalyst@lists.rawmode.org
> > Subject: [Catalyst] Why I chose Perl and Catalyst
> > 
> > Following the discussion late last year about Perl
> not being 
> > selected as the language of choice by those who
> make the 
> > decisions, I thought I should write up my
> experience (as the 
> > CTO who gets to make the
> > decisions) as to why we chose Perl, Catalyst,
> DBIx::Class for 
> > our system platform.
> > 
> > I've finally done that - here it is for anyone who
> has an interest:
> > 
> > "Perl + DBIx::Class + Catalyst - Our Technology
> Choice"
> > 
> >
>
http://software-reviews.summer-snowstorm.com/content/view/17/27/
> > 
> > 
> > -- 
> > 
> > Jon
> 
> ___
> 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/
> 



 

We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/col

[Catalyst] Question about Angerwhale Catalyst Application

2007-02-09 Thread John Napiorkowski
Hi,

I guess this question might be a little OT for the
list, but I figured what I was wondering about could
be of interest to people other than myself.

I've been looking at the source code of Angerwhale
(http://search.cpan.org/~jrockway/Angerwhale-0.02/)
because I'm always interested in learning about the
ways other people build Catalyst applications.  One
thing I was trying to understand was the reference to
the context object in the new method of one of the
models
(http://search.cpan.org/~jrockway/Angerwhale-0.02/lib/Angerwhale/Model/Filesystem.pm)

Here's a few lines of the code to illustrate:

sub new {
my ($self, $c) = @_;
$self = $self->NEXT::new(@_);

$self->context($c);

}

I was under the impression that it you needed the
context in a component you needed to override
ACCEPT_CONTEXT, since new is only called once when the
application starts up.  Using ACCEPT_CONTEXT
transforms your component to a type Class, since it
creates a new object for each request instead of using
the same one over and over.  But maybe I am not
understanding it?

Also, what's the benefit of override new instead of
COMPONENT?  Was there any particular thinking that
went into this choice?

Appreciate some thoughts, just trying to improve my
best practices.

Thanks,
John


 

We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

___
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] HTTP redirect - delayed Firefox

2007-02-08 Thread John Napiorkowski

--- Svilen Ivanov <[EMAIL PROTECTED]> wrote:

> 2007/2/8, John Napiorkowski <[EMAIL PROTECTED]>:
> [...]
> >
> > I believe that when redirecting as a result of a
> post
> > that 303 is supposed to be correct, whereas 302 is
> > used for redirects when the information is merely
> at a
> > different location.  But I'm not an expert.  So
> 303 is
> > probably what most of us use redirect for, like
> when
> > you click on save in a form and then you want to
> > redirect the user back to a different page.
> >
> > I think this is use is because when Firefox sees a
> 302
> > it's expecting more info or something and it
> doesn't
> > play nice with the build in server.  It didn't
> bother
> > me enough to dig.
> 
> Thank you John for your prompt answer! I tried 303 -
> still lags for 5
> seconds when "-k" is on. I can live with this delay
> as long it doesn't
> appear when I deploy the app on Apache
> mod_perl/fcgi. Do you know if
> it appears on test server only?

For me it disappeared when running under
mod_perl+Apache2.  I think that's why there isn't a
big push to solve it.  Good luck.  --john


> 
> Regards,
> Svi
> 
> ___
> 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/
> 



 

The fish are biting. 
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php

___
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] HTTP redirect - delayed Firefox

2007-02-08 Thread John Napiorkowski

--- Svilen Ivanov <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I'm experiencing very odd issues when I'm trying to
> make HTTP redirect
> with '$c->res->redirect'.
> 
> I use the development server with option "-k - keep
> alive". If I make
> HTTP redirect, Firefox 2.0.0.1 waits exactly 5
> seconds before it loads
> the new location. If I disable the keep alive the
> 5-second delay is
> gone. Konqueror behaves the same way. Internet
> Explorer (surprise,
> surprise) is exact opposite  - it doesn't work at
> all w/o keep alive,
> and if the keep alive is enabled, there is no delay.
> Opera works OK w/
> or w/o keep-alive - no delay.
> 
> I've read few postings that explains the IE and keep
> alive issues but
> I couldn't explain why FF/Konqueror wait 5 sec
> before executing the
> redirect if keep alive is on.
> 
> Any ideas?

I also have this issue.  Funny enough if you do a HTTP
303 See Other rather than a HTTP 302 Found you don't
get this problem.  HTTP 303 flies.  However 302 is
default for Catalyst res->redirect unless you are
explicit.

I believe that when redirecting as a result of a post
that 303 is supposed to be correct, whereas 302 is
used for redirects when the information is merely at a
different location.  But I'm not an expert.  So 303 is
probably what most of us use redirect for, like when
you click on save in a form and then you want to
redirect the user back to a different page.

I think this is use is because when Firefox sees a 302
it's expecting more info or something and it doesn't
play nice with the build in server.  It didn't bother
me enough to dig.

--john

> 
> Regards,
> Svi
> 
> P.S. I can supply HTTP request/responses captured
> with Ethereal if needed
> 
> ___
> 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/
> 



 

Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

___
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?

2007-02-08 Thread John Napiorkowski

--- Jason Kohles <[EMAIL PROTECTED]> wrote:

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

Yeah, that's what I thought as well.  It's not a bad
idea though, however I can understand wanting just one
way to add the action class.  Well, doing
ActionClass('+myapp::Action::...') isn't too bad :) 
--john

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



 

Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

___
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] MyAction for locally namespaced ActionClasses?

2007-02-08 Thread John Napiorkowski
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.

--John


 

Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 

___
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] overriding the match method for custom actions

2007-02-08 Thread John Napiorkowski

--- John Napiorkowski <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> Does anyone know the correct way to override the
> match
> method of an Action?  The docs give a great example
> for overriding the execute method, and there are
> some
> CPAN examples showing how to override dispatch, but
> I
> can't seem to find one for match.  From looking at
> the
> source code I gather that this function should
> return
> 1 if the match is successful and false otherwise.  I
> have two questions:
> 
> 1) When the match fails should I "return;" or do I
> need to literally "return 0;".  Both seem to work,
> but
> I haven't done too many tests.  Does anyone know?
> 
> 2) It's correct to explicitly return the result of
> the
> superclass?  Something like:
> 
> sub match
> {
>   my ( $self, $c ) = @_;
> 
>   ## where _check_custom_match does something and
> then
>   ## return 1 or 0 based on the outcome.
> 
>   my $status = $self->_check_custom_match($c) &&
>$self->NEXT::match( @_ );
> 
>   return $status;
> }
> 
> Does this look right to you?
> 
> BTW, does anyone know if your custom matches get run
> when doing a $c->uri_for($c->action, [EMAIL PROTECTED])?  What
> I
> mean is that $c->uri_for($c->action, ...) will
> return
> nothing if you don't pass the expected arguments,
> which tells me that the match method must get
> invoked,
> but I'm not sure if my custom matches also get
> invoked.  I think it would be great if it did. 
> Anyway, I'll experiment a bit and try to figure it
> out.
> 
> Thanks!
> John

I did some investigating for the $c->uri_for question.
 It seems that you can indeed use this to create URI
objects that won't pass the match test.  For example:

sub test2 :Local :Args(1)
{
  my ($self, $c) = @_;

  $c->log->_dump( $c->uri_for($c->action, 1) );
  $c->log->_dump( $c->uri_for($c->action) );
}

Both dumps give a URL object, although the second one
returns a link that won't work, since the 'test2'
action requires an argument.  This is seems a bit
different behavior from when you try to create a uri
from an action that is the endpoint in a chain; in
that case if you don't pass the correct number of args
it will return undef.  However even chained actions
don't run the match methods, so I guess it's really
the same. 

Changing this would be expensive I think.  Sounds like
something that would make a good plugin though.  Just
something to remember.

For the overriding match method issue for custom
Action Classes I settled on a standard pattern which
seems to work properly.  Looks like:

sub match
{
  my ( $self, $c ) = (shift, @_);

  ## where _validate_args does something and then
  ## return 1 or 0 based on the outcome.

  my $check   = $self->_validate_args($c);
  my $status  = $check ? $self->NEXT::match(@_) : 0;

  return $status;
}

> 
>  
>

> No need to miss a message. Get email on-the-go 
> with Yahoo! Mail for Mobile. Get started.
> http://mobile.yahoo.com/mail 
> 
> ___
> 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/
> 



 

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.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/


[Catalyst] overriding the match method for custom actions

2007-02-08 Thread John Napiorkowski
Hi,

Does anyone know the correct way to override the match
method of an Action?  The docs give a great example
for overriding the execute method, and there are some
CPAN examples showing how to override dispatch, but I
can't seem to find one for match.  From looking at the
source code I gather that this function should return
1 if the match is successful and false otherwise.  I
have two questions:

1) When the match fails should I "return;" or do I
need to literally "return 0;".  Both seem to work, but
I haven't done too many tests.  Does anyone know?

2) It's correct to explicitly return the result of the
superclass?  Something like:

sub match
{
  my ( $self, $c ) = @_;

  ## where _check_custom_match does something and then
  ## return 1 or 0 based on the outcome.

  my $status = $self->_check_custom_match($c) &&
   $self->NEXT::match( @_ );

  return $status;
}

Does this look right to you?

BTW, does anyone know if your custom matches get run
when doing a $c->uri_for($c->action, [EMAIL PROTECTED])?  What I
mean is that $c->uri_for($c->action, ...) will return
nothing if you don't pass the expected arguments,
which tells me that the match method must get invoked,
but I'm not sure if my custom matches also get
invoked.  I think it would be great if it did. 
Anyway, I'll experiment a bit and try to figure it
out.

Thanks!
John 


 

No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

___
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?

2007-02-06 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> 
> On 6 Feb 2007, at 16:15, John Napiorkowski wrote:
> > package manage::Model::Action;
> >
> > my $r = ActionReflector->new;
> >
> > $r->reflect_action_for(
> >
> >   'mylib::schemas::db::membership::members',
> >__PACKAGE__.'membership::members::create',
> >   'Create',
> > );
> >
> > [one of the above for each action type]
> >
> > Would also have solved the problem, I guess?  I
> guess
> > this way give you more finely tuned control.
> 
> Yeah, and the intent is to build a  
> 'Reaction::InterfaceModel::ObjectClass'
> classexporter thing that  
> sugars up Reaction::Class with stuff to make this
> easier.

So should we consider "reflect_actions_for" to be
deprecated?  Because right now if your DBIC classes
are anywhere other than in a folder right underneath
the Schema the trunk version won't work.

--john

> 
> -- 
> Matt S Trout, Technical Director, Shadowcat Systems
> Ltd.
> Offering custom development, consultancy and support
> contracts for  
> Catalyst,
> DBIx::Class and BAST. Contact mst (at)
> shadowcatsystems.co.uk for  
> details.
> + Help us build a better perl ORM: http://dbix- 
> class.shadowcatsystems.co.uk/ +
> 
> 
> 
> ___
> 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/
> 



 

Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

___
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?

2007-02-06 Thread John Napiorkowski

--- Matt S Trout <[EMAIL PROTECTED]> wrote:

> 
> On 6 Feb 2007, at 15:33, John Napiorkowski wrote:
> 
> >
> > --- Jason Kohles <[EMAIL PROTECTED]> wrote:
> >
> >> 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...
> >
> > Not sure if this is the same bug as what is
> causing
> > you trouble.  My problem is when I have 'deep'
> > hierarchies under my DBIC Schema, something like:
> >
> > /myapplib
> >   /Schema
> > db.pm, # inheriting from DBIx::Class::Schema
> >   /db
> > /membership
> >   members.pm #inherit from DBIx::Class
> >
> > so the package name for that "members.pm" file
> would
> > be something like:
> >
> > package myapplib::Schema::db::membership::members;
> >
> > I found the actions that the action reflector
> would
> > create would look something like:
> >
> > catapp::Model::Action::Createmembers
> > catapp::Model::Action::Deletemembers
> > catapp::Model::Action::Updatemembers
> 
> Which is why I'm mostly using the
> ->reflect_action_for syntax and  
> using Model::Membership::Members::Action::Create and
> similar, to go  
> with the way stuff works by default in
> InterfaceModel::Object- 
>  >action_for

So something like:

package manage::Model::Action;

my $r = ActionReflector->new;

$r->reflect_action_for(

  'mylib::schemas::db::membership::members',
   __PACKAGE__.'membership::members::create',
  'Create',
);

[one of the above for each action type]

Would also have solved the problem, I guess?  I guess
this way give you more finely tuned control.

--john

> 
> 
> -- 
> Matt S Trout, Technical Director, Shadowcat Systems
> Ltd.
> Offering custom development, consultancy and support
> contracts for  
> Catalyst,
> DBIx::Class and BAST. Contact mst (at)
> shadowcatsystems.co.uk for  
> details.
> + Help us build a better perl ORM: http://dbix- 
> class.shadowcatsystems.co.uk/ +
> 
> 
> 
> ___
> 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/
> 



 

Get your own web address.  
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

___
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?

2007-02-06 Thread John Napiorkowski

--- John Napiorkowski <[EMAIL PROTECTED]> wrote:

> 
> --- Jason Kohles <[EMAIL PROTECTED]> wrote:
> 
> > 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...
> 
> Not sure if this is the same bug as what is causing
> you trouble.  My problem is when I have 'deep'
> hierarchies under my DBIC Schema, something like:
> 
> /myapplib
>   /Schema
> db.pm, # inheriting from DBIx::Class::Schema
>   /db
> /membership
>   members.pm #inherit from DBIx::Class
> 
> so the package name for that "members.pm" file would
> be something like:
> 
> package myapplib::Schema::db::membership::members;
> 
> I found the actions that the action reflector would
> create would look something like:
> 
> catapp::Model::Action::Createmembers
> catapp::Model::Action::Deletemembers
> catapp::Model::Action::Updatemembers 
> 
> Which was bad because then when I tried to access
> the
> create/delete/update actions I'd get an error, since
> it wasn't properly linked to my real model name
> space.
> 
> I made a very small change in
> ...DBIC::ActionReflector
> and got:
> 
> catapp::Model::Action::Createmembership::members
>  
>  
> catapp::Model::Action::Deletemembership::members
>  
>  
> catapp::Model::Action::Updatemembership::members
>  
>  
> 
> which worked for me :)
> 
> I'm still not sure this is totally correct.  I think
> I'd personally prefer:
> 
> catapp::Model::Action::Create::membership::members  
>  
>
> catapp::Model::Action::Delete::membership::members  
>  
>
> catapp::Model::Action::Update::membership::members 
> 
> Instead, but I guess there's a good reason it's not
> this way.
> 
> One thing I'm not sure about is if I should regex to
> remove all the "::" to something like:
> 
> catapp::Model::Action::Createmembership-members 
>  
> 
> catapp::Model::Action::Deletemembership-members 
>  
> 
> catapp::Model::Action::Updatemembership-members 
> 
> I tried that and it still worked for me, but again I
> am not knowledgeable enough to know what is best.
>  
> Here's my patch; hope it helps, or at least starts
> to
> help (also attached):
> 
> Index: InterfaceModel/Action/DBIC/ActionReflector.pm
>
===
> --- InterfaceModel/Action/DBIC/ActionReflector.pm
> (revision 282)
> +++ InterfaceModel/Action/DBIC/ActionReflector.pm
> (working copy)
> @@ -37,8 +37,8 @@
>implements reflect_actions_for => as {
>  my ($self, $class, $reflected_prefix) = @_;
>  foreach my $action ( keys %{
> $self->reflect_action_types } ) {
> -  my @stem_parts = split('::', $class);
> -  my $last_part = pop(@stem_parts);
> +   my $base_schema =
> $class->result_source_instance->schema();
> +   my ($last_part) =
> $class=~/$base_schema\:\:(.+?)$/;
>my $action_class =
> "${reflected_prefix}::${action}${last_part}";
>$self->reflect_action_for($class,
> $action_class, $action);
>  }
> 

Hi,

After looking at this I could see it would be better
to move the call to result_source_instance->schema()
to outside the loop and save some time.   I could
probably precompile the regex as well, but I doubt it
would help very much for this simple match.  Updated
patch attached.

--john




 

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

reaction.patch
Description: 2107148715-reaction.patch
___
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?

2007-02-06 Thread John Napiorkowski

--- Jason Kohles <[EMAIL PROTECTED]> wrote:

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

Not sure if this is the same bug as what is causing
you trouble.  My problem is when I have 'deep'
hierarchies under my DBIC Schema, something like:

/myapplib
  /Schema
db.pm, # inheriting from DBIx::Class::Schema
  /db
/membership
  members.pm #inherit from DBIx::Class

so the package name for that "members.pm" file would
be something like:

package myapplib::Schema::db::membership::members;

I found the actions that the action reflector would
create would look something like:

catapp::Model::Action::Createmembers
catapp::Model::Action::Deletemembers
catapp::Model::Action::Updatemembers 

Which was bad because then when I tried to access the
create/delete/update actions I'd get an error, since
it wasn't properly linked to my real model name space.

I made a very small change in ...DBIC::ActionReflector
and got:

catapp::Model::Action::Createmembership::members  
 
catapp::Model::Action::Deletemembership::members  
 
catapp::Model::Action::Updatemembership::members  
 

which worked for me :)

I'm still not sure this is totally correct.  I think
I'd personally prefer:

catapp::Model::Action::Create::membership::members
   
catapp::Model::Action::Delete::membership::members
   
catapp::Model::Action::Update::membership::members 

Instead, but I guess there's a good reason it's not
this way.

One thing I'm not sure about is if I should regex to
remove all the "::" to something like:

catapp::Model::Action::Createmembership-members   

catapp::Model::Action::Deletemembership-members   

catapp::Model::Action::Updatemembership-members 

I tried that and it still worked for me, but again I
am not knowledgeable enough to know what is best.
 
Here's my patch; hope it helps, or at least starts to
help (also attached):

Index: InterfaceModel/Action/DBIC/ActionReflector.pm
===
--- InterfaceModel/Action/DBIC/ActionReflector.pm
(revision 282)
+++ InterfaceModel/Action/DBIC/ActionReflector.pm
(working copy)
@@ -37,8 +37,8 @@
   implements reflect_actions_for => as {
 my ($self, $class, $reflected_prefix) = @_;
 foreach my $action ( keys %{
$self->reflect_action_types } ) {
-  my @stem_parts = split('::', $class);
-  my $last_part = pop(@stem_parts);
+ my $base_schema =
$class->result_source_instance->schema();
+ my ($last_part) =
$class=~/$base_schema\:\:(.+?)$/;
   my $action_class =
"${reflected_prefix}::${action}${last_part}";
   $self->reflect_action_for($class,
$action_class, $action);
 }


 

Never Miss an Email
Stay connected with Yahoo! Mail on your mobile.  Get started!
http://mobile.yahoo.com/services?promote=mail

reaction.patch
Description: 2107148715-reaction.patch
___
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] Reaction Development?

2007-02-05 Thread John Napiorkowski
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).

Would it be okay to write a test that lives in the
Reaction namespace, like a normal CPAN module? 
Appreciate any thoughts on the matter.

--john



 

Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/

___
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] Perl Foundation Grants Call for Proposals

2007-02-05 Thread John Napiorkowski
Hi,

Maybe old news for some people but there is a call for
proposals for grants from the Perl Foundation.  Might
be a good chance to get some funding to take care of a
few bits that people generally don't like to do for
fun or don't generally get paid for.  Maybe we could
brainstorm a bit, settle on one or two good ideas and
then get someone who has experience writing grant
proposals to type it up?  If nobody steps up to do the
writeup I can volunteer for it. I do have a lot of
writing and presentation experience, just never wrote
a formal proposal before which is why I'm asking for
someone with more experience to take the lead on it.

Here's the link;

http://www.oreillynet.com/onlamp/blog/2007/02/grants_calls_for_proposals.html


Some ideas to jump start the thinking:

-- More docs for Reaction.  The code and concept for
this is really great and I think it fills an important
gap for Catalyst but I think the learning curve seems
a bit high for average programmers, at least at this
point.

-- Helpers to automatic common stuff, like creating a
web interface to manage user accounts, or a forum,
etc.  This idea got kicked around a while ago and I
recall someone actually wrote up quite a few details.

-- A version of the classic "Pet Store" example web
application, built using Catalyst best practices. 
This was a detailed example of a web app that the Java
people used to explain how to build an application
from the ground up, and was intended to show off all
sort of best practices.  I think the C# people cloned
this, trying to show off how C# was easier.  This
would be more of an advocacy thing than an improve the
framework thing.

Not saying the above are great ideas, but I hoped to
get your brains going.

Thanks!
John





 

Have a burning question?  
Go to www.Answers.yahoo.com and get answers from real people who know.

___
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] chained actions, knowing if current action is an endpoint or not

2007-02-01 Thread John Napiorkowski

--- Jonas Alves <[EMAIL PROTECTED]> wrote:

> On 01/02/07, Dami Laurent (PJ)
> <[EMAIL PROTECTED]> wrote:
> >
> >  Dear Catalysters,
> >
> > I would like to set up an action chain where the
> entry point to the chain
> > (first action) has to do different things
> depending on whether there is
> > another action down the chain or not.
> >
> > Is there a way in the API to ask Catalyst about
> what is pending in the
> > rest of the action chain ? or a way to know if the
> current action is being
> > used as an endpoint or not ?
> >
> > Thanks in advance, L. Dami
> >
> 
> I think you can't have one action that is both an
> endpoint and a normal
> chained action at the same time. You have to define
> two actions with the
> same PathPart.

Hmm, interesting point.  I'm going to go and try
writing something that trys to modify the
ActionContainer and see what happens! --john


> 
> -- 
> Jonas
> > ___
> 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/
> 



 

Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 

___
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] chained actions, knowing if current action is an endpoint or not

2007-02-01 Thread John Napiorkowski

--- "Dami Laurent (PJ)" <[EMAIL PROTECTED]>
wrote:

> Dear Catalysters,
> 
> I would like to set up an action chain where the
> entry point to the
> chain (first action) has to do different things
> depending on whether
> there is another action down the chain or not. 
> 
> Is there a way in the API to ask Catalyst about what
> is pending in the
> rest of the action chain ? or a way to know if the
> current action is
> being used as an endpoint or not ?
> 
> Thanks in advance, L. Dami

You could check the action attributes via
$c->action->attributes->{...} to look for an Args.
That would tell you it's an endpoint.  Or try looking
at Catalyst::ActionContainer and see if there is
something in there that gets you to the information
you need.  I'd do a $c->log->_dump($c->action) and see
what's in there.

Wish I could offer more help.  --john


> > ___
> 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/
> 



 

Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index

___
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] Operation "eq": no method found, ... Dispatcher.pm line 377

2007-01-23 Thread John Napiorkowski

--- Michael Reece <[EMAIL PROTECTED]> wrote:

> 
> On Jan 22, 2007, at 1:30 PM, John Napiorkowski
> wrote:
> 
> >
> > --- Michael Reece <[EMAIL PROTECTED]> wrote:
> >
> >> i am getting intermittent errors (under mod_perl;
> >> Catalyst version
> >> 5.7003) from $c->dispatcher->uri_for_action:
> >>
> >> Operation "eq": no method found, left argument in
> >> overloaded package
> >> URI::_generic, right argument has no overloaded
> >> magic at /usr/local/
> >> lib/perl5/site_perl/5.8.8/Catalyst/Dispatcher.pm
> >> line 377
> >>
> >> sub uri_for_action {
> >>  my ( $self, $action, $captures) = @_;
> >>  $captures ||= [];
> >>  foreach my $dispatch_type ( @{
> >> $self->dispatch_types } ) {
> >>  my $uri =
> $dispatch_type->uri_for_action(
> >> $action, $captures );
> >>  return( $uri eq '' ? '/' : $uri ) # line
> >> 377
> >>  if defined($uri);
> >>  }
> >>  return undef;
> >> }
> >>
> >>
> >> i am calling $c->dispatcher->uri_for_action like
> so:
> >>
> >>  my $action =
> >> $c->dispatcher->get_action_by_path($path);
> >>  unless ($action) {
> >>  $c->log->error("uri_to cannot
> >> get_action_by_path($path)");
> >>  return undef;
> >>  }
> >>
> >>  my @action_args = (defined $snippets) ?
> >> @$snippets : ();
> >>  my $uri =
> >> $c->dispatcher->uri_for_action($action,
> >> @action_args);
> >>  unless ($uri) {
> >>  $c->log->error("uri_to cannot find
> >> uri_for_action $action");
> >>  return undef;
> >>  }
> >>
> >>
> >> any ideas?
> >>
> >> ---
> >> michael reece :: software engineer ::
> >> [EMAIL PROTECTED]
> >
> > Hi,
> >
> > This may not help you at all but I don't think you
> if
> > all you want is the URI for a given action that
> this
> > is the method to use.  Typically I use the
> $c->uri_for
> > and controller->action_for methods.  This works
> pretty
> > well for me.
> >
> > my $uri =
> >
> $c->uri_for($c->controller(xxx)->action_for('action
> > private name');
> >
> > If you just need the uri for an action in the
> current
> > controller and action you can make it even
> shorter:
> >
> > my $uri = $c->uri_for($c->action);
> >
> > or for a different action in the same controller:
> >
> > my $uri =
> > $c->uri_for($c->controller->action_for('action
> name');
> >
> > I think there are even easier ways to do this,
> might
> > want to search the archives.
> >
> > Can you give me a few more details about your use
> case
> > and setup and then maybe I can understand what the
> > best way to solve your problem is.
> >
> > --John
> >
> 
> can you tell me where $c->controller->action_for is
> documented?

It's in:
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7006/lib/Catalyst/Base.pm

Catalyst:Base, which is the base class to Controllers.
 This get's you the Action Object for the named
action.

> 
>
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7006/lib/Catalyst/
> 
> Controller.pm is rather blank.

Yeah, I had this trouble as well.  You need to get
used to checking the source a lot, that will certainly
help.

> 
> my specific use case here is
> 
>my $uri = $c->uri_to('/some/controller/method',
> @path_args, {% 
> query_args}, [EMAIL PROTECTED]);
> 
> i convert the $path '/some/controller/method' to an
> action using $c- 
>  >dispatcher->get_action_by_path, and then get the
> uri for the  
> $action via $c->dispatcher->uri_for_action as
> mentioned at
> 
>
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7006/lib/
> 
>
Catalyst.pm#%24c-%3Euri_for(_%24path%2C_%40args%3F%2C_%5C%
> 
> 25query_values%3F_)
> 
> i will take a look at action_for and see if it will
> do what i want.   
> looks like i would first have to transform
> '/some/controller/method'  
> into 'Some::Controller' + 'method', which would work
> for most cases,  
> except when the controller namespace differs from
> the package  
> namespace (ie, Controll

Re: [Catalyst] Operation "eq": no method found, ... Dispatcher.pm line 377

2007-01-22 Thread John Napiorkowski

--- Michael Reece <[EMAIL PROTECTED]> wrote:

> i am getting intermittent errors (under mod_perl;
> Catalyst version  
> 5.7003) from $c->dispatcher->uri_for_action:
> 
> Operation "eq": no method found, left argument in
> overloaded package  
> URI::_generic, right argument has no overloaded
> magic at /usr/local/ 
> lib/perl5/site_perl/5.8.8/Catalyst/Dispatcher.pm
> line 377
> 
> sub uri_for_action {
>  my ( $self, $action, $captures) = @_;
>  $captures ||= [];
>  foreach my $dispatch_type ( @{
> $self->dispatch_types } ) {
>  my $uri = $dispatch_type->uri_for_action(
> $action, $captures );
>  return( $uri eq '' ? '/' : $uri )# line
> 377
>  if defined($uri);
>  }
>  return undef;
> }
> 
> 
> i am calling $c->dispatcher->uri_for_action like so:
> 
>  my $action =
> $c->dispatcher->get_action_by_path($path);
>  unless ($action) {
>  $c->log->error("uri_to cannot
> get_action_by_path($path)");
>  return undef;
>  }
> 
>  my @action_args = (defined $snippets) ?
> @$snippets : ();
>  my $uri =
> $c->dispatcher->uri_for_action($action,
> @action_args);
>  unless ($uri) {
>  $c->log->error("uri_to cannot find
> uri_for_action $action");
>  return undef;
>  }
> 
> 
> any ideas?
> 
> ---
> michael reece :: software engineer ::
> [EMAIL PROTECTED]

Hi,

This may not help you at all but I don't think you if
all you want is the URI for a given action that this
is the method to use.  Typically I use the $c->uri_for
and controller->action_for methods.  This works pretty
well for me.

my $uri =
$c->uri_for($c->controller(xxx)->action_for('action
private name');

If you just need the uri for an action in the current
controller and action you can make it even shorter:

my $uri = $c->uri_for($c->action);

or for a different action in the same controller:

my $uri =
$c->uri_for($c->controller->action_for('action name');

I think there are even easier ways to do this, might
want to search the archives.

Can you give me a few more details about your use case
and setup and then maybe I can understand what the
best way to solve your problem is.

--John

> 
> 
> 
> ___
> 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/
> 



 

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.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/


Re: [Catalyst] Accessing YAML details from within the Model libraries

2007-01-18 Thread John Napiorkowski

--- Anthony Gladdish <[EMAIL PROTECTED]>
wrote:

> Hi,
> 
> I'm trying to pull out all my DBIx::Class connection
> details for my
> Catalyst application, from a .yml config file,
> something like:
> 
> ---
> model: MyCatPackage::Cat::Model::MyPackageDB
> schema_class: MyPackage::Schema
> connect_info:
> dsn: DBI:mysql:database=somedb;host=somehost
> username: user1
> password: password1
> 
> Is it possible to access these details from the
> application's Model
> libraries? If so, what is the recommended way?
> 
> I only seem to be able to access
> '__PACKAGE__->config->{schema_class}'
> (for example), via the catalyst application's main
> library, and NOT from
> within any of the Model libraries.
> 
> Thanks,
> 
> Anthony

I put all my config into into the .yml files for
models.  My setup look like this:

'Model::myschemas':
  schema_class: 'Schema::db'
  connect_info:
- 'DBI:mysql:database=mydb;host=localhost'
- 'xx'
- 'xxx'
- RaiseError: 1
  PrintError: 0
  ShowErrorStatement: 1
  TraceLevel: 0

I'm not sure about Models, but anything you put into a
controller is available via $self->{attr}

'Controller::test':
  attr: onetwothree

then: 

package myapp::Controller::test;

[snip snip]

sub myaction :Local {

 my ($self, $c) = @_;

 $c->log->info($self->{attr}); #onetwothree to log
}

I haven't tested this but I image it would work from
Views and Models as well.  Give it a try.

--john

> 
> ___
> 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/
> 



 

Get your own web address.  
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

___
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] Recommend methods for form handling

2007-01-17 Thread John Napiorkowski

--- Jim Spath <[EMAIL PROTECTED]> wrote:

> I was wondering what the current consensus among
> Catalyst users is about 
> what the best way to approach forms is?
> 
> I started off writing the forms directly into the
> template, validating 
> with FormValidator::Simple, and trying to fill
> values in with FillInForm.
> 
> I really liked FormValidator::Simple alot, and
> writing the forms 
> directly in the template gives designers complete
> control, but I had 
> some trouble with FillInForm and read that it could
> be slow, so I 
> decided to try something else.
> 
> I'm trying out HTML::Widget now, since the Advanced
> CRUD tutorial uses 
> it, and I guess it seems ok, although its validation
> capabilities don't 
> seem as powerful as FormValidator::Simple.  Also, it
> seems like it makes 
> it harder for designers to work with the forms, and
> I'm about its 
> performance.
> 
> I guess I'm just looking for some opinions on which
> methodology to 
> choose.  Performance is probably the biggest
> consideration for me, but 
> validation, ease of development, and allowing for
> designers to easily 
> edit the appearance are all important.
> 
> Thanks!
> Jim

I think FillInForm is quasi depreciated, since it
parses each request and can slow things down quite a
bit.

I'm personally using HTML::Widget with a custom Model
and ActionClass wrapping it's functionality.  You can
give back layout control to the page designers if you
need to (you don't need to use it's built in view
logic).  However I don't have a great example to show
you, I just use the default as_xml output and wrap it
in a custom style sheet.  It generally looks ok, but I
agree that if you need very sophisticated layout needs
you probably can't use the default.

There's a controller and custom actionclass for
Formbuilder (the plugin is depreciated, don't use it)
over at:
http://search.cpan.org/~jcamacho/Catalyst-Controller-FormBuilder-0.02/lib/Catalyst/Controller/FormBuilder.pm

I actually used the plugin version and liked it's
approach of using a config file to create fields and
setup validation.  However I'm not sure how hard it is
to create complex validation logic, like validation
associated with a callback sub.

This looks like a lot of work was put into it to make
it really work well for Catalyst; I'd be inclined to
try if for someone new I was making if I hadn't
already spend so much time on my HTML::Widget
wrappers.

Then there is the Reaction project (search the list
archive for more).  This is more than just for forms
though, but I think it represents more state of the
art thinking.  If you've played with Java Struts and
Tiles and JSF some of the ideas there will seem
familar (at least I think so, but I've been known to
see stuff that wasn't there :)  However the learning
curve is a bit steep since it uses cutting edge Perl
disciplines like Moose for object oriented
programming.  If you have time to spare in the project
it's probably worth a long hard look at.

There are other form systems around but I think that
covers what I've seen people talking about on the
list.

good luck,

John

> 
> ___
> 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/
> 



 

Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

___
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] Best Practices Question: What to put in an ActionClass Versus a Custom Controller?

2007-01-16 Thread John Napiorkowski
Hi,

I've been thinking a lot about all the different ways
Catalyst let's you do stuff and wondering what, if
any, thoughts any of you might have regarding some of
the overlapping features of Controllers and
ActionClasses, particularly when thinking about
creating good reusable code.

Before we had ActionClasses if you wanted to create
chunks of reusable logic, you created base Controllers
and inherited from them, or you inherited from other
standard Perl modules that were designed to work well
with controllers.  So all the glue logic was in the
controller.  Now with ActionClasses you have the
ability to create classes for logic that is outside of
the controller completely.  So this gives you two ways
to create reusable code.  So with ActionClasses your
Controllers start to look more like big configuration
files, in some ways.

Now, most of the examples in the tutorials show all
the glue and processing logic, like form processing,
inside the controllers; given this one could feel that
this is the Catalyst way.

>From looking at other MVC systems, like struts, you
tend to see nearly the opposite, one big controller
and lots of actions, at least in the examples I see in
the Struts tutorial.  My understanding of Jifty is
that it's similar, they have a module for mapping urls
to code.  Now, in Struts there is nothing stopping you
from creating more then one base controller, but it
seems like the controller is more of a big config
file.  In fact, the meat of struts is inside xml
config files.

Seems like in some ways that Catalyst is moving in
that direction.  Most of the Reaction examples I see
have the controllers mostly used for setting
configuration stuff, all the action takes place in the
action classes.

So given this I am wondering if we could establish
some best practices about when is it good to put that
glue logic in Controllers versus in an ActionClass. 
Here as some thoughts I came up with:

Controllers Good for:

-- Configuration (can put everything in the global
catalyst config.yml file)

-- mapping URLS to Code

-- containing methods and attributes of use during a
request.

ActionClasses Good for:

-- When you need to create custom url matches that
can't be handled by one of the exisintg Action
attributes such as Path, Regex, etc.

-- Encapsulating reused functionality, such as form
processing or accessing models.

If I follow these ideas then I find my code starts to
look a lot like the Java Struts examples I see around
a lot.  Is that good or bad do you think?  Am I
missing something great about using Controllers for
logic inheritance purposes over using ActionClasses?

Anyway, it was a long weekend in the USA and I haven't
been able to get my head back to work yet.  Just
wondering what your thought are.

--john


 

Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.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/


Re: [Catalyst] Re: Preferred Ajax framework

2007-01-10 Thread John Napiorkowski

--- Victor Igumnov <[EMAIL PROTECTED]> wrote:

> 
> On Jan 10, 2007, at 11:56 AM, Steve Atkins wrote:
> 
> >
> > On Jan 10, 2007, at 11:17 AM, John Napiorkowski
> wrote:
> >
> >>
> >> --- Victor Igumnov <[EMAIL PROTECTED]> wrote:
> >>
> >>> Dojo! It goes beyond just ajax. It encompasses
> >>> widgets.
> >
> >> I was excited about dojo as well but I really
> found
> >> that the widgets loaded quite slowly.  Maybe I am
> just
> >> doing it wrong but (for example) when using the
> tab
> >> widget on IE I'd see all the tab panes for a
> second or
> >> two before the control initialized.  I find that
> >> unacceptable.  Again, I'm probably not using it
> >> correctly but it's just too hard to use right
> IMHO.
> >>
> >
> > They also don't work, even a little, in Safari.
> >
> > From a purist point of view I'm happy to blame
> Safari
> > for that, but it's pretty much a deal-breaker for
> any
> > website that you want the general public to be
> able
> > to use. I'd love to be able to use some of the
> neat
> > features, but I don't want to have to implement
> > two (or more) websites to cope with different
> browsers.
> >
> > All the jquery-based plugins I've tried so far
> seem to
> > work fine in all recent browsers that have
> javascript,
> > which trumps the other issues for me right now.
> 
> Actually everything I have tried so far *does* work
> in Safari. Safari  
> is my primary browser.
> Concerning the "slowness" of Dojo you need to turn
> off Dojo's DOM  
> parser and push specific Dojo elements into
> searchIds.
> With all that in place, Dojo flies on every browser.
> 
> // /static/ is Needed if you place dojo.js and src
> into your root/ 
> static/  directory
> djConfig = { baseScriptUri: "/static/",
> parseWidgets: false,  
> searchIds: [] };
> 
> 
> djConfig.searchIds.push("box");
> 
> This should get you started. And yes, your right
> Dojo's documentation  
> blows. Read the code? Javascript isn't hard to
> understand.

This is a good tip, thanks.  Not sure it helps me
right now though, since my typical goal is to have
widgets my end web designers can use with their
existing knowledge.  From that standpoint Jquery and
other CSS selector style toolkits are great.  All they
need to know is to have a particular CSS class name
wrapping some content and it works.  For them it's
very intuitive.  I'm sure as best practices emerge
most of these problems will be solved.  Dojo does have
great scope and completeness, Jquery, despite the
number of plugins, still seems more like a DIY
approach.  If you just need a few widgets and AJAX
style forms, that is fine.  If you want to build out a
serious web application complete with resizable panes,
etc, then you will probably be better off with Dojo or
YUI.  YUI probably has better documentation right now.
 I don't have trouble reading the source for help but
I just sort of feel like I shouldn't need to to get
basic stuff to work, and that is the current trouble I
have with Dojo; although I have to caveat that with
the fact I haven't played with it for about 5 months.

> 
> > Cheers,
> >   Steve
> >
> >
> >
> > ___
> > 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/
> 
> 
> ___
> 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/
> 



 

Have a burning question?  
Go to www.Answers.yahoo.com and get answers from real people who know.

___
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: Preferred Ajax framework

2007-01-10 Thread John Napiorkowski

--- Victor Igumnov <[EMAIL PROTECTED]> wrote:

> Dojo! It goes beyond just ajax. It encompasses
> widgets. Want to do  
> SVG/VML chats? Dojo got it covered with dojo.chart.
> Dojo seems to be  
> the only JS framework with a packaging system, so
> its fairly unique,  
> it can load extra code bits on demand. However,
> since it encompasses  
> so much it seems to be on the slower side of
> frameworks. I would  
> advise to use mod_deflate and build a minimal dojo
> build and require  
> stuff on demand.
> 
> Just my two cents.
> 
> -Victor

I was excited about dojo as well but I really found
that the widgets loaded quite slowly.  Maybe I am just
doing it wrong but (for example) when using the tab
widget on IE I'd see all the tab panes for a second or
two before the control initialized.  I find that
unacceptable.  Again, I'm probably not using it
correctly but it's just too hard to use right IMHO.

I do have great hope for it's future though, I think
in a year or two the docs will be better and some of
those problems will fix themselves either in the code
or by faster browsers.  Just right now it's too much
for me.  My two cents.  -john

> 
> 
> On Jan 10, 2007, at 12:54 AM, Daniel McBrearty
> wrote:
> 
> > another + for jquery. just because I got going so
> quickly and easily,
> > i have to say.
> >
> > On 1/9/07, Kieren Diment <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >> On 10/01/07, A. Pagaltzis <[EMAIL PROTECTED]>
> wrote:
> >> > * John Napiorkowski <[EMAIL PROTECTED]>
> [2007-01-09 22:50]:
> >> > > I prefer Jquery.
> >> >
> >> > Another vote for jQuery.
> >>
> >>
> >> The docs for jquery are very good.
> >>
> >> See
> >>
>
http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/JQChat
> >> for a very simple example.  There's a few
> Prototype examples in  
> >> the example
> >> directory as well.
> >>
> >> Mind you, other people prefer Dojo or YUI. 
> Basically it's up to you
> >>
> >>
> >>
> >> ___
> >> 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/
> >>
> >>
> >>
> >
> >
> > -- 
> > Daniel McBrearty
> > email : danielmcbrearty at gmail.com
> > www.engoi.com : the multi - language vocab trainer
> > BTW : 0873928131
> >
> > ___
> > 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/
> 
> 
> ___
> 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/
> 



 

Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited

___
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/


  1   2   3   >