Re: [Catalyst] Changing format of date field

2014-01-07 Thread Ian Docherty
I suggested that you extend DBIx::Class::InflateColumn to create
DBIx::Class::InflateColumn::MyDateTime to give you the result you need.

However, I would state that although I have shown you how to do this,
personally I would keep decisions about how to display data where it
belongs, in the view, and stay with the object.dmy() which makes it quite
clear your intent, rather than doing it 'at a distance' in the model.

Kind Regards
icydee


On 7 January 2014 09:32, Adam Witney awit...@sgul.ac.uk wrote:


 Thanks for your reply Ian,

 So you mean copy DBIx::Class::InflateColumn::DateTime under my lib/
 directory and build into the DateTime formatter option?


 On 6. 1. 2014 15:42, Ian Docherty wrote:

 DateTime has an option to change the default stringification with a
 'formatter' option.

 Also DBIx::Class::InflateColumn::DateTime is a convenience method, you
 could choose to use the DBIx::Class::InflateColumn yourself and combine
 this with the DateTime formatter option to give you the result you are
 looking for.

 icydee


 On 6 January 2014 15:18, Adam Witney awit...@sgul.ac.uk
 mailto:awit...@sgul.ac.uk wrote:

 Hi,

 I have a date field in a DBIx::Class Result class using
 InflateColumn::DateTime. When I pass this through a Catalyst/TT
 application, the date is presented in -MM-DD format.

 I can modify this to DD/MM/ in my TT template with
 object.dmy('/'), but I would prefer to change the default DateTime
 stringification, however I am not quite sure where or how to do this?

 Any ideas greatly appreciated.

 Thanks

 Adam

 _
 List: Catalyst@lists.scsys.co.uk mailto:Catalyst@lists.scsys.co.uk
 Listinfo:
 http://lists.scsys.co.uk/cgi-__bin/mailman/listinfo/catalyst
 http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive:
 http://www.mail-archive.com/__catalyst@lists.scsys.co.uk/

 http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.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/
 catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.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/
 catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.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/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Changing format of date field

2014-01-06 Thread Ian Docherty
DateTime has an option to change the default stringification with a
'formatter' option.

Also DBIx::Class::InflateColumn::DateTime is a convenience method, you
could choose to use the DBIx::Class::InflateColumn yourself and combine
this with the DateTime formatter option to give you the result you are
looking for.

icydee


On 6 January 2014 15:18, Adam Witney awit...@sgul.ac.uk wrote:

 Hi,

 I have a date field in a DBIx::Class Result class using
 InflateColumn::DateTime. When I pass this through a Catalyst/TT
 application, the date is presented in -MM-DD format.

 I can modify this to DD/MM/ in my TT template with object.dmy('/'),
 but I would prefer to change the default DateTime stringification, however
 I am not quite sure where or how to do this?

 Any ideas greatly appreciated.

 Thanks

 Adam

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

___
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 Catalyst context object from script

