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 Felix Antonius Wilhelm Ostmann

From the code:

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

   $user ||= $c-user;

   unless ( $user ) {
   Catalyst::Exception-throw(
   No logged in user, and none supplied as argument);
   }

   Catalyst::Exception-throw(User does not support roles)
 unless $user-supports(qw/roles/);



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





Jens Schwarz schrieb:

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?

Jens
  



--
Mit freundlichen Grüßen

Felix Antonius Wilhelm Ostmann
--
Websuche   Search   Technology   GmbH  Co. KG
Martinistraße 3  -  D-49080  Osnabrück  -  Germany
Tel.:   +49 541 40666-0 - Fax:+49 541 40666-22
Email: i...@websuche.de - Website: www.websuche.de
--
AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310
Komplementärin: Websuche   Search   Technology
Verwaltungs GmbH   -  AG Osnabrück  -   HRB 200359
Geschäftsführer:  Diplom Kaufmann Martin Steinkamp
--


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


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

2009-02-04 Thread Jens Schwarz
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?

Jens
-- 
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL 
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a

___
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] check_user_roles [ $user ], @roles ?

2009-02-04 Thread Felix Antonius Wilhelm Ostmann

Eden Cardim schrieb:

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



  

uh, that should be a can't give a string :( damn!


Not if you want it to DTRT.

  



--
Mit freundlichen Grüßen

Felix Antonius Wilhelm Ostmann
--
Websuche   Search   Technology   GmbH  Co. KG
Martinistraße 3  -  D-49080  Osnabrück  -  Germany
Tel.:   +49 541 40666-0 - Fax:+49 541 40666-22
Email: i...@websuche.de - Website: www.websuche.de
--
AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310
Komplementärin: Websuche   Search   Technology
Verwaltungs GmbH   -  AG Osnabrück  -   HRB 200359
Geschäftsführer:  Diplom Kaufmann Martin Steinkamp
--


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


[Catalyst] 2nd call for papers: PostgreSQL Conference East

2009-02-04 Thread Joshua D. Drake
PostgreSQL Conference East is being held at historic Drexel University
on April 3rd through 5th 2009 . This is the second call for papers. The
call for papers ends Feb 23rd and speakers will be notified on the 27th.
You may submit your talk here: http://www.postgresqlconference.org . We
are looking for a wide range of topics. Can you speak on any of the
below topics? What about a different topic? As long as it is centered
around Postgre SQL we want to hear about it.

Hacker topics:
 MVCC
 C Function development
 Writing Procedural Languages
 Creating types
 The planner
 Optimization tips
 Explaining the process model

DBA topics:
 Backing up PostgreSQL
 Understanding and Configuring Autovacuum
 Normalization
 Trigger Happy (how to use triggers ;)
 PITR -- happiness is a shipped transaction log
 User / Groups / Roles
 Security

End User development:
 Web Frameworks with PostgreSQL
   Pylons
   Grails
   Rails
   Cake
   Turbo Gears
   Django

Solutions:

  Do you have a successful case study to present? 
  How did you solve a problem with PostgreSQL?
  Do you have an Open Source product that runs on PostgreSQL?

As always we let the presenters drive the feel of the conference. If you
have an itch, let's figure out how to scratch it (as long as it is with
PostgreSQL). Submit your paper today:
http://www.postgresqlconference.org/
-- 
PostgreSQL - XMPP: jdr...@jabber.postgresql.org
   Consulting, Development, Support, Training
   503-667-4564 - http://www.commandprompt.com/
   The PostgreSQL Company, serving since 1997


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


[Catalyst] template design issue: varibales stand-alone components

2009-02-04 Thread Gene Selkov
This question may be slightly off-topic, as it stems from my use of Mason 
in templates. Maybe I wouldn't have had this problem if I used something 
else. But I intend to re-organize my existing app with Catalyst, in a way 
that would allow me to continue using Mason, and I would like to know 
proficient Catalyst users' opinion on what seems to be fairly general 
design problem.


I looked at TT once; it scared me: I didn't like the way it looked and 
found it more difficult to type than Mason. Let me assume for a moment 
that the question is generic, and I will attempt to present it in abstract 
terms.


Mason templates usually consist of two parts: the template itself and the 
code providing values for its variables. Mason calls that code %init, 
and the variables defined there can be interpolated into the template. 
%init is not the only source of values for template variables, and it is 
entirely optional. Variables can also be defined as template arguments; in 
that case, their values will be supplied by the caller. But I am not 
concerned with arguments. I am concerned with the variables whose values 
are created through hard work, requiring possibly a lot of code and 
interactions with various agents. In a complicated Mason template, that 
usually happens in the %init section, which contains regular perl code.


