Re: [Catalyst] Getting DBIC schema from outside Catalyst?

2017-03-09 Thread Eden Cardim
On Wed, Mar 8, 2017 at 6:15 PM, Robert Brown  wrote:

> Hi Jen,
>
> You can use MyApp::Schema outside of Catalyst:
>
> my $schema = MyApp::Schema->connect( $ENV{ LIVE } ? 'live' : 'dev' );
>
> (I'm additionally using DBIx::Class::Schema::Config to be able to connect
> to different servers by using different config files)
>
> $schema->resultset('Instance')->search_rs(), etc.
>
>
If you want to reuse the configuration from MyApp:

use MyApp;
my $schema = MyApp->model('DBICModelName')->schema;

You may need to adjust @INC accordingly, etc.
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] KISS - Base Subroutines.

2016-07-15 Thread Eden Cardim
"Andrew"  writes:

> Is there a keep it simple stupid answer to the following question:
>
> Put a subroutine in a separate place, where it can be accessed / called, by
> whatever controllers need to use it?

Create MyApp::Model::Whatever then $c->model('Whatever')->subroutine

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] New design

2013-07-23 Thread Eden Cardim
 Mark == Mark Keating m.keat...@shadowcat.co.uk writes:

Mark The nice chaps at Evozon have recently been making design
Mark mocks for a bunch of Perl sites and they have come up with a
Mark fresh look for Catalyst. Take a look and let me know what
Mark you guys think.

Mark http://www.mdk.me.uk/community/mocks/Catalyst.jpg

I love it!

-- 
Eden Cardim
ShadowCat Systems Ltd.

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst and Dist::Zilla?

2012-07-06 Thread Eden Cardim
 Bill == Bill Moseley mose...@hank.org writes:

Bill Is there an existing way to get Dist::Zilla to build a Makefile.PL
Bill that will bring root into blib for installation?

Bill I'd be happy to move away from Module::Install::Catalyst since it
Bill does a copy every time I run Makefile.PL -- which is slow for a very
Bill large root.  I'd rather have make handle it just like the files in
Bill lib.

What I've done before is to move root and other directories into share
and use the ShareDir plugin. You will need to adjust $c-path_to to
point to the share dir appropriately, I've been planning to submit a
patch for this, but haven't found the time.

-- 
Eden Cardim
+55 11 9644 8225

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst and Dist::Zilla?

2012-07-06 Thread Eden Cardim
 Bill == Bill Moseley mose...@hank.org writes:

Bill So you are saying move root to share/root and let everything in root
Bill get managed like a share directory?   

Bill $c-path_to uses $c-config-{home} as its base.   So, it's really
Bill $c-config-{home} that would need to be changed, right?   $c-
config- {root} is based of $c-config-{home}, too.   Which means
Bill everything in the app's home directory would need to move, too --
Bill like config.yml (or whatever you use) and any other files or
Bill directories that were placed there.

Yeah, and I always move my configuration files somewhere outside the
root of the app anyway.

Bill File::ShareDIr also acts a bit differently than how the current home
Bill and root work.

Bill For example, prove -vl t/test.t and prove -vb t/test.t  (lib vs.
Bill blib) currently will both use the same home (and therefore root).  
Bill Since -b uses blib/lib then Catalyst probably should also use blib/
Bill lib/App/root to be consistent, right?

Yes, this is an area I'm still not comfortable with, what I ended up
doing as a quick hack was creating symlinks into share/.

Bill File::ShareDire might help that, though.