2012-10-31 Thread Ian Docherty
On 31 October 2012 10:41, Anthony Gladdish
anthony.gladd...@newcastle.ac.uk wrote:
 Hi,

 Got a lot of code in a controller that should be moved out and into an 
 external script (that's called by a cronjob) which calls stuff from the Model 
 and then emails it.

 The script can access the model fine and re-use a Template::Toolkit template 
 already written fine (I'm using MIME::Lite::TT). However, in the template 
 itself there's a lot of calls to the Catalyst context object, in the form of:

 [% Catalyst.uri_for( ... ) %]

 ... which aren't displaying anything. I don't really want to hard code the 
 URIs, so is there a way to get access to the Catalyst context object of a 
 running app, in a separate external script?

I can understand the reluctance to hard-code URIs, however i would be
reluctant to suggest that you bring in the whole of Catalyst just to
satisfy this one requirement.

What is the template? I presume it is an email, and that you are
putting links to locations within your Catalyst application into the
email?

What form of uri_for are you using? If it is just to capture the
applications root then could you replace it with your own convenience
routine that just implemented that aspect of what uri_for is doing
without bringing in the whole of Catalyst?

Regards
Ian

___
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 is $c undefined?

2012-10-30 Thread Ian Docherty
On 30 October 2012 11:09, Craig Chant cr...@homeloanpartnership.com wrote:
 Thanks Ian,

 The hierarchy is something that I am finding mind-blowing at the moment,
 $self-jqgrid-render($self, , you are calling methods jqgrid-render on 
 $self, passing in $self, I'm sure it makes sense to you :-)

 One thing I would like clarification with if possible.

 Where do I put code that requires the use of more than one model?

 Do I create a separate model that acts as an interface between the other 
 models?

 You see I have two SQL servers in opposite ends of the country and so I have 
 a model built on Model::DBI that can access one server and another Model that 
 can access the other, but I have functionality that needs data from both , do 
 some calculations and output accordingly.

 I assume this does not go in the controller, but I create an interface model 
 with the required methods and functionality that the controller uses?

Craig. Yes, try to keep it out of the Controller.

My opinion is, that if you have business logic that uses data from two
SQL servers (each of which has it's own model) then this would be a
model in it's own right. First think of this business logic outside of
Catalyst, it might have accessors for each of the SQL instance
objects. Create a BusinessModel for this logic. You might find that
this then becomes the only Model that you need to access from
Catalyst, and the SQL server objects are not directly called from
Catalyst, but are subsumed by BusinessModel.

Then use Catalyst::Model::Adaptor with your BusinessModel giving
Catalyst access to all of it's methods.

Kind Regards
Ian

___
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::HA

2012-08-26 Thread Ian Docherty
On 26 August 2012 09:49, Theo Bot theo@proxy.nl wrote:

 Tom

 You are right. It's an DBIC issue. Do you happen to know where I csn
 address this issue?

 Regards

 Theo


 Theo
The approach I always take in these circumstances is to use CPAN search to
find the
module in question and then look to see where I go for support. It usually
works for me.

http://search.cpan.org/~frew/DBIx-Class-0.08200/lib/DBIx/Class.pm

Kind Regards
Ian
___
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::RabbitMQ

2012-08-18 Thread Ian Docherty
On 18 August 2012 20:36, Gianni Ceccarelli dak...@thenautilus.net wrote:
 I'm using a combination of CatalystX::ComponentsFromConfig and 
 Net::Stomp::Producer. The first (t0m's code, even if released by me) allows 
 you to avoid writing essentially empty model classes (and to apply roles via 
 configuration file). The second is the one that actually deals with 
 messaging. As the name implies it's using STOMP, but there's actually rather 
 little in the interface that depends on it. It works like this:

 - a send method takes a destination (queue name, whatever), a hashref of 
 headers (including a 'type', that I imagine being similar to RabbitMQ's 
 routing key), and a byte string for the message payload
 - if the message payload is a reference, it is passed through a serialiser
 - a transform_and_send method allows you to pass some internal 
 representation, and having the logic to transform it into a message in a 
 specialised class

 We've been using something very similar at $work for a coulpe of years now, 
 and it seems to be simple and flexible enough.
 --
   dakkar - mobilis in mobile


It's 'normal' not to create Catalyst specific models, but to create
your model outside of Catalyst (so you can use it in things like cron
jobs for example) in which case you just use a thin adaptor class. See
Catalyst::Model::Adaptor

If you do it that way you don't need to publish a cpan module at all.

- icydee

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

2012-04-11 Thread Ian Docherty
On 11 April 2012 09:38, Johannes Kilian jo.kil...@gmx.de wrote:
 Hi there,

 I've got a probably simple question, but cannot figure it out yet.

 I'm using Template::Toolkit and Catalyst - and I'm having problems with 
 absolute URLs ...

 Within my Template I have the following absolute URL:
 a href=http:\\myserver1\test.htmlblabla/a


Just in case this is not a typo, try

a href=http://myserver1/test.html;blabla/a

Instead.

 After processing the Template (via Catalyst::View::TT) my previously correct 
 URL is modified to:
 http:\\mycatalystserver\myserver1\test.html

 (where mycatalystserver is the server where catalyst runs ...)

 Who modifies my URL - Catalyst or Template::Toolkit? (I think it's catalyst - 
 since within my template I do only have plain text in the eyes of 
 Template::Toolkit ...)

 And most important
 How can I suppress this modification to be able to use the original URL?

 Thanks in advance
 Johannes
 --
 Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
 belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

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

___
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::View::JSON jqGrid

2010-06-28 Thread Ian Docherty

I suspect you have not configured your View::JSON correctly.

Ensure you have it configured in your equivalent to MyApp.pm as follows.

__PACKAGE__-config-{'View::JSON'} = {
expose_stash= 'json_data',
};

and it should then do what you want.

Regards
Ian


On 28/06/2010 05:17, Xiao Yafeng wrote:

Hi,
  I'm using Catalyst::View::JSON and
Catalyst::TraitFor::Controller::jQuery::jqGrid to retrieve JSON data
to front page. Below is the code concerned (copy much partially from
Catalyst::TraitFor::Controller::jQuery::jqGrid example):

package UW::Controller::Site;
use utf8;
use Moose;
use namespace::autoclean;
BEGIN {extends 'Catalyst::Controller'; }
with 'Catalyst::TraitFor::Controller::jQuery::jqGrid';

sub json : Local{
my ($self, $c) = @_;
my $merchant_rs = $c-model('WindyDB::Merchant')-search({});
$merchant_rs = $self-jqgrid_page($c, $merchant_rs);
my $row = 0;
my @row_data;
my $i = 0;
while (my $mer = $merchant_rs-next){
$i ++;
my $mer_id = $mer-mer_id;
$c-log-debug($mer_id);
my $single_row = {
'id'   =  $i,
'cell' =  [
'id' =  $mer-mer_id,
'name' =  $mer-mer_name,
],
};
push @row_data, $single_row;

}

$c-log-debug( @row_data);
$c-stash-{json_data}-{rows} = \...@row_data;
$c-stash-{current_view}  = 'JSON';
}


But I found the format is a little weird :
{current_view:JSON,json_data:{page:0,records:8,rows:[{id:1,
cell:[test1,6]},{id:2, cell[test2,7]}],total:1}}
Actually, as jqGrid doument, data format should be:
{ total: xxx, page: yyy, records: zzz, rows : [ {id:1,
cell:[cell11, cell12, cell13]}, {id:2, cell:[cell21,
cell22, cell23]}, ... ] }

Does That means current_view and json_data pairs are surplus? So
is there a way to remove current_view and json_data before server
ship?
or does I use the modules incorrectly? I'm new to Catalyst and jqGrid,
please help.
Any replies are really appreciated!

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





___
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::View::JSON jqGrid

2010-06-28 Thread Ian Docherty
If you think that either the code or documentation of 
Catalyst::TraitFor::Controller::jQuery::jqGrid is wrong then drop me an 
email please.


Regards
Ian

On 28/06/2010 05:17, Xiao Yafeng wrote:

Hi,
  I'm using Catalyst::View::JSON and
Catalyst::TraitFor::Controller::jQuery::jqGrid to retrieve JSON data
to front page. Below is the code concerned (copy much partially from
Catalyst::TraitFor::Controller::jQuery::jqGrid example):

package UW::Controller::Site;
use utf8;
use Moose;
use namespace::autoclean;
BEGIN {extends 'Catalyst::Controller'; }
with 'Catalyst::TraitFor::Controller::jQuery::jqGrid';

sub json : Local{
my ($self, $c) = @_;
my $merchant_rs = $c-model('WindyDB::Merchant')-search({});
$merchant_rs = $self-jqgrid_page($c, $merchant_rs);
my $row = 0;
my @row_data;
my $i = 0;
while (my $mer = $merchant_rs-next){
$i ++;
my $mer_id = $mer-mer_id;
$c-log-debug($mer_id);
my $single_row = {
'id'   =  $i,
'cell' =  [
'id' =  $mer-mer_id,
'name' =  $mer-mer_name,
],
};
push @row_data, $single_row;

}

$c-log-debug( @row_data);
$c-stash-{json_data}-{rows} = \...@row_data;
$c-stash-{current_view}  = 'JSON';
}


But I found the format is a little weird :
{current_view:JSON,json_data:{page:0,records:8,rows:[{id:1,
cell:[test1,6]},{id:2, cell[test2,7]}],total:1}}
Actually, as jqGrid doument, data format should be:
{ total: xxx, page: yyy, records: zzz, rows : [ {id:1,
cell:[cell11, cell12, cell13]}, {id:2, cell:[cell21,
cell22, cell23]}, ... ] }

Does That means current_view and json_data pairs are surplus? So
is there a way to remove current_view and json_data before server
ship?
or does I use the modules incorrectly? I'm new to Catalyst and jqGrid,
please help.
Any replies are really appreciated!

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





___
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] Format last modified date field ...

2009-12-28 Thread Ian Docherty

Kiffin
It looks to me like when you print the date field it is doing 
stringification of the DateTime object.


Try doing

user.last_modified.ymd

In your template and see what you get. If you get something like 
'2009-12-28' then you can output any of the formats that DateTime supports.


Regards
Ian

Kiffin Gish wrote:

I'm using a last_modified field which is being displayed like this
2009-12-28T18:25:28 (what's that 'T' doing in there?) but want to use
a different format, how?

In the list.tt2 file for listing users, I have:

[% WHILE (user = users_rs.next) -%]
  [% FOREACH col IN users_rs.result_source.columns -%]
[% user.$col %]/td
  [% END %]
[% END -%]

In the schema Users:

__PACKAGE__-load_components(InflateColumn::DateTime, TimeStamp,
Core);
__PACKAGE__-table(users);
__PACKAGE__-add_columns(
  ...
  last_modified,
  {
data_type = DATETIME,
default_value = undef,
is_nullable = 1,
size = undef,
  },
);

Thanks alot in advance.





___
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] Organize tests in sub-directories

2009-11-26 Thread Ian Docherty

Tomas Doran wrote:


On 24 Nov 2009, at 20:31, Octavian Râşniţă wrote:
I would like to structure the t directory as lib/MyApp is structured. 
Is it possible to be able to configure the app somehow so `make test` 
checks all the test files even if they are in sub-directories?


Yes, you just say something like:

tests 't/*.t', 't/*/*.t', 't/*/*/*.t'; # However many levels deep you need


Isn't it safer and simpler to use

tests recursive

in Makefile.PL rather than risk missing a level if at some point you add 
another level and you forget to update the Makefile.PL?




in Makefile.PL

Cheers
t0m


Regards
Ian

___
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] Advice on namespace for a potential Catalyst cpan module

2009-07-15 Thread Ian Docherty
WRT my previous post I now have a module for a Moose Role useable in a 
Catalyst Controller to manage breadcrumb trail navigation.


The module automatically builds up a breadcrumb trail as you navigate 
through the web application and can then be used to produce an ordered 
list of the pages you have visited. This aids navigation since you can 
click on any of the previous pages visited. A bit like a browsers history.


This might be something worth of putting on cpan. If so what would be a 
suitable namespace?


CatalystX::BreadCrumb

springs to mind or perhaps

CatalystX::Controller::BreadCrumb

since it is a role to be used in Controllers.

Or are there any other 'standards' for Moose Role modules?

Regards
Ian

___
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] Just a hint on using Roles

2009-07-14 Thread Ian Docherty

Hi
I am looking at creating a generic Breadcrumb module to use with 
Catalyst. The basic idea being that some controllers will 'reset' a 
breadcrumb path back to the start (for example when clicking on a main 
menu) and some controllers will append to the existing breadcrumb.


e.g.
Main menu item linking to /users will display a list of all users (reset 
breadcrumb)


Clicking on a link on that page to go to /user/123 will append the new 
URI to the breadcrumb, /user/123/edit appends again. etc.


I would then be able to create a BreadCrumb Role that could be used with 
some of my controllers to maintain a breadcrumb structure on the stash 
that could then be used in my templates?


ISTM that this is an ideal application of Roles? I would welcome 
comments if this is a sensible approach and I can research the details 
further myself.


Regards
Ian


___
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] offset the URI of an existing Cat App

2009-07-07 Thread Ian Docherty

Hi
I have always written Cat Apps so they start at the '/' URI but now I 
have been asked to 'offset' one so that:-


/becomes /foo
/userbecomes /foo/user
/admin/1 becames /foo/admin/1

etc.

I saw the __PACKAGE__-config-{namespace} that could be used but this 
would still require an entry in each of my controllers. e.g.


package MyApp::Controller::Root;
...
__PACKAGE__-config-{namespace} = 'foo';
...


package MyApp::Controller::Admin;
...
__PACKAGE__-config-{namespace} = 'foo/admin';
...


etc. which strikes me as very unsatisfactory.

I think I must have missed something. Is there a single point where I 
can make a change that will replicate through all my controllers? Can 
anyone put me right?


Regards
Ian

___
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] offset the URI of an existing Cat App