Additionally, perl can be used across the template in a manner similar to 
c preprocessing directives, providing means for conditional rendering and 
for generation of repetitive patterns (tables, lists, c.).


Even further, instead of inserting a value of a variable into the text, 
a chunk of perl code can be called in-line and replaced with its return 
value.


Alternatively, instead of calling perl code embedded into the template, 
the template can insert another template.


I am conflicted about the best way to use templates even in the 
non-catalyzed Mason, and I would like to resolve this conflict before I 
move it to Catalyst. Here's an example. I can generate the same output 
with these two template variants:


- variant 1 --

Dear Dr. % $surname %, ...

%init
  my $surname = get_ldap_surname($uid);
/%init
~~

- variant 2 --

Dear Dr.  lib/ldap_surname.mason, uid = $User  ...

~

The first variant does all the work within the same template, while the 
second variant delegates that same work to another template, which can be 
reused in other templates. I can't afford more than a trivial example, but 
please imagine that a typical template can have dozens of variables and/or 
sub-templates (known as components in Mason).


If I consistently follow the first variant, I end up with fairly 
efficient, but extremely messy and unreadable code that provides 
everything the template needs in one place. The template itself 
tends to be complicated and incomprehensible.


However, if I delegate bits of work (as well as rendering) to various 
sub-templates, I can achieve highly readable object-oriented structure, 
with simple and easy-to-understand components -- in terms of appearance as 
well as behavior -- at the cost of elevated redundancy and poor 
performance. Many components end up going to the same place for copies of 
the data, not knowing that their siblings have already been there and 
queried the same table row, for example.


I wonder what is considered good design, vis-a-vis this dilemma, and what 
is the Catalyst way of doing this. I understand, roughly, that my first 
variant is more easily adaptable to Catalyst: take all that code in 
%init, put it in one controller action and make it fill places in a 
single template -- right? What should I do if I want to implement the 
second variant, based on sub-templates, and what can I do to avoid 
redundancy in controller actions, if I go that way? Is there a third way I 
am not aware about?


Thanks,

--Gene

___
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] template design issue: varibales stand-alone components

2009-02-04 Thread J. Shirley
On Wed, Feb 4, 2009 at 12:39 PM, Gene Selkov
selko...@observercentral.net wrote:
 This question may be slightly off-topic, as it stems from my use of Mason in
 templates. Maybe I wouldn't have had this problem if I used something else.
 But I intend to re-organize my existing app with Catalyst, in a way that
 would allow me to continue using Mason, and I would like to know proficient
 Catalyst users' opinion on what seems to be fairly general design problem.

 I looked at TT once; it scared me: I didn't like the way it looked and found
 it more difficult to type than Mason. Let me assume for a moment that the
 question is generic, and I will attempt to present it in abstract terms.

 Mason templates usually consist of two parts: the template itself and the
 code providing values for its variables. Mason calls that code %init, and
 the variables defined there can be interpolated into the template. %init
 is not the only source of values for template variables, and it is entirely
 optional. Variables can also be defined as template arguments; in that case,
 their values will be supplied by the caller. But I am not concerned with
 arguments. I am concerned with the variables whose values are created
 through hard work, requiring possibly a lot of code and interactions with
 various agents. In a complicated Mason template, that usually happens in the
 %init section, which contains regular perl code.

 Additionally, perl can be used across the template in a manner similar to c
 preprocessing directives, providing means for conditional rendering and for
 generation of repetitive patterns (tables, lists, c.).

 Even further, instead of inserting a value of a variable into the text, a
 chunk of perl code can be called in-line and replaced with its return value.

 Alternatively, instead of calling perl code embedded into the template, the
 template can insert another template.

 I am conflicted about the best way to use templates even in the
 non-catalyzed Mason, and I would like to resolve this conflict before I move
 it to Catalyst. Here's an example. I can generate the same output with these
 two template variants:

 - variant 1 --

 Dear Dr. % $surname %, ...

 %init
  my $surname = get_ldap_surname($uid);
 /%init
 ~~

 - variant 2 --

 Dear Dr.  lib/ldap_surname.mason, uid = $User  ...

 ~

 The first variant does all the work within the same template, while the
 second variant delegates that same work to another template, which can be
 reused in other templates. I can't afford more than a trivial example, but
 please imagine that a typical template can have dozens of variables and/or
 sub-templates (known as components in Mason).

 If I consistently follow the first variant, I end up with fairly efficient,
 but extremely messy and unreadable code that provides everything the
 template needs in one place. The template itself tends to be complicated and
 incomprehensible.

 However, if I delegate bits of work (as well as rendering) to various
 sub-templates, I can achieve highly readable object-oriented structure, with
 simple and easy-to-understand components -- in terms of appearance as well
 as behavior -- at the cost of elevated redundancy and poor performance. Many
 components end up going to the same place for copies of the data, not
 knowing that their siblings have already been there and queried the same
 table row, for example.

 I wonder what is considered good design, vis-a-vis this dilemma, and what is
 the Catalyst way of doing this. I understand, roughly, that my first variant
 is more easily adaptable to Catalyst: take all that code in %init, put it
 in one controller action and make it fill places in a single template --
 right? What should I do if I want to implement the second variant, based on
 sub-templates, and what can I do to avoid redundancy in controller actions,
 if I go that way? Is there a third way I am not aware about?

 Thanks,

 --Gene


