Re: [Catalyst] Request paths - rejoining Chained actions together.

2008-05-10 Thread Tomas Doran


On 9 May 2008, at 15:55, J. Shirley wrote:

On Fri, May 9, 2008 at 5:00 AM, Tomas Doran [EMAIL PROTECTED]  
wrote:

Some example URLs:

/volume/*/track/*/format/*
/track/*format/*
snip
sub format : Chained('tracksequence', 'trackonvolume') PathPart 
('format')

Args(1) {}

But this doesn't work...

snip


It sounds like your actions are capture arguments, rather than
separate midpoints (since they're working on the same resource,
anyway).

If you have someoperation as a CaptureArg, and stick that away in the
stash to perform the action later in the chain, you should get what
you want.



I see what you mean, but that means I have to do a reasonable amount  
of error handling myself, as there are only a few sets of actions  
which are valid..


Also, the number of arguments to access a resource can vary..

My URLs are of the form:

/thing/canonical_identifier/further/*/chained/*/things
/thing/other_identifier_p1/*/other_identifier_p2/*/further/*/chained/ 
*/things


Looking up by the canonical identifier, and another identifier are  
also actually different operations, so it'd be nice to be able to  
split them, but more to the point what you suggested just won't work,  
as I can't just say CaptureArgs(4) - as there can be different  
numbers of arguments for various points to join..


If I was to hack some code (and tests) up which supported my  
originally suggested syntax ( Chained('sub1', 'sub2') for joining  
chains), what would anyone feel about it?


Cheers
Tom


___
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] session in DB example in Catalyst book

2008-05-10 Thread Andrew
The only Session.pm is found in /AddressBook/Schema. I don't have Models for the People or Addresses that I'm retrieving in this address book example, but I've only got Schemas and Controllers. The code of /AddressBook/Schema/Session.pm is and as you can see by the package designation Session.pm is suppose to be under the Schema directory and not the Model directory. package AddressBook::Schema::AddressDB::Session;use base qw/DBIx::Class/;__PACKAGE__-load_components(qw/Core/);__PACKAGE__-table('sessions');__PACKAGE__-add_columns( id = { data_type = "CHAR", is_nullable = 0, size = 72 }, session_data = { data_type = "TEXT", is_nullable = 1, size = undef },
 expires = { data_type = "INTEGER", is_nullable = 1, size = undef});__PACKAGE__-set_primary_key('id');1;-- On Fri, 5/9/08, Andreas Marienborg [EMAIL PROTECTED] wrote:From: Andreas Marienborg [EMAIL PROTECTED]Subject: Re: [Catalyst] session in DB example in Catalyst bookTo: [EMAIL PROTECTED], "The elegant MVC web framework" catalyst@lists.scsys.co.ukDate: Friday, May 9, 2008, 10:19 PMOn May 10, 2008, at 3:53 AM, Andrew wrote:Using the Rockway's Catalyst book to help bring me up to speed on Catalyst and I've got a problem that I can't figure out.On page 59, where it uses a database to store the session key, I've made all the code changes, but when I start the server it gives me the following error:"Couldn't find a model named DBIC::Session at /usr/local/share/perl/5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 143.Compilation failed in require at script/addressbook_server.pl line 53."You don't seem to have the Model you configured the session store to use. Do you have the MyApp/Model/DBIC/Session.pm file?- andreas

  Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.

___
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] Anybody who fancies some LWP poking ...

2008-05-10 Thread Daniel McBrearty
 I think there was some discussion over the same error in the POE HTTP
 client over on perlmonks that included a this is the line of code that
 is wrong. I can't find the link offhand though.

well, I see really three places to look at this:

1. in HTTP::Message - IMO the check on the content is fine, but there
is really no need to die on failure, at least not until the rest of
the codebase gets fixed. Hence my short term fix of just removing
that. Bah.

2. in Test::WWW:Mechanize::Catalyst , you get:

# For some reason Test::WWW::Mechanize uses $response-content everywhere
# instead of $response-decoded_content;
$response-content( $response-decoded_content );

which is the line that causes problems up the chain (I think that the
content check that happens in HTTP::Message-new() is not an issue).

So here, the question is, *why*? Is the right fix for T:W:M to change
to using decoded_content and remove this line? Or just remove this
line anyway? Or is there another issue?

I'd like Leon's opinion on this. Forwarding to him again.

___
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] UTF-16 surrogate message when writing binary data (image)

2008-05-10 Thread Matt S Trout
On Fri, May 09, 2008 at 02:58:41PM +0800, Martin Ellison wrote:
 If I write binary data (a JPEG) using $c-res-body then I get all these
 errors
 
  stderr: UTF-16 surrogate 0xdf98 at /usr/lib/perl/5.8/IO/Handle.pm line 199.
 
 My code looks like
 
   $c-res-content_type(q{image/jpeg});
 $c-res-header( 'Content-Disposition', q{inline} );
 $c-res-body($pic_image);
 
 Presumably, something is assuming that the output is Unicode text and trying
 to interpret it accordingly. These error messages are all over the log,
 making it difficult to read, besides any impact the situation may be having
 on the output.
 
 Is there any way to fix this issue (eg something like binmode)?