2009-07-07 Thread Ian Docherty

Octavian Râsnita wrote:

From: Ian Docherty catal...@iandocherty.com

Hi
I have always written Cat Apps so they start at the '/' URI but now I 
have been asked to 'offset' one so that:-


/becomes /foo
/userbecomes /foo/user
/admin/1 becames /foo/admin/1


Hi,

If using mod_perl, instead of:

Location /
SetHandler perl-script
PerlResponseHandler MyApp
/Location

use:

Location /foo
SetHandler perl-script
PerlResponseHandler MyApp
/Location

And the application should work at the new location.


Thanks, that did the trick. I was looking for something more complicated!


But if in the templates you use urls like:

a href=/user.../a

you need to change them to urls like:
a href=[% c.uri_for('/user') %].../a

If you use fastcgi, instead of:

FastCgiExternalServer /tmp/myapp.fcgi -socket /tmp/myapp.socket
Alias / /tmp/myapp.fcgi/

you could use:

FastCgiExternalServer /tmp/myapp.fcgi -socket /tmp/myapp.socket
Alias /foo /tmp/myapp.fcgi/

Note! I know these only from theory, because I always needed to use apps 
only at /.


HTH.

Octavian





etc.

I saw the __PACKAGE__-config-{namespace} that could be used but this 
would still require an entry in each of my controllers. e.g.


package MyApp::Controller::Root;
...
__PACKAGE__-config-{namespace} = 'foo';
...


package MyApp::Controller::Admin;
...
__PACKAGE__-config-{namespace} = 'foo/admin';
...


etc. which strikes me as very unsatisfactory.

I think I must have missed something. Is there a single point where I 
can make a change that will replicate through all my controllers? Can 
anyone put me right?


Regards
Ian

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



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





___
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 connection info to an custom model/external lib

2009-04-11 Thread Ian Docherty

Eric Wright wrote:

I have what I hope is not a dumb question. I'm trying to follow best
practices here and am writing a piece of business logic that I feel
should be Catalyst agnostic and therefore am creating a custom model.
(However, at the moment Catalyst is the primary consumer of this lib.)
I'd like to use my DBIC::Schema goodness for DB access and happily
have abstracted that via Catalyst::Model::DBIC::Schema. The thing is I
realized that if I connect to this schema outside of the scope of
Catalyst via DBIx::Class::Schema-connect I have to pass in the
connection info separately which really bugs me because I've already
defined it via a configuration file for the Catalyst app (using
Config::General). I suppose I could just pass that info into the model
but that seems messy and redundant to me. If I subclass
Catalyst::Model well then I'm tightly coupled with Catalyst again. I'd
like to just be able to glue the model to Catalyst and do a:

$c-model('MyCustomModel')-foo(...)

and it just work.

It seems to me there should be a simple way for this schema to know
its connection info based on context and I figured there's like a
slick Catalyst ninja kind of method for doing this that my brain is
just not grasping at the moment. How do you do this sort of thing? Is
the magic in the Catalyst glue?

Thanks in advance for any advice/thoughts/comments...

-Eric
  
I use an external yaml file to hold connection information. In that way 
I can easily have different

configurations for different environments, dev, staging, live.

# production database access
DBIxProd:
   dsn:'DBI:mysql:host=localhost;database=myapp_prod'
   username:   fred
   password:   secret
...

In my Catalyst model I do something like.

package myapp::Model::DBIxProd;

use strict;
use base 'Catalyst::Model::DBIC::Schema';

__PACKAGE__-config(
   schema_class= 'myapp::Storage',
   connect_info = [
   myapp-config-{DBIxProd}{dsn},
   myapp-config-{DBIxProd}{username},
   myapp-config-{DBIxProd}{password},
   { 'mysql_enable_utf8' = 1 },
   { on_connect_do =[ 'set names utf8' ] },
   ]);

1;

And in my external app (usually in a 'tools' subdirectory) I do 
something like.


use FindBin;
use lib $FindBin::Bin/../lib;

use myapp::Storage;
use YAML;

my $config = YAML::LoadFile($FindBin::Bin/../myapp.yml);

my $schema = myapp::Storage-connect(
   $config-{DBIxProd}{dsn},
   $config-{DBIxProd}{username},
   $config-{DBIxProd}{password},
   { mysql_enable_utf8  = 1 },
   { on_connect_do = [ 'set names utf8' ] },
);


Regards
Ian

___
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: Including a submenu

2009-04-07 Thread Ian Docherty

Matthew Topper wrote:

On Tue, 7 Apr 2009 21:20:26 +1000
Kieren Diment kie...@diment.org wrote:

  
Argh.  That begs the question as to why you are doing development  
under apache, and not just using the built in test server for the  
purpose that it's intended.


If the answer is that the dev server is single request and you've
got lots of ajax, use the HTTP::Prefork engine:

$ cpan Catalyst:Engine::HTTP::Prefork
$ CATALYST_ENGINE=HTTP::Preform script/myapp_server.pl

I can't think of a good reason to use apache for development.
Sanity checking immediately before deployment, yes, but  actual  
development ... it's really better not to unless there's a very very  
good reason (and my manager requires that we smear ourselves in the  
blood of chickens fed exclusively on virgin slugs when we come into  
work every day isn't a very good reason).



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



Well, my post might raise a question, but it sure isn't a logical
fallacy ;)

I'm curious as to whether there's a technical reason not to develop
under apache, or whether it's just bad practice (and why, if it's the
latter). The machine isn't doing anything else, so it's not as if I'm
disrupting other services with all of the restarting.

To me, restarting apache isn't any more work than restarting the test
server with the added benefit of not having to re-test everything to
make sure it still works under apache when I'm done.  However, if
there's a technical reason why it's a bad idea, I'd be very interested
to know it so that I can stop doing it this way.

