Re: [Catalyst] [RFC] Loading Plugins from lib/MyApp/Plugins

2007-12-18 Thread Bogdan Lucaciu
On Tuesday 18 December 2007 04:39:36 Christopher Laco wrote:
 I know I've been down this thread before. When writing a framework that
 generates customized Catalyst apps, it would be a whole lot easier
 (well, more proper) to add plugins in lib/MyApp/Plugins, just like we do
 with controllers/models/view, than it is to molest the MyApp.pm 'use
 Catalyst' line to include custom plugins.

 I'm assuming that it's just a matter of tweaking the Module::Pluggable
 search paths at the appropriate time when Cat is starting up.

 Is this a planned feature for 5.8? Could it be?
 Yes, I'll volunteer to put some tuits on it if need be.

I would rather have this in the config.
Even some Views/Models can be just in the config, as the files on disk are 
sometimes mostly empty.

-- 
Bogdan Lucaciu
http://www.wiz.ro

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


Re: [Catalyst] [RFC] Loading Plugins from lib/MyApp/Plugins

2007-12-18 Thread John Napiorkowski

--- Bogdan Lucaciu [EMAIL PROTECTED] wrote:

 On Tuesday 18 December 2007 04:39:36 Christopher
 Laco wrote:
  I know I've been down this thread before. When
 writing a framework that
  generates customized Catalyst apps, it would be a
 whole lot easier
  (well, more proper) to add plugins in
 lib/MyApp/Plugins, just like we do
  with controllers/models/view, than it is to molest
 the MyApp.pm 'use
  Catalyst' line to include custom plugins.
 
  I'm assuming that it's just a matter of tweaking
 the Module::Pluggable
  search paths at the appropriate time when Cat is
 starting up.
 
  Is this a planned feature for 5.8? Could it be?
  Yes, I'll volunteer to put some tuits on it if
 need be.
 
 I would rather have this in the config.
 Even some Views/Models can be just in the config, as
 the files on disk are 
 sometimes mostly empty.

I'd also vote for the config, since I've had several
use cases of using one set of plugins in dev and a
subset of that on prod.  I'm sure I'm not the only
one.

-john

 
 -- 
 Bogdan Lucaciu
 http://www.wiz.ro
 
 ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo:

http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive:

http://www.mail-archive.com/[EMAIL PROTECTED]/
 Dev site: http://dev.catalyst.perl.org/
 



  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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


Re: [Catalyst] [RFC] Loading Plugins from lib/MyApp/Plugins