My best guess here is that $pic_image is, or looks like, a file handle,
and so when Catalyst is sending the response it's doing so by reading
from the filehandle and the error's turning up during $fh-read.

It'd of course be easier for you to confirm this, since you have the
copy of IO/Handle.pm and the line number - maybe you could look?

A good way to check would be to loop reading $pic_image yourself and
see if you get the same warning ...

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/

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


Re: [Catalyst] Variable Catalyst seems to be undefined.

2008-05-10 Thread Matt S Trout
On Sat, May 10, 2008 at 12:09:21AM +1000, Kieren Diment wrote:
 Catalyst::View::TT uses c.stash.whatever in templates, while  
 Catalyst::View::TTSite uses Catalyst.stash.whatever

Sort of.

the TTSite -helper- generates a Catalyst::View::TT subclass with

__PACKAGE__-config(
  ...
  CATALYST_VAR = 'Catalyst',
  ...
);

and whatever that's set to, that's what your variable's gonna be called.
Unless you don't set it at all, in which case it's called 'c'.

Personally I prefer 'ctx', so at some point somebody's probably going to
take my personal opinion as an official best practice[0] yet again and
there'll be a helper that does that as well ;)

More seriously, though - if something goes weird in a component in your
app, please read the documentation for whatever that component does a
'use base' on - it's -usually- going to be enlightening.

[0] If anybody ever finds out who coined the phrase best practice please
tell me so I can send them a flaming llama turd as an expression of my
love of it.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/

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


[Catalyst] Re: Request paths - rejoining Chained actions together.

2008-05-10 Thread Aristotle Pagaltzis
* Tomas Doran [EMAIL PROTECTED] [2008-05-10 09:25]:
 If I was to hack some code (and tests) up which supported my
 originally suggested syntax ( Chained('sub1', 'sub2') for
 joining chains), what would anyone feel about it?

You could no longer make `uri_for` work in the general case if
you did that.

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.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] session in DB example in Catalyst book

2008-05-10 Thread Matt S Trout
On Fri, May 09, 2008 at 06:53:47PM -0700, Andrew wrote:
 table cellspacing='0' cellpadding='0' border='0' trtd style='font: 
 inherit;'Using the Rockway's Catalyst book to help bring me up to speed on 
 Catalyst and I've got a problem that I can't figure out.brbrOn page 59, 
 where it uses a database to store the session key, I've made all the code 
 changes, but when I start the server it gives me the following 
 error:brbrCouldn't find a model named DBIC::Session at 
 /usr/local/share/perl/5.8.8/Catalyst/Plugin/Session/Store/DBIC.pm line 
 143.brCompilation failed in require at script/addressbook_server.pl line 
 53.brbrI've installed Session::Store::DBIC module and even reinstalled 
 it to see if missed out on the Session model and I get the same error.nbsp; 
 Any ideas?br/td/tr/tablebr
 
   hr size=1Be a better friend, newshound, and 
 know-it-all with Yahoo! Mobile. a 
 href=http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
   Try it now./a
 

You're posting in HTML only.

Fix your mail client.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/

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


Re: [Catalyst] IMPORTANT: To all Catalyst::Whatever Authors, please read and ACT

2008-05-10 Thread Ashley

On May 10, 2008, at 5:39 PM, Kieren Diment wrote:
If you maintain a Catalyst::Plugin, View, Controller or anything  
else, please pay attention and address the following issue:


YAML is not an appropriate configuration format for use in perldoc  
because both yaml and perldoc are sensitive to white space.   
Therefore they interact.  Even worse they interact in different  
ways depending on the formatter being used.


You may say that this is not important because people can just  
remove the indentation from the perldoc at the beginning of each  
line of the config, but this makes your module less usable for  
people, and *requires thought*.


If using the trivial parts of your module requires thought, this is  
overhead for someone learning how to use your software which can be  
avoided (see http://en.wikipedia.org/wiki/Cognitive_load for details).


So in your modules, Ideally you will provide  provide both a   
__PACKAGE__-config() example, and an example using a   
serialisation format like  Config::General (which is much harder to  
stuff up than yaml).  If you're only going to provide one example  
though please don't make it YAML.  If you don't want to have to  
maintain two config examples, then provide the __PACKAGE__  
declaration, which means at least us poor users can then do:


perl -Ilib -e 'use MyApp; use Config::General; Config::General-new- 
save_file(myapp.conf, MyApp-config);'


Two or more config examples is nice and kind to users and I think  
it's a great best practice to include it (maybe someone would attach  
a simple script to dump several formats? If I have time this weekend,  
I'll try if no one beats me to it).


Arguing that users who cargo-cult their configs from POD deserve  
coddling and MODULE AUTHORS MUST ACT TO AVERT THIS DISASTER is silly.


-Ashley


___
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] IMPORTANT: To all Catalyst::Whatever Authors, please read and ACT