Thanks,
Matt
  

Using Apache (already running)

You edit a controller
You switch to browser, spend minutes wondering why your change has no 
effect.

Slap head, switch to console
Restart apache
Switch to browser
Test changes

Using test server (already running)

You edit a controller.
Test server automatically detects the change to the controller.and 
restarts (HUPs) test server

Switch to browser
Test changes

even if you don't forget to restart apache it is saving you time, time 
after time.


Regards
Ian
___
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] testing catalyst app - need context

2009-03-02 Thread Ian Docherty

Kate Yoak wrote:

Hi there,


Here is a newbie question:

I like to test my functionality in bits and pieces as I write it.  How
do I go about getting myself the context object in a test script?

For example, one of the tests catalyst installs is t/model_App.t where
it loads the model.  I'd love to then be able to use the model the same
way a controller would:

my $acc = $c-model('Account')-find(1);

Instead, I am doing 


my $model = MyApp::Model::App-new();
my $acc = $model-recordset('Account')-find(1);

In addition to being less than ideal because I am doing something
different that I expect real application code to do, it presents
configuration problems.  Like, turns out, in order for config to take
effect, I have to run __PACKAGE__-setup; after configuring it - which
won't be necessary, I think, in a real app.

Is the practice of unit tests that break up the layers of catalyst
frowned upon? Or what should I do to make it work right?
  
Best practice is to keep your model separate from Catalyst so that you 
can (for example) create batch scripts or cron

jobs that work on the model without having to load the whole of Catalyst

Your model then would be in something like MyApp::Storage and accessed 
by your tests as so...


my $schema = MyApp::Storage-connect(
   'DBI:mysql:host=localhost;database=my_database',
   'username',
   'password',
   { 'mysql_enable_utf8' = 1 },
   {on_connect_do =[ 'set names utf8' ] }
);
my $acc = $schema-resultset('Account')-find(1);

You would be testing your database layer separately from Catalyst.

Your Catalyst Model would then look something like.

package MyApp::Model:MyDB;

use strict;
use base 'Catalyst::Model::DBIC::Schema';

my $dsn = 'dbi:mysql:port=3406:host=localhost';

__PACKAGE__-config(
   schema_class = 'MyApp::Storage',
   connect_info = [
   $dsn.';dbname=my_database',
   'username',
   'password',
   { 'mysql_enable_utf8' = 1 },
   { on_connect_do =[ 'set names utf8' ] },
   ],
);


Regards
Ian

___
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] Authorization header and fastcgi

2009-02-20 Thread Ian Docherty

Mark.
I was not looking at $c-engine-env, but now that I am, there is no 
Authorization or HTTP_AUTHORIZATION there either.


I have decided to side-step this issue and create an 'Authentication' 
header rather than an 'Authorization' header and to hell with the 
'standard'.


(Besides the 'standard' is badly named anyway!)

Thanks everyone for help with this matter.

Regards
Ian

Mark Trostler wrote:

are you looking in  $c-engine-env?
Mark

Ian Docherty wrote:

Matt Pitts wrote:

-Original Message-
From: Ian Docherty [mailto:catal...@iandocherty.com]
Sent: Tuesday, February 17, 2009 9:51 AM
To: The elegant MVC web framework
Subject: [Catalyst] Authorization header and fastcgi

Hi
The 'Authorization' header is not being passed to my Catalyst
application.

I have read the archives about fastcgi not passing the header and I
have
tried the following in my Apache 2 config

RewriteCond %{HTTP:Authorization} ^(.+)
RewriteRule ^(.*)$ $1 [E=HTTP_AUTHORIZATION:%1,PT]

FastCgiIpcDir /var/fcgi_ipc
FastCgiServer
/var/www/www.pharmaventures.com/script/pharmaventures_fastcgi.pl
-pass-header HTTP_AUTHORIZATION -pass-header Authorization -processes


5
 

-initial-env PV_DEBUG=0 -initial-env PV_HBX=1 -initial-env
PV_DSN=dbi:mysql:port=3306:host=127.0.0.1

I don't see a header and I don't see any environment variable in my


Cat
 

app.

I have tried variations on the -pass-header Authorization -pass-header
AUTHORIZATION but neither works.

Any other ideas?



The following is working for me in Apache 2.2 with 
FastCgiExternalServer

and Cat 5.8014

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)
RewriteRule ^(.*)$ $1 [E=HTTP_AUTHORIZATION:%1,PT]

Without any special declarations on my FastCgiExternalServer directive.

Could it be something specific to running the FastCGI internal vs.
external?

Did you forget to turn RewriteEngine On?

v/r
-matt pitts

__

'RewriteEngine On' was there, it makes no difference.

I too am on Cat 5.7014

I will experiment with changing between FastCGI static and dynamic 
mode to see if that makes any difference.


Regards
Ian


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




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




___
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] Authorization header and fastcgi

2009-02-19 Thread Ian Docherty

Matt Pitts wrote:

-Original Message-
From: Ian Docherty [mailto:catal...@iandocherty.com]
Sent: Tuesday, February 17, 2009 9:51 AM
To: The elegant MVC web framework
Subject: [Catalyst] Authorization header and fastcgi

Hi
The 'Authorization' header is not being passed to my Catalyst
application.

I have read the archives about fastcgi not passing the header and I
have
tried the following in my Apache 2 config

RewriteCond %{HTTP:Authorization} ^(.+)
RewriteRule ^(.*)$ $1 [E=HTTP_AUTHORIZATION:%1,PT]

FastCgiIpcDir /var/fcgi_ipc
FastCgiServer
/var/www/www.pharmaventures.com/script/pharmaventures_fastcgi.pl
-pass-header HTTP_AUTHORIZATION -pass-header Authorization -processes


5
  

-initial-env PV_DEBUG=0 -initial-env PV_HBX=1 -initial-env
PV_DSN=dbi:mysql:port=3306:host=127.0.0.1

I don't see a header and I don't see any environment variable in my


Cat
  

app.

I have tried variations on the -pass-header Authorization -pass-header
AUTHORIZATION but neither works.

Any other ideas?



The following is working for me in Apache 2.2 with FastCgiExternalServer
and Cat 5.8014

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)
RewriteRule ^(.*)$ $1 [E=HTTP_AUTHORIZATION:%1,PT]

Without any special declarations on my FastCgiExternalServer directive.

Could it be something specific to running the FastCGI internal vs.
external?

Did you forget to turn RewriteEngine On?

v/r
-matt pitts

__

'RewriteEngine On' was there, it makes no difference.

I too am on Cat 5.7014

I will experiment with changing between FastCGI static and dynamic mode 
to see if that makes any difference.


Regards
Ian


___
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] Testing RESTful web services

2008-10-06 Thread Ian Docherty

 David Wright wrote:

Ian Docherty wrote:
  

Moritz Onken wrote:


Am 05.10.2008 um 10:47 schrieb Ian Docherty:

  

Hi
I am writing a simple test to test a POST method in a web service
but my controller does not see any content in the POSTed request.

In the controller both the $c-request-body and
$c-request-content_length are undefined.

Any ideas?

-- test.t ---
use strict;
use warnings;

use Catalyst::Test 'MyApp';
use HTTP::Request;

my $req = HTTP::Request-new(
  'POST',
  '/foo',
  [
  Content_Type = 'text/plain'
  ],
  hello world,
  );


It's Content-type = ...
  

Yup, typo on my part, but it does not change the problem. There is
still no content in the request when it gets to the controller.