2007-12-18 Thread Christopher H. Laco
Ash Berlin wrote:
 
 On 18 Dec 2007, at 02:39, Christopher Laco wrote:
 
 I know I've been down this thread before. When writing a framework that
 generates customized Catalyst apps, it would be a whole lot easier
 (well, more proper) to add plugins in lib/MyApp/Plugins, just like we do
 with controllers/models/view, than it is to molest the MyApp.pm 'use
 Catalyst' line to include custom plugins.
 
 I don't quite see the point of this. Why not just add methods to
 MyApp.pm? (I'm guessing there might actually be a sane reason for you
 not wanting to do it this way, but I can't grok what it is)
 
 Ash

Mainly, because there is no automated, programmatic way to add plug ins
to a generated Cat app without editing code.

The scenario is:

mango.pl MyApp

which in turn, uses $helper-mk_app, just like catalyst.pl MyApp does.
After that point, my scripts can add models, view and controllers just
dandy, but there's no way to add plugins unless I literally open
MyApp.pm in the script, and do:

s/
   ConfigLoader StaticSimple
/
   ConfigLoader
   MyApp::Plugin::Foo
   OtherApp::Plugin::Bar
   Static::Simple
/

That's nasty at best and will fail eventually when the defaults change.
I can add models/view/controllers by dropping files in the correct
directories, why not plugins?

Aside from Mango, anyone who generates Cat based apps automatically when
accounts are created (like virtual hosts...MediaTemple) may want or need
to also install default plugins. Just dorpping them in a Plugins
directory just like M/V/C makes more sens than trying to automatically
edit code in my book.

-=Chris





signature.asc
Description: OpenPGP digital signature
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Re: retrieving multiple values from forms

2007-12-18 Thread Peter Karman


On 12/17/2007 05:27 PM, A. Pagaltzis wrote:

 The sane thing is to have *TWO* methods, one that *always*
 returns a scalar, and one that *always* returns a list. (Or
 rather, an arrayref, because if it’s just a list, it is easy to
 improperly treat it like a scalar, whereas if it’s an arrayref
 it’s impossible to forget to unpack the array when you meant to
 do that.)
 

I did something similar in my last $job, where I just had a begin() block in my 
Root.pm
that reset params-{foo} to always return an arrayref.

-- 
Peter Karman  .  [EMAIL PROTECTED]  .  http://peknet.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/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Re: retrieving multiple values from forms

2007-12-18 Thread jagdish eashwar
On Dec 18, 2007 6:56 AM, Andrew Rodland [EMAIL PROTECTED] wrote:

 On Monday 17 December 2007 05:27:46 pm A. Pagaltzis wrote:
  The *sane* thing is neither.
 
  The sane thing is to have *TWO* methods, one that *always*
  returns a scalar, and one that *always* returns a list. (Or
  rather, an arrayref, because if it's just a list, it is easy to
  improperly treat it like a scalar, whereas if it's an arrayref
  it's impossible to forget to unpack the array when you meant to
  do that.)
 
  Then you can say what you mean, you can say it *easily* either
  way, and the result is always completely determined by what the
  code says and not at all by what the data looks like. Sanity.

 Yeah, I can agree with this. I realized the same thing myself... after
 posting
 my original message of course. Teach me to wait a bit longer before
 hitting
 send in the future. Anyway yeah, what I really want is param_list
 or param_aref, without any of the actual CGI compat of param -- param
 just comes closer to my goal than params. Not sure what the ideal behavior
 for the only one version would be, but params is at least practical. If
 you
 see ARRAY(0xbadfad) where you expected useful data it's not that hard to
 trace back and see what you did wrong.

 Andrew
 Hi,

 I am unable to keep up with the discussion.

 When I use @role_id = $c-req-param(role_id) as Andrew suggested, I am
 getting an error in Catalyst  saying Can't use string (4) as a HASH ref
 while strict refs in use. 4 is one of the values that the code is
 fetching.

 So I changed the code to read @role_id = $c-req-params(role_id) as
 Kevin suggested and put [EMAIL PROTECTED] in the stash. Now there was no 
 error, but
 I got ARRAY(0x987e5e0) in the template instead of the role_id values.

 So I further changed the code to $role_id = $c-req-params(role_id) and
 put $values in the stash. Now I could access in the template the multiple
 role_ids that the code was picking up. I realised then that I pick up single
 values also in the same way.

 So is the way for picking up multiple values the same as for picking up
 single values?

 Moving on from here, I want to pick up the corresponding role descriptions
 for each role_id from a database table and show role descriptions rather
 than the role_id's in the template.

 When I am picking up only a single role_id, I am able to achieve this by
 using
 my @role_desc = $c-model('myleavedb::role_types')-find($role_id)
 and putting [EMAIL PROTECTED] in the stash.

 I am unable to figure out how the coding is to be done when I retrieve
 multiple role_id's.
 I tried looping over the multiple role_ids in the arrayref ($role_id), but
 couldn't get the code right.


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


Re: [Catalyst] [RFC] Loading Plugins from lib/MyApp/Plugins

2007-12-18 Thread John Napiorkowski

--- Christopher H. Laco [EMAIL PROTECTED] wrote:

 John Napiorkowski wrote:
  --- Bogdan Lucaciu [EMAIL PROTECTED] wrote:
  
  On Tuesday 18 December 2007 04:39:36 Christopher
  Laco wrote:
  I know I've been down this thread before. When
  writing a framework that
  generates customized Catalyst apps, it would be
 a
  whole lot easier
  (well, more proper) to add plugins in
  lib/MyApp/Plugins, just like we do
  with controllers/models/view, than it is to
 molest
  the MyApp.pm 'use
  Catalyst' line to include custom plugins.
 
  I'm assuming that it's just a matter of tweaking
  the Module::Pluggable
  search paths at the appropriate time when Cat is
  starting up.
  Is this a planned feature for 5.8? Could it be?
  Yes, I'll volunteer to put some tuits on it if
  need be.
 
  I would rather have this in the config.
  Even some Views/Models can be just in the config,
 as
  the files on disk are 
  sometimes mostly empty.
  
  I'd also vote for the config, since I've had
 several
  use cases of using one set of plugins in dev and a
  subset of that on prod.  I'm sure I'm not the only
  one.
  
  -john
 
 
 And what if I want some models/views/controllers for
 dev vs. live?
 I wouldn't want to rely on config to do that either.
 But I get the point.

I think you're totally on with this, you probably
don't want to mutate the whole system to much,
probably bad practice to do so, but the plugins do
seem to be a special case, since I've seen lot of
places using the stacktrace plugin on dev and forget
to remove it for production...


 
 I don't think they have to be mutually exclusive
 either. If you don't
 want to use the Plugins directory, don't put
 anything in it, and use
 config insteadand vice versa.
 
 -=Chris
 
That's true.  Myself I've been taking this approach in
lots of my code, mostly using the
MooseX::Object::Pluggable so that I can break out
functionality into discrete bits, and really loving
the approach.  I created a couple of base classes for
quickly building dispatchers and command chains from a
plugin namespace.

I like both approaches, see advantages and the lack of
mutual exclusiveness, but I'm wondering now about the
syntax and the potential for confusion with new users.

--john

  ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo:

http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive:

http://www.mail-archive.com/[EMAIL PROTECTED]/
 Dev site: http://dev.catalyst.perl.org/
 



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


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


Re: [Catalyst] [RFC] Loading Plugins from lib/MyApp/Plugins

2007-12-18 Thread Christopher H. Laco
Christopher Laco wrote:
 I know I've been down this thread before. When writing a framework that
 generates customized Catalyst apps, it would be a whole lot easier
 (well, more proper) to add plugins in lib/MyApp/Plugins, just like we do
 with controllers/models/view, than it is to molest the MyApp.pm 'use
 Catalyst' line to include custom plugins.
 
 I'm assuming that it's just a matter of tweaking the Module::Pluggable
 search paths at the appropriate time when Cat is starting up.
 
 Is this a planned feature for 5.8? Could it be?
 Yes, I'll volunteer to put some tuits on it if need be.
 
 -=Chris

Just to keep the conversation rolling, let's put aside the Plugins
directory for the moment.

If you wanted to load plugins from config, what would you like to see?
What would you need?

1. Load all plugins specifically from config, ignoring what's in
MyApp.pm when specified?

  plugins:
- ConfigLoader
- Session
- Session::State::Cookie
- Session::Store::File
- +MyApp::Plugin::Frobnisicate
- Static::Simple


2. Load plugins from a location?

  plugins:
path: __path_to(lib, MyApp, Plugins)


3. Prepend/Append plugins to be loaded around MyApp.pm?

plugins:
  prepend:
- Debug
  append:
- Static::Simple
- +MyApp::Plugin::Foo

-=Chris



signature.asc
Description: OpenPGP digital signature
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] upload breakage