2008-05-10 Thread Kieren Diment


On 11 May 2008, at 10:56, Ashley wrote:

Arguing that users who cargo-cult their configs from POD deserve  
coddling and MODULE AUTHORS MUST ACT TO AVERT THIS DISASTER is silly.



No, users who don't understand how to use the code well enough that  
they have to rely on the documentation need documentation that won't   
confuse them with trivial stuff and unadvertised interaction bugs.   
YAML in pod causes these bugs, which impacts on the learning curve  
significantly, so please don't use it in documentation.  If you're  
still not convinced after reading  http://en.wikipedia.org/wiki/ 
Cognitive_load then I'm happy to these issues  off-list.


Your users are not you, they do not have your levels of  
understanding, and they are guaranteed to go about understanding  
things in a different way to the way that  you did.  Please keep  
their cognitive overhead to a minimum so they can realise their  
potential more quickly and easily.


___
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] Invalid session ids being generated

2008-05-10 Thread Jonathan Rockway
* On Fri, May 09 2008, Hartmaier Alexander wrote:
 Delete the session cache file!
 I had a similar problem.

 -Alex


 -Original Message-
 From: Ryan Pack [mailto:[EMAIL PROTECTED] 
 Sent: Friday, May 09, 2008 1:03 AM
 To: The elegant MVC web framework
 Subject: RE: [Catalyst] Invalid session ids being generated

 I was able to fix it by downgrading Catalyst::Plugin::Session.  We were
 on 0.13 until I upgraded to .19 (latest) along with a bunch of other
 Catalyst modules.  Just as a last resort before I downgraded everything
 back to the way it was I tried just downgrading
 Catalyst::Plugin::Session and it worked!  Woohoo!

Both of these sound like fragile workarounds.  If you guys can do a bit
more digging, I would appreciate it.  It would be good to actually fix
the problems, after all.

Regards,
Jonathan Rockway

-- 
print just = another = perl = hacker = if $,=$

___
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] IMPORTANT: To all Catalyst::Whatever Authors, please read and ACT

2008-05-10 Thread Ashley

On May 10, 2008, at 6:44 PM, Matt S Trout wrote:

On Sat, May 10, 2008 at 05:56:41PM -0700, Ashley wrote:

Arguing that users who cargo-cult their configs from POD deserve
coddling and MODULE AUTHORS MUST ACT TO AVERT THIS DISASTER is silly.


There are several requests A DAY on #catalyst that come down to YAML
indentation mistakes.

If users are clearly repeatedly not getting this, it's time to  
change stuff.


If we do a 5.71 I think the catalyst.pl default should change then,  
and

then after a few months we file bugs against every distribution still
using YAML examples instead of code and/or .conf.



As I said, I'm all for more examples and even volunteered to write a
script to make it easy to sync them. It wouldn't be much fun to be
actively disallowed from using the example that I am going to
want to see or stub from when I run perldoc. I like helping others
but I write code primarily for myself. I know you don't like YAML,
Matt, but I do. I don't see that having a best practice of ... top 3?
configs is incompatible with the stated goal.

I believe YAML/POD is causing problems but since it's the most
used example it's simply going to be the most asked about whether
or not it's intrinsically problematic. If the docs only had  
fragmentary XML

or Apache style confs, the irc would be getting plenty of questions
on those instead.





___
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] IMPORTANT: To all Catalyst::Whatever Authors, please read and ACT

2008-05-10 Thread Ashley

On May 10, 2008, at 7:18 PM, Kieren Diment wrote:

On 11 May 2008, at 10:56, Ashley wrote:

Two or more config examples is nice and kind to users and I think  
it's a great best practice to include it (maybe someone would  
attach a simple script to dump several formats? If I have time this  
weekend, I'll try if no one beats me to it).


That on the other hand would be useful (sorry missed it first  
time).  Could you make a CatalystX::ConfigMaker that dumps  
catalyst_config.pl into $PATH somewhere?  CatalystX::Starter is a  
small and simple module that shows how to do this.


I'd love to try. I'll take a look this weekend. Thanks for pointing me  
at the starter modules, I hadn't looked at it yet.


devilsAdvocate type=tangent for=MST style=voice:facetious
The biggest stumbling block and learning curve with Catalyst is almost  
undeniably DBIC… Maybe we should consider a script that files tickets  
against any documents that reference it going forward. I mean sure  
it's useful but think of all the questions it generates! Why DBIC  
users pollute the Catalyst list all the time and some of the devs even  
cross post.

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