It's not a typo, the constructor accepts underscores as well as dashes
so that you can build requests without having to quote the hash keys.

  

Just a slight modification to my original statement. In the controller
the request body is undef, but the request length is 0 (not undef)



IIRC you have to manually add content-length yourself, HTTP::Request
doesn't build it for you.
  

Excellent. That was exactly the problem. Thanks.

Regards,
David


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

  


___
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] Testing RESTful web services

2008-10-05 Thread Ian Docherty

Hi
I am writing a simple test to test a POST method in a web service but my 
controller does not see any content in the POSTed request.


In the controller both the $c-request-body and 
$c-request-content_length are undefined.


Any ideas?

-- test.t ---
use strict;
use warnings;

use Catalyst::Test 'MyApp';
use HTTP::Request;

my $req = HTTP::Request-new(
   'POST',
   '/foo',
   [
   Content_Type = 'text/plain'
   ],
   hello world,
   );

my $response = request($req);

-



___
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] Testing RESTful web services

2008-10-05 Thread Ian Docherty

Moritz Onken wrote:


Am 05.10.2008 um 10:47 schrieb Ian Docherty:


Hi
I am writing a simple test to test a POST method in a web service but 
my controller does not see any content in the POSTed request.


In the controller both the $c-request-body and 
$c-request-content_length are undefined.


Any ideas?

-- test.t ---
use strict;
use warnings;

use Catalyst::Test 'MyApp';
use HTTP::Request;

my $req = HTTP::Request-new(
  'POST',
  '/foo',
  [
  Content_Type = 'text/plain'
  ],
  hello world,
  );


It's Content-type = ...
Yup, typo on my part, but it does not change the problem. There is still 
no content in the request when it gets to the controller.


Just a slight modification to my original statement. In the controller 
the request body is undef, but the request length is 0 (not undef)


Regards
Ian


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

2008-07-11 Thread Ian Docherty

Thomas Klausner wrote:

... do I need to hang myself?

I'm (finally) playing around with chained, and like it very much.
But now I have some sort of design question, on which I'd like to 
collect some feedback:


Say, you want to edit things. The general way of editing is the same for 
most things, only the thingies you want to edit differ (i.e. their 
fields).


(slightly OT, but some background: We want to use HTML::FormFu 
for actual form generation, but do not want to use the config-file 
aproach, but something like a 'registry' where each field and it's 
definition is stored (basically we have several different things using 
similar fields...))



What to you think is better:
A) lots of chain

package Thing:
use base 'Generic';
sub base : Chained('/') PathPart('thing') CaptureArgs(0) {}
sub setup_fields : Chained('item') CaptureArgs(0) {
# define a list of fields and store them in stash
}

package Generic;
sub item : Chained('base') PathPart('') CaptureArgs(1) {
# load thing and store in stash
}
sub show_form : Chained('setup_fields') Args(0) {
# take field list, make form, etc 
}


I'd end up with an URL like 
  /thing/123/setup_fields/show_form
  
I really don't think you should expose your implementation in your URI. 
For example if in the future you decide to re-write your system to not 
use FormFu and not have a setup_fields and a show_form method you have 
to change your interface. It is rather like the advantages you get by 
encapsulation in OO programming, you can change the internal 
implementation without worrying about the interface.


B) Plain Old Methods

package Thing:
use base 'Generic';
sub base : Chained('/') PathPart('thing') CaptureArgs(0) {}
sub edit : Chained('item') Args(0) {
my ($self, $c) = @_;
$self-setup_fields($c, ... );
$self-make_form;
# 
}


package Generic;
sub item : Chained('base') PathPart('') CaptureArgs(1) {
# load thing and store in stash
}
sub setup_fields {}
sub make_form {}
sub handle_form {}

I'd end up with an URL like 
  /thing/123/edit

which IMO looks nicer.
  
And IMO too. this is exactly how to use chaining. Don't hang yourself by 
trying to use chaining for everything.


So, is A) just overdoing chained? B) looks ok, but is it using chained 
to it's full potential?
  
It is using chaining to it's full potential (given the simple example 
you gave) but in a more complex example, e.g.

/manufacturer/123/component/456/subcomponent/789/edit

it would be clearer that chaining is going to make something like this 
much easier by putting the manufacturer object on the stash, then the 
next chain puts the component object on, then the subcomponent, then it 
chains to the 'edit' controller.

I'd really like to hear some of your thoughts...

  



___
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] FYI: Contracting possibilities

2008-05-13 Thread Ian Docherty
Ian Docherty always feels people who refer to themselves in the third 
person are being pretentious, as in http://zenshadow.vox.com/profile/  ;-)


Brian Cassidy wrote:

Hey All,

I was notified via private message that a start-up in Silicon Valley 
is looking for some Catalyst help. I figured I'd forward on the message.


Please read the relevant post here:

http://zenshadow.vox.com/library/post/catalyst-help-please.html

-Brian

NB: I know nothing about this person or their company. I'm just 
passing along the info.


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




___
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] Multi-language and REST

2008-04-25 Thread Ian Docherty
I have been pondering how to take an existing Catalyst application and 
make it multi-lingual.


I would prefer to use a RESTful method, so this would translate /foo/bar 
to /en/foo/bar or /fr/foo/bar (for English and French respectively).


The problem as I see it is how to do this. I don't want to move all my 
controllers, e.g. MyApp::Controller::Foo::Bar to 
MyApp::Controller::Lang::Foo::Bar


What other alternatives are there?

Regards
Ian

___
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] Multi-language and REST

2008-04-25 Thread Ian Docherty

Christopher H. Laco wrote:

Ian Docherty wrote:
I have been pondering how to take an existing Catalyst application 
and make it multi-lingual.


I would prefer to use a RESTful method, so this would translate 
/foo/bar to /en/foo/bar or /fr/foo/bar (for English and French 
respectively).


The problem as I see it is how to do this. I don't want to move all 
my controllers, e.g. MyApp::Controller::Foo::Bar to 
MyApp::Controller::Lang::Foo::Bar


What other alternatives are there?

Regards
Ian


Well, I'm sure there's a somewhat elegant way to do this with Chained, 
but it the other controllers don't use Chained now, that could get fun.
I have considered chained, and would be prepared to re-write the 
existing controllers. A bigger decision would be renaming the 
controllers or moving them.


e.g. existing MyApp::Controller::Foo::Bar maps to URI /foo/bar

To match against /lang/foo/bar either I can leave the controller where 
it is (lib/MyApp/Controller/Foo/Bar.pm) or move it 
(lib/MyApp/Controller/Lang/Foo/Bar)


The first approach is less work (only using chained) the second is more 
work, but maps the URI namespace more logically to the Class names.


What would people do if they were writing a Catalyst App from scratch 
with this feature? That would tell me what the 'best practice' is even 
if it means a big re-write exercise.


The brute force way is to inspect the request and rip out the language 
portion before sending it on to get dispatched...just like the Flavour 
plugin does with file extensions:


sub prepare_path {}
One of my pet peeves  is exemplified in the 'Flavour' plugin. It is such 
minimal documentation that it neither tells you what it does or why it 
does it. OK, I can look at the code, but it is too much effort unless I 
think I have a good reason to do so. I assume in this case that it is 
something to do with date strings in the URI (for blogging?). I can't be 
ar**d!


___
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] Multi-language and REST

2008-04-25 Thread Ian Docherty

Dave Rolsky wrote:

On Fri, 25 Apr 2008, Ian Docherty wrote:


http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html#z12

Yes, I have done this previously, it is elegant, but not RESTful and 
does not make it easy for users to change their settings on a 
site-by-site basis dynamically, as you could if you provided a 
language selection box on each page.