Bill File::ShareDir expects an auto directory -- so prove -vl won't work
Bill (because File::ShareDir expectes to find lib/auto which likely
Bill doesn't exist in the source).

Bill prove -vb works because File::ShareDir looks for blib/lib/auto/
Bill App, and things in shareget copied then when running make.

Bill I tend to use prove -vl quite often, so that's a problem when also
Bill using File::ShareDir.  (Maybe there's a solution I'm not aware of).

  my $share_dir = eval { File::ShareDir::dist_dir('MyApp') };
  __PACKAGE__-config(home = $share_dir) if $share_dir;

This has worked fine for me, if there's sharedir it means the app has
been installed. As long as you don't have the app installed in your dev
environment (and you don't want that for a myriad of reasons anyway), it
should work fine. What's dangerous about this is that if you end up
installing the app in your dev environment for some reason, things can
get *very* confusing, so maybe an alert warning about it somewhere would
be in order.

Bill I like the idea of using share for root -- just because it uses the
Bill Makefile to copy files (when needed) instead of
Bill Module::Install::Catalyst's method of copying all files every time
Bill when running Makefile.PL.  I've got over 5500 files in my root.

Bill Maybe all that's needed is Catalyst::Util's home function to figure
Bill out if running out of lib or from an installed location (prove -l
Bill  vs. prove -b) so it can use the right root using existing methods
Bill or via File::ShareDir.

It already does the installed vs checkout verification, all that's
lacking is the sharedir integration.

Bill Still, not sure I'd want to move the app configuration out of the app
Bill home.

You still need a place for the config to live when you install the app.

-- 
Eden Cardim
+55 11 9644 8225

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Eden Cardim
 Octavian == Octavian Rasnita orasn...@gmail.com writes:

Octavian Thanks. I know about it, but it doesn't solve what I want... to
Octavian start the web server automaticly when the computer starts after
Octavian MySQL was started.

Note that if you'd using Catalyst::Model::DBIC::Schema, you don't need to wait
for MySQL to come up, as it does lazy connecting. If someone issues a request
during the mysql startup time, they'll get a 500 error, which you can handle
via an error document and is much better than a plain 404.

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to access $c-apache in 5.9?

2012-04-20 Thread Eden Cardim
 Hailin == Hailin Hu i...@h2l.name writes:
Hailin Finally, something like below works for me.

Hailin my $apache = $c-engine-env-{'psgi.input'}; #
Hailin Apache2::RequestRec $apache-user( $username );

Hailin I supposed that an accessor of apache should be a method instead
Hailin of a key of hash.  Is this the right way to retrieve the
Hailin apache/mod_perl object?

No it's not, this ties your application to a specific backend server
implementation (which is what caused your problem in the first
place). Whenever you need to access $c-engine-env, you should be applying a
Plack::Middleware to your .psgi instead.

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Starman and Catalyst

2012-04-05 Thread Eden Cardim
 Bill == Bill Moseley mose...@hank.org writes:

Bill Anyone here using Starman in production?   Can you describe any
Bill special config needed, what you are using for serving static
Bill content, and anything else to be aware of?

You might want --preload-app if you want to save memory.

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Error loading data from schema

2012-04-04 Thread Eden Cardim
 Kenneth == Kenneth S Mclane ksmcl...@us.ibm.com writes:

Kenneth I am getting the following error: Caught exception in
Kenneth dbms::Controller::AccountView-list Can't call method all on
Kenneth an undefined value at
Kenneth /tmp/catalyst/dbms/script/../lib/dbms/Controller/AccountView.pm
Kenneth line 7.

Kenneth this is the referenced sub:

Kenneth sub list : Local { my ($self, $c) = @_; $c-stash(accounts =
Kenneth $c-model('dbms::ACCOUNT_VIEW')-all); $c-stash(template =
Kenneth 'accountview/list.tt2'); }

Kenneth I have seen quite a few posts about this error but no real
Kenneth explanations of what is causing the issue.  I created a view in
Kenneth the DB containing the data I need to display on the page.  The
Kenneth error is occurring at this line: $c-stash(accounts = $c-
Kenneth model('dbms::ACCOUNT_VIEW')-all); which I have tried several
Kenneth different things. If I remove the -all I get no error and my
Kenneth header row appears. I cannot find anything that tells me
Kenneth specifically what this should be composed of. Any pointers to
Kenneth help figure this out are appreciated.

When the app loads, you should get a list of loaded components, please show us
that list.

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Error loading data from schema

2012-04-04 Thread Eden Cardim

| dbms::Model::ORANGES::AccountView   | class|

Kenneth Strange, I do not see it listed, yet it got created and works
Kenneth when I call the /index.

You probably want $c-model('ORANGES::AccountView');

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Passing REMOTE_USER to development server

2012-03-02 Thread Eden Cardim
 Stephen == Stephen Shorrock stephen.shorr...@gmail.com writes:

Stephen Using an older version of Catalyst (5.80007) I used to start the
Stephen development server with:

Stephen REMOTE_USER=userid myapp_server.pl

Stephen and have available in the application userid via
Stephen $ENV{REMOTE_USER}.  Having upgraded to 5.90010 this no longer
Stephen appears to work nor does attempting to access via $c-engine-env
Stephen or $c-req-remote_user.

Stephen How can I set the remote user on development user startup and
Stephen then how should I access it in my controller?

use Plack::Middleware::ForceEnv, this and other upgrade caveats are documented
in Catalyst::Upgrading

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst 5.90010 server must be in CWD to run?

2012-02-21 Thread Eden Cardim
 Louis == Louis Erickson lerick...@rdwarf.net writes:

Louis Looking at @INC, it's clear that Catalyst no longer adds
Louis $basename/../inc to the path - I haven't dug into the code to
Louis find where the change was.

You mean ../lib, right?

Louis I know all the help and samples have people run
Louis script/myapp_server.pl, but I never do; I run it from the script
Louis directory.

There's no problem with that at all (caveats given below), but do you have a
specific reason for doing it that way?

Louis I'm also concerned that having to be in the right CWD
Louis will allow loading of unexpected modules, rather than being based
Louis on the app's location, as I'd expect.

This isn't much about the CWD, it's about setting the right @INC, which is a
problem related to perl (and pretty much any programming language) as a
whole. You can run the app from anywhere, as long as you tell it where to find
the libs it needs. If you used the standard scaffolding script, that should be
lib/ under your MyApp dir, plus the site_perl libs (which are hard-coded into
@INC by the perl binary in most cases). If you're concerned about loading
unexpected modules, sanitize @INC before you use() anything. Catalyst tries to
make a few guesses as to what @INC should be, and the doc examples try to
match those assumptions, but there's no way it can catch all the possible
scenarios, so if for some reason you decide to do something different than
what's doc'ed, you'll need to adjust the environment accordingly.

Louis Is this a deliberate change?  Is there a reason for it?  Or is it
Louis an unexpected change?

Louis So, I'd think this is deliberate.  It will also affect all the
Louis scripts.  What is this going to do to myapp_fastcgi, when the
Louis webserver doesn't set the WD as expected?

I'm not exactly sure about the specific motivation for that change, but
script/myapp_fastcgi.pl is just a perl source like any other, adjust @INC
before running it (via PERL5LIB, -I, etc.) and you'll be fine.

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Built in profiling in the UI

2012-02-21 Thread Eden Cardim
 Adam == Adam Sjøgren a...@koldfront.dk writes:

Adam   Hi Has anyone built something similar to this:

Adam  * http://code.google.com/p/mvc-mini-profiler/

Adam for Catalyst?

Adam Similar information is available on the console/in the log in
Adam debug-mode of course, but bringing it into developers face might be
Adam motivating...  And the database query integration looks nice.

See Plack::Middleware::Debug and it's plugins. Specifically,
Plack::Middleware::Debug::CatalystLog, Plack::Middleware::Debug::DBITrace and
Plack::Middleware::Debug::DBIProfile


-- Eden Cardim Need help with your Catalyst or DBIx::Class project?  Code
  Monkey http://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd.  Want
  a managed development or deployment platform?  http://edencardim.com
  http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst 5.90010 server must be in CWD to run?

2012-02-21 Thread Eden Cardim
 Louis == Louis Erickson lerick...@rdwarf.net writes:

Louis No, I mean ../lib relative to the script's main directory.  If I'm
Louis in / and run the script with a full path, I don't want or expect
Louis ../lib to be added to @INC.  I want and expect the script to find
Louis the paths relative to itself, as the structure of the app as it is
Louis often used are.

Yes, and Catalyst does try to locate lib (not inc) to the best of it's
ability, you need one of Makefile.PL, Build.PL or dist.ini in the same
directory as lib, cos' that's the mechanism it uses for locating an
uninstalled app. If you don't have those, create at least one, even if it's
bogus. If you do have them, and you're still having trouble, it's a bug.

Louis Another person responded that checkout meant checked out from
Louis source control, and yes, I'd guessed that.  Checked out instead of
Louis what?

Checked out as opposed to installed to site_perl/local-lib via a tarball where
you won't have any of the marker files mentioned above, and Catalyst tries to
find the app in there as well.

Louis How does that change the environment?

Basically, if the script isn't lower down the same hierarchy as the marker
files, or it's not installed to site_perl, there's nothing Catalyst can do
about it.

Louis Who is that affecting and how?
Louis Do the scripts not run in MyApp/scripts there, or is the
Louis difference for the alternative?

They run however you choose to run them, whether Catalyst can find lib or not
depends on you providing enough info for it to do that.

Louis Would that be after running 'make
Louis install', and then being in the path somewhere?  Wouldn't finding
Louis lib be even more critical in that case?  Adding a ../lib or even
Louis $basename/../lib wouldn't be appropriate there.

Yes, but there's only so much that can be automated.

-- 
  Eden Cardim Need help with your Catalyst or DBIx::Class project?
  Code Monkey http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment platform?
 http://edencardim.comhttp://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Paradigm question: how to use ResultSet level security based on $c-user?

2011-10-18 Thread Eden Cardim
 will == will trillich will.trill...@serensoft.com writes:

will Question: when a user logs in to our Catalyst app, he/she
will should only see the items he/she is allowed to see. But the
will only way we can figure how to do this is to pass $c-user
will either to the ResultSet methods or to the FormHandler methods,
will making the app more and more interdependent... Is there a
will better paradigm in the context of a Catalyst app?

That is perfectly fine as long as you define an API for user and stick
to it so you can replace it via duck typing afterwards.

will Right now we're working this via DBIC ResultSet like so:

will package Incident::Schema::DB::ResultSet::Incident;
will use base 'DBIx::Class::ResultSet';

will sub security {
will     my $rs      = shift;
will     my $user    = shift;

will     $user = $user-obj
will         if ( $user-can('obj') );
will     if ( $user-is_admin ) {
will         return $rs; # everything is visible to admins
will     }

will     my %visible_teams = map { $_ = 1 }
will         $user-corp_team_ids; # method from Incident::User schema
will     $rs = $rs-search(
will         { 'me.team' =
will             { -in = [ keys %visible_teams ] }
will         },
will         { order_by = ['created'] }
will     );

will     return $rs;
will }

will Then...

will package Incident::Web::Controller::Ticket;
will BEGIN { extends 'Catalyst::Controller'; }

will sub base : Chained('/auth') PathPart('ticket') CaptureArgs(0) {
will     my ( $self, $c ) = @_;
will     my $rs = $c-model('Incident::Ticket')-security( $c-user );
will     $c-stash( incident_rs = $rs );
will }

will Is this Kosher? In this context it's a DBIC resultset
will depending on another DBIC object, so it may not be as big an
will issue as, say, when we have HTML::FormHandler popup menus that
will should only show the user options based on the user's role
will and/or organization.

will Is there a canonical way to approach this both in ResultSets
will and in FormHandler forms?

You might want to look at 
Catalyst::TraitFor::Model::DBIC::Schema::WithCurrentUser

-- 
  Eden Cardim
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Compress HTML

2011-09-08 Thread Eden Cardim
 Brian == Brian Cassidy brian.cass...@gmail.com writes:
Brian I've used HTML::Packer [1] with good results. It will also do CSS/JS
Brian minification via CSS::Packer and JavaScript::Packer if you need that
Brian as well.

Brian [1] https://metacpan.org/module/HTML::Packer

And now that Catalyst has moved to being 100% plack compliant, you can
integrate that effortlessly via Plack::Middleware::HTMLMinify

-- 
  Eden Cardim
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Model Testing Problems.

2011-09-05 Thread Eden Cardim
 John == John Karr brain...@brainbuz.org writes:

John I have a catalyst application that I've been working on for
John some time (it is pretty big now), and am finally trying to
John write tests for it. The application runs error free when run
John in its entirety. But I can't get Model Tests to run. My Model
John is DBI based, where each DSN has a MyApp::Model::DSN parent
John module and then there are MyApp::Model::DSN::Table child
John modules which contain the methods relevant to each table. I
John would like to access my model methods in a manner similar to
John how I do in an application:
 
John  is( $BoPeep-model('DBI::Flock')-CountSheep(), 3 , 'CountSheep. 
There are 3 sheep in BoPeeps flock' ) ; 

use MyApp;
is( MyApp-model('DBI::Flock')-CountSheep(), 3 , 'CountSheep. There are 3 
sheep in BoPeeps flock' ) ;

The above snippet should work, assuming the CountSheep() method is in place.

-- 
  Eden Cardim
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Refactoring Controllers

2011-07-29 Thread Eden Cardim
 Steve == Steve  st...@matsch.com writes:

Steve Hi all,
Steve I have a question regarding controller refactoring, and whether 
subclassing
Steve (or adding a Moose role) would be a good idea for a particular 
application.

Steve The application creates 6 different types of invoices, each 
representing a
Steve particular type of service.  Currently, I have a controller for each 
that
Steve handles the various steps that must be taken to produce and 
ultimately send
Steve these invoices.  ALL OF THESE CONTROLLERS HAVE THE SAME ACTIONS, and 
most of
Steve the same logic, which to me says I should refactor these 
controllers...I
Steve just don't know how, and also whether the benefit is worth the work. 
 Almost
Steve certainly it would not be worth it in and of itself, however I might 
want to
Steve write another application someday where knowing this would certainly 
be
Steve useful :)

Steve So IF this seems reasonable, and my controllers are 'FOOcontrol',
Steve BARcontrol', 'BAZcontrol', and my actions are 'initialize', 
'upload_data',
Steve process', 'generate_invoices'...etc., what is a good way to stay 
DRY?  In
Steve particular I'm having a hard time wrapping my mind around how the 
URI's
Steve would be handled.

If the actions aren't private, you want to create a base controller to
preserve the URI paths and keep them consistent across the several
inheriting controllers. If not, move the methods into a model and use
delegation.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Best practices for extending DBIC model

2011-07-14 Thread Eden Cardim
 Eric == Eric Wright ewri...@linescale.com writes:

Eric I'm using Catalyst::Model::DBIC::Schema. Is there a preferred
Eric way to hook into the result set to customize things the way I
Eric need?

http://beta.metacpan.org/module/Catalyst::Model::DBIC::Schema#traits

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] error while starting my dev enviroment

2011-07-10 Thread Eden Cardim
 Charlie == Charlie Gonzalez itchar...@gmail.com writes:

Charlie Does this mean that when making a decision on an OS for
Charlie Catalyst apps the best choice of a linux OS is  CentOs or
Charlie Redhat?

Your best bet on any system is to leave the vendor perl alone and build
one exclusively for your app. If it's a production-scale system, you
want to do that anyway, given most vendor perls come with threading
support and that will impact performance. You can then install all the
dependencies from CPAN, to get minimum maintainance interference between
the OS and your app.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] DBI Models Question.

2011-06-12 Thread Eden Cardim
 John == John Karr brain...@brainbuz.org writes:

John The mistake in my code brings up the other question (which applies to 
ORM
John models as well): How to get the model to take its parameters from
John appname.conf instead of having to input them directly in the model.

It already works that way, try:

Model::RSVP
  dsn   'DBI:Pg:dbname=rsvp;host=joomla.brain.buz',
  user  joomla
  password  007drupal
Model

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] What text editor to use?