The Catalyst method is quite simple, since it tries to adhere to the
MVC design patterns.

You would not set the variable in your templates, instead in the controller.

sub action_name : Local {
my ( $self, $c ) = @_;
   $c-stash-{surname} = $c-model('LDAP')-get_ldap_surname($id);
}

Then your template gets 'surname' and you can just do:

Hello % $surname %!


You can substitute out your model for an API compatible-version and
your app works.
You can substitute out your template language and your app still works.

-J

___
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] Re: Hello, Deployment of Catalyst apps in a shared web hosting account without shell

2009-02-04 Thread Anton Katsarov
В 11:30 +0200 на 03.10.2008 (пт), Aristotle Pagaltzis написа:
 That’s going to be extraordinarily slow.

Hello this site:

http://www.djmag.bg/

is running on CGI. I think it works fast enough. How do you find it?

Regards.


___
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] Re: Hello, Deployment of Catalyst apps in a shared web hosting account without shell

2009-02-04 Thread J. Shirley
On Wed, Feb 4, 2009 at 12:59 PM, Anton Katsarov t...@katsarov.org wrote:
 В 11:30 +0200 на 03.10.2008 (пт), Aristotle Pagaltzis написа:
 That's going to be extraordinarily slow.

 Hello this site:

 http://www.djmag.bg/

 is running on CGI. I think it works fast enough. How do you find it?

 Regards.


It's hideously slow.  It took 16 seconds to load, and most of that was
the first byte.

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


[Catalyst] [OT] Event-driven middleware?

2009-02-04 Thread Brian Kirkbride

Hello Catalyst-world,

We have a Catalyst app that is fronted by Lighttpd and we're looking 
to switch to NginX instead.  Problem is that we have a number of 
policy based rules that are executed on a per-request basis.  These 
are currently implemented as mod_magnet scripts.


Ideally we'd like to remove these from the frontend webserver 
configuration entirely and move them closer to the application. 
Problem is that we can't have Catalyst run the checks for each request 
(including those for static resources), there are WAY too many 
concurrent requests.


What we really need is an event-driven piece of middleware that can 
intercept each request and decide whether to return an X-Sendfile to 
the frontend or transparently pass the original request through to 
Catalyst.


Perlbal is an obvious choice but seems like overkill for our needs. 
We have no need for a full HTTP proxy and I'd like to preserve the 
speed/flexibility we have with UNIX domain sockets and FastCGI.  Maybe 
something based on PoCo::Proxy::TCP is a better option?


I'd appreciate any musings other Catalyst users might have...

Best,
Brian

___
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] template design issue: varibales stand-alone components

2009-02-04 Thread Gene Selkov

On Wed, 4 Feb 2009, J. Shirley wrote:


The Catalyst method is quite simple, since it tries to adhere to the
MVC design patterns.

You would not set the variable in your templates, instead in the controller.

sub action_name : Local {
   my ( $self, $c ) = @_;
  $c-stash-{surname} = $c-model('LDAP')-get_ldap_surname($id);
}

Then your template gets 'surname' and you can just do:

Hello % $surname %!


I understood as much. The problem I am grappling with is the complexity of 
the web pages I have to present, with many different states and 
transitions. There is no way I can code for that with a single template.