Why do you say it's not RESTful?

I think it's very RESTful, but it depends on how you think about it. 
If the language of the content is basically an issue of formatting, 
then switching language based on a header is perfect. The client 
provides sufficient information to produce a correct response _on each 
request_ as part of HTTP. This is basically the essence of REST.


OTOH, if you consider each language's content fundamentally separate 
things, then each language should have its own set of URIs.
Yes, this is exactly what I had in mind. I did not (and still don't) 
consider the language of the content as 'formatting', the content for 
each language is different (in my mind).


I don't really want this to start another flame-war about RESTful etc. 
this point is outside of my original request so I won't respond (on 
list) to this off-topic subject any more.


Regards
Ian

___
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] Multi-language and REST

2008-04-25 Thread Ian Docherty

Christopher H. Laco wrote:

Ian Docherty wrote:

Christopher H. Laco wrote:

Ian Docherty wrote:
I have been pondering how to take an existing Catalyst application 
and make it multi-lingual.


I would prefer to use a RESTful method, so this would translate 
/foo/bar to /en/foo/bar or /fr/foo/bar (for English and French 
respectively).


The problem as I see it is how to do this. I don't want to move all 
my controllers, e.g. MyApp::Controller::Foo::Bar to 
MyApp::Controller::Lang::Foo::Bar


What other alternatives are there?

Regards
Ian


Well, I'm sure there's a somewhat elegant way to do this with 
Chained, but it the other controllers don't use Chained now, that 
could get fun.
I have considered chained, and would be prepared to re-write the 
existing controllers. A bigger decision would be renaming the 
controllers or moving them.


e.g. existing MyApp::Controller::Foo::Bar maps to URI /foo/bar

To match against /lang/foo/bar either I can leave the controller 
where it is (lib/MyApp/Controller/Foo/Bar.pm) or move it 
(lib/MyApp/Controller/Lang/Foo/Bar)


The first approach is less work (only using chained) the second is 
more work, but maps the URI namespace more logically to the Class names.


What would people do if they were writing a Catalyst App from scratch 
with this feature? That would tell me what the 'best practice' is 
even if it means a big re-write exercise.


The brute force way is to inspect the request and rip out the 
language portion before sending it on to get dispatched...just like 
the Flavour plugin does with file extensions:


sub prepare_path {}
One of my pet peeves  is exemplified in the 'Flavour' plugin. It is 
such minimal documentation that it neither tells you what it does or 
why it does it. OK, I can look at the code, but it is too much effort 
unless I think I have a good reason to do so. I assume in this case 
that it is something to do with date strings in the URI (for 
blogging?). I can't be ar**d!





It does just what just what Bill suggested.

I check if the prefix is a valid language (if it's one of the language
files I loaded at startup), if so I then remove it from the request
path and append it to the request base.

In prepare_path.. you inspect the requested path.. yank out the 
language.. then pass along the remaining path...which should map to 
your existing controllers just fine.
I have actually taken a look at the Flavour plugin (can't see for the 
life of me why it is called that!) and it gives an example of yanking 
off the //mm/dd at the start of a path, putting the values into 
accessors of flavour (e.g. $c-flavour-year) leaving the rest of the 
path to be processed as normal. This is pretty much what I want to do 
for the language so thanks for pointing out the plugin to me.


I am pretty confident that I can now write a plugin to strip out a 
language from the start of a path in the same way.


Looking at the Catalyst best practices, am I going to be polluting the 
catalyst namespace by writing this as a plugin? I can't see any 
alternative (making it a base Controller is actually what I am trying to 
avoid).


Any suggestions as to a namespace for this? Catalyst::Plugin::LangURI 
perhaps?


As far as chained goes... I thought there was an example floating 
around that has Root::lang as Chained, then all other modules Chaine 
against /lang as their root instead of /...
I should not need this if I do the above then I can leave my existing 
controllers unchanged (and unchained).


-=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/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Re: Catalyst-Manual-FAQ Addition

2008-04-02 Thread Ian Docherty

Jess Robinson wrote:



On Wed, 2 Apr 2008, Paul Makepeace wrote:

On Mon, Mar 31, 2008 at 7:09 PM, Aristotle Pagaltzis 
[EMAIL PROTECTED] wrote:

* Russell Jurney [EMAIL PROTECTED] [2008-03-31 14:30]:


I discovered that 'call' is a reserved word for Catalyst

 controllers, and any subroutines in a controller named 'call'
 will be ignored.

 OK, but?


So, we should attempt to inform other people that they might also 
stumble over this problem.



 So, attached is a patched Catalyst::Manual::FAQ indicating this
 condition.

 ? err, how is your question a frequently asked one?


In my opinion the FAQ is for short'n'sweet 1-2 line answers to a) 
frequent questions and b) how to find stuff in the docs in general.


This should probably also be in Manual::Intro, or wherever the 
official list of action types is (which imo should be in the manual 
alone, that should be supplimentary) ..



There would be some good mileage out of Catalyst::Manual::Gotchas


Only if people know to look there ;)

You could always refer to Catalyst::Manual::Gotchas in the FAQ ;)


Jess

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




___
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 test server response times.

2008-01-31 Thread Ian Docherty

Ash Berlin wrote:


On 30 Jan 2008, at 09:51, Andrew Payne wrote:


On Jan 30, 2008 9:14 AM, Ian Docherty [EMAIL PROTECTED] wrote:

It is frequently (but not always) taking 20 seconds or so to display a
page in my browser


The only times I've had this happen, it's been DNS issues -- in my
case, dhcpd putting a duff entry in resolv.conf

YMMV, but worth checking.
Searching for DNS issues on Catalyst found this link from about 18 
months ago with a
proposed patch to Catalyst::Engine::HTTP.pm to disable reverse DNS if 
required. This
would have allowed me to solve this issue but AFAIK this patch was not 
applied


http://grokbase.com/profile/id:CFXND-g-bACl4AfTYfKSIP6B7aA91udMOUneLfCbr9E


Andrew


Also possible is that the Catalyst test server is trying to lookup 
your reverse DNS. Are you running with or with out debug enabled on 
the builtin server?


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




___
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 test server response times.

2008-01-30 Thread Ian Docherty

Jason Kohles wrote:


On Jan 30, 2008, at 10:23 AM, Roderick A. Anderson wrote:


Ian Docherty wrote:
I have moved (back) to using the built in Catalyst server for 
testing purposes.
It is frequently (but not always) taking 20 seconds or so to display 
a page in my browser
even though the timings reported by the Catalyst server are about 
0.2 sec. so I know that

it is not the Catalyst app that is causing the delay.


Having read the other postings on this I wonder if you have a 
large-ish css or Javascript file being loaded.  I've noticed a bit of 
a delay when I was trying the Ext2.js examples from the Ext2 site.


This delay is related more to the complexity of the javascript than 
it's size.  It's essentially the compile-time penalty of the library 
in use, ExtJS is one of the bigger ones that I've noticed it on, it 
can take quite a while for it get loaded/decompressed/setup and ready 
to go.  It's much faster when using a release version rather than a 
testing version, and there are tools that will let you build custom 
ExtJS versions with just the features you are actually using included, 
so you don't have to wait for initialization for features you aren't 
using.
I am using extjs and realised that this could be an issue but I created 
a brand new minimal Catalyst application and I saw the same issues.


Also I used wget to get the web page, which of course does not execute 
the javascript.


The 15 second long delay is prior to the Catalyst debug information 
being printed. The actual execution of the various controllers is very 
quick (sub 0.3 seconds)