2011-04-12 Thread Eden Cardim
 John == John M Dlugosz wxju46g...@snkmail.com writes:
John I installed Emacs, and found that it's too alien for me.  Basic 
things like
John selecting with the mouse and keyboard together are different from my 
current
John habits.  Is there a more GUI front-end?

As is the case with vi(m), emacs revolves around the concept that
removing your hands from the home row on the keyboard is bad for
productivity (touch-typists can do things much faster with a keyboard
than with a mouse) and also hampers your ability to edit code remotely
in several situations (like debugging code on a headless web server or
recovering your screwed X session). If you need an editor that favors
mice and GUIs, try Padre.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Updating a database entry

2011-04-11 Thread Eden Cardim
 Francisco == Francisco Obispo fobi...@isc.org writes:

Francisco Remember that Catalyst uses DBIx::Class as an ORM.

No it doesn't, but you can use DBIx::Class if you want to, or any other
ORM, for that matter, given it's perl and you can use whatever modules
you want.

Francisco so it must be able to uniquely identified each row with
Francisco a Primary Key.

This is orthogonal to the fact that you're using DBIC inside Catalyst,
it actually depends on the data model you've implemented.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Force the session to be saved.

2011-04-11 Thread Eden Cardim
 Duncan == Duncan Garland duncan.garl...@motortrak.com writes:

Duncan Thanks, but the script file has been rendered with the wrong
Duncan information by that point so delaying execution wouldn’t
Duncan help.

What exactly is the problem? You've speculated on sessions but you
haven't mentioned what the expected behaviour is and what you're getting
instead of that.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] What text editor to use?

2011-04-11 Thread Eden Cardim
 Erik == Erik Colson e...@ecocode.net writes:

Erik Emacs has mmm-mode for this...
Erik my 2c

Emacs also has a set of extensions written by jrockway that facilitate
the writing of perl code in general. I use that combined with yasnippet
and the perltidy extension for maximum throughput and it's very
satisfying.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Implementing a 'remember me on this computer' button

2011-04-11 Thread Eden Cardim
 Edmund == Edmund von der Burg e...@ecclestoad.co.uk writes:

Edmund That is a configuration parameter and so gets set at startup and is
Edmund applied to all cookies from then on. I want to be able to change the
Edmund expiry for an particular cookie so that some sessions persist and
Edmund others don't.

You can always manipulate the session cookies manually. Use
$c-get_session_cookie, it returns a CGI::Simple::Cookie.

--8---cut here---start-8---
-config-{Plugin::Session::State::Cookie}{cookie_expires} = 0;

$c-authenticate;
$c-get_session_cookie-expires($ttl) if $remember_user;
--8---cut here---end---8---

Should do the trick.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Setting Model Class Variable from Catalyst Config

2011-04-11 Thread Eden Cardim
 David == David Schmidt davew...@gmx.at writes:

David Usually that's achieved by adding an attribute to your model and then
David providing the value at model instantiation time

--8---cut here---start-8---
MyApp-config-{Model::Foo}{bar} = 'baz';

package MyApp::Model::Foo;
has bar = (is = 'ro');
--8---cut here---end---8---

The above should set the bar attribute during load time for you straight
out of the box.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Help System - Can a controller's index capture the remainder of the path as a series of arguments?

2011-04-11 Thread Eden Cardim
 Kyle == Kyle Hall kyle.m.h...@gmail.com writes:

Kyle Thanks to Bill and David the info. I'm still learning how to use
Kyle Catalyst, it's almost overwhelming when compared to CakePHP ( which is
Kyle what I started with as my first framework ) here is what I've got:

Kyle My button: a href=[% c.uri_for('/help', c.action ) %]
Kyle class=button id=menu-helpHelp/a

Kyle My Help controller:
Kyle sub index : Chained('/') PathPart('help') Args {
Kyle my ( $self, $c, @path ) = @_;

Kyle my $path = join('/', @path);

Kyle $c-stash-{template} = help/$path.tt;
Kyle }

Kyle Seems to work fine. Any suggestions for improvements?

Is there any non-static content in the help files? If not, you can get
away with serving the plain files straight from root/help via:

--8---cut here---start-8---

MyApp-config-{'Plugin::Static'}{dirs} = [ 'help' ];

--8---cut here---end---8---

As usual you'll want to serve that straight via apache or whatever in
production.

And in your templates:

--8---cut here---start-8---

a href=[% c.uri_for('/help', c.req.path) %]/Help/a

--8---cut here---end---8---

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] redirect and ajax

2011-03-21 Thread Eden Cardim
 piccard == piccard  picc...@web.de writes:

piccard yes, thank u, this was my emergency-solution. I just
piccard thought it could also be done by the server, more elegantly
piccard ;-)

Redirections are always implemented by the client, all the server does
is set a header. If the redirection isn't happening, your JS client
isn't respecting the header. So yes, you need to write code on the
client-side that does the redirection for you.

-- 
Eden Cardim
Software Engineer
Shadowcat Systems Ltd.
http://www.shadowcat.co.uk
http://blog.edencardim.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Conversion from Subversion to Git complete!

2011-02-18 Thread Eden Cardim
 fREW == fREW Schmidt fri...@gmail.com writes:

fREW I should have sent this out on Tuesday, but it slipped my
fREW mind.  The conversion is complete!  You can access the new
fREW repo at

fREW gitweb: 
http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/Catalyst-Runtime.git;a=summary
fREW read access: 
git://git.shadowcat.co.uk/catagits/Catalyst-Runtime.git
fREW read/write: catag...@git.shadowcat.co.uk:Catalyst-Runtime.git

fREW If you'd like to get write access to the repo pop into the IRC
fREW channel (#catalyst on irc.perl.org) and ask about it; we can
fREW possibly get you hooked up

Were the previous commit bits preserved?

-- 
Eden Cardim
Software Engineer
Shadowcat Systems Ltd.
http://www.shadowcat.co.uk
http://blog.edencardim.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Sanity Check -- requesting feedback on chaining approach

2011-02-15 Thread Eden Cardim
 will == will trillich will.trill...@serensoft.com writes:

will Catalystas -- this chaining stuff is wicked awesome. We've
will been following the below paradigm for the most part, and now
will we want to expand a bit: package MyApp::Controller::Xyzzy;

will sub base     : Chained         PathPart('xyzzy') CaptureArgs(0) {  }
will   sub list   : Chained('base') PathPart('')             Args(0) {  }
will   sub item   : Chained('base') PathPart('')      CaptureArgs(1) {  }
will     sub view : Chained('item') PathPart('')             Args(0) {  }

will The two new nodes we want to insert are for csv-download
will (delivering all records) and paging (delivering a
will subset). Here's what we're thinking:

will package MyApp::Controller::Xyzzy;
will sub base     : Chained         PathPart('xyzzy') CaptureArgs(0) {  }
will   sub list   : Chained('base') PathPart('')      CaptureArgs(0) {  }
will     sub page : Chained('list') PathPart('')             Args(0) {  }
will     sub csv  : Chained('list') PathPart('csv')          Args(0) {  }
will   sub item   : Chained('base') PathPart('')      CaptureArgs(1) {  }
will     sub view : Chained('item') PathPart('')             Args(0) {  }

will Here the index view would come from page() instead of directly
will from list(). csv() would download
will resultset-search-({%params})-all whereas page() would
will resultset- search({%params},{page=$p,rows=$r}).

will So any search parameters would be handled inside list() and
will then paging parameters would be handled separately inside
will page(). Right? Is there an elegant way to separate the two
will sets of parameters?

Yes, this will work:

# in list()
$c-stash-{rs} =
  $c-model('Foo')-search({%params});

# in page()
$c-stash-{paged_rs} =
  $c-stash-{rs}-search({}, {page = $p, rows = $r});

...if that's what you're asking.

Other interesting things you can do:

sub add_item :Chained('list') PathPart('add') Args(0) {
my($self, $c) = @_;
$c-stash-{rs}-create({ %more_params })
}

sub related_items :Chained('list') PathPart('related') CaptureArgs(0) {
my($self, $c) = @_;
$c-stash-{rs} = $c-stash-{rs}-related_resultset('');
}

sub related_page :Chained('related_items') PathPart('page') Args(0) {
my($self, $c) = @_;
$c-forward('page');
}

sub related_csv :Chained('related_items') PathPart('csv') Args(0) {
my($self, $c) = @_;
$c-forward('csv');
}

Assuming %params in list() was a simple key/value map, add_items() is
going to use those, in addition to whatever's in %more_params, which is
cool because if you change the criteria in list(), it propagates
everywhere else as well. Plus, you reuse the page/csv implementation
easily. The combination of chained DBIC resultsets and catalyst chains
is very similar to curried functions (I believe that's what the initial
design goal was).

-- 
Eden Cardim
Software Engineer
Shadowcat Systems Ltd.
http://www.shadowcat.co.uk
http://blog.edencardim.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Ajax Problem.

2011-01-06 Thread Eden Cardim
 Rohan == Rohan M rohan7...@gmail.com writes:

Rohan Dear All,
Rohan I want to use Ajax in my Catalyst application.

Rohan Thing's that I've done till now :

Rohan 1) Created a Javascript function on an event (onblur event) in my 
view (tt page).
Rohan 2) Created xmlhttp object in that Javascript function.
Rohan 3) Called the '/controller/action' path with parameters.
Rohan 4) The Action subroutine searches database and puts results in the 
stash

Rohan I could see, the things are working till the fourth step correctly.