I am used to the idea that I can have a parent template (autohandler in 
Mason), which provides basic navigation and status display for the site; 
autohandler then invokes another template (a master template for that 
particual page's content) which itself uses various odd templates for 
recurrent elements in the page, and the change of state sometimes consists 
of replacing one little component of a sub-component with a component of a 
totally different nature (say, a name is replace with a list of names, or 
a blank display component is replaced with a message resulting from a 
prior action).


Mason seems to be perfect for that; I have built a fairly complicated 
site, and succeeded in making it look simple for the user, but it is an 
ugly mess within. It's enough for me to spend a month without doing 
something with it that I forget how it works. Even worse, I have to pass 
the project on to someone, and before that happens, I want to achieve some 
transparent architecture that a stranger can navigate and understand. 
Having done some minor work in Catalyst on other projects, I have high 
expectations. But I don't have a clear vision of how such recursive 
templating will play out in Catalyst.


If I understood the Catalyst model correctly, I will need some sort 
of nested views. Or am I complicating the problem beyond necessity? How 
else can I achieve mutable views with a hierachy of sub-views?



Thanks,

--Gene

___
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] template design issue: varibales stand-alone components

2009-02-04 Thread Andrew Rodland
On Wednesday 04 February 2009 05:25:41 pm Gene Selkov wrote:
 On Wed, 4 Feb 2009, J. Shirley wrote:
  The Catalyst method is quite simple, since it tries to adhere to the
  MVC design patterns.
 
  You would not set the variable in your templates, instead in the
  controller.
 
  sub action_name : Local {
 my ( $self, $c ) = @_;
$c-stash-{surname} = $c-model('LDAP')-get_ldap_surname($id);
  }
 
  Then your template gets 'surname' and you can just do:
 
  Hello % $surname %!

 I understood as much. The problem I am grappling with is the complexity of
 the web pages I have to present, with many different states and
 transitions. There is no way I can code for that with a single template.

There's no single template implied. By default you're probably going to have 
a template per-action, though that's completely up to you, and TT provides 
tools such as WRAPPER, INCLUDE, and BLOCK to let you organize and reuse your 
code. I'd suggest spending a little time with the Template::Manual as well as 
having a look at some real-life Catalyst apps.

Andrew



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


[Catalyst] Problem using Catalyst::Plugin::I18N and Catalyst::Plugin::PageCache

2009-02-04 Thread Larry Leszczynski
Hi all -

I have two problems that I think are related, I think I may just be
missing something simple...

First, I'm having trouble getting Catalyst::Plugin::I18N to use a
specific language (grabbed from user preferences).  Inside
MyApp::Controller::Root::auto() I am doing this:

$c-log-debug('$c-languages from auto-detect: ' .
dump($c-languages));
$c-log-debug('$c-language: ' . $c-language);

$c-log-debug('Setting language to en...');
$c-languages(['en']);

$c-log-debug('$c-languages: ' . dump($c-languages));
$c-log-debug('$c-language: ' . $c-language);

which results in this:

[debug] $c-languages from auto-detect: [en-us, en, i-default]
   (this looks right based on my browser settings)

[debug] $c-language: i_default
   (why does it pick i-default instead of en-us or en?)

[debug] Setting language to en...
[debug] $c-languages: [en]
   (this looks right)

[debug] $c-language: i_default
   (I expected en here)

Am I doing something wrong?

Next problem has to do with C::P::PageCache - it uses $c-language
internally when generating page cache keys, so my page cache keys always
have i_default in them.  I'm guessing it has to do with the problem
above...

I am using Catalyst 5.8000_04 and the following plugin versions (which I
think are all up-to-date):

Catalyst::Plugin::I18N  0.08
Catalyst::Plugin::PageCache  0.21
Catalyst::Plugin::Unicode  0.8

Any help much appreciated.

Thanks!
Larry

___
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] template design issue: varibales stand-alone components

2009-02-04 Thread Bill Moseley
On Wed, Feb 04, 2009 at 05:25:41PM -0600, Gene Selkov wrote:
 On Wed, 4 Feb 2009, J. Shirley wrote:

 The Catalyst method is quite simple, since it tries to adhere to the
 MVC design patterns.

 You would not set the variable in your templates, instead in the controller.

 sub action_name : Local {
my ( $self, $c ) = @_;
   $c-stash-{surname} = $c-model('LDAP')-get_ldap_surname($id);
 }

 Then your template gets 'surname' and you can just do:

 Hello % $surname %!

 I understood as much. The problem I am grappling with is the complexity 
 of the web pages I have to present, with many different states and  
 transitions. There is no way I can code for that with a single template.

Hopefully, not, but you can come close.

 I am used to the idea that I can have a parent template (autohandler in  
 Mason), which provides basic navigation and status display for the site;  
 autohandler then invokes another template (a master template for that  
 particual page's content) which itself uses various odd templates for  
 recurrent elements in the page, and the change of state sometimes 
 consists of replacing one little component of a sub-component with a 
 component of a totally different nature (say, a name is replace with a 
 list of names, or a blank display component is replaced with a message 
 resulting from a prior action).

Maybe I've had too much TT Koolaid (try some, it's yummy), but my
one-word answer would be WRAPPER.