2007-12-18 Thread Joe Landman

Hi folks:

  I am trying to set up a simple multiple upload form.  Using jQuery 
multi class for the interface portion.  The form looks like this:


   form action=/upload class=multi enctype=multipart/form-data 
input type=file class=multi /
input type=submit name=upload value=upload file(s) /
input type=hidden name=destination_path value=% 
$destination_path % /

input type=hidden name=form_submit value=yes /
   /form

and the receiving action is basically a cut and paste from the cookbook

  my $path  = $c-req-param('destination_path');
  $c-log-debug('* path = '.$path);
  if ( $c-request-parameters-{form_submit} eq 'yes' ) {
  $c-log-debug('* uploading! ');
  for my $field ( $c-request-upload  ) {
  $c-log-debug('*** field '.$field);
  my $upload   = $c-request-upload($field);
  my $filename = $upload-filename;
  my $target   = File::Spec-catfile($path,$filename);
  $c-log-debug('*** name  '.$filename);
  $c-log-debug('*** target'.$target);

  unless ( $upload-link_to($target) || 
$upload-copy_to($target) ) {

  die( Failed to copy '$filename' to '$target': $! );
  }
  }
  }

Now when I try to upload a file, in this case a simple perl script named 
wireless.pl ... fairly small as a simple test case, the controller reports


[debug] Query Parameters are:
.-+--.
| Parameter   | Value 
 |

+-+--+
| destination_path| /tmp 
 |
| file| wireless.pl 
 |
| file1   | 
 |
| form_submit | yes 
 |
| upload  | upload file(s) 
 |

'-+--'
[debug] GET request for upload from 127.0.0.1
[debug] Path is upload
[debug] * path = /tmp
[debug] * uploading!
[debug] * dump = $VAR1 = 'upload file(s)';

but it never seems to hit the innards of the loop.  So it doesn't 
actually go through extracting the file name and so on.


Any clues?  Is it obvious what I am doing wrong here?

And if there is a better way to do multi file upload using Catalyst and 
jQuery, please, by all means, I am all ears ...


Thanks!

--
Joe Landman
[EMAIL PROTECTED]

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


[Catalyst] Re: retrieving multiple values from forms