If I use CATALYST_DEBUG=0 then the problem goes away.

Lately, the problem has gone away even without turning debug off.

One possibility I am still investigating is that the problem only occurs 
if two or more developers are running a server at the same time. (jury 
is still out on this)


Regards
Ian


___
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: REST - like uri design for CRUD

2008-01-29 Thread Ian Docherty

Aristotle Pagaltzis wrote:

* Ian Docherty [EMAIL PROTECTED] [2008-01-28 13:45]:
  

OK, so I put the item into the request body, but this does not
tell the remote client the ID of the created item.



Why does it need it? Is the URI not enough? If not, is the URI
*really* not enough (ie. could things be arranged so that it is)?
  
The 'create' is a POST to the URI http://mydomain.com/svc/doc with the 
content being
the document to save. However, the client has to know the ID of the 
created document

(which at this point is only known by the server).
  

Say for example that I am putting arbitrary documents (xml,
text, images) etc. onto the server via a web service in a
RESTful manner, I do this with a POST to my server. The server
needs to respond with something in the header to indicate the
ID of the document just POSTed.



Well, then don’t render the body of the item in the 201 response,
and do not set Content-Location, and instead just put some JSON
or XML or whatever in there.
  
OK, this would have been my first choice but I was misled I think by 
some other threads.
  

I do this in the Location header.



Location may only ever be a URI. If you put anything else there,
you’re doing it wrong.
  

Yes I agree.
  

e.g. POST /svc/upload (the document save)
Location /svc/view/1234 (the location of the item just saved, ID=1234)

So the URI is parsed by the programmatic client to extract the
'1234' yes/no?



No. Clients should never parse URIs. If you need to tell them
something they need to be able to understand, you put it in the
body.

(They should not construct URIs either. If they need to request
parametrisable URIs, the server should send them a form. Or if
you’re creating a non-browser HTTP API, you can send the client
a URI Template.)
  
This is something I have not seen mentioned before. I have no idea what 
a 'URI Template'
would look like. I don't see what is wrong with 'constructing' a URI, 
e.g. what is wrong
with the client 'knowing' that URI http://mydomain.com/svc/view/1234 is 
the location to

retrieve item 1234?

This is the hypermedia constraint in REST: clients only follow
links and forms. They don’t have any hardwired knowledge of the
server URI space.

(Note, though, that things get muddled with Ajax clients. If the
Ajax client is code served by the server (called _Code on Demand_
in REST), then it’s effectively a Turing-complete kind of form
markup, so it’s fine for that code to have hardwired knowledge.
But in practice, the Ajax client probably talks to a publically
available HTTP interface, and making that interface require hard-
wired knowledge of non-Code-on-Demand clients is wrong, so it’s
probably better to follow the hypermedia constraint even in on-
demand code.)

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] How to return a 401 from Catalyst

2008-01-27 Thread Ian Docherty

Ian Docherty wrote:
Related to my earlier thread about basic authentication, what do I 
have to do to return a 401 error from within Catalyst?


I have tried to understand the documentation at 
http://www.ietf.org/rfc/rfc2617.txt but it does not help me in a 
practical manner.


My understanding is that when the Catalyst app refuses the credentials 
given it must return a 401 with a 'realm' that is

just a string used to identify the service.

For example, when I create a test script for my Controller using LWP 
as follows


my $ua = LWP::UserAgent-new;
$ua-credentials('linux:8001','some_realm_or_other','sage_1001','sage');

Then my script fails because I have not set a 'realm' correctly in my 
Catalyst controller. All I have done so far is as follows.


   if ($login_success) ) {
  # do something
   }
   else {
   $c-response-status(401);
   return 0;
   }

Obviously I need to do more to return the realm, but what exactly?

Answering my own question after a bit of digging around.

It seems that all that is needed is to return the appropriate header as 
follows.


   $c-response-header('WWW-Authenticate' = 'Basic realm=My 
Realm');

   $c-response-status(401);
   return 0;

Simple really ;)


Regards
Ian

p.s. I note that there is nothing in Test::WWW (that I can find) that 
tests return status's such as 200, 401 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/




___
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] $c-req-body oddity

2008-01-26 Thread Ian Docherty
I am sending a POST to a Catalyst app and according to the documention I 
expected the request body to
contain the data I sent. Instead it holds a filename in the tmp 
directory which contains the document. Is

this an expected behaviour?

e.g. in my test script

my $request = HTTP::Request-new(POST = 'http://linux:3000/svc/to/1001');
$request-content_type('text/text');
$request-content('THIS IS THE STRING');
my $response = $ua-request($request);


If I look at the value in $c-request-body in my controller I get 
something

like '/tmp/LEVo4ciz1g'

And if I look at the content of the temp file I find my 'THIS IS THE 
STRING'

text.

Is this a document problem or something else?

Regards
Ian

___
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] Authentication for web services (slightly off topic)

2008-01-24 Thread Ian Docherty

Thanks to Andrew Page for this suggestion.

By running the Catalyst server and using wget to get the page the 
Controller recognises the username and password


wget --http-user=sage --http-password=s3cr3t http://linux:8001/svc/status

output

Authorization [sage][s3cr3t]

If I run the Catalyst server and then run my test as follows.

CATALYST_SERVER=http://linux:8001 make test

Then the output is
Authorization [][]

So, it appears that the problem is with my test script not passing the 
credentials to the Catalyst App.


I will carry on working on this but any other suggestions are welcome.

Regards
Ian

Ian Docherty wrote:
Now this should work, but I can't make it do so. I can't read the 
authorization username/password


In my test I have
--
use strict;
use warnings;
use lib 't/lib';

use Test::More tests = 1;

my $mech = WWW::Test::Mechanize-new;

$mech-credentials('admin','s3cr3t');
$mech-get_ok(http://localhost/svc/status;);

ok ($mech, 'Can mechanize');
1;
--
In my controller I have
--
sub auto : Private {
   my ($self, $c) = @_;
 my ($username, $password) = $c-req-headers-authorization_basic;
 print STDERR Authorization [$username][$password]\n;
}
--
Which gives the output
--
[Wed Jan 23 22:29:13 2008] 01_test.t: Use of uninitialized value in 
concatenation (.) or string at /var/.../Controller/Svc.pm line 44.
[Wed Jan 23 22:29:13 2008] 01_test.t: Use of uninitialized value in 
concatenation (.) or string at /var/.../Controller/Svc.pm line 44.

Authorization [][]
--
In other words I can't seem to get access to the username password

Regards
Ian


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




___
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] Authentication for web services (slightly off topic)

2008-01-24 Thread Ian Docherty

Ian Docherty wrote:
Now this should work, but I can't make it do so. I can't read the 
authorization username/password


In my test I have
--
use strict;
use warnings;
use lib 't/lib';

use Test::More tests = 1;

my $mech = WWW::Test::Mechanize-new;

$mech-credentials('admin','s3cr3t');
$mech-get_ok(http://localhost/svc/status;);

ok ($mech, 'Can mechanize');
1;
--
In my controller I have
--
sub auto : Private {
   my ($self, $c) = @_;
 my ($username, $password) = $c-req-headers-authorization_basic;
 print STDERR Authorization [$username][$password]\n;
}
--
Which gives the output
--
[Wed Jan 23 22:29:13 2008] 01_test.t: Use of uninitialized value in 
concatenation (.) or string at /var/.../Controller/Svc.pm line 44.
[Wed Jan 23 22:29:13 2008] 01_test.t: Use of uninitialized value in 
concatenation (.) or string at /var/.../Controller/Svc.pm line 44.

Authorization [][]
--
In other words I can't seem to get access to the username password

Regards
Ian


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




___
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] Authentication for web services (slightly off topic)