My templates for each page typically only contain the markup to render
the specific data for that request.  Wrapper templates handle
everything else (menus, layout, columns, banners, everything) is
pulled in from nested wrapper templates.  It's very rare that an
include file is referenced more than once.


Also, this makes me cringe a bit:

Dear Dr.  % $surname %!

I would think you would hide that in an object (or hash if you like as
TT doesn't care), and do:

Dear Dr. [% user.surname %]

so you don't spend all your coding time populating the stash in your
controllers.


-- 
Bill Moseley
mose...@hank.org
Sent from my iMutt


___
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] template design issue: varibales stand-alone components

2009-02-04 Thread Malcolm
On Wednesday 04 February 2009, Gene Selkov wrote:

 I understood as much. The problem I am grappling with is the complexity of
 the web pages I have to present, with many different states and
 transitions. There is no way I can code for that with a single template.

 I am used to the idea that I can have a parent template (autohandler in
 Mason), which provides basic navigation and status display for the site;

Is there any reason for not using Mason? I've been using it with Catalyst 
without any problems. 


___
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] template design issue: varibales stand-alone components

2009-02-04 Thread J. Shirley
On Wed, Feb 4, 2009 at 4:40 PM, Malcolm
mjh-lists-catal...@liminalflux.net wrote:
 On Wednesday 04 February 2009, Gene Selkov wrote:

 I understood as much. The problem I am grappling with is the complexity of
 the web pages I have to present, with many different states and
 transitions. There is no way I can code for that with a single template.

 I am used to the idea that I can have a parent template (autohandler in
 Mason), which provides basic navigation and status display for the site;

 Is there any reason for not using Mason? I've been using it with Catalyst
 without any problems.


I think it is almost like using Emacs as a text editor, versus vi.
Emacs users espouse the amazing features and customization, while vi
users just sit down and write code because they're using an inferior
editor (I use vi.)

You already have a framework, so why use Mason?

Mason's dhandlers and autohandlers are some of its better features,
but they're not really designed to work in conjunction with Catalyst
(you can still use them, but... probably more work than you would get
unless you had specific goals to reach.)

If you simply think of templating languages, I find that Mason's
distinguishing advantages disappear if you -only- use is as a
templating language.

So, it boils down to: Do you know Mason well enough to get the most
out of it, while still designing your Catalyst application concisely
and in an abstract fashion?  If not, probably best to use TT, which is
simpler and offers some really neat features that seem to favor better
Catalyst applications (WRAPPER, most notably).

Hope that helps, and I can avoid any flamewars :)

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


[Catalyst] IO::Pipe and the Catalyst Server

2009-02-04 Thread Bill Moseley
I have a module that uses IO::Pipe and when I run it under the
Catalyst server the pipe doesn't work (see below).

Anyone using IO::Pipe in an application?  Even if not, any idea
what's happening here?  Is the Cat server selecting this handle
somehow?

If I run the application with mod_perl the pipe works perfectly.


It's a very simple module:

$ cat lib/Echo.pm 
package Echo;
use strict;
use warnings;
use IO::Pipe;

sub sayit {
my $pipe = IO::Pipe-new;
$pipe-reader( '/bin/echo', 'hello' );

warn about to read from handle\n;
while ( $pipe ) {
chomp;
warn Got [$_]\n;
}
}

1;


Produces:

$ perl -Ilib -MEcho -le 'Echo::sayit()'
about to read from handle
Got [hello]


Now use it in a Catalyst application:

$ cat lib/Pipe.pm 
package Pipe;
use strict;
use warnings;
use Catalyst::Runtime '5.70';
use Catalyst;
use NEXT;

use Echo;

__PACKAGE__-config( name = 'Pipe' );
__PACKAGE__-setup();


sub default :Private {
my ( $self, $c ) = @_;
Echo::sayit();
$c-response-body( 'echo' );
$c-response-status(200);
$c-response-content_type( 'text/plain' );
}


1;

Running Catalyst from the command line:

$ script/pipe_test.pl /
about to read from handle
Got [hello]   what I would expect
echo

But, using the server:

$ script/pipe_server.pl

In another window:

$ GET http://localhost:3000/
echo

And the server's output:

$ script/pipe_server.pl
You can connect to your server at http://bumby2:3000
about to read from handle
hello

Looks like my pipe is leaking.

Again, if I run the app under mod_perl it works as expected.

I might try IPC::Cmd next.


-- 
Bill Moseley
mose...@hank.org
Sent from my iMutt


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