Rohan Now, how can I render the stash variables in the current tt page?

There's not much difference in how Catalyst handles Ajax, all it sees
are normal HTTP requests. You just have to take care to serve the
correct content for each request. Typically, you'll have a controller
action for loading the HTML/JS structure and a set of supplementary
actions to render the partials.

Rohan Or Will I need to parse the entire content?

It depends on what response you build inside catalyst, for partials you
want to not render the htmlbody etc. tags, since you're going to
update the document via innerHTML.

For implementation specifics you're going to have to show your catalyst
code.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst Workflow Framework Integration

2010-12-13 Thread Eden Cardim
 Eric == Eric Berg eb...@bergbrains.com writes:

Eric Can anyone make any recommendations for workflow solutions for
Eric catalyst?  I see that Workflow and Class::Workflow seem to be
Eric the primary options.

Class::Workflow is a regular perl class that you can integrate via a
Catalyst::Model, see the catalyst manual for that: http://goo.gl/Adudh

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst::Model::DBIC::Schema - Print Debug statement

2010-12-03 Thread Eden Cardim
 Blaine == Blaine Everingham grandmasterbla...@hotmail.com writes:

Blaine I'm trying to see the queries the actual query code that is
Blaine submitted to the database when I perform a find on a model.
Blaine I've tried:

Blaine 1) Adding $ENV{DBIC_TRACE}++ to the MyApp.pm

You need to set it before the storage object is constructed, namely,
it should work if you place it before the call to MyApp-setup

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Multiple chain sources?

2010-11-22 Thread Eden Cardim
 Matthew == Matthew Braid catal...@mdb.id.au writes:

Matthew Hi all, Just wondering - is it possible for an action to
Matthew have multiple chain paths?

Matthew I'd like my site to have a path like /user/N/profile
Matthew (/user/N being a chain path, /profile being an end node off
Matthew that path), but also have a path like /my/profile (where
Matthew /my is a chain path that acts as if the user put their own
Matthew ID on the end of /user/N).

No, that's currently not possible with chained. Matt and I, howeever,
are working on a grammar-based dispatcher that will allow easy
expression of those types of constructs.
You'll have to declare something like:

sub my :Chained('base') CaptureArgs(0) {
  my($self, $c) = @_;
  $c-forward(user = [$c-user-id]);
}

and then chain onto that.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Begginer's question about application structure

2010-11-22 Thread Eden Cardim
 Martin == Martin Bendix martinben...@yahoo.co.uk writes:

Martin My model should be well separated from the controller.
Martin Most, if not all of the application functionality should be
Martin exposed via the model, so that the Catalyst controller only
Martin needs to make simple calls to the model.  To do this, model
Martin classes should be created in 'lib/myapp', with simple
Martin adapters in 'lib/myapp/Model', using
Martin Catalyst::Model::Adaptor.

Controllers need to act as an adaptor between the model and the
view. So, for instance, mapping $cd-artist into a value that's suitable
for placing in a form field value attribute is the responsibility of
the controller (cos' when you change the UI into a CLI switchboard, for
instance, the mapping is going to be different).

Martin At this point, I am a little less clear on how best to structure my 
application.

Martin As my models will be primarily concerned with accessing the 
database, how much 
Martin database code should go in my model classes, and how much in the 
Martin DBIx::Class::ResultSet classes?  For example, should I write a 
method in my 
Martin DBIx::Class::ResultSet classes that can add new CDs when supplied 
with title, 
Martin artist and a track list?  Or would it be better to put this in my 
model?

You need to constrict the scope of your methods as much as
possible. That is, try not to write any code that makes the ResultSet
aware that it's being used in a web application. I find that most of
DBIC's API is well suited for being invoked directly by the
controller. You just need to avoid any constructs that make the
controller aware that there's actually a relational database behind the
model, because then you're free to swap out to an alternative
implementation. A general rule of thumb is to try to avoid writing
complex -search methods in the controller, put those behind a
friendlier method on the ResultSet, for instance write a resultset
method that allows you to write $cds-released('this year') (which you
can implement via DatetimeX::Easy) instead of
$cds-search({ 'YEAR(me.date)' = DateTime-now-year }).

Martin Data validation could be handled by HTML::FormHandler, but
Martin any validation performed here won't be of much use if I
Martin later provide an alternative interface to my application.  I
Martin assume that I should therefore delegate validation to my
Martin model as well, so that the same validation methods can be
Martin used no matter what the interface?

I'm of the opinion that using form generators puts you through the same
amount of trouble than writing/validating forms by hand, so I just dodge
the HTML::FormHandler thing altogether, but that's just me, YMMV.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Suggestions on how to handle 12 page form

2010-11-16 Thread Eden Cardim
 Eric == Eric Berg eb...@bergbrains.com writes:

Eric What about breaking the form up logically and saving each
Eric section in a session object as they move through the form.
Eric That or incrementally save and maintain a db flag that
Eric indicates doneness.  Frankly, with.a form that long, it'd be
Eric rude to require the user to start from scratch if they
Eric couldn't finish in one session.

Be careful with how you implement it using the session though, if they
give up on the process and come back later, they'll land in the middle
of the previous process and possibly not remember why. Also, if you just
stash the values in the session, you can't do useful things like passing
a URI pointing to a half-filled form for someone else to fill in.

One way to do it and not break HTTP's stateleness that much is to create
a token for each form fill attempt, and resubmit it throughout each
page of the form in order to get to the session-stashed data and prefil
the form from it, then the app figures out what's the next step based on
how much of the form is filled. It's basically the same thing as a
regular form except that you write to the session using the token you
got from the current request. At the final step, you commit the data to
the storage and clear the token/data from the session.

If you want to get sophisticated, you can create a new token for each
step and create a linked list of tokens, in order to create a
bread-crumb-like behaviour.

I've been wanting to write a module with that logic for some time now,
but I always find myself lacking the tuits.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Question about Chained Controller

2010-11-15 Thread Eden Cardim
 Charlie == Charlie Garrison garri...@zeta.org.au writes:

Charlie I've never bothered to find out why, but I've run into
Charlie situations where $c-user_exists returns true and $c-user
Charlie returns false. I just check for defined($c-user) instead
Charlie and that solved it for me.

Probably a mangled session?

Charlie I also agree with other users that auto is a better place
Charlie to do that check.

Chaining is a lot more powerful because it allows you to distribute
responsibilities hierarchically throughout several actions:

package MyApp::Controller::Root;

sub foo :Chained('/') CaptureArgs(0) {
  my ($self, $c) = @_;
  $c-detach unless $c-user_exists;
}

sub do_something :Chained('foo') Args(0) {}

sub bar :Chained('foo') PathPart('') CaptureArgs(0) {
  my($self, $c) = @_;
  $c-detach unless $c-assert_user_roles('bar_level_users');
}

sub do_something_else :Chained('bar') Args(0) {}

It also gives you a lot more flexbility, given you can change the
chaining via config:

Controller::Root
actions
do_something_else
Chained foo
/do_something_else
/actions
/Controller::Root

The above configuration will eliminate the check for the
'bar_level_users' role before running do_something_else.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Forward on to other actions after removing first path segment?

2010-11-15 Thread Eden Cardim
 Dorian == Dorian Taylor (Lists) dorian.taylor.li...@gmail.com writes:

Dorian I'm ambiguous on two things:

Dorian 1) I don't understand why an outside request to /foo will find its 
way to
Dorian /foo/index in MyApp::Foo but a forwarded request will not. I  
understand I'm
Dorian supposed to use 'visit' or 'go' but they don't seem to  do
Dorian it either.

Internal action paths are one thing and URI's are another. Forwarding
and dispatching are two separate things. The dispatch process matches a
URI and happens once per request (unless you invoke -go or
-visit). Forwarding is mostly a shortcut for passing the context on to
other subroutines.

Dorian 2) I'm not entirely sure about the 'right' way to get the rest of 
the
Dorian request-URI path. As a (.*) in the regex function attribute? Some  
other way?

See Chained actions, as mentioned in Ben's previous post.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Question about Chained Controller

2010-11-15 Thread Eden Cardim
 Charlie == Charlie Garrison garri...@zeta.org.au writes:

Charlie I use a :AuthRequired method attribute and check for that
Charlie in auto method. Is there anything inherently wrong with
Charlie that method? I got the technique from someone on this list
Charlie a while back.

When your requirements pile up, auto is going to become a big block of
monolithic code, and your methods are going to have enormous sequences of
attributes. Plus, I find it more logical to have the checking code
closer to where it's required, as opposed to having to maintain the
attributes scattered around the app then locate and edit the related
code in auto.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] error handling (Chain where ajax and non-ajax actions chain off)

2010-11-10 Thread Eden Cardim
 David == David Schmidt davew...@gmx.at writes:

David I tend to put related actions into a controller. E.g.: all actions
David dealing with artists into the Artists.pm controller and so on.
David You advise (as I understood) means having an additional controller for
David every controller where I want to support XHR requests.

David Is there a flaw in how I lay out my controllers?

Personally, I tend to treat controllers just like any other class, I factor them
out when the implementation asks for it. For this case, I think breaking down
into separate classes makes sense so you can leverage the catalyst action flow
to model your application into layers that get more specific as you drill down
the url hierarchy:

/artist   = calls MyApp::Controller::Root::end()
/artist/1 = calls MyApp::Controller::Root::end()
/artist/1/xhr = calls MyApp::Controller::Artist::XHR::end()

also, since $c-controller (without any arguments) returns the controller of the
current dispatched action, you can rely on it to determine the context of the
generic actions, for instance, your error handling:

$c-detach($c-controller-action_for('error_404'));

in Controller::Artist:

sub error_404 :Action {
  my($self, $c) = @_:
  $c-stash-{template} = 'error_404.tt'
}