2007-12-18 Thread kevin montuori
 je == jagdish eashwar [EMAIL PROTECTED] writes:

  So I changed the code to read @role_id =
  $c-req-params(role_id) as Kevin suggested and put [EMAIL PROTECTED] in
  the stash. Now there was no error, but I got ARRAY(0x987e5e0) in
  the template instead of the role_id values.

i dare say that's not what i'd suggested.  i wrote:

my @titles = ref $c-request-params-{title} 
   ? @{ $c-request-params-{title} } : ($c-request-params-{title} || ''); 

the @{ ... } bit  was not extraneous.  

(on the other hand, if there's a more idiomatic way of doing this i'd
love to hear about it.)  

but this is not a catalyst issue, 'perldoc perlref' for more on
references.


cheers.
k.

-- 
kevin montuori

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


Re: [Catalyst] Re: retrieving multiple values from forms

2007-12-18 Thread Matt S Trout
On Mon, Dec 17, 2007 at 07:26:53PM -0600, Andrew Rodland wrote:
 On Monday 17 December 2007 05:27:46 pm A. Pagaltzis wrote:
  The *sane* thing is neither.
 
  The sane thing is to have *TWO* methods, one that *always*
  returns a scalar, and one that *always* returns a list. (Or
  rather, an arrayref, because if it’s just a list, it is easy to
  improperly treat it like a scalar, whereas if it’s an arrayref
  it’s impossible to forget to unpack the array when you meant to
  do that.)
 
  Then you can say what you mean, you can say it *easily* either
  way, and the result is always completely determined by what the
  code says and not at all by what the data looks like. Sanity.
 
 Yeah, I can agree with this. I realized the same thing myself... after 
 posting 
 my original message of course. Teach me to wait a bit longer before hitting 
 send in the future. Anyway yeah, what I really want is param_list 
 or param_aref, without any of the actual CGI compat of param -- param 
 just comes closer to my goal than params. Not sure what the ideal behavior 
 for the only one version would be, but params is at least practical. If you 
 see ARRAY(0xbadfad) where you expected useful data it's not that hard to 
 trace back and see what you did wrong.

Exactly my point. Except you should ideally use query_params and body_params
explicitly in most cases; it's fairly rare that you don't know which is which.

I'd love to see a patch for say 'query_value', 'query_array', plus body_* and
any_param_* methods (names made up on the spot and neither final nor necessarily
even any good :)

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.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/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] DBIC ResultSet - what columns in it?

2007-12-18 Thread Silvio Almeida

I was looking for a way to get column names from a ResultSet.

If I have a table with columns id, to, from, subject which is mapped 
into Email then if I do


$c-model('Email')-{_source_handle}{schema}{source_registrations}{Reuniao}{_ordered_columns}

then I get [ qw/ id to from subject / ] indeed, but it would be nice to 
have a simpler method to get there.



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


[Catalyst] Re: [RFC] Loading Plugins from lib/MyApp/Plugins

2007-12-18 Thread Fayland Lam

Christopher H. Laco wrote:

Christopher Laco wrote:

I know I've been down this thread before. When writing a framework that
generates customized Catalyst apps, it would be a whole lot easier
(well, more proper) to add plugins in lib/MyApp/Plugins, just like we do
with controllers/models/view, than it is to molest the MyApp.pm 'use
Catalyst' line to include custom plugins.

I'm assuming that it's just a matter of tweaking the Module::Pluggable
search paths at the appropriate time when Cat is starting up.

Is this a planned feature for 5.8? Could it be?
Yes, I'll volunteer to put some tuits on it if need be.

-=Chris


Just to keep the conversation rolling, let's put aside the Plugins
directory for the moment.

If you wanted to load plugins from config, what would you like to see?
What would you need?

1. Load all plugins specifically from config, ignoring what's in
MyApp.pm when specified?

  plugins:
- ConfigLoader
- Session
- Session::State::Cookie
- Session::Store::File
- +MyApp::Plugin::Frobnisicate
- Static::Simple




++;
but ConfigLoader need to load config?

generally we can do something like:

# MyApp.pm
use Catalyst qw/ConfigLoader/;

__PACKAGE__-setup(); # this would load __PACKAGE__-config;
if ( __PACKAGE__-config-{plugins} ) {
   __PACKAGE__-setup_plugins( __PACKAGE__-config-{plugins} );
}

that's it I think.




2. Load plugins from a location?

  plugins:
path: __path_to(lib, MyApp, Plugins)


3. Prepend/Append plugins to be loaded around MyApp.pm?

plugins:
  prepend:
- Debug
  append:
- Static::Simple
- +MyApp::Plugin::Foo

-=Chris





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



--
Fayland Lam // http://www.fayland.org/

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