2008-01-24 Thread Ian Docherty
Problem solved with an upgrade to Test::WWW::Mechanize::Catalyst 0.41 
and Test::WWW::Mechanize 1.18


Ian Docherty wrote:
Now this should work, but I can't make it do so. I can't read the 
authorization username/password


In my test I have
--
use strict;
use warnings;
use lib 't/lib';

use Test::More tests = 1;

my $mech = WWW::Test::Mechanize-new;

$mech-credentials('admin','s3cr3t');
$mech-get_ok(http://localhost/svc/status;);

ok ($mech, 'Can mechanize');
1;
--
In my controller I have
--
sub auto : Private {
   my ($self, $c) = @_;
 my ($username, $password) = $c-req-headers-authorization_basic;
 print STDERR Authorization [$username][$password]\n;
}
--
Which gives the output
--
[Wed Jan 23 22:29:13 2008] 01_test.t: Use of uninitialized value in 
concatenation (.) or string at /var/.../Controller/Svc.pm line 44.
[Wed Jan 23 22:29:13 2008] 01_test.t: Use of uninitialized value in 
concatenation (.) or string at /var/.../Controller/Svc.pm line 44.

Authorization [][]
--
In other words I can't seem to get access to the username password

Regards
Ian


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




___
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] Authentication for web services (slightly off topic)

2008-01-23 Thread Ian Docherty
This might seem like a stupid question, and one that probably has a 
simple solution.


If I am serving XML over HTML (a simple web service), how do I 
authenticate the client?


I would not expect cookies to be a sensible solution.

I could use Apache Basic Authentication, but I would prefer to hold 
usernames passwords in

a database rather than a htpasswd file.

That's about the limit of what I can think of.

The second question (and the reason why this is still on-topic) is that 
I want to have a web application

and a web service running from the same Catalyst application.

So, if I had a URL with a pre-path of http://mydomain.com/service then 
this would be directed to the
web services (with their own authentication) and anything else would be 
directed to the web application

(with standard username-password login).

Is it feasible to authenticate these using two different methods in 
Catalyst?


Regards
Ian




___
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] Authentication for web services (slightly off topic)

2008-01-23 Thread Ian Docherty

Andrew Payne wrote:

On Jan 23, 2008 2:30 PM, Ian Docherty [EMAIL PROTECTED] wrote:
  

This might seem like a stupid question, and one that probably has a
I could use Apache Basic Authentication, but I would prefer to hold
usernames passwords in
a database rather than a htpasswd file.



Just do

my ($username, $password) = $c-req-headers-authorization_basic;

There's no need to have Apache handle it.

I have an app with both an HTML and a REST/XML interface (under
'/REST/'), and simply give the REST controller its own auto() sub,
containing the above line. Works fine.
  
How would you test that or see if it works if you were using the 
Catalyst built in server?

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/

  


___
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] Authentication for web services (slightly off topic)

2008-01-23 Thread Ian Docherty

Andrew Payne wrote:

On Jan 23, 2008 2:30 PM, Ian Docherty [EMAIL PROTECTED] wrote:
  

This might seem like a stupid question, and one that probably has a
I could use Apache Basic Authentication, but I would prefer to hold
usernames passwords in
a database rather than a htpasswd file.



Just do

my ($username, $password) = $c-req-headers-authorization_basic;

There's no need to have Apache handle it.

I have an app with both an HTML and a REST/XML interface (under
'/REST/'), and simply give the REST controller its own auto() sub,
containing the above line. Works fine.
  
I am slow today. What you said here has slowly percolated through my 
thick head! I could
not get it out of my mind that I had to set up Apache to request basic 
authentication for (in your
example) the '/REST/' location. Obviously I don't need to do that so 
long as the Catalyst App

is able to read the authentication data sent by the client system!

Thanks. That solves my problem I believe.
Regards
Ian

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/

  


___
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] Catalyst::View::JSON parameters

2007-12-03 Thread Ian Docherty
I am trying to set the 'autoconv' flag for JSON so that numbers are 
quoted (it seems that Ext JS API requires it)


I can't see any way to pass options to JSON through Catalyst::View::JSON

On looking at the code for C::V::JSON it creates a new JSON::Any object 
but does not pass on any parameters (probably because there is no 
standard parameter mappings for the different JSON modules).


I am at a loss as to how to do this without writing my own C::V::JSON

Any suggestions?

Regards
Ian Docherty



___
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] BBC's Perl on Rails nuttiness

2007-12-02 Thread Ian Docherty

Zbigniew Lukasiak wrote:

On Dec 2, 2007 12:38 PM, Ian Docherty [EMAIL PROTECTED] wrote:
  

Zbyszek
You have to remember that Siemens are responsible for ensuring the
stability of the public facing infrastructure.
This makes it important not to introduce new modules, or upgrade
existing modules, without an extensive
testing period to make sure it works with all existing applications. The
trouble with this is that it is easier to
keep stable (or work around existing known problems) by not installing
anything new.



Sure - but as I understand BBC is their client and this policy makes
the life of BBC programmers pretty miserable.  
  
Yes, it does make for a pretty frustrating work environment sometimes 
and although Siemens should

be working for the BBC it often feels like the other way around.

This does not sound
like a good business direction.  I know this is not a simple problem,
and to solve it we will have to get through to the management level,
but we actually are in much better position to reach that level than
the poor BBC employees.

--
Zbyszek
http://brudnopis.blogspot.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/

  


___
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] email confirmation widget?

2007-10-11 Thread Ian Docherty

Dave Rolsky wrote:

On Wed, 10 Oct 2007, Dustin Suchter wrote:


Has anyone put together a nice email-validation-link-generator
widget for Catalyst (or Perl, for that matter)? All I can find on
CPAN is something that is part of Jifty (whatever that is).

http://search.cpan.org/~jesse/Jifty-0.70824/plugins/Login/lib/Jifty/Plugin/Login/Action/ConfirmEmail.pm 



In a perfect world this widget would be really simple:

-generates long random codes for use in confirm links
-stores those links server-side in temp files instead of a DB to
prevent DDoS on a db


Huh? You can't prevent a DDoS by storing stuff on the filesystem and 
not in a DBMS. And the distributed part isn't the issue, it's just the 
DoS part one would worry about. Presumably filling up the file system 
will also cause a DoS, but so would signing up for an account in the 
app of choice and submitting too much content.


More importantly, some people will _need_ to store it in the DBMS 
because they have multiple web servers and don't want to enable NFS 
just to store it in the file system ;)


If this sort of plugin were useful, the storage should probably be 
pluggable, just like with Sessions. I'm not convinced that this sort 
of thing can be made generic enough to be a useful plugin, but that's 
a different issue.



-dave


I don't have code for this any more, but it is possible to do this
without storing anything either in the DB or the filesystem so it would
prevent any DoS.

The principle is this.

Create a text string containing the user-id and the date, e.g.
'666-20001011' then append a 'secret' code to it only known by the
server giving you a string like '666-20001011-ThiSW1llNev3rBQuessed'.

You now apply your favorite one-way hash function to this string, for
example MD5 or SHA1.

You now include in your email the link to the site with the string
''666-20001011-SHAD1orMD5string goes here'

When you receive the code you can tell (from the date) if it has expired
and the user-id and you can verify the hash value by re-applying the
server secret code to these values by re-creating the string.

This gives you email validation, with timeout, without having to store
anything serverside.

Regards
Ian


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