in Controller::Artist::XHR:

sub error_404 :Action {
  my($self, $c) = @_;
  $self-status_not_found($c,
message = 'Cannot find what you were looking for!'
  );
}

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] error handling (Chain where ajax and non-ajax actionschain off)

2010-11-10 Thread Eden Cardim
 Octavian == Octavian Rasnita orasn...@gmail.com writes:

Octavian Can I find more information about the :Action dispatch type?
Octavian Is it just a replacement for :Private? Or it is something 
different?

Yes, it's effectively a replacement for :Private.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] error handling (Chain where ajax and non-ajax actions chain off)

2010-11-09 Thread Eden Cardim
 David == David Schmidt davew...@gmx.at writes:

David Hello list Both ajax and non-ajax actions chain off the same
David action (base_with_id). If an error occurs (like the resource
David doesn't exist) I detach to '/error404' in my Root Controller.
David I just introduced the ajax stuff and before that 'error404'
David simply rendered an error template. Now I'd like to check if
David it is an xmlhttp request using
David 
http://search.cpan.org/~flora/Catalyst-TraitFor-Request-XMLHttpRequest-0.01/
David and then either render the error template like before OR use
David the status_not_found() helper from
David http://search.cpan.org/~bobtfish/Catalyst-Action-REST-0.87/

David To use status_not_found I need to extend my Root Controller
David from Catalyst::Controller::REST

David That'd mean i have to check the type of request again in my
David roots end method to avoid rendering of the template.


David #Root.pm
David sub render : ActionClass('RenderView') {}
David sub end :Private {
David my ($self, $c) = @_;
David unless ($c-request-is_xhr) {
David $c-forward('render');
David }
David }

David Any comments on that solution are appreciated as are pointers
David to alternatives.

Put the ajax code into a separate controller with an XHR-specific end
action (probably empty, for your case) and chain from there.

-- 
 Eden CardimNeed help with your perl Catalyst or DBIx::Class 
project?
   Software Engineer   http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.Want a managed development or deployment 
platform?
http://blog.edencardim.com http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] myapp_test.pl - running code from the command line

2010-11-03 Thread Eden Cardim
 Jonathon == Jonathon Soong j...@investmentscience.com.au writes:

Jonathon Yes I realise now it might make more sense in the Model,
Jonathon but at the moment it is in the Controller (it is someone
Jonathon else's code, so more difficult for me to refactor).

That's barely an excuse, if you can run the code, you can read the code,
and if you can read the code, you can at least copy it into a model and
drop the usage of the original controller, unless there are legal
constraints in place which forbid that specific practice.

Jonathon There are two questions I have then: 1. How do you call a
Jonathon Model's function from the command line?  2. Is there no
Jonathon way to call controller methods that require
Jonathon authentication?

for the model case, you can

use MyApp;
MyApp-model('Foo')-bar;

for the authentication case, you're very probably relying on the
authentication API inside the controller code, which for most cases
won't work at all in a non-web environment. You'd have to mimic the
entire environment, which is a lot more trouble than just factoring your
code correctly.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to access the real App in prepare_arguments in Catalyst::Model::Adaptor

2010-11-02 Thread Eden Cardim
 Jérôme == Jérôme Etévé jerome.et...@gmail.com writes:

Jérôme The problem is that here $app is not an instance of MyAPP,
Jérôme but just the class name 'MyApp' .

Jérôme How do I access the instance of MyApp from this method?

There is no such thing as the instance of MyApp, all of the intrinsic
state of the application is accessible via the class. The instantes
represent a specific request/response cycle. So if you want to hold onto
an instance, you need to rebuild the entire containing object for each
instance as well. Also, you want to weaken the attribute or it'll leak
memory. 

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Postgresql database with non default -public- schema

2010-10-23 Thread Eden Cardim
 Hetényi == Hetényi Csaba csabiw...@tata.hu writes:

Hetényi  Thank You All for help The db_schema option works:

Hetényi script/pcm_create.pl model DB DBIC::Schema Pcm::Schema
Hetényi create=static components=TimeStamp,EncodedColumn
Hetényi db_schema=pcmbiz 'dbi:Pg:.

Hetényi I hope at some point in the future the schema loader will
Hetényi support multiple db schemas!

Hetényi The automatic schema generation is a very convenient
Hetényi feature -especially in developing phase, when table
Hetényi structures often change. :)

Have a look at DBIx::Class::Schema::Versioned, it's designed
specifically for managing changes in your schema.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Organizing link generators

2010-10-23 Thread Eden Cardim
 Evan == Evan Carroll m...@evancarroll.com writes:

Evan My view often needs to generate complex links for chained
Evan actions.  Does anyone have a better way of doing this then
Evan recreating the link generators in the controller?

$c-stash-{generate_link_edit} = sub {
  my $vin = shift;
  $c-uri_for_action(
  '/auth/company/lot/vin/edit'
  , [
$c-stash-{chained_company_id}
, $c-stash-{chained_lot_id}
, $vin
  ]
  , ()
  );
};

$c-stash-{generate_link_vehicle_add} = sub {
  $c-uri_for_action(
  '/auth/company/lot/inventory/add'
  , [
$c-stash-{chained_company_id}
, $c-stash-{chained_lot_id}
  ]
  , ()
  );
};

You should weaken the $c since that code will leak memory without
it. And yes, that's currently the best way to generate urls (that I can
think of anyway), although you can save some typing by using hash slices
instead.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reuse of controllers

2010-09-20 Thread Eden Cardim
 Pavel == Pavel A Karoukin pa...@yepcorp.com writes:

Pavel I got the basics from t0ms blog
Pavel (http://bobtfish.livejournal.com/#post-bobtfish-264317) An
Pavel example how i use it can be found here
Pavel 
http://wiki.catalystframework.org/wiki/wikicookbook/controllerwithfileupload
Pavel (the interesting part is in the file Resource.pm in the
Pavel attachment
Pavel 
http://wiki.catalystframework.org/wiki/wikicookbook/ControllerWithFileUpload.attachment/100)

An overlooked feature of Catalyst is the ability to modify actions via
the configuration:

package MyRole::Login;
use Moose::Role;

sub login { etc... }

package MyApp::Controller::Login;
use Moose;
with 'MyRole::Login';

__PACKAGE__-config(action = { login = { PathPart = 'sign-in' } } );

package MyOtherApp::Controller::Login;
use Moose;
with 'MyRole::Login';

__PACKAGE__-config(action = { login = { PathPart = 'log-in } } );

note that you can use any key that you would use as an action attribute,
including chainining, and catalyst automatically promotes the method to
an action due to the existence of the config.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Confused: how to handle system-level errors with fallback pages

2010-08-31 Thread Eden Cardim
 Stuart == Stuart Watt sw...@infobal.com writes:

Stuart !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01
Stuart Transitional//EN I have a timing/configuration issue, and
Stuart any pointers would be welcome.

Stuart The problem: how to handle configuration/system errors
Stuart by fallback to an error page.

[snip]

Stuart I could just be missing some documentation: maybe this
Stuart is covered but I haven't been able to find it.

Have you read Catalyst::Manual::Cookbook?

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Modifying Catalyst component load order

2010-07-17 Thread Eden Cardim
 Rob == Rob Hoelz rho...@inoc.com writes:
Rob This way, applications requiring a custom load order can
Rob override determine_component_load_order if they which, and
Rob plugins can override it to provide cool features like
Rob dependency resolution.

Rob Thoughts?

Load order makes the framework be less flexible IMO. Why don't you just
defer the execution of the initialization code until after
setup_components?

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Alternatives to Catalyst ?

2010-04-23 Thread Eden Cardim
On Fri, Apr 23, 2010 at 8:36 AM, Oleg Pronin syber@gmail.com wrote:
 Can you hear the difference between 3mln/s and 24k/s ?
 I do not say that using hashes are good. But i'm sure that developers
 MUST NOT use super-slow frameworks like Moose-shit (which tries to
 emulate perl6 on perl5:   what for???) only to get good maintened
 code. That's the own problems of developers how do they organize
 internals. Why users of Catalyst must suffer from that ?

You have the choice of using another framework, you also have the
choice of using a prior version of Catalyst that doesn't have Moose in
it, and you also have the choice of forking Catalyst and trying to
come up with something better. Good luck.

  Or you wanna
 tell that good maintened code must have a price of 100x slow down
 ??? that an absurdity can't you see it?
 It is possible to get good code (with MIXINS, C3, etc) without such a
 great losses. If you see that something slows down application more
 than 2x why do you use it? kick it off ! Benchmark.pm is your friend!

Your benchmark is flawed by definition, read what the other messages
in the topic say, putting a subroutine call in front of an access to a
hash key is going to raise execution time in any language or
framework.
High-level code is slower than low-level code, get used to it. If
execution slows down by 2x and speeds up development by 4x, it's
probably worth using, this is a very basic topic at software
engineering school, go educate yourself.

 Finnaly, you are creating framework for other people and the main
 thing is how it looks outside, not inside.

Yes, frameworks are supposed to encapsulate complexity. Again, a basic
topic in software engineering school.

 Sorry for my hard post, i'm just a little nervious :(

If you're nervous, see a shrink, trolling won't help you or anyone else.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://blog.edencardim.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Alternatives to DBIx?

2010-04-17 Thread Eden Cardim
On Sat, Apr 17, 2010 at 7:38 PM, Lyle webmas...@cosmicperl.com wrote:
 TBH if I really found the need for the DB to match up to objects, then I'd
 use an Object Database, not a Relational one. The only real argument for
 using a relational one instead, in that situation, is the performance
 benefits. When you want top performance from a relational database, you
 won't be using an ORM anyway.

Actually, DBIx::Class, isn't necessarily an ORM, it's a Data Access
Layer, given that inflation to objects is merely the default behaviour
for it. You can very effortlessly coerce it to build an arbitrary data
structure instead of objects from the data that's fetched from the
database, and all the code up to the point where it inflates to
objects is pretty much what you'd write if you used raw DBI anyway.
Running arbitrary SQL is also very trivial to accomplish. In fact, I
have a few projects where DBIx::Class is used solely as a query
library and they all perform very well and were set up quite quickly,
because I didn't have to spend time designing, building and testing an
access layer.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Managing errors - cut execution flow.

2010-03-18 Thread Eden Cardim
On Thu, Mar 18, 2010 at 3:03 PM, David oldskif...@yahoo.es wrote:
 Hi,


 I am not sure how to manage errors in my Catalyst application. When I detect
 an error, I forward the error to my Error View, but the execution doesn't
 stop.

 When my application was not in Catalyst, I used exit 1; once I had done
 forward to my Error View, but this doesn't work in my Catalyst application.

 Is there a politely way in Catalyst of cutting the execution process when I
 find an error and forward this error to my Error View?

You must be running with fork mode on or via some process manager. We
need further information about how you're running the application
before telling you what to do.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Multiple path for the same action

2010-02-17 Thread Eden Cardim

Julien I want to let users decide how to name their URL.  For
Julien example, by default, the url looks like this: /home/Julien

Julien But people can decide to change /home with anything they
Julien want through an administration panel: /name/Julien
Julien /first-name/Julien /my-website/Julien etc.

The politically correct way to do it would be to create your own
dispatch type. See Catalyst::DispatchType and the built-in dispatch
types (Catalyst::DispatchType::*) for that.

Or, a simpler way to hack it in would be:

sub foo :Chained('/') PathPart('') Args(2) {
my($self, $c, $prefix, $username) = @_;
$c-user-check_prefix($prefix) or $c-detach('/error_404');
}

Also, make sure you store the old prefixes and redirect to the new ones
adequately as to not break the web.

--
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] datetime formatting ...

2010-02-11 Thread Eden Cardim
 Kiffin == Kiffin Gish kiffin.g...@planet.nl writes:

Kiffin I've got a datetime column defined:
__PACKAGE__- add_columns(
Kiffin   ...  last_modified, { data_type = DATETIME,
Kiffin default_value = undef, is_nullable = 1, size = undef, },
Kiffin );

Kiffin For some reason it's being displayed like this:

Kiffin 2010-01-05T20:35:14

Kiffin How can I get that 'T' out of there, replacing it with the
Kiffin usual space?

-last_modified-strftime('%F %T')

See perldoc DateTime for more formatting options.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Perl code attributes in Moose roles

2009-12-21 Thread Eden Cardim
 Bernhard == Bernhard Graf cataly...@augensalat.de writes:

Bernhard Now this becomes:

Bernhard   package MyApp::Base::User; with
Bernhard 'MyApp::Role::Controller::Create';

Bernhard   package MyApp::Base::Page; with
Bernhard 'MyApp::Role::Controller::Create';

Bernhard Where can I add the ACL attributes for edit_new?

Try MooseX::Role::Parameterized

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Multiple deployments sharing code, data, and configuration

2009-12-19 Thread Eden Cardim
 Stuart == Stuart Watt sw...@infobal.com writes:

Stuart In our application, we have two parts - an indexing system
Stuart that builds a set of databases, and a front end based on
Stuart Catalyst. The issue we are facing is that each generated
Stuart deployment runs almost exactly the same code, apart from
Stuart needing different database references, and maybe a little
Stuart additional Template-Toolkit stuff to provide custom logos,
Stuart search configuration data, etc.

Stuart What we ended up doing was using a new environment variable,
Stuart *_SITE_ROOT, which points to an individual site's deployment
Stuart base; this is effectively combined with *_HOME in a search
Stuart path for TT files and for configuration files. On a few rare
Stuart occasions we also add a local deployment lib directory
Stuart @INC. This means we can maintain all the deployments in
Stuart parallel, even when they contain different data.

Stuart The only substantive change we needed was in our subclass of
Stuart Catalyst::Plugin::ConfigLoader, which overrides find_files
Stuart to try the SITE_ROOT directory first, then HOME, for each
Stuart file previously identified - these are generally the config
Stuart file with and without the local suffix. It's the only way we
Stuart found of achieving a directory level separation between the
Stuart local deployment and the shared code base.

Stuart My question: is there an easier/better way to do this? If
Stuart not, I'd be keen to turn this into a patch, and rename stuff
Stuart where I get better suggestions.

I'm confused as to what you're trying to achieve. From what I
understood, what you're doing is equivalent to copying the source tree
around (which is what you call a deployment) and using a different
configuration for each copy. If that's what you're trying to do, I'd say
it's easier/saner to just maintain different configurations for each
deploy type in the repo itself, then use some mechanism, like symlinks,
or CATALYST_CONFIG to switch between them in specific deploys.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Renaming a Catalyst Application

2009-12-16 Thread Eden Cardim
 Tom == Tom Stall t...@es.net writes:
Tom t0m,

Tom Excellent point As this is my first time through this, I
Tom setup a sandbox to work through the process. I will do it
Tom again, with a hopefully greater level of understanding, to
Tom continue development.

A good way to figure out the deps is to load your application then check
%INC, it's pretty trivial to munge the file paths in the keys/values and
produce output suitable for appening into Makefile.PL, of course, it
isn't perfect, as it lists core modules and doesn't figure out what
modules were installed as dependencies, but it's a good start for a
production-worthy Makefile.PL

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Access to DBIx schema from outside Catalyst

2009-12-07 Thread Eden Cardim
 Dermot == Dermot  paik...@googlemail.com writes:

Dermot Hi, I haven't finished reading the book yet so I hope this
Dermot question won't be answered there.

Dermot If I have a Class outside my Cat App, I can have access to
Dermot that via C::Model::Adapator. Is there a method for giving
Dermot that external Class access to Catalyst features,
Dermot particularly the DBix schema and perhaps the debug and log
Dermot methods?

Both DBIx::Class::Schema and Catalyst::Log are regular perl classes
and you can use them anywhere in a perl program just like you'd use any
other class.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How to execute a script

2009-12-04 Thread Eden Cardim
 Ha == Ha, Tuan Trung hatrungt...@gmail.com writes:

Ha Hi Joel, Jose and Tom, Thank you very much for your help.

Ha My fault, I updated to 5.800013, and script run fine.

Ha To Joel: Thank you for your opinion, however, I want to build a
Ha site where user could do some batch work on the server.  So
Ha whenever user click on a button, I execute another process on
Ha server. And when things done, I alert user by mail to check the
Ha result. So I think TCP time out will not be a problem.

In a critical application you'll want to run these processes
assynchronously anyway, not just because of the time-out, but other
things like security and manageability come into play. The typical way
to get this done is to implement a job queue.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] namespace problem

2009-11-25 Thread Eden Cardim
 Andrew == Andrew Rodland and...@cleverdomain.org writes:

Andrew For the sake of sanity, what you need to do is stop
Andrew inheriting from a concrete controller. It really doesn't
Andrew make a lot of sense and there are a lot of ways it could
Andrew break something. As Moritz writes, if you need a controller
Andrew base class, write a controller base class and inherit from
Andrew that.

Or even better, write a role instead.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Handling configuration outside the Catalyst application

2009-08-27 Thread Eden Cardim
On Thu, Aug 27, 2009 at 11:10 PM, Daniel Austindaniel.aus...@gmail.com wrote:
 Hello

 How are you handling configuration for applications or code that run
 outside of Catalyst?

 For example, in my model tests, I have code like this:

    use MyCompany::CatApp;
    my $app = MyCompany::CatApp-new();
    my $model = $app-model('DB::Model')-new({});
    ok( $model-insert );

 etc.

 This way the model tests are talking to the right database as
 configured for that environment. But it seems slow to run and it's not
 the right coupling if I have, say, a cronjob that wants to use the
 same models.

 Are there any patterns anyone can recommend?

Catalyst::Model::DBIC::Schema is just an adaptor for loading a
DBIC::Schema inside a catalyst application. You can use
MyApp::Schema::DB anywhere outside your catalyst application, see
DBIx::Class::Schema for how to connect your schema to a database
backend without the help of C::M::DBIC::Schema.

Besides that, I've just finished writing code for $work that does a
few hacks to use Catalyst::Plugin::ConfigLoader outside the context of
a catalyst application. it's a temporary solution, my opinion is that
there should be an external module for use by any application, not
just cat, and the plugin should just hook that module into Catalyst.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reading Database At Startup

2009-08-20 Thread Eden Cardim
On Wed, Aug 19, 2009 at 3:40 PM, Tomas Doranbobtf...@bobtfish.net wrote:
 before run = sub {
    my $c = shift;
    # Do stuff
 };

 instead - no method redispatch to cock up the arguments on..

Besides that, I wouldn't execute model-related logic anywhere inside
MyApp.pm, since that will take a you a step closer to creating a god
object.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Reading Database At Startup

2009-08-19 Thread Eden Cardim
On Sun, Aug 16, 2009 at 12:09 PM, Ovidpubliustemp-catal...@yahoo.com wrote:
 Hi all,

 This should be painfully obvious, but I don't see it :)

 For a personal project, I want users to be able to click on a letter and get 
 a list of countries starting with that letter.  I can do this:

    my $letters = $c-model('DB')-storage-dbh-selectcol_arrayref(
        'select distinct(substr(name,1,1)) as letter from country order by 
 letter'
    );
    $c-stash-{letters} = $letters;


 But the country list is static and I want this available at startup.  'sub 
 begin' fails because that's called once per request, not once per app.

 What's the recommend way of handling this?  (I'm using DBIx::Class for the 
 model)

package MyApp::Model::DB;

extends 'Catalyst::Model::DBIC::Schema';

has country_letters = (isa = 'ArrayRef', is = 'ro', lazy_build = 1);

sub _build_country_letters {
  my($self) = @_;
  return $self-storage-dbh-selectcol_arrayref(
'select distinct(substr(name,1,1)) as letter from country order by letter'
  );
};

sub BUILD { shift-country_letters } # optionally, force load-time construction

# in a distant controller

$c-stash-{letters} = $c-model('DB')-country_letters;

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Why no extra attributes on Private actions?

2009-08-15 Thread Eden Cardim
On Sat, Aug 15, 2009 at 3:44 PM, Bill Moseleymose...@hank.org wrote:
 Why does Catalyst::Controller not allow additional attributes on Private
 actions?

 Marcus added this code in r5558 back in November of 2006.

   5558 marcus if ( $attrs-{Private}  ( keys %$attrs  1 ) ) {
   5558 marcus $c-log-debug( 'Bad action definition '

 Yes, I asked[1] this same question a year an a half ago and Jonathan was
 nice enough to recommend overriding register_actions if I wanted different
 behavior. But, that didn't answer my question. Unfortunately, there's no
 comments in the code, and the svn log for that change offers no hints.

 Is there a specific reason that Private actions may not have additional
 attributes?

You can achieve the same effect by using the :Action tag instead, as
mst suggested in reply to the same thread:
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg01413.html

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Loading template according to request path

2009-08-13 Thread Eden Cardim
On Tue, Aug 11, 2009 at 8:11 PM, J. Shirleyjshir...@gmail.com wrote:
 The fact that Chained doesn't render template from PathPart, but from the
 action name? :)

 It would be content/html.tt -- not content/as/html.tt

not really:
 # insert jshirley's end action here

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Loading template according to request path

2009-08-13 Thread Eden Cardim
On Wed, Aug 12, 2009 at 9:58 PM, Richard Thomasr...@mac.com wrote:
 Matt,

 I don't know if any of this is useful to you. We do something that sounds a
 bit like what you're after, by tweaking the template include_path with each
 request. It's a classic path setting algorithm, working back from most
 specific to least specific location.

 ie, a template that says PROCESS something.tt that is the end result of
 the URI /myapp/xx/yy/zz will look for something.tt in tt/xx/yy/zz, then
 tt/xx/yy, then tt/xx, or tt/base. This gives us enormous flexibility to
 tweak the output at any node or leaf of the tree.

 You can create empty something.tt files in various places too, that has a
 negating effect.

 MyApp/C/Root.pm contains

 sub auto {
    ...
    $c-stash-{reportfolders} = split('/',$c-req-path);
    ...
 }

 MyApp/V/TT.pm contains

 sub process {
    my ($self, $c) = @_;
    if (my $reportfolders = $c-stash-{reportfolders}) {
        my @orig_path = @{$self-include_path};
        my @this_path = ();
        for my $orig_entry (@orig_path) {
            for (my @folders = @$reportfolders; @folders; pop @folders) {
                push @this_path, join('/', $orig_entry, '..', @folders);
            }
            push @this_path, $orig_entry;
        }
       �...@{$self-include_path} = @this_path;
        #$c-log-debug(sprintf('%s:process: dynamic include_path is %s.',
 __PACKAGE__, join(':',@{$self-include_path})));
        $self-SUPER::process($c);
       �...@{$self-include_path} = @orig_path;
    } else {
        $self-SUPER::process($c);
    }
 }

 Hope that's useful.

The problem with that approach is that your view is now heavily
coupled to your controller semantics. Whenever the semantics change,
you'll run into refactor hell making the template paths match. Also,
if you have arguments in your paths, say, /foo/*/bar/*, you'll be
allowing the addition of per-record customization templates, which
leads to refactor hell once again when your underlying model changes.
Of course, this problem also exists with the traditional
template-by-action-name approach. This is why, theoretically, views
are supposed to be dispatch-agnostic and it's specifically the
controller's job to tell the view how to render data.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Loading template according to request path

2009-08-11 Thread Eden Cardim
On Tue, Aug 11, 2009 at 2:15 PM, Matt Whipplem...@mattwhipple.com wrote:
 Thanks everyone for your input, I'm certainly gathering that there is
 nothing preexisting that does what I'm looking to do.  I'll continue to
 clean up my version and throw it on CPAN if it seems appealing enough.  As a
 quick overview the basic premise is a more direct link from the path to the
 template which would be used for those times when the URI path determines
 presentation after passing through a reusable action handler which tailors
 content (and doesn't necessarily have to worry about the template
 selection).  This is presently done in the auto action so that overriding
 the behavior is natural and any extended logic can be handled when and where
 desired.

That's precisely what chained actions are for:

sub content : Chained('/') CaptureArgs(0) PathPart('content/as') {
my($self, $c) = @_;
$c-stash-{data} = $c-model('Content');
}

# /content/as/html -- renders root/content/as/html.tt
sub html : Chained('content') Args(0) {}

# /content/as/text -- renders root/content/as/text.tt
sub text : Chained('content') Args(0) {}

# /content/as/graph
# doesn't process a template at all as long as View::SVG sets $c-res-body
sub graph : Chained('content') Args(0) {
my($self, $c) = @_;
$c-forward('View::SVG'); # sets res-body, res-content_type, etc.
}

sub whatever : Chained('content') Args(0) { #etc... }

# insert jshirley's end action here

what's missing?
-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] CatalystX::CRUD Storage Error

2009-07-17 Thread Eden Cardim
On Thu, Jul 16, 2009 at 11:36 PM, Peter Karmanpe...@peknet.com wrote:
 There really is no method called 'storage' in DBIx::Class::ResultSet, so at
 least the error message is telling the truth.

- $self-app_class-model( $self-model_name )-storage-sqlt_type
+$self-app_class-model( $self-model_name )-result_source-storage-sqlt_type

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Configuration based on hostname

2009-07-13 Thread Eden Cardim
On Sun, Jul 12, 2009 at 4:29 AM, Mihai Bazonmi...@bazon.net wrote:
 Let me clarify that.  I don't want to run the app more than once.  I
 just want the application to switch configuration file and database
 depending on the hostname that each particular request targets.

I tend to do:

$c-config-{'Plugin::ConfigLoader'}{config_local_suffix} = hostname();

that way, you can set up your app-wide config in myapp.conf and the
host specific config in myapp_hostname.conf

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst-Model-Validated example broken?

2009-06-12 Thread Eden Cardim
On Fri, Jun 12, 2009 at 12:11 PM, Guillaume Chambriatg...@riseup.net wrote:
 wishing to use Moose type constraints to validate my actions input,
 I eventually discovered examples/Catalyst-Model-Validated in the SVN
 repository.

 Does anyone use this code? If not, what are you using instead?

This is an unmaintained oversimplification of how Reaction works. I
put the example up as proof-of-concept code. I believe castaway has
gone a bit further and integrated this into a production app.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] [Announce] Catalyst::Runtime 5.7099_04. IMPORTANT; PLEASE TEST!

2009-03-14 Thread Eden Cardim
On Fri, Mar 13, 2009 at 11:06 PM,  kakim...@tpg.com.au wrote:
 Guys,

  can some one please elaborate further on this or point me to a doc on
 cpan to read about?
 I'm getting a very annoying warning as below and can't figure it out.
 Please help.

 [warn] Used regexp fallback for $c-model('myApp::View::HTML'), which
 found 'myApp::View::HTML=HASH(0x8ef7b50)'. Relying on regexp fallback

You're not using the API correctly, your call should be $c-view('HTML')

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Getting strange warning each time a request is made to myApp

2009-03-14 Thread Eden Cardim
On Sat, Mar 14, 2009 at 10:49 AM,  kakim...@tpg.com.au wrote:
  Any idea or documentation that I could read up to find out on how to
 configure a default view?

$c-view is documented in perldoc Catalyst

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] DBIx makes Catalyst startup painfully slow

2009-02-10 Thread Eden Cardim
On Tue, Feb 10, 2009 at 7:53 AM, Neo [GC] n...@gothic-chat.de wrote:
 Is this normal? Is there _any_ way to speed things up? Does anyone know,
 what DBIx even does the whole time
 (probing the database or something)?

http://www.grokbase.com/topic/2007/08/17/dbix-class-startup-speed/tcXHEoyXXwHvcI5RppiTmCiHg4g

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] DBIx makes Catalyst startup painfully slow

2009-02-10 Thread Eden Cardim
On Tue, Feb 10, 2009 at 2:08 PM, Neo [GC] n...@gothic-chat.de wrote:
 I'm afraid this is all I can get out of it, as I don't have any fancy
 load_classes-stuff or anything in my models, just definitions like table(),
 add_columns(), has_many(), belongs_to() aso.
 If someone knows further tweaking, please be free and post it! :)

 Btw: My main schema constists of 148 tables with a rather complex layout.
 Every foreign key constraint is included.

 I wonder what magic DBIx does in the remaining 4 seconds... In another
 project - written in PHP - I have models with similar functionality created
 by a self-written class, which is executed at every request and takes about
 0.05 seconds on the same machine...

-load_classes is a DBIx::Class::Schema method, check the docs, if you
don't provide any arguments it uses Module::Find to scan the disk in
search of table classes, and given you have 148 tables, that's
probably what's hitting you. Just declare all your loadable classes
manually and you'll probably shave off most of load time.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] check_user_roles [ $user ], @roles ?

2009-02-04 Thread Eden Cardim
On Wed, Feb 4, 2009 at 10:03 AM, Jens Schwarz blacky6...@gmx.de wrote:
 Hi *,

 in my Catalyst app I use $c-check_user_roles(qw/Admin/) to determine, if the 
 currently logged in user is part of the Admin role. Works fine.

 Now I want to check if _another_ (currently _not_ logged in user) is part of 
 the Admin role. I read the documentation of 
 Catalyst::Plugin::Authorization::Roles and found that check_user_roles can 
 optionally take $user as additional parameter. But it does not work as I 
 suspected: With ...

 $c-log-info(  . $c-check_user_roles( some_other_user , qw/Admin/ ));

 ... Catalyst debug just gives me ...

 [debug] Role denied: some_other_user, Admin
 [info] 

 ... where I expected something like ...

 [info]  1

 some_other_user is a username string, in the column username of my user 
 table. myapp/myapp.conf ist setup accordingly (i.e.: user_class myapp::user 
 and id_field username).

 What am I doing wrong?

$c-check_user_roles expects a user object not a username string (how
would it distinguish a user name from a role name?). You can get a
user object via $c-find_user.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] check_user_roles [ $user ], @roles ?

2009-02-04 Thread Eden Cardim
On Wed, Feb 4, 2009 at 10:50 AM, Felix Antonius Wilhelm Ostmann
ostm...@websuche.de wrote:
 From the code:

   if ( Scalar::Util::blessed( $roles[0] )
$roles[0]-isa(Catalyst::Authentication::User) )
   {
   $user = shift @roles;
   }

   $user ||= $c-user;

That particular bit means you need to feed it a blessed scalar,
namely, *an object*.

 i think you can give a string ... you must load the user into a user-object
 fit for the Authorization::Roles

Not if you want it to DTRT.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Plugin dependencies best practices

2008-11-26 Thread Eden Cardim
On Wed, Nov 26, 2008 at 6:45 PM, Eric Wright [EMAIL PROTECTED] wrote:
 I wrote a plugin to add some global functionality to our apps which depends
 on Catalyst::Plugin::Authorization::ACL. The problem is trying to configure
 setup for this plugin. When I override setup or setup_actions the necessary
 engine for ACL has not yet been loaded unless I edit the source for ACL by
 moving its dispatch invocation of $app-NEXT::setup_actions(@_)  to the end
 of its routine. Is there a better way to ensure that dependencies for your
 plugin are in place during setup?

Load your plugin before Auth::ACL and call $app-NEXT::setup_actions
before everything else

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Filtering tables from model scaffolding

2008-11-07 Thread Eden Cardim
On Fri, Nov 7, 2008 at 12:46 PM, Rapid Synergy [EMAIL PROTECTED] wrote:
 We've recently started using Catalyst on one of our projects and so far I am
 very happy with its capabilities. One question I have is related to the
 scaffolding script used for generating a DBIC model. In particular, we have
 thousands of tables in our MySQL database that are auto generated but not
 core to our Catalyst application. Everytime a change is made to the schema,
 the scaffolding creates thousands of unneeded objects that I end up needing
 to delete. Is there a way to filter the tables generated by this script?
 Perhaps a better method exists for this sort of thing?

See DBIx::Class::Schema::Loader, particularly, the make_schema_at()
function and the constraint and exclude options.

-- 
   Eden Cardim   Need help with your Catalyst or DBIx::Class project?
  Code Monkeyhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://edenc.vox.com/http://www.shadowcat.co.uk/servers/

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Model--best practice help

2008-10-05 Thread Eden Cardim
On Sun, Oct 5, 2008 at 2:03 PM, Dr. Jennifer Nussbaum
[EMAIL PROTECTED] wrote:
 So ive got these two model classes, one i call with 
 $c-model('MyAppDB::Book') and the other with $c-model('Book'). The problem
 is, i have some things that are Cat specific and i dont want them in my 
 schema class (becaues i use this in non-Cat apps), but i dont want to
 have to have two separate models that i call by different names at
 different times.

 Whats the way im supposed to be setting these up?

Create a class that's independent of Catalyst and glue it to your app
via Catalyst::Component::InstancePerContext:

package MyApp::Book;

use Moose;

has store = (isa = 'DBIx::Class::ResultSet', is = 'ro', required = 1);

sub foo { shift-store-search(etc...) }
sub bar { ... }
...

package MyApp::Model::Book;

use Moose;
extends 'Catalyst::Model';
with 'Catalyst::Component::InstancePerContext'

use MyApp::Book;

has store_model_name (isa = 'Str', is = 'ro', required = 1);

__PACKAGE__-config(store_model_name = 'MyAppDB::Book');

sub build_per_context_instance {
  my($self, $c) = @_;
  my $store = $c-model($self-store_model_name);
  return MyApp::Book-new(store = $store);
}

# in some distant controller:

$c-model('Book')-foo;
$c-model('Book')-bar; # runs on the same instance as the previous call

-- 
edenc.vox.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] best practices - model or controller ?

2008-10-04 Thread Eden Cardim
On Sat, Oct 4, 2008 at 9:31 AM, Peter Karman [EMAIL PROTECTED] wrote:
 You don't need a real plugin unless you need to override the dispatch process.
 But I often put convenience methods in my MyApp.pm base class. So implement 
 your
 idea #1 and then add:

 package MyApp;

 sub logdb {
my $c = shift;
my $msg = shift or croak msg required;
$c-model('AppDB')-add($msg);
 }

I would set up a config key for the model to make things flexible:

sub log_model {
  my($c) = @_;
  return $c-model($c-config-{log_model});
};

sub logdb {
   my $c = shift;
   my $msg = shift or croak msg required;
   $c-log_model-add($msg);
}

you can do this with controllers too, if you decide you need different
models per controller

-- 
edenc.vox.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Using a post argument in a template

2008-07-24 Thread Eden Cardim
On Fri, Jul 25, 2008 at 1:12 AM, James S. White [EMAIL PROTECTED] wrote:
 I'm passing an argument to the method via a post, and then catch it with
 my ( $self, $c, $myarg ) = @_; shouldn't there be a way to mine it without
 using [% c.req.arguments.0 %] in the template?

 like [% c.controller('Page').methodname.myarg %] or something...

You want [% c.req.body_params.myarg %] if it's a post, [%
c.req.params.myarg %] if you don't care. I would munge the parameters
in the controller and try to formalize an API to interact with the
view though. Also, avoid making your view-side code be
controller-dependent, you'll surely regret it later.

-- 
edenc.vox.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Catalyst site design drafts feedback thread

2008-06-12 Thread Eden Cardim
On Wed, Jun 11, 2008 at 4:54 PM, Matt S Trout [EMAIL PROTECTED] wrote:
 (1) http://www.browsing.co.uk/cat

The color scheme works well, I'm particularly fond of the red and grey
combination, and I'd get rid of the colourful lines above the content
columns. I dislike the ingredients image with the black border,
although it looks cute now, it'll quickly fade into dullness after
looking at it on the course of the next few years, which is why I
think it should be a logo-related image like (2).

 (2) http://agaton.scsys.co.uk/~matthewt/catsite/cat_mock_web_001.png

The major pro for this is the crop circle image which stands out quite
nicely. Inspite of liking the greenish tones, I'd like the color
theming to be redish to match the logo. The content regions would look
better if they were seamless. The white catalyst name over light
green looks pretty dull and the gradient button-like toolbar options
are hard to read.

 (3) http://ion0.com/hx/cat/new-version-2-26.jpg

Too much blur and the main content box puts most of the screen to
waste. I've never liked toolbar options on bold fonts, it's too
aggressive.

 (4) http://ion0.com/hx/cat/catalystSiteDesign3.jpg

Same as (3), and the color theme doesn't work.

 (5) http://agaton.scsys.co.uk/~matthewt/catsite/catsite-Penfold.pdf

The simplistic take works well, although I don't see a reason for the
bordered gradient on the left panel or the grey background on the
right. Bold font option list annoys me, so do the dot list separators.
Version number should be omitted on the download link.

-- 
edenc.vox.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] How do I access 'Catalysed' custom datasets?

2008-03-19 Thread Eden Cardim
On Tue, Mar 18, 2008 at 4:40 PM, Ian Sillitoe [EMAIL PROTECTED] wrote:
  sub get_custom_resultset {
   my ($from, $to) = @_;
my $result_source_name = ResultSetFrom${from}To${to};
   my $result_source;

   # check if we haven't already made this
   if ( grep { $reps_source_name eq $_ } MySchema-sources() ) {
  $result_source = MySchema-resultset($reps_source_name);
   }
snip
 Is this something to do with setting the __PACKAGE__-resultset_class (if
 so, I'll take it to the dbi-class list)?

No, it's got to do with the fact that you seem to be confused about
what ResultSets and ResultSources are, they're very different things.
So, yes take it to the DBIC mailing list.

 Side question - should I expect the
 'catalysed' schema to behave exactly the same as the non-catalysed schema?

There's no such thing as a Catalysed Schema, what
Catalyst::Model::DBIC::Schema does is create accessor methods which
conveniently access the schema for you. Thus, $c-model('Schema::Foo')
actually calls $c-model('Schema')-schema-resultset('Foo') behind
the scenes.

-- 
edenc.vox.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] sending a variable to more than one tt2 template

2008-03-06 Thread Eden Cardim
On Thu, Mar 6, 2008 at 7:36 PM, Emily Heureux [EMAIL PROTECTED] wrote:
 Hi, I have a variable in a Controller method sent to the stash for a
 particular tt file.  What if I want that same variable to be available to
 another tt file?  I assume I cannot set two templates in one method.

yeah you can:

my $vars = { foo = 'bar' };
my $output1 = $c-view('TT')-render($c, 'template1.tt', $vars);
my $output2 = $c-view('TT')-render($c, 'template2.tt', $vars);

-- 
edenc.vox.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/