Re: [Catalyst] App breaks after updating to Catalyst::Plugin::Session::State::URI v0.14

2010-08-19 Thread Ash Berlin
On 19 Aug 2010, at 13:07, Charlie Garrison wrote:
 Good evening,
 
 I updated heaps of modules on my dev server last night, and my app broke 
 horribly. Various errors in the log, common one being:
 
Caught exception in engine Wrong Content-Length value: 


I see this error occasionally when I restart a server and the client is in the 
middle of a request and retries. Does this error happen every time? Including 
once you close the browser and using lwp-request etc.?

-ash

 
 I reverted to a backup and updated modules in small batches. The error 
 returned when updating Catalyst::Plugin::Session::State::URI v0.14.
 
 The change notes indicate a couple things I probably should focus on:
 
- Fix behaviour when debug is turned on by wrapping prepare_path
  rather than prepare_action (RT#56753).
- Fix for loading the session ID with a cookie for some actions
  and Session::State::URI for others (RT#57620)
 
 I'm guessing the error is due to the change from prepare_action to 
 prepare_path but I don't know enough about the C::Engine internals to figure 
 out what the real problem is. Or maybe it's not even a problem with 
 C::Engine, and that's just where exception gets thrown.
 
 During my testing I determined the issue happens when running under both 
 myapp_server and myapp_fastcgi. (So I don't think it's an issue specific to 
 C::Engine::HTTP or C::Engine::FastCGI.)
 
 Can anyone help with the debug process from here? What should I try next? 
 What other info should I provide?
 
 Plugin list is:
 
 __PACKAGE__-setup(qw/
ConfigLoader
AutoCRUD
Static::Simple
Params::Nested
I18N
Unicode::Encoding
Cache::HTTP
 
Session
Session::Store::DBIC
Session::State::Cookie
Session::State::URI
 
Authentication
Authorization::Roles
Authorization::ACL
RequireSSL
 
Cache
 /);
 
 
 Just using C::P::Session::State::URI v0.13 for now is fine. But I'd like to 
 get this solved before pushing changes to production.
 
 Thanks,
 Charlie




___
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] App breaks after updating to Catalyst::Plugin::Session::State::URI v0.14

2010-08-19 Thread Ash Berlin
On 19 Aug 2010, at 18:12, Charlie Garrison wrote:
 Good morning,
 
 On 19/08/10 at 9:12 AM -0700, Bryan Opfer b...@opfermail.com wrote:
 
 I have the same exact behavior in my app after upgrading to 0.14.  So,
 I don't think it is just your app.  Interestingly, if I remove param
 from my config and use the mode where the session id is appended to
 the URI, then things work fine.  But, if I use the session id in the
 param, it breaks just like your app.
 
 We're hitting the same thing then. I've just been playing with 
 C::P::Session::State::URI code and found that if I change line 323 from:
 
if ( my $sid = $c-request-param($param) ) {
 
 to:
 
if ( my $sid = 0 ) {
 
 then the problem goes away. So without knowing more about Cat internals I 
 would conclude that calling $c-request-param during `prepare_path` is 
 creating problems elsewhere. I also tried:
 
if ( my $sid = $c-request-parameters-{$param} ) {

Try changing parameters to query_parameters. It sounds like hitting params is 
causing it to read the body and mess things up when it comes to read the body 
again.

Also if you could see to creating a (failing) regression test this would help.



 
 And that fails as well.
 
 I've tried following the code logic but I'm quickly getting lost in all the 
 different prepare_* methods spread among Catalyst.pm and the different 
 C::Engine modules.
 
 For now I've changed C::P::Session::State::URI with `sub prepare_action 
 {...]` rather than `prepare_path` and my app is working. Hopefully someone 
 with some better ideas than me can suggest what the proper fix is.
 
 
 Charlie




___
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] A point of confusion/frustration on chained actions

2010-05-19 Thread Ash Berlin
On 19 May 2010, at 23:16, Stephen Howard wrote:
 I am trying to sort out some interdependent chains and I'm having trouble 
 figuring out why the urls I'm trying to build aren't working out.
 
 I have a site where the primary objects of interest are flash-based 
 tutorials.  Each tutorial can have comments, and each comment can have 
 replies.  I'm using jQuery to manipulate comments in a REST fashion, and I'm 
 aiming for a url map like this:
 
 /tutorials # GET a list of tutorials, or POST a new 
 tutorial
 /tutorials/*   # GET/POST/DELETE a specific tutorial
 /tutorials/*/comments  # GET the comments for a tutorial, or POST 
 a new comment
 /tutorials/*/comments/*# GET/POST/DELETE a specific comment
 /tutorials/*/comments/*/replies# GET the replies for a comment, or POST a 
 new reply
 /tutorials/*/comments/*/replies/*  # GET/POST/DELETE a specific reply
 
 But the best I've been able to come up with is this:
 
  /tutorials
 ^tutorials/(\d+)$
 /tutorial/*/comments
 /tutorial/*/comment/*/replies
 /tutorial/*/comment/*/reply/*
 
 missing: /tutorial/*/comment (what would I call it? /tutorial/*/cmt ?)
 
 Essentially I'm hitting an issue with is due to the (seeming?) impossibility 
 of matching a chained set of actions at multiple url depths. Is it possible 
 to build the url structure I'm looking for above using chained actions?
 
 thanks,
 Stephen

You can get it exactly as you want:

(manually re-ordered the below to match your desired list)
[debug] Loaded Chained actions:
.-+--.
| Path Spec   | Private  |
+-+--+
| /tutorials  | /tutorials (0)   |
| | = /all_tutorials|
| /tutorials/*| /tutorials (0)   |
| | - /a_tutorial (1)   |
| | = /show_tutorial|
| /tutorials/*/comments   | /tutorials (0)   |
| | - /a_tutorial (1)   |
| | - /comments (0) |
| | = /show_tutorial_comments   |
| /tutorials/*/comments/* | /tutorials (0)   |
| | - /a_tutorial (1)   |
| | - /comments (0) |
| | - /a_comment (1)|
| | = /show_comment |
| /tutorials/*/comments/*/replies | /tutorials (0)   |
| | - /a_tutorial (1)   |
| | - /comments (0) |
| | - /a_comment (1)|
| | - /replies (0)  |
| | = /show_replies |
| /tutorials/*/comments/*/replies/*   | /tutorials (0)   |
| | - /a_tutorial (1)   |
| | - /comments (0) |
| | - /a_comment (1)|
| | - /replies (0)  |
| | - /a_reply (1)  |
| | = /show_reply   |
'-+--'



sub tutorials : Chained('/') PathPart CaptureArgs(0) {
  # stash tutorials rs
}
sub all_tutorials : Chained('tutorials') PathPart('') Args(0) {
  # empty, or set stash for view
}

sub a_tutorial : Chained('tutorials') PathPart('') CaptureArgs(1) {
  # stash tutorial
}
sub show_tutorial : Chained('a_tutorial') Args(0) PathPart('') {
 # setup view
}

sub comments : Chained('a_tutorial') CaptureArgs(0) PathPart {
  # stash comments rs from stash-{tutorial}
}

# You get the idea hopefully
sub show_tutorial_comments : Chained('comments') Args(0) PathPart('') {}
sub a_comment : Chained('comments') CaptureArgs(1) PathPart('') {}

sub show_comment : Chained('a_comment') Args(0) PathPart('') { }

sub replies : Chained('a_comment') PathPart CaptureArgs(0) {}
sub show_replies : Chained('replies') Args(0) PathPart('') {}
sub a_reply : Chained('replies') CaptureArgs(1) PathPart('') {}
sub show_reply : Chained('a_reply') Args(0) PathPart('') {}


-ash

Re: [Catalyst] KiokuDB, MongoDB and the NoSQL thing

2010-03-04 Thread Ash Berlin
On 4 Mar 2010, at 23:38, Darren Duncan wrote:
 MongoDB specifically represent data with is JSON documents.

Not quite true. They are BSON (B = binary) and have specific types for dates, 
regexps and binary data___
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] Possible error in DBIx::Class::TimeStamp

2009-07-31 Thread Ash Berlin


On 31 Jul 2009, at 17:39, Oleg Kostyuk wrote:


Hello guys,

I'm looking at this part of DBIx/Class/TimeStamp.pm :



And you're posting this to the wrong list:

NAME
DBIx::Class - Extensible and flexible object - relational mapper.

GETTING HELP/SUPPORT
The community can be found via:

  Mailing list: http://lists.scsys.co.uk/mailman/listinfo/dbix-class/

  SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/

  SVNWeb: http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/

  IRC: irc.perl.org#dbix-class

___
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] RFC: Makefile warning in catalyst apps

2009-07-28 Thread Ash Berlin


On 28 Jul 2009, at 09:27, Devin Austin wrote:


okay, I got this right this time.

What are everyone's thoughts on including a warning and forced  
confirmation when a user  goes to make install an application, be  
it downloaded from cpan or elsewhere?


Something like, you are running make install, are you REALLY sure  
you want to install this application system wide?  If you aren't  
sure, then CTRL + C., or, make reallywantoinstall, etc.


Thoughts?


If the module is on CPAN, then this option would be *really* annoying  
- if some one has gone to the trouble of cpanning the module and you  
did 'cpan Mojomojo' i think the intention is pretty clear?


___
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] RFC: no make install on catalyst apps

2009-07-28 Thread Ash Berlin


On 28 Jul 2009, at 14:48, Jeremiah C. Foster wrote:


O HAI!

The debian-perl team has built packages for Catalyst to allow debian  
users easy installation and quality assurance. The addition of the  
proposed installation code in Catalyst would break current apps and  
would most likely be removed by debian / ubuntu because it  
fundamentally interferes with a user's stated wishes. When a user  
calls aptitude install catalyst they explicitly want catalyst  
installed and not a message saying are you sure you want to install  
catalyst?


Personally, I greatly prefer the UNIX philosophy of silence equals  
success, and would not welcome any notification around installation.


Regards,

Jeremiah


To clarify, Devin was not talking about installing Catalyst itself,  
but an app written with catalyst (say Angerwhale or Mojomojo.) But the  
same principle applies.


___
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: sql debugging hooks

2009-07-11 Thread Ash Berlin


On 11 Jul 2009, at 19:47, Minty wrote:


But I want to inject my $debugger via the Model or schema, and
enable/disable it globablly via a configuration file flag.


What I meant to say was I want to inject my custom debugobj handler
globally (at least in development), then simplify the code in the
Controllers to just:

 $model-result_source-storage-debug(1);
 my $employee = $mode-find(123);
 $model-result_source-storage-debug(0);

When I want to debug that one particular query.



See http://search.cpan.org/perldoc?Catalyst::Model::DBIC::Schema::QueryLog 
 and http://search.cpan.org/perldoc?Catalyst::TraitFor::Model::DBIC::Schema::QueryLog 
.


That includes a TT snippet you can (conditionally) put in your  
wrapper, or you could produce something similar for console output


-ash

___
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 path seperator?

2009-06-22 Thread Ash Berlin


On 22 Jun 2009, at 13:25, Neo [GC] wrote:


Hi!

Is it possible to change the path seperator or to define an optional  
new seperator and if yes, how?


Example:
Instead of
/foo/bar/something?param=value
for
MyApp::Controller::Foo::Bar
I'd like to use
/foo.bar.something?param=value

Thanks in advance and regards,
Tom Weber


Sounds like you want a custom prepare path sub, and if you use it a  
custom uri_for. Check the docs for the sigs: you can just define these  
methods in your MyApp.pm.


-ash

___
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] Test::WWW::Mechanize::Catalyst and Catalyst::Controller::HTML::FormFu

2009-06-22 Thread Ash Berlin


On 22 Jun 2009, at 19:50, Kiffin Gish wrote:


I'm using Test::WWW::Mechanize::Catalyst to test my Catalyst App, more
specifically the process for registering new user accounts.

The application form is generated by  
Catalyst::Controller::HTML::FormFu

with the expected fields: username, password, confirm_password, email
and the submit = 'Register' button (indicator).

When using the good ol' browser the form is submitted and an email  
sent

for validation, no problem.

However, making the exact same call with  
Test::WWW::Mechanize::Catalyst

as follows:

my $fields = {
   username = $username,
   password = $password,
   confirm_password = $password,
   password_hint = $password_hint,
   email = $email,
   submit = 'Register'
};

$mech-submit_form(
   form_number = 0,
   fields = $fields,
);

will not work because within the sub register : Global FormConfig of  
my
controller, $form-submitted_and_valid is returning false for some  
weird

reason.

I tried debugging the HTML::FormFu stuff but this is all very
complicated.

Can anyone help me here?


I'm guessing HTML::FormFu determines that the form is submitted by the  
value of the input from the submit button (rather that it just being a  
post request which is my personal preference)


To get WWW::Mechanize to send this value do, call


$mech-submit_form(
with_fields = $fields,
button = 'submit' # or what ever the name attr of the submit  
button is.

);

___
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] Slow fastcgi: A debugging aid

2009-05-05 Thread Ash Berlin


On 5 May 2009, at 04:36, Jon Schutz wrote:


Octavian Râsnita wrote on 5/4/09 5:43 PM:


It would be nice to be able to limit the number of requests per

fastcgi

child process...



On Mon, 2009-05-04 at 19:56 -0500, Peter Karman wrote:


Catalyst::Plugin::AutoRestart



Would I be correct in my reading of the code, that since the exit()
happens in handle_request, the request that triggers the restart does
not get served?


No, Since the second line is

  my $ret = $c-next::method(@args);

This does the normal request handling first (including writing any  
data) then it checks the process.


-ash
___
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] unknown resource

2009-05-02 Thread Ash Berlin


On 2 May 2009, at 09:25, Octavian Râşniţă wrote:


Hi,

I've started to use fastcgi with Apache and after a little fight  
with it, I made it work, but I can't access /server-status anymore.


I've checked and mod_status.so  is loaded in httpd.conf:

LoadModule status_module modules/mod_status.so

and it is also configured to show the server status on /server- 
status for everyone:


Location /server-status
SetHandler server-status
Order deny,allow
Allow from all
/Location

But when I access /server-status the Catalyst app gives the  
following error:


Unknown resource server-status

(or Unknown resource server-status/ if I add a slash at the end)

I couldn't find anything about this issue anywhere.

Do you have any idea what could be the problem?

I use Apache 2.2.9, Perl 5.10.0 and the latest version of Catalyst  
under Fedora.


Octavian



I'm guessing you've got your cat app rooted/deployed on '/' and are  
using FastGCI (from your other thread)?


If so then I think you need something like this in the config:

Alias /server-status /server-status
Alias / /path/to/fcgi

--
ash
___
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] Bad gateway error

2009-05-02 Thread Ash Berlin


On 2 May 2009, at 10:31, Octavian Râşniţă wrote:


Hi,

In Catalyst::Manual::Cookbook I read

  # 502 is a Bad Gateway error, and will occur if the backend  
server is down
  # This allows us to display a friendly static page that says  
down for

  # maintenance
  Alias /_errors /var/www/MyApp/root/error-pages
  ErrorDocument 502 /_errors/502.html
...

I've configured Apache this way, but if I stop the external Catalyst  
fastcgi app, instead of giving this HTTP error, it gives a 500  
error, and in the logs I find:


[Sat May 02 12:24:23 2009] [error] [client 89.122.248.135] (2)No  
such file or directory: FastCGI: failed to connect to server /tmp/ 
tb.fcgi: connect() failed
[Sat May 02 12:24:23 2009] [error] [client 89.122.248.135] FastCGI:  
incomplete headers (0 bytes) received from server /tmp/tb.fcgi


Do I need to do something more to make Apache give the 502 error?

Thank you.

Octavian


Then the Cookbook is wrong. I've never seen anything but a 500 error  
from any web server I've used.



___
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] Announce: Test::WWW::Mechanize::Catalyst 0.51

2009-03-16 Thread Ash Berlin
New version released that closes a few rt.cpan bugs and fixed a few  
issues I was having with CATALYST_SERVER.


0.51 Mon Mar 16 10:00 GMT 2009
 - Doc updates from thejester
 - User agent fixes from ANDREMAR
 - Fix bug where redirect was followed on a 500 response
 - All remote requests (i.e. CATALYST_SERVER env var) now use our  
own
   mechanize object, rather than an unconfigurable one from  
Catalyst:Test



-ash

___
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: OT: JS no longer sucks, (was Catalyst - any good AJAX tutes?)

2009-03-08 Thread Ash Berlin


On 8 Mar 2009, at 15:18, Aristotle Pagaltzis wrote:


* Ashley a...@sedition.com [2009-03-07 22:20]:

I used to feel the same about JS. The language itself has improved


Objection:

* http://fishbowl.pastiche.org/2009/02/20/the_dom_stigma/

When recommending jQuery to co-workers, friends, random
passers-by and the occasional hobo (as I have been wont to do
recently) I have tended to summarize its merit as “it makes
Javascript not suck.” Which is rubbish. Javascript has always
been perfectly cromulent. What jQuery does is make the DOM API
not suck.


Regards,
--
Aristotle Pagaltzis // http://plasmasturm.org/


Counter-objection: The DOM is not the JS language. 
___

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] RFC: New to Catalyst questions

2009-02-17 Thread Ash Berlin


On 17 Feb 2009, at 11:34, Bjørn-Helge Mevik wrote:


Jay Kuri wrote:


To that end I'm soliciting your thoughts on things that you found
particularly hard to get a grip on when you started using catalyst.
(or that you are currently having trouble with)


My biggest problem was how to handle the Norwegian characters (æøå) in
an app with MySql, DBIx::Class, TT and mod_perl.  use Catalyst
qw/Unicode/ only solves the TT and mod_perl side of the pipeline.  I
finally ended up with (IMHO) a cludge: adding on_connect_do = [ set
character_set_client = 'utf8', ] to the connect_info.  It only works
as long as the internal coding in Perl happens to be utf8.


http://search.cpan.org/~capttofu/DBD-mysql-4.010/lib/DBD/mysql.pm#mysql_enable_utf8 
 for a less kludgy way





I also had problems finding out how to create more comples FormFu
forms, with respect to layout, types of objects, and constraints.  The
main problem was that the documentation is (IMHO) scarce and scattered
over a large number of files.  (This is arguably a FormFu problem, but
FormFu is important for Catalyst applications. :-)



This is generally the problem with any such scaffold - they are fine  
until they aren't. You either make them simple to use and learn, or  
possible to extend how you want. Not both.


-ash
___
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] Announce: Test:WWW::Mechanize::Catalyst 0.50

2009-02-17 Thread Ash Berlin

All,

After a little time of CPAN somking the dev release and having no  
failures, and a few people saying it still works, its time for a  
proper release.


Winging its way through the intertubes of PAUSE and your CPAN mirrors  
are the following changes:


0.50 Tue Feb 17 09:12 GMT 2009
 - Remove warning in HTTP::Cookies
 - Call BUILDALL

0.50_2 Thur Feb 12 09:47 GMT 2009
 - Make t/multi_content_type.t handle case when server cant be  
started,

   which is almost always due to port in use.

0.50_1 Thur Feb 5 09:02 GMT 2009
 - App classname no longer has to be passed to import:
$m = T::W::M::C-new(catalyst_app = 'Catty')
   now works.
 - Can now use TWMC two test two different apps in the same perl
   interpreter due to the above change
 - Removed Test::WWW::Mechanize::Catalyst::Aux package as it  
isn't needed

   any more
 - Add 'host' accessor for white-label testing
 - Moosification
 - Can now test against remote CATALYST_SERVER without having to  
load the

   app class

If you are desperate to try it out earlier, download it from 
http://perlitist.com/static/Test-WWW-Mechanize-Catalyst-0.50.tar.gz

If there are any problems - tough you should have tested the dev  
release. A.K.A failing test cases welcome.


-ash

___
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] Announce: Testers wanted for Test::WWW::Mechanize::Catalyst

2009-02-06 Thread Ash Berlin

All,

I've taken over maint of TWMC and fixed the bug that the lastest  
WWW::Mechanize/LWP introduced, and made a few changes:


Revision history for Perl module Test::WWW::Mechanize::Catalyst:

0.50_1 Thur Feb 5 09:02 GMT 2008
- App classname no longer has to be passed to import:
   $m = T::W::M::C-new(catalyst_app = 'Catty')
  now works.
- Can now use TWMC two test two different apps in the same perl
  interpreter due to the above change
- Removed Test::WWW::Mechanize::Catalyst::Aux package as it isn't  
needed

  any more
- Add 'host' accessor for white-label testing
- Moosification
- Can now test against remote CATALYST_SERVER without having to  
load the

  app class

Please run against your test suites, particularly if you subclass TWMC  
in any ways. Since mst hasn't been about yet to give me PAUSE  
permissions to upload the 0.50_1 to cpan, its here:


 http://perlitist.com/static/dump/Test-WWW-Mechanize-Catalyst-0.50_1.tar.gz

-ash



___
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] create model

2009-01-30 Thread Ash Berlin


On 30 Jan 2009, at 21:40, gdewitt wrote:



Hi, I am using Catalyst, DBIx and postrges.  My tables have primary  
keys.

When you create a primary key in postres a unique index is implicitly
created as well.  So the majority of my tables have a constraint  
that looks

like this:

 CONSTRAINT table_pkey PRIMARY KEY (id)

I use catalyst to create my DBIx table definitions like this:

create.pl model MyModel 

The resulting DBIx table definitions reflect the primary key as well  
as the

unique constraint like this:

__PACKAGE__-set_primary_key(id);
__PACKAGE__-add_unique_constraint(table_pkey, [id]);

So if I write a query like this:

   my $result = $c-model('Schema::Table')-find( 'x' );

it results in the following SQL:

SELECT x,y,z FROM table me WHERE (  ( me.id = 'x' ) OR ( me.id =  
'x' )  );


This is happening because the 'find' function checks all the unique
constraints on the table, and in this case there are 2 ('primary' :  
'id' and

'table_pkey' : 'id')

I can get around this by writing my query like this:

   my $result = $c-model('Schema::Table')-find( { 'id'= 'x' }, {
'key'='primary' } );

But that is a pain.

Does anyone know a way that I can stop the 2nd unique constraint:

__PACKAGE__-add_unique_constraint(table_pkey, [id]);

from being generated in my table definition files?



simple. Ignore the fact that Pg created a unique index to go with the  
primary key - you created just a primary key, what Pg does is  
irrelevant.


i.e. get rid of the add_unique_constraint. That is only needed if you  
explicitly create (and want to search on) a subsequent unique  
constraint.


-ash

___
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] Detach won't detach?

2009-01-26 Thread Ash Berlin


On 26 Jan 2009, at 18:56, koniczynek wrote:


Hello Everyone,

I am trying to accomplish what seems to be impossible. There is a
controller, and inside this controller there are 3 methods:
- auto
- do_something
- end

In auto I am testing if user is logged in, if so I am detaching to the
do_something function, if not, I am redirecting to the / In end  
function

there is nothing at this point. The code looks somehow like this:

sub auto :Private {
 my ( $self, $c ) = @_;

 $c-log-debug('action start');
 if ( ! user_logged_in) {
   $c-redirect( $c-req-base );
 } else {
   $c-detach( $c-action-{name} );
 }
 $c-log-debug('action end');
}


detach in auto does not detach/stop processing the entire request,  
just the chain of auto commands.


To stop the request from in auto you need to return a false value. I'm  
fairly sure this is documented somewhere - cant look now as i'm on a  
painfully slow link


FWIW, I'd personally do this with chained actions, but its your choice.

-ash

___
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] Large static files behind Authorisation

2009-01-04 Thread Ash Berlin


On 4 Jan 2009, at 13:50, Ash Berlin wrote:



On 4 Jan 2009, at 08:48, Trevor Phillips wrote:

I'm working on a Catalyst application, and one of the requirements  
is to deliver large-ish files to authorised users only. I'm a bit  
wary about passing through large files in a framework I don't know  
the intricacies of, since a mishandled large file can explode  
memory usage of a daemon. However, the usual let Apache/proxy  
handle it solution bypasses the required Authorisation phase.


I'm currently trying to use Catalyst::Plugin::Static::Simple, which  
has a documented function serve_static_file to serve a static file  
from a Controller. However, I am getting an error as the TT View is  
still trying to apply a default template.


Is there an easy way to turn off the TT View, and have the file  
properly treated as static content in an efficient manner by  
Static::Simple?


My usual solution to this problem would be to implement  
Authentication as a mod_perl Access handler over static content,  
but the host provider won't give access to random mod_perl libs -  
and I'm quite happy with Catalyst's Auth infrastructure for  
everything else...


Thanks...



(Not terribly useful to you since I guess you are using Apache,  
but:) what I'd do here is make use of Lighttpd's X-SendFile response  
header: http://blog.lighttpd.net/articles/2006/07/02/x-sendfile


I'm sure nginx has something similar, but as far as I'm aware apache  
doesn't


-ash



At least not as part of the core distribution anyway: 
http://tn123.ath.cx/mod_xsendfile/

___
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] Large static files behind Authorisation

2009-01-04 Thread Ash Berlin


On 4 Jan 2009, at 08:48, Trevor Phillips wrote:

I'm working on a Catalyst application, and one of the requirements  
is to deliver large-ish files to authorised users only. I'm a bit  
wary about passing through large files in a framework I don't know  
the intricacies of, since a mishandled large file can explode memory  
usage of a daemon. However, the usual let Apache/proxy handle it  
solution bypasses the required Authorisation phase.


I'm currently trying to use Catalyst::Plugin::Static::Simple, which  
has a documented function serve_static_file to serve a static file  
from a Controller. However, I am getting an error as the TT View is  
still trying to apply a default template.


Is there an easy way to turn off the TT View, and have the file  
properly treated as static content in an efficient manner by  
Static::Simple?


My usual solution to this problem would be to implement  
Authentication as a mod_perl Access handler over static content, but  
the host provider won't give access to random mod_perl libs - and  
I'm quite happy with Catalyst's Auth infrastructure for everything  
else...


Thanks...



(Not terribly useful to you since I guess you are using Apache, but:)  
what I'd do here is make use of Lighttpd's X-SendFile response header: http://blog.lighttpd.net/articles/2006/07/02/x-sendfile


I'm sure nginx has something similar, but as far as I'm aware apache  
doesn't


-ash

___
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] Best practice for database connections, where $c is not available?

2008-12-31 Thread Ash Berlin


On 31 Dec 2008, at 15:37, Oliver Charles wrote:


Hi,

This has hit me a few times, and I've just encountered it again, so I
thought it would be good to ask those wiser than I :)

There have been a few times where I could do with querying the
database (which I'd normally do through $c-model), but this is not
available. For example, I've added the option for users to specify how
to display dates on our website, through a variety of formats. I
thought the best way to do this, would be using a Template Toolkit
plugin:

   [% USE user_date %]
   The date is [% user_date.format(some_date) %].

However, this plugin needs to access the user preferences model
($c-model('UserPreference')-date_format($user)). Should I be
instantiating this model (the Catalyst model is a very lightweight
wrapper around a non-catalyst specific model) - or is there a better
option?

- Ollie




The way I do this is by overriding template_vars in my View:TT (which  
has $c available) to provide format_date and format_datetime subs/ 
closures (I just let the user specify a TZ, but the idea is the same):


sub template_vars {
my ($self, $c) = @_;

return (
$self-NEXT::template_vars($c),
format_datetime = sub { $self-format_datetime($c, @_) },
format_date = sub { $self-format_date($c, @_) },
);
};

sub format_datetime {
my ($self, $c, $date) = @_;
return unless $date;

if ($c-user  $c-user-timezone) {
  $date-set_time_zone('UTC');
  $date-set_time_zone($c-user-timezone);
}

my $str = $date-strftime(%e %B %Y, %R);
$str =~ s/^ //;
return $str;
}


___
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] need to patch Test::WWW::Mechanize::Catalyst

2008-11-19 Thread Ash Berlin


On 19 Nov 2008, at 20:21, Jason Gottshall wrote:


My recent patch to 5.80 trunk (svn rev 8612) enables the setting of a
default virtual hostname via import:

 use Catalyst::Test 'MyApp', { default_host = 'virtual.com' };

Based on my reading of the Test::WWW::Mech::Catalyst source, some  
minor

changes would need to be made there in order to use the same semantics
with Mech::Cat. Should I try to patch this myself, or is there a  
maintainer out there who can make it happen?


Thanks!
Jason

--
Jason Gottshall
[EMAIL PROTECTED]



The maintainer is Léon Brocard. But send a patch and make his life  
easier :)

___
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: Off Topic: Re: [Catalyst] [Announce] MojoMojo 0.999021 has been released to CPAN

2008-11-02 Thread Ash Berlin


On 2 Nov 2008, at 08:10, Ali M. wrote:


There is another project by Sebastien Riedel, and its called Mojo,
just one Mojo.

I think the people working on MojoMojo, should contact Sebastien and
work out the naming thing, because it sometimes gets confusing
following the news about either.


best regards and good luck to both projects
ali




First Mojomojo CPAN release: 29 Aug 2007
First Mojo CPAN release: 24 Sep 2008.

Now which one is at fault do you suppose?



___
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: PDF creation in Catalyst?

2008-10-22 Thread Ash Berlin


On 22 Oct 2008, at 20:50, Aristotle Pagaltzis wrote:


* Kirby Krueger [EMAIL PROTECTED] [2008-10-22 20:20]:

Can someone give me those few lines? :-)


   sub MyApp::Controller::Root::renderview :  
ActionClass('RenderView') {}


   sub MyApp::Controller::Root::end : Private {
   my $self = shift;
   my ( $c ) = @_;
   $c-forward( '/renderview' );
   if ( $c-req-param( 'pdf' ) ) {
   my @pdf_cmd = Text::ParseWords::shellwords( $c-config- 
{ pdf_cmd } );

   $c-res-content_type( 'application/pdf' );
   $c-res-body( IPC::Filter::filter( $c-res-body,  
@pdf_cmd ) );

   }
   }

And in `myapp.conf`:

   pdf_cmd prince -i html -s prince.css -o - -

Yes, PrinceXML http://www.princexml.com/ costs $$$, *however*,
it renders HTML to PDF verbatim instead of requiring you to use
completely different stuff like FOP or LaTeX – which is an
especially big selling point if you’re looking to generate PDF
from a CMS-ish thing where users can enter HTML content. It also
supports pretty much all print-related CSS stuff, which includes
control over line breaks and the like, and also provides
proprietary CSS extensions to do things like page headers and
footers, page numbering, and so on. For us, the effort we avoided
of having to write PDF-specific code (the above lines are
literally the only PDF-related code in the app) and then maintain
it over more than made up for the price tag.




Sounds interesting - In fact so interesting i contemplated doing  
something similar a few months ago before decided i didn't have time  
due to major release in like 3 days time _



http://perlitist.com/static/talks/pdf_typesetting.pdf -- I even wrote  
a talk about it :)


(No i've not really got anywhere with the code since. I've spent about  
a total of 6 hours on it since I gave that talk)


-ash


___
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] [PATCH] [RFC] Override base URI

2008-10-10 Thread Ash Berlin


On 10 Oct 2008, at 19:21, Jason Kuri wrote:


I'd also love a way to callback from uri_for - but that's another
story and issue altogether.

Jay




Seen http://search.cpan.org/~rkitover/Catalyst-Plugin-SmartURI-0.029/lib/Catalyst/Plugin/SmartURI.pm 
 ?


___
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::Plugin::UploadProgress

2008-10-01 Thread Ash Berlin


On 1 Oct 2008, at 08:41, Stephan Jennewein wrote:


On Wednesday 01 October 2008 03:25:42 am Tomas Doran wrote:

On 1 Oct 2008, at 01:44, Stephan Jennewein wrote:

On Wednesday 01 October 2008 12:39:08 am Andy Grundman wrote:

What Catalyst engine are you using?  What you described sounds like
the behavior with the default HTTP engine.  If that's what you're
using, try enabling fork mode with -f.


I'm trying fastcgi with lighttpd. Does it work with
fastcgi, do I have to use one thread (at the moment i'm using 5)?


No, the issue is that it doesn't work _unless_ you're using multiple
threads.

Can you replicate this behavior with myapp_server.pl -f, or does this
only happen for you with lighty?



Ups, my first mail didn't arrive,  myapp_server.pl --fork works  
fine. With

lighty the javascript stuff appears after pressing the button, but the
filesize is -1 and so you don't see any progressbar.

Stephan


Hmmm I wonder if thats because lightly is processing the upload to a  
temp file itself? I've seen references to a similar upload progress  
thing built into lighttpd, but that might only be in svn/1.5 versions...


-ash

___
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::Response - send a file

2008-08-19 Thread Ash Berlin


On 19 Aug 2008, at 14:27, Dermot wrote:


2008/8/19 Carl Franks [EMAIL PROTECTED]:

2008/8/19 Dermot [EMAIL PROTECTED]:

sub downloadFile {

my ($name, $filepath) = @_;

my $length = (stat($filepath))[7];
my $res = $c-response;
$res-content_length($length);

$res-headers-({ 'Content-Disposition' =
attachment;filename=$name} ); # CODE ref error


Where did you get this syntax idea from? Since when has headers been  
returning a coderef? Go read the docs again: http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7014/lib/Catalyst/Response.pm#$res-%3Eheader


Fix the above headers you have, and use the snippet luke gave below



open my $filehandle, '', $filepath
  or die $!;

$c-response-body( $filehandle );






___
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] Squatting::On::Catalyst

2008-07-30 Thread Ash Berlin


On 30 Jul 2008, at 02:27, John Beppu wrote:




On Tue, Jul 29, 2008 at 5:21 AM, Daniel McBrearty [EMAIL PROTECTED] 
 wrote:

my 0.05 (possibly a bit OT) :

Off-topic or not, I think these are interesting and valid questions.

I looked previously at a few ways of adding forums etc to the site
using 3rd party code, indeed there are many possibilites (some perl,
some not)

The thing that was always a sticker for me was getting some kind of
logical integration, ie:

1. letting users keep existing member and login creds

Now that composition and embedding of web apps is becoming a  
reality, we have to start anticipating needs like this.  For  
example, the documentation for an app that's built to be embedded  
could state that:

It expects a user object to be in its session's u key.
The app will expect to be able to call the -name method on this  
user object.  (Some apps may want more...  others less...  this is  
just a hypothetical example.)
If that key is undef, the app will assume the current session is not  
in a logged in state.
 I think being up-front about login policy would be enough to share  
users across multiple web apps joined together as one cohesive unit.



I dont. Lets take the example of embedding a forum. It will most  
likely store its data in a DB of its own design. It will also quite  
likely have its own user table, and have FKs referencing that  
table see the problem? There's more to sharing users than just  
logging.


I can't really see any way around that other than on a case-by-case  
basis sadly. Someone please feel free to correct me.


-ash___
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] Auth tutorial merry-go-round

2008-07-07 Thread Ash Berlin

On 7 Jul 2008, at 09:40, Dermot wrote:


Hi,

I have been following the tutorial and am stuck in a loop. In my Root
controller I have the following

sub auto : Private {
  my ($self,$c) = @_;
  if ($c-controller eq $c-controller('Login')) {
   return 1;
  }
  if (!$c-user_exists) {
   $c-log-debug('***Root::auto User not found, forwarding to / 
login');

   $c-response-redirect($c-uri_for('/login'));
   return 0;
  }
# user found
  return 1;
}

In my Login controller I have

sub index :Path :Args(0) {
   my ( $self, $c ) = @_;

# Get the username and password from form
   my $username = $c-request-params-{username} || ;
   my $password = $c-request-params-{password} || ;

# If the username and password values were found in form
   if ($username  $password) {
   # Attempt to log the user in
   $c-log-debug(User=$username, Password=$password);
   if ($c-authenticate({ username = $username,password =
$password} ) ) {
# If successful, then let them use the application
   $c-log-debug(Login Success);
   $c-response-redirect($c-uri_for('/books/list'));
   return;
} else {
# Set an error message
   $c-stash-{error_msg} = Bad username or password.;
}
}
# If either of above don't work out, send to the login page
   $c-stash-{template} = 'login.tt2';
}


When i login I see these debug messages

[debug] Path is login
[debug] User=admin, Password=admin
[debug] Created session 0628e51d5825d7309fd64a2404dd907bbea0ae27
[debug] Login Success
...
. 
+---.
| Action |  
Time  |
+ 
+---+
| /auto  |  
0.000649s |
| /login/index   |  
0.032623s |

| /end
...
[debug] GET request for books/list from 127.0.0.1
[debug] Path is books/list
[debug] ***Root::auto User not found, forwarding to /login
[debug] Redirecting to http://localhost:3000/login;

So while $c-authenticate can see my login in my Login controller, it
can't in Root/auto !!!  Can anyone point tell where I am going wrong?
TIA,
Dp.




What session store and state modules are you using? I know this  
happens to me when I forget to load up memcached (which is the store  
module i'm using)


-ash


___
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: Private Chained Actions?

2008-06-22 Thread Ash Berlin


On 22 Jun 2008, at 18:56, Aristotle Pagaltzis wrote:


* Jonathan Rockway [EMAIL PROTECTED] [2008-06-22 15:35]:

* On Fri, Jun 20 2008, Aristotle Pagaltzis wrote:

That’s even uglier. Imagine there isn’t just `hello` but half
a dozen other methods all sharing the same setup. So the setup
code is one or two screens down the source file. Now when you
look at `hello` you have absolutely no indication whatsoever
that there might be other code running before it.


I guess. But this is Perl, there's never any indication of
anything. There's no indication that my function is receiving
arguments of a particular type.


Except, y’know, the code in the method body that’s *right there*.


There's no indication that my function throws exceptions.


I hope you’re not using exceptions for standard control flow.


There's no indication that use Foo has side effects.


Yes, and that causes no end of intermittent trouble. Ovid had
some recent posts on use.perl about getting bitten hard.


Even in Catalyst, there is a ton of implicit behavior. There is
no indication that begin/end/auto applies to my action (at
least until the action runs).


Except, method modifiers are explicit, not implicit – just
defined at a distance, the way you wrote it. In contrast, if you
use Catalyst you know that there may always be begin/end/auto
actions.

I mean, if you have to write out your intent to modify a method
anyway, why not also put that next to the code that will actually
be affected?

I recommend Schwern’s recent “Skimmable Code” talk.

Note well, I’m not arguing against method modifiers in general.

Regards,


FWIW I also think that the method modifiers makes it harder to skim  
the code, since most of the time you find the end action then look up  
the chain to see what is happening (at least I do) - method modifiers  
make this a much harder thing to find.


-ash


___
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] script/myapp_fastcgi.pl -d vs. nohup script/myapp_fasctgi.pl

2008-06-06 Thread Ash Berlin


On 6 Jun 2008, at 14:50, Mitch Jackson wrote:


On Fri, Jun 6, 2008 at 4:22 AM, Dan Dascalescu
[EMAIL PROTECTED] wrote:

Works as expected. Even after I log out (without running nohup), the
app correctly logs requests to myapp.stderr. I'm writing a tutorial  
on

Catalyst deployment with lighttpd and fastcgi at
http://catwiki.toeat.com/gettingstarted/howtos/deploy/ 
lighttpd_fastcgi

(please feel free to amend) and want to get a good understanding of
this issue.


Your tutorial is informative.  It's nice to see a non-apache
deployment guide.  When deploying under apache, the web server is
easily configured to deliver static content without asking the fastcgi
process to do it.  Is that possible with this lighttpd configuration?

e.g. myapp.com/static gets served directly by lighttpd, while all
other requests go through the catalyst app.

/Mitchell K. Jackson



http://perlitist.com/articles/catalyst-with-lighttpd

___
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] untainting utf8 text for db

2008-06-05 Thread Ash Berlin


On 5 Jun 2008, at 19:05, Daniel McBrearty wrote:


database contains text fields which can be in any language and contain
any text and punctuation

1. I am getting params back via a web form to create new records. What
do I do to validate input (apart from length check)?

2. I want to take a param and do a like(%$param%) search returning
matching records. How do I protect this?


You mean foo LIKE '%$param%'  and its done by

$rs-search({ col = { -like = %$param% } })

-ash

___
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] C::P::UploadProgress

2008-05-14 Thread Ash Berlin

On 14 May 2008, at 15:32, Octavian Rasnita wrote:


Hi,

Can C::P::UploadProgress be made to work under Windows?
I've seen that it requires C::P::Cache::FastMmap and this module  
can't be installed under Windows, even after installing  
Cache::FastMmap::WithWin32.


Thank you.

Octavian



Doesn't work how? Build errors? Just plain doesn't work?

___
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] $row-copy causing exit from controller(!)

2008-05-01 Thread Ash Berlin


On 1 May 2008, at 13:33, Ash Berlin wrote:



On 1 May 2008, at 13:25, Jonathan Rockway wrote:


* On Thu, May 01 2008, Paul Makepeace wrote:
I'm seeing something exceedingly odd: copying data causing a  
premature

return from the controller, like a detach(),

  foreach my $table (@chart_related_tables) {
my $rs = $ds-resultset($table);
warn copying $table for , $new_chart-uid;
for my $row ($rs-search({web_chart_spec_uid = $chart- 
uid})) {

  warn ..row , $row-web_chart_spec_uid, $row;
  $row-copy({web_chart_spec_uid = $new_chart-uid});  #  
XXX

}
#$_-copy({web_chart_spec_uid = $new_chart-uid})
#for $rs-search({web_chart_spec_uid = $chart-uid});
die cloned, $new_chart-uid;
  }



Is copy throwing an exception?  Are you using an old version of
stacktrace?

If yes and yes: upgrade StackTrace (it eats exceptions)
If no and no: something is horribly wrong (perl -d may help)
If yes and no: see above.

I have a feeling it's the first one.  Another possibility is that  
copy

is last-ing out of itself.


If also occasionally seen exceptions disappear without stack trace  
one. Its a right pain to track down what causes it (lots of source  
diving and perl -d)


er... 'I've also  stack trace plugin'

___
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] So, what do we want in the -next- book?

2008-04-04 Thread Ash Berlin

On 4 Apr 2008, at 13:17, Kieren Diment wrote:



On 4 Apr 2008, at 23:01, Ian Sillitoe wrote:


[...] Or like others have suggested, a cookbook with a large  
variety of

useful examples showing best practices for different situations.



That's exactly what I would like to see. I got the first book  
(thanks!)

and would buy such a cookbook immediately.



Seconded... and, like one of the previous posters, I've just emailed
(proposals@) O'Reilly (.com) making a case for Catalyst Cookbook/Best
Practices.



Thanks for that.  The next book is only going to happen if a proper  
publisher ponies up a proper advance, contract and co.


There is need for discussion though.  i had a look at the source for  
Catalyst::Model::File the other day, and while what it does is  
pretty easy to understand, I don't really understand why moose is in  
there for example.  So what I'm saying is things like common idioms  
you'll see in catalyst model and controller code.


Moose is in there for InstancePerContext, so that you can do:

$c-model('File')-cd('foo/bar');
$c-model('File'')-slurp('file.txt');

to access the contents of $configured_root_dir/foo/bar/file.txt.

I could have written the ACCEPT_CONTEXT sub myself, but DRY and all  
that.


-ash

___
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] sqlite3

2008-03-19 Thread Ash Berlin


On 19 Mar 2008, at 12:39, gautam gupta wrote:


Hi All,
is it mandatory to use sqlite3 in catalyst ?
--  
Not by a long shot. Catalyst also doesn't talk to a database itself.  
And DBIx::Class to which I'm guessing you are talking about can use  
almost any database that perl can talk to.


-ash___
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] bypassing password authentication

2008-03-11 Thread Ash Berlin


On 11 Mar 2008, at 18:33, Jim Spath wrote:

I'm currently using password authentication in a Catalyst app, but  
would like to implement a way to log in as a particular user,  
without knowing the password.  (Please don't respond with don't do  
this... I'm aware of the security ramifications of this kind of  
functionality).


I'll already have all the information on the user, except for their  
password, since we hash the password before storing it.


The end goal would be to have an authenticated session.

Thanks!
- Jim



*WARNING* might not work with the new auth framework. But here's some  
code:


sub login_as : Local Args(1) {
  my ($self, $c, $user_id) = @_;

  $c-res-redirect($c-uri_for()) if $user_id =~ /\D/;

  my $user = $c-model('DBIC::User')-find($user_id); 

  if ($user) {
$c-set_authenticated($c-find_user({ id = $user-email}));
$c-flash(message = Logged in as @{[$user-email]});
  }

  return $c-res-redirect('/');
}


___
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] CGI.pm and Catalyst?

2008-03-07 Thread Ash Berlin

On 7 Mar 2008, at 09:03, Alex Povolotsky wrote:


Martin Ellison wrote:
Is there anything attached to Catalyst similar to the CGI.pm  
module? That is, creating the HTML by a series of procedure calls  
rather than by instantiating a template?


Or is there some way to link up the existing CGI module? $c- 
response-body(ul(li(q{hello}), li(q{world} ?


Or is it not a good idea?

I couldn't find anything from a search, so excuse me please if this  
has been covered before.


Creating HTML inside the code is the best way to make unreadable,  
unmaintainable program with mysterious errors.


Alex.


There's always Template::Declare[0] which lets you do

template simple = sub { html { head {} body { p {'Hello, world wide  
web!'} } } };
And keep the html in a sensible place (i.e. not in your controllers).  
Never used it but i know Jon Rockway has so perhaps he can comment on  
how useful it actually is.


-ash
[0]: 
http://search.cpan.org/~sartak/Template-Declare-0.28/lib/Template/Declare.pm___
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] Error from Session plugin

2008-03-04 Thread Ash Berlin

Right then.

I've been seeing this error on and off for a while when under the dev  
server, often caused when I'm debugging (perl -d) and restart the  
server mid-request. Somehow the browser gets its knickers in a twist  
or something. Error is:


Tried to set invalid session ID  
'5c5ad62b4e9273eb1d5cba69ef4f9e33eeb6ed66, yourpreferences_session'

 at 

Anyway, why are we dying when an invalid session ID is encountered?  
Why not log the error and pretend exactly like there was no session id  
found at all? Thoughts?


-ash

Oh, and I'm not sure what causing it exactly, but somehow the session  
id is getting messed up in the cookie:


  DB10 x $c-get_session_id
0  '5c5ad62b4e9273eb1d5cba69ef4f9e33eeb6ed66, yourpreferences_session'

  DB13 x $c-request-cookies
0  HASH(0x44240c0)
   'yourpreferences_session' = CGI::Simple::Cookie=HASH(0x4427700)
  'name' = 'yourpreferences_session'
  'path' = '/'
  'value' = ARRAY(0x44275d4)
 0  '5c5ad62b4e9273eb1d5cba69ef4f9e33eeb6ed66,  
yourpreferences_session'






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

2008-03-02 Thread Ash Berlin


On 2 Mar 2008, at 03:50, Jonathan Rockway wrote:


In the second case, it's just a bug in the Session::Store::Cache store
that can be fixed with the addition of a backend_expires configuration
key, probably set to never by default.


Not quite true. It would look like it fixes it for most cases. A cache  
is just a cache. Don't rely on them (particularly memcahced) to keep  
data around until you told it you would like it to expire at - there  
is no guarantee of this happening, especially under heavy load.


Ash

___
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::Controller::REST based controllers

2008-02-26 Thread Ash Berlin


On 26 Feb 2008, at 21:43, Damon Snyder wrote:


Hi Ash, Everyone,
Thanks, that seemed to move me along further. I'm still unable to  
get the content part of the POST. I'm able to send the username and  
password through, but for some reason my controller gets empty  
content. Here is the request I've formed:


# with mech object
my $t1 = Test::WWW::Mechanize::Catalyst-new;
$t1-add_header( 'Content-type' = 'text/x-json' );

$req = new HTTP::Request (POST, http://localhost/rest/something;,
['X-Username' = 'x', 
'X-Password' = 'x'],
to_json({ stuff })
);
$res = $t1-request( $req );
### fails with my Bad Request
 end


In the above request, username and password are processed  
successfully, but no content is received.  I look for the content in  
$c-req-data.


Here is the analogous LWP request:

# LWP object
$ua = new LWP::UserAgent;
$req = new HTTP::Request (POST, http://localhost:3000/rest/something 
,

['X-Username' = 'x', 
'X-Password' = 'x'],
to_json({ stuff })
);
$req-content_type('text/x-json');
$res = $ua-request($req);
### successfully creates the object
 end



Why not just change $ua-request there to $t1-request in your last  
snippet (i.e. set content_type on the request object, not on the mech  
object. It probably ignores it when you pass a Request object)




___
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] newbie - syntax error

2008-02-22 Thread Ash Berlin


On 22 Feb 2008, at 14:47, Dermot wrote:


Hi,

I hope my first question isn't too dumb.

In the routine below I want to test if the method is being called  
with an additional parameters. So if the uri is ~/list/2
return only the files with user=id. If no parameter is called (~/ 
list) return all files. The functions works as it is but obviously I  
can not recall all files.


Without the comments the list function returns a syntax error. In  
fact I can also get the same error is I do:


my $files;
 $files : Stashed = $c-model('ImagesDB::Files')-search({user =  
$id});



use base 'Catalyst::Controller::BindLex'
...
sub list : Local {
 my ($self, $c, $id) = @_;
 #my $files;
 #if (defined($id)) {
my $files : Stashed = $c-model('ImagesDB::Files')- 
search({user = $id});

 #}
 #else {
 #  my $files : Stashed = $c-model('ImagesDB::Files');
 #}
 $c-stash-{template} = 'files/list.tt2';
}


Can anyone give me a pointer? Thanx.
Dp.



my $files : Stashed;

if (...) {
  $files = ...
} else {
  $files = 
}

BindLex cant cope when you declare the same variable ($files) multiple  
times in different scopes. ___
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] Development environments and performance

2008-01-16 Thread Ash Berlin


On Jan 16, 2008, at 5:51 PM, [EMAIL PROTECTED] wrote:


John Goulah [EMAIL PROTECTED] wrote on 01/16/2008 11:13:06 AM:





Why wouldn't you just use the standalone server bundled with
Catalyst?  Fcgi is great for production, but the processes are
fairly thick memory wise, so having instances for each developer
could be an issue.   We use the cat server for development and works
fine for about 5-10 people at any given time on a modest box (4G ram)


Could be a massive assumption,  but usually when you go through the  
cost
(time, cap) of building out a dev server environment you want it to  
mirror

your production servers as much as possible so that you spend time
squishing bugs that may exist in your production environment -- not  
some

other different environment.  If they are using FCGI in prod it makes
perfect sense to do so in dev.  Why battle bugs that may be  
introduced on
the standalone server, or worse miss bugs that _do_ affect your  
production

environment because you are developing on a different environment?

-Wade



No, thats a testing environment. Dev is usually very different  
process. At least at every place I've worked at.


___
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: utf8 / pg double encoding problem

2008-01-06 Thread Ash Berlin
Never trust dumper or printing to your terminal to tell if something  
is in UTF8 or not. Terminals try to be too smart.


This is what Devel::Peek is for. Use it. Trust that.

On Jan 6, 2008, at 1:08 PM, Aristotle Pagaltzis wrote:


* Daniel McBrearty [EMAIL PROTECTED] [2008-01-06 13:30]:

On Jan 6, 2008 1:29 AM, Aristotle Pagaltzis [EMAIL PROTECTED] wrote:

* Daniel McBrearty [EMAIL PROTECTED] [2008-01-06 00:00]:

[debug] abçöeü
[debug] $VAR1 = ab\x{c3}\x{a7}\x{c3}\x{b6}e\x{c3}\x{bc};
[debug] it's UTF8!


Err, why doesn't Dumper say ab\x{e7}\x{f6}e\x{fc}? Strange
that the first line looks correct, though.


because it is utf8? shouldn't it be?


What Dumper outputs is the UTF-8 byte sequence; but the next line
says that the Unicode flag is set, so this is a character string,
not a byte string. So it’s already double-encoded.

I don’t understand why the first line looks correct though.

In any case the raw HTTP request that leads to all this would be
interesting.

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/



___
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] utf8 / pg double encoding problem

2008-01-05 Thread Ash Berlin


On Jan 5, 2008, at 11:28 PM, Andrew Rodland wrote:


On Saturday 05 January 2008 04:54:59 pm Daniel McBrearty wrote:
well I'm damned, I thought I had this stuff working squeaky clean.  
But

I was wrong. I actually had two bugs cancelling each other out -
usually.
[snip]
--' [debug] abçöeü
[debug] $VAR1 = ab\x{c3}\x{a7}\x{c3}\x{b6}e\x{c3}\x{bc};
[debug] it's UTF8!

Looks like the problem is here... the utf8 flag is on, indicating  
that $edit
is a string of characters, rather than bytes -- but the dumper  
output seems
to show that these characters correspond to UTF-8 encoded bytes,  
instead of
the actual characters of the data -- meaning that the bytes actually  
stored
in the string are along the lines of ab\x{c3}\x{83}\x{c2}\x{a7}...  
not
good. Somewhere, your data got the utf8 flag set by assumption  
instead of
by decoding. $edit = decode(UTF-8, $edit) should clear it up,  
although

finding the original problem is probably a better idea. :)

Andrew


ISTR that last time I looked at C::P::Unicode, it did things in a  
manner that I didn't like. I can't remember if this is because i  
thought it was wrong or if it just didn't work right for me, but maybe  
some more eyes on C::P::Unicode might be a good idea.


-ash
___
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] Problem with Catalyst::Plugin::I18N using UTF-8

2007-12-21 Thread Ash Berlin
I looked at the Unicode plugin and I believe it most likely will  
break the
integration against our LDAP backend, for example when searching for  
names
containing characters like æøå. (OpenLDAP requires its input as  
UTF-8.)


In addition, this is bad if your code (or templates) contains  
special unicode

characters; which then becomes double-encoded.


The Unicode plugin looks like could be useful if you are migrating  
old data or

an old website that didn't use UTF-8 before. It is definitely not the
solution for me, as it means more data processing and might  
introduce new

bugs.


As I said in my first post, the solution (which works for me) was to  
turn off
the Decode parameter. This makes more sense to me now, since my mo/ 
po-files

are already in UTF-8 and don't need to be converted.


Right, I think there is some confusion on your part as to what is the  
proper way of handling unicode in perl.


(The basic problem is that perl's magic internal representation just  
happens to look exactly like UTF-8 plus a magic flag. Longer  
description below)



First off, you need to understand the difference between characters  
and bytes/octets


æøå is a character string
\303\246\303\270\303\245 is a utf8 byte sequence != a string

\303\246\303\270\303\245 + UTF8 flag = æøå perl string

From perldoc perlunicode

  ... What the UTF8 flag means is  
that the
   sequence of octets in the representation of the scalar is  
the
   sequence of UTF−8 encoded code points of the characters  
of a
   string.  The UTF8 flag being off means that each octet  
in this
   representation encodes a single character with code point  
0..255
   within the string.  Perl's Unicode model is not to use  
UTF-ˆ’8 until

   it is absolutely necessary.

The problem lies in that you can have two strings of data that look  
the same when you print them, lets take the example you gave of æøå.  
If this data comes from a source that doesn't set the UTF8 flag, the  
SV (scalar value - where perl internals store scalars) will have the  
characters of


  \303\246\303\270\303\245

However since non of these code points are above 255 (they cant be as  
each character = one byte) perl thinks this isn't a utf8 string.  
Devel::Peek is a good module for this:


  DB3 x $foo = \303\246\303\270\303\245
0  'æøå'
  DB4 Dump($foo)
SV = PV(0x918d08) at 0x926848
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x5ace10 \303\246\303\270\303\245\0
  CUR = 6
  LEN = 8

It looks right, but wait - LEN = 8. Perl thinks its a string of 8  
characters that our terminal just happens to print right.


Compare that with:

  DB6 x $bar = \x{E6}\x{F8}\x{E5}
0  '???'
  DB7 Dump($bar)
SV = PV(0x9398dc) at 0x9306b4
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x5acbf0 \346\370\345\0
  CUR = 3
  LEN = 4

Still not quite what we want...

  DB10 Dump($baz = Encode::decode(utf8, $foo))
SV = PVMG(0x974e20) at 0x974168
  REFCNT = 1
  FLAGS = (POK,pPOK,UTF8)
  IV = 0
  NV = 0
  PV = 0x656d30 \303\246\303\270\303\245\0 [UTF8  
\x{e6}\x{f8}\x{e5}]

  CUR = 6
  LEN = 8
  MAGIC = 0x6575e0
MG_VIRTUAL = PL_vtbl_utf8
MG_TYPE = PERL_MAGIC_utf8(w)
MG_LEN = 3


Right, *now* $baz is a proper unicode string that perl knows is a  
string of UTF8 *characters*




To relate this to your problem, you are getting some of your data  
double encoded because the data (from the perl module you are using to  
access your LDAP server) is returning a byte sequence that perl  
doesn't know is supposed to be UTF8.


The answer is to do Encode::decode(utf8, $utf8_byte_sequence)
 on all the data coming back from your LDAP server (or to find the  
right option to make the module you are using do it).


Any of this make any sense?


PS. It seems that even Apple has problems with UTF8. In writing this  
email I saved it in my drafts folder. When I came back to edit it  
again, the non-ascii characters got fluffed up. Fun eh?




___
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] DBIC ResultSet - what columns in it?

2007-12-19 Thread Ash Berlin


On 19 Dec 2007, at 05:09, Silvio Almeida wrote:


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

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


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


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



Silvio


As an indication, if you are using a method or accessor that starts  
with '_' then you are doing something wrong - underscore implies it is  
'private'.


Also the string you are passing to $c-model looks wrong... I'd expect  
there to be a MyDB:: or similar in front of that.


Ash


___
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] Input/Parameter Checks

2007-12-13 Thread Ash Berlin


On 13 Dec 2007, at 22:43, Jonathan Rockway wrote:



On Thu, 2007-12-13 at 21:53 +, Ash Berlin wrote:

2) avoiding SQL injection

This is simple. never interpolate *anything* from the user into SQL.
Use placeholders. Or better yet use an ORM such as DBIx::Class.


Be mindful of these cases, though:

 # 1
 my $col = $req-params-{col};
 $rs-search({}, { order_by = \$col DESC });



Agreed. I never do anything like that anyways ;)


 # 2
 my $user = $rs-create({
 is_admin = 0,
 username = $c-req-param('username'),
 });


This comes under never interpolate *anything* from the user into SQL.




It's easy to write insecure code even with advanced ORMs and  
frameworks.

Just not quite as easy as it is in PHP :)

Regards,
Jonathan Rockway




___
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] Save as...

2007-11-09 Thread Ash Berlin

Octavian Rasnita wrote:

Hi,

I try to print a file to the browser using:

$c-res-content_type('Application/Octet-Stream');
$c-res-header(Content-Disposition = 
attachment;filename=\$file\);

# $c-res-header('Content-Length' = length($content));
$c-res-body($content);

If I try to save the file pressing enter on the link to download the 
file, the window that asks me if I want to save it appears, but after 
I press the Save button, nothing happends, and it doesn't ask me for 
the name of the file.


But if I right-click on that link and chose Save as... from the 
context menu, it always ask me immediately for the name of that file.


Can you tell me what other headers do I need to print, or what else 
should I need to do in order to be able to save the file by just 
clicking the link (pressing enter on it)?


Thanks.

Octavian


I do the following:

   $c-res-header('Content-disposition', qq{attachment; 
filename=$name - $date.pdf});

   $c-res-headers-content_type('application/pdf');
   $c-res-body($out);

The only difference I can see there is a space after the ';'

___
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] Beginner question: View directory

2007-11-08 Thread Ash Berlin

Dave Rolsky wrote:

On Thu, 8 Nov 2007, Kieren Diment wrote:

Good call, my mistake.  Goes to show that there's not usually much 
(or any) extra stuff that needs to be done in the View class.  I was 
actually struggling to think of code related things  (rather than 
config) which  you might want to put in there.   Personally I've 
always munged headers in the sub end : ActionClass(’RenderView’) {} 
subs (see perldoc Catalyst::Action::RenderView for details).


I have a few bits of code in my view class, but not much.

For the Mason view, I had subclass new() and chown() all the files 
created by the Mason Interp object to make things happy under 
mod_perl. Mason has this built-in to its mod_perl integration, but 
that doesn't get used with Catalyst.


I also have a method has_template_for_path() which does what it says. 
I call this from some controller auto() methods where the URI in 
question is basically static content that doesn't need a separate 
controller method.



-dave

Similarly, I setup subs that I always want aviabale in the TT stash, 
such as format_datetime (which formats a DateTime object according do 
the currently logged in user's prefernce.) I also assing VMethods to 
$Template::Whatever::SCALAR_OPS here, since this seems like the place 
that such code belonds.


-ash


___
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] New Catalyst site

2007-10-30 Thread Ash Berlin
Carl Johnstone wrote:
 I would like to announce that www.manchestereveningnews.co.uk has just 
 been relaunched using Catalyst and mod_perl.
 
 Further to my original email, we've now finished rolling out our Manchester 
 newspaper sites onto Catalyst.
 
   a.. Accrington Observer www.accringtonobserver.co.uk
   b.. The Asian News www.theasiannews.co.uk
   c.. Glossop Advertiser www.glossopadvertiser.co.uk
   d.. Heywood Advertiser www.heywoodadvertiser.co.uk
   e.. Macclesfield Express www.macclesfield-express.co.uk
   f.. Manchester Metro News www.metronews.co.uk
   g.. Middleton Guardian www.middletonguardian.co.uk
   h.. North East Manchester Advertiser www.nemadvertiser.co.uk
   i.. Oldham Advertiser www.oldhamadvertiser.co.uk
   j.. Prestwich Advertiser www.prestwichadvertiser.co.uk
   k.. Rochdale Observer www.rochdaleobserver.co.uk
   l.. Rossendale Free Press www.rossendalefreepress.co.uk
   m.. Salford Advertiser www.salfordadvertiser.co.uk
   n.. South Manchester Reporter www.southmanchesterreporter.co.uk
   o.. Stockport Express www.stockportexpress.co.uk
   p.. Tameside Advertiser www.tamesideadvertiser.co.uk
   q.. Wilmslow Express www.wilmslowexpress.co.uk
 
 Carl

Glad to hear it. But how many damn newspapers does one metropolis need?


___
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] Catalyst::Plugin::Prototype

2007-10-12 Thread Ash Berlin
Stefan Kühn wrote:
 The documentation of Catalyst::Plugin::Prototype is a rather thin.
 Only one example of a method is given:
[% c.prototype.observe_field( 'editor', uri, { 'update' = 'view' } ) %]
 
 Is it correct that Catalyst::Plugin::Prototype uses and that the
 methods can be determined from
perldoc Catalyst::Plugin::Prototype  ?
 
 Or how can i find it's methods?
 
 Stefan

Dont use this plugin. It is one of the more stupid plugins. The entirety
of the code is this:

package Catalyst::Plugin::Prototype;

use strict;
use base 'Class::Data::Inheritable';
use HTML::Prototype;

our $VERSION = '1.33';

__PACKAGE__-mk_classdata('prototype');
eval { require HTML::Prototype::Useful; };

if ( $@ ) {
__PACKAGE__-prototype( HTML::Prototype-new );
} else {
__PACKAGE__-prototype( HTML::Prototype::Useful-new );
}

Just create a HTML::Prototype yourself and be done with it if you want
to use Prototype.

-ash


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


Re: [Catalyst] Re: Encoding problem - ?fastcgi?

2007-10-08 Thread Ash Berlin
I'm also sending generated PDFs from my FastCGI bassed app. The only
difference between my setup and yours appears to be the use of
C::P::Unicode.

Works fine for me. Not very useful I'm affraid.

-ash

Richard Robinson wrote:
 On Mon, Oct 08, 2007 at 02:07:18PM +0200, A. Pagaltzis wrote:
 Hi Richard,

 did you ever get this sorted? Quoting in full since you seem to
 have been warnocked. I have no idea what to suggest but am
 curious about this issue as a matter of personal interest.
 
 Nice word, I hadn't met it before. Exactly - is no-one else doing this, or
 is everyone else doing it with no problem ?
 
 No, I haven't got any further, I'm kind of stuck on it. The workaround makes
 it go away for now  there are other things I need to be sorting out too, so
 I'm just kind of waiting for an idea to appear from somewhere ... 
 
 
 
 * Richard Robinson [EMAIL PROTECTED] [2007-09-20 20:15]:
 I got my all-singing all-dancing Catalyst app onto a proper
 server a few days ago. It's all going much better than I
 thought it might, a couple of friendly guinea-pigs, a fine crop
 of helpful comments, glitches getting spotted  fixed, a
 thriving TODO list ... and one problem which worries me - I
 prefer bugs to be in my code, because then I can fix them and
 end of story, but I don't think this is.

 There is a point where I send data out as a variety of other
 mime-types. This is either text, in a small range of iso-8859
 encodings (I work in utf8 internally, of course, so this is
 encoded specifically). or binary, generated from that text as a
 temporary file by external programs and read in from that. This
 is output with, eg,

 $c-res-content_type('application/pdf');
 $c-res-body($data);

 Developing  testing this on my machine at home, this works as
 it should. On the remote server, I can view the files directly,
 and they're as they should be; I can request the data through
 :3000 from script/appname_server.pl, and again, it's correct;
 but hand it out through script/appname_fastcgi.pl +
 mod_fastcgi/apache and it's broken; each single byte with the
 high bit set is replaced by a 0xC3 0xsomethingelse pair -
 it's been recoded into utf8, with values that assume it was
 Latin 1 to start with (regardless of anything I put in the
 Content-Type). Workaround is to replace the code above with a
 redirect to the temporary file, which then goes out through
 Static::Simple and arrives uncorrupted.

 The data leaves my code with the utf8 flag unset, and is
 handled properly by C::P::Unicode. So I think it must be in the
 fastcgi conversation ? Has anybody else seen this, or have any
 ideas ?  I can't see any changes in C::E::FastCGI.pm that offer
 any Clue, and I'm really not sure where to go next.

 System at home, where it doesn't happen, is Apache/2.0.54 with
 Catalyst modules from, I think, last January or thereabout (the
 new Debian stable caught me by suprise, bringing the home box
 up to date is going to be a big job  I have other things I'd
 rather be doing).  Remote system, where it does happen, is
 Apache/2.2.3 with cpan upgrade a few days ago. mod_fastcgi is
 the same on both (2.4.2)
 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/[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] Re: Catalyst Unicode woes ctd.

2007-10-07 Thread Ash Berlin
Simon Wilcox wrote:
 A. Pagaltzis wrote:
 I know I’m not very constructive here… but have I mentioned that
 TT2 sucks?
 
 It would, perhaps, have been a little more constructive if you had 
 recommended the alternative that you use that doesn't have these issues.
 
 Simon.
 

From the TT mailing list I have heard some good things about
Template::Alloy. It supports the syntax of TT2 and others, but does
things less stupidly.

Saying that I've never used it...

-ash

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