Re: [Catalyst] Multilanguage application

2006-08-25 Thread Daniel McBrearty
sub lang : Chained('/') CaptureArgs(1) PathPart(''){
  my ($self, $c, $lang) = @_;

  # need to check that $lang is valid and handle that here
  if (valid($lang)) {
} else {
}

}

sub doit : Chained('lang') Args(0) {
my ($self, $c) = @_;
}

this now matches /*/doit, and doit needs to be able to rely on the
language being in the stash.

in fact there are a number of ways the language can be detected. For
me, these are (highest priority first) ... :

1. the uri
2. the session (maybe, i'm thinking about this ... the argument is
that the user shouldn't have to manually set the language twice while
a cookie persists).
3. the browser settings.

so we need to try these in turn ... as soon as we get a valid value,
set it in the session/stash where all downstream actions get it.



On 8/10/06, Matt S Trout <[EMAIL PROTECTED]> wrote:
> Renaud Drousies wrote:
> > On Thu, August 10, 2006 4:39 pm, Matt S Trout said:
> >> sub lang :Chained('/') :CaptureArgs(1) :PathPart('') {
> >>my ($self, $c, $lang) = @_;
> >>
> >> }
> >>
> >> sub foo :Chained('/lang') :Args(0) { # /en/foo etc.
> >>
> >> Chained was designed to support this sort of stuff without the need for
> >> prepare_path hacks, which I've used before but always found a tad ugly.
> >>
> >
> > But then I am not sure to understand how to dispatch actions correctly to
> > different controllers. This looks like all actions must be defined in the
> > same controller.
>
> No, that "sub foo" could be in any controller.
>
> > If I have that 'sub lang' in my Root controller, how can I reach my
> > original 'sub index: Private' in MyApp::C::Foo (or any other action
> > defined there) so that the Foo controller is used when I request /en/foo?
>
> read the Catalyst::DispatchType::Chained POD first. If you still have
> questions, ask 'em then :)
>
> ___
> List: Catalyst@lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>


-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

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


Re: [Catalyst] Multilanguage application

2006-08-25 Thread Daniel McBrearty
sorry, I hit send by accident. please disregard that last mail. still
working out how i want to use this.


-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

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


Re: [Catalyst] Multilanguage application

2006-08-25 Thread A. Pagaltzis
* Daniel McBrearty <[EMAIL PROTECTED]> [2006-08-25 12:10]:
> in fact there are a number of ways the language can be
> detected. For me, these are (highest priority first) ... :
> 
> 1. the uri
> 2. the session (maybe, i'm thinking about this ... the argument
> is that the user shouldn't have to manually set the language
> twice while a cookie persists).
> 3. the browser settings.

Using the session and browser settings are fine; but best is if
you implement them using redirection.

Ie. when someone visits the site, and their session says they
want French, you redirect them to `/fr/$whatever`.

Ideally, only the front page of the site has a language-less URI,
and only there do you redirect. Then whatever other URI they
might bookmark will always have a language code, so on subsequent
pages the problem doesn’t come up at all.

Regards,
-- 
Aristotle Pagaltzis // 

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


Re: [Catalyst] Multilanguage application

2006-08-25 Thread Daniel McBrearty
that's what I'm thinking AP. cheers.

lang Chained('/) looks in the uri. If it succeeds, it sets
stash/session too. If it fails it redirects to /default which checks
session and redirects, or browser then set session and redirect. If
all else fails show a chooser page.



On 8/25/06, A. Pagaltzis <[EMAIL PROTECTED]> wrote:
> * Daniel McBrearty <[EMAIL PROTECTED]> [2006-08-25 12:10]:
> > in fact there are a number of ways the language can be
> > detected. For me, these are (highest priority first) ... :
> >
> > 1. the uri
> > 2. the session (maybe, i'm thinking about this ... the argument
> > is that the user shouldn't have to manually set the language
> > twice while a cookie persists).
> > 3. the browser settings.
>
> Using the session and browser settings are fine; but best is if
> you implement them using redirection.
>
> Ie. when someone visits the site, and their session says they
> want French, you redirect them to `/fr/$whatever`.
>
> Ideally, only the front page of the site has a language-less URI,
> and only there do you redirect. Then whatever other URI they
> might bookmark will always have a language code, so on subsequent
> pages the problem doesn't come up at all.
>
> Regards,
> --
> Aristotle Pagaltzis // 
>
> ___
> List: Catalyst@lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>


-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

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


[Catalyst] [ANNOUNCE] Catalyst::Plugin::ConfigLoader 0.13

2006-08-25 Thread Brian Cassidy
Hello All,

I've just put out a new release of the ConfigLoader plugin. Nothing on 
the surface has changed. Underneath, however, the guts of the config 
file loading has been extracted out into a separate module: Config::Any. 
Hopefully other apps and/or modules will find this new package useful.

Special thanks goes out to Joel Bernstein who did the work on 
ConfigLoader and Config::Any, and Portugal Telecom for sponsoring this work.

Changes file:

0.13  Fri Aug 25 2006
- loading code factored out into Config::Any [EMAIL PROTECTED]
  sponsored by Portugal Telecom

-Brian

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


[Catalyst] Special characters and MySQL issue

2006-08-25 Thread Tobias Kremer
I have my content-type header set to ISO-8859-1 because I'm dealing with
legacy data from a latin1 encoded MySQL database (otherwise data from the
database is not displayed correctly in the browser). There's a form on my
site for searching users by attribute. Now here's the problem:

Doing a search where, for instance, firstname = "Müriam" (note the
German umlaut) the search result contains users with a firstname of
Myriam (note the y instead of the german umlaut). I tried to trace down
the problem but was unable to really figure out what is going wrong. The
data from the form is URL-escaped correctly to "M%FCriam". I tried putting
the following in the controller handling the request:

$c->log->warn( $c->request->param( 'value' ) );

and it spits out:

"[warn] M"
(note that everything after the german umlaut is missing - maybe just a
console problem?)

I access the model like this:

my $rs = $model->search_like( {
  $c->request->param( 'attribute' ) => $c->request->param( 'value' )
} );

The mysql query log shows the search string as:

SELECT [...] WHERE [...] LIKE 'M\xfcriam'

Entering a query with this search string manually into the mysql console
client yields no results - as expected because there is no user with a
firstname of Müriam.

Any ideas on what's going on here? :)

Thanks in advance for any help!

Toby

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


Re: [Catalyst] Special characters and MySQL issue

2006-08-25 Thread Jonathan Rockway
What happens if you 'use encoding "iso-8859-1"' at the top of the script
that accepts this data?

BTW my suggestion is to not send latin-1 to the browser.  Use the
"Encode" module to convert from latin-1 bytes to perl characters, and
then use the C::P::Unicode module to send UTF-8 to the browser.  When
the request comes in, it will be in UTF-8, and C::P::Unicode will decode
the UTF-8 octets to perl characters.  When you're talking to the
database, use "Encode" to encode perl characters to latin-1.  This will
throw an exception when you get invalid characters (like the umlaut).
Since your database can't handle umlauts, I think this is a better
result than returning random rows (or no rows at all).

I can be more detailed if you want, just let me know.

Relevant documentation:

perldoc utf8
perldoc encoding
perldoc Encode
man perluniintro
man perlunicode
man perllocale

Good luck.  And remember that utf8::encode decodes, and utf8::decode
encodes.  That took me a while to understand.

(decode takes UTF-8 octets and encodes them to perl characters)
(encode takes perl characters and decodes them to UTF-8 octets)

Regards,
Jonathan Rockway

Tobias Kremer wrote:
> I have my content-type header set to ISO-8859-1 because I'm dealing with
> legacy data from a latin1 encoded MySQL database (otherwise data from the
> database is not displayed correctly in the browser). There's a form on my
> site for searching users by attribute. Now here's the problem:

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


[Catalyst] Chained actions question

2006-08-25 Thread leonard . a . jaffe

I haven't asked a question in a couple
of days, so I figured you were all going through withdrawal, and I'd hook
you up.

I am thinking about some restful URLs
for a particular bit of a screen I'm working on.

It is a master detail edit/view screen,
and I want to be able to specify the master record via its primary key
(id), or its date (report_date - -MM-DDD).
I only ever want to refer to the detail
records by their PKs (id).
The report has an id, a date, and a
presenter
The issue has issue detail, an id, and
a report_id foreign key.

My screen shows a list of all of the
issues for a particular status report. 

I need to be able to handle URLs like
these:

1) /report/9/        
                     
           -   displays all the master/detail
screen  for master(9) and all of its detail children
2) /report/2006/08/22    
                   -
  likewise for master(2006-08-22) and all of its detail children
3) /report/add/      
                     
       -   inserts a new master record for today's
date 

4) /report/9/add/      
                    -
 inserts an issue for master(9)
5) /report/2006/08/22/add    
    -   inserts an issue for master(2006/08/22)
[ likewise for update of issue data]

6) /report/9/edit/3      
                     
      - displays the screen for master(9) with issue(3)
loaded into the issued add/edit form.
7) /report/2006/08/22/edit/3  
             - displays the screen for
master(2006/08/22) with issue(3) loaded into the issued add/edit form.

Now, I'm not entirely sure I wan tot
use the numeric id columns as part of the URLs since I can be passing the
date around on the URL, or in the session, but that might just be my reaction
to not being bale to write working action declarations.
But I've been unable to work out the
proper method declarations to create this setup as Chained actions, which
is what calls to me whenever I see restful URLs like these.  What
is currently stumping me is trying to use either 1 or 3 args for the report
key.

Has anybody done this kind of setup
before?
Any hints would be greatly appreciated.

Len.

--
Leonard A. Jaffe      (614)213-4283
JP Morgan Chase,   DSS Instrumentation Services
[EMAIL PROTECTED]





This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law.  If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED.  Although this transmission and
any attachments are believed to be free of any virus or other
defect that might affect any computer system into which it is
received and opened, it is the responsibility of the recipient to
ensure that it is virus free and no responsibility is accepted by
JPMorgan Chase & Co., its subsidiaries and affiliates, as
applicable, for any loss or damage arising in any way from its use.
If you received this transmission in error, please immediately
contact the sender and destroy the material in its entirety,
whether in electronic or hard copy format. Thank you.

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


Re: [Catalyst] Chained actions question

2006-08-25 Thread Matt S Trout
[EMAIL PROTECTED] wrote:
> 
> I haven't asked a question in a couple of days, so I figured you were 
> all going through withdrawal, and I'd hook you up.
> 
> I am thinking about some restful URLs for a particular bit of a screen 
> I'm working on.
> 
> It is a master detail edit/view screen, and I want to be able to specify 
> the master record via its primary key (id), or its date (report_date - 
> -MM-DDD).
> I only ever want to refer to the detail records by their PKs (id).
> The report has an id, a date, and a presenter
> The issue has issue detail, an id, and a report_id foreign key.
> 
> My screen shows a list of all of the issues for a particular status report.
> 
> I need to be able to handle URLs like these:
> 
> 1) /report/9/  -   displays all 
> the master/detail screen  for master(9) and all of its detail children
> 2) /report/2006/08/22-   likewise for 
> master(2006-08-22) and all of its detail children
> 3) /report/add/-   inserts a new 
> master record for today's date
> 
> 4) /report/9/add/   -  inserts an issue for 
> master(9)
> 5) /report/2006/08/22/add -   inserts an issue for 
> master(2006/08/22)
> [ likewise for update of issue data]
> 
> 6) /report/9/edit/3   - displays the 
> screen for master(9) with issue(3) loaded into the issued add/edit form.
> 7) /report/2006/08/22/edit/3- displays the screen for 
> master(2006/08/22) with issue(3) loaded into the issued add/edit form.
> 
> Now, I'm not entirely sure I wan tot use the numeric id columns as part 
> of the URLs since I can be passing the date around on the URL, or in the 
> session, but that might just be my reaction to not being bale to write 
> working action declarations.
> But I've been unable to work out the proper method declarations to 
> create this setup as Chained actions, which is what calls to me whenever 
> I see restful URLs like these.  What is currently stumping me is trying 
> to use either 1 or 3 args for the report key.
> 
> Has anybody done this kind of setup before?
> Any hints would be greatly appreciated.

sub base :Chained('/') :PathPart('report') :CaptureArgs(0)

sub master_by_id :Chained('base') :PathPart('') :CaptureArgs(1)

sub master_by_date :Chained('base') :PathPart('') :CaptureArgs(3)

then you'd set up a controller base-class for your actual actions with their 
own 'base' action, and declare one as chained off of master_by_id and the 
other off of master_by_date

That might seem like unnecessary duplication, but it's -really- handy in terms 
of doing uri_for($action, ...) because it allows you to explicitly specify 
which path you're following.

-- 
  Matt S Trout   Offering custom development, consultancy and support
   Technical Directorcontracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

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


Re: [Catalyst] Chained actions question

2006-08-25 Thread Len Jaffe
On 8/25/06, Matt S Trout <[EMAIL PROTECTED]
> wrote: > > 
[EMAIL PROTECTED] wrote:> > [ question about chained ]>  [Matt's answer - see previous in thread]Thanks Matt.I'm home now, but I'll try it out on Monday.Len. -- 
LenJaffe [AT] JaffeSystems [dot] com
___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Amazon EC2

2006-08-25 Thread Mark Blythe
Some interesting food for thought for the weekend.  How many of you
saw the launch of Amazon's EC2 (Elastic Compute Cloud) service beta on
Wednesday?

http://www.amazon.com/b/ref=sc_fe_c_1_3435361_1/103-7963297-2261459?ie=UTF8&node=201590011&no=3435361&me=A36L942TSJ2AJA

A machine image with a ready-to-go Catalyst environment would be cool.
 A plugin (or other form of tool) that would self-replicate, spawning
additional virtual servers as traffic increased would be even cooler.
Kind of like the Apache multi-process model, but applied to
create-on-demand virtual Catalyst servers.

No, I don't have an EC2 account.  I did get the invite, but the thing
filled up in like 2 hours.

Anyway, something to think about.  I bet somebody is already working
on a Rails one.

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