[Catalyst] Re: generating and redirecting to pdfs

2009-10-27 Thread Aristotle Pagaltzis
* Jason Galea li...@eightdegrees.com.au [2009-10-26 23:45]:
 On Sun, Oct 25, 2009 at 12:49 AM, Aristotle Pagaltzis pagalt...@gmx.dewrote:
  * Jason Galea li...@eightdegrees.com.au [2009-10-21 01:50]:
 $c-res-header( 'Content-Disposition' = 
   'attachment;filename='.$c-stash-{pdf_filename} );
 
  This will break for filenames with spaces in them. For strict
  correctness, you want this:
 
 ( my $pdf_filename = $c-stash-{ pdf_filename } ) =~ s!!\\!g;
 $c-res-header( 'Content-Disposition' = qq(attachment; 
  filename=$pdf_filename) );
 ^  
   ^
 ^  
   ^

 hmm.. I'm missing something here...

Yup.

 won't that simply escape double quotes and not affect spaces?

No.

:-)

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] generating and redirecting to pdfs [OT]

2009-10-27 Thread Richard Jones

Steve Rippl wrote:

On Mon, 2009-10-26 at 18:49 -0400, hkcl...@gmail.com wrote:

[..]
Thanks for the input.  I came across Catalyst::View::PDF::API2 but couldn't 
get that to work for some reason.  I hadn't tried ..PDF::Reuse but right now 
HTML::HTMLDoc is working pretty well for me.


Just as an aside, I've been using HTMLDOC server-side for years and have 
only just noticed HTML::HTMLDoc. It's a neat wrapper but I haven't found 
a way of setting header  footer size (equivalent of --headfootsize 
option), except to directly access the objects private parts:


$htmldoc-_set_doc_config('headfootsize', 9)

which breaks all the conventions, but works. I notice the H::H package 
hasn't been updated since 2005 so I guess it's safe enough to do this. 
Anyone encountered this issue before?

--
Richard Jones

___
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] Serialize a resultset?

2009-10-27 Thread Tomas Doran


On 27 Oct 2009, at 07:21, Octavian Râşniţă wrote:


Hi,

Can a DBIC resultset be serialized in order to be stored in the cache?



This is a dbix::class question, not a Catalyst question.

But, nonetheless, why not just use   
DBIx::Class::ResultClass::HashRefInflator


Cheers
t0m


___
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] Unicode in request captures

2009-10-27 Thread Bernhard Graf
Hi t0m,

 I filed a bug report together with patch and test about Unicode
 characters in request captures more than two weeks ago:

 https://rt.cpan.org/Public/Bug/Display.html?id=50339
 
 *Taken*

fine.

 I've got a branch on Catalyst currently to deal with some other encoding
 Captures / CaptureArgs issues.

good to hear.

 I think that your patch may be a little too enthusiastic about encoding
 as it is currently, but also looks like a reasonable first attempt.

hmm, what do you mean with too enthusiastic?

 I'll incorporate this into my branch
 http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Runtime/5.80/branches/uri_encode_captures_andor_args_take2/
 
 
 Many thanks for the patch, I'll update you further on the status of the
 branch in RT.

Thx

Bernhard


___
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] Debian recommendation

2009-10-27 Thread Buchan Milne
On Friday, 16 October 2009 13:20:12 Octavian Râşniţă wrote:
 Hi,

 I've seen a recommendation on this list for Debian for running perl apps,
 and recently I started to use this distro.

 I've seen that I can install perl modules very hard under Debian if I use
 the CPAN shell.
 For example if I run

 $ cpan
 cpan install Class::MOP

 it gives an Unknown error and it doesn't want to install and the same
 with Catalyst::Runtime.

 But if I do then

 cpan look ModuleName
 $ perl Makefile.PL
 $ make
 $ make test
 $make install

 I can install the modules without problem (usually).
 However, I need to manually install each dependency.

 I've seen this strange thing under 2 Debian systems so I think it is not a
 Debian bug.

 Does this happen to you? If yes, how do you solve it?

I note that both Mandriva (which has had it for a few years) and Fedora now 
have working Catalyst packages. Mandriva also has a CPANPLUS backend (which is 
being actively used for packaging new CPAN modules, however other tools - 
written in perl - are used for updating all packages).

I am prepared to package other Catalyst modules for Mandriva on request.

Regards,
Buchan


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

2009-10-27 Thread Evan Carroll
 Is there a Catalyst Request method for getting the path and the
 query_string?
 (Everything's after the base).

$c-req-uri-path_query

-- 
Evan Carroll
System Lord of the Internets
http://www.evancarroll.com

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


Re: [Catalyst] Debian recommendation

2009-10-27 Thread Alejandro Imass
Sorry for the top post but my answer is simple. I have used Debian for
Catalyst development since I discovered Catalyst. I use CPAN because
no distro can keep up with the fast changing Catalyst world, so it's
no use to use the distro packages. Besides I develop in Debian and
deploy in FreeBSD 6 and 7, so I am used to CPAN anyway.

Perhaps you know this and failed to mention it but Debian has a clear
Perl Policy:

http://www.debian.org/doc/packaging-manuals/perl-policy/

My rule is that many XS-type modules are better installed with the
distro's packages DBI, and the DBDs are examples of this. The rest of
the Catalyst packages I install with CPAN and have yet to run into any
problems. I have been using Debian since 2.0 and Catalyst since it
came out.

Best,
Alejandro Imass

On Mon, Oct 26, 2009 at 5:08 PM, Evan Carroll li...@evancarroll.com wrote:
 I just wanted to buzz in and be slightly more explicit. Debian doesn't
 understand Perl, and they don't care about CPAN. Debian hand-hacks
 stuff in the most virulent and ridiculous fashion: they'll open up a
 perl class, hack in an extra method, make random other methods die
 explicitly, and then they'll make your system dependent on it. I use
 CPAN too, and Debian as my primary distribution but that doesn't
 change a thing. They could for instance, subclass a module for use by
 the system into a ::Debian package, but instead they choose the dirty
 hack-it-in method which makes life difficult for those of us who want
 to simply get a job done. The Debian packages don't have to pass the
 natural tests, they're not published under the same namespaces, they
 don't change version numbers, and they're hardly sound improvements.

 Debian will justify this because they want the system configured
 through /etc, and not at the whim of each individual author, but
 unfortunately that doesn't help us here, or people that depend on the
 non-debian behavoir.

 Use CPAN at your risk, it might work -- it might not. I do, and I feel
 comfortable saying most programmers on this list can probably navigate
 around the problems Debian creates, but for the end perl user, Debian
 is a horrible platform.

 --
 Evan Carroll
 System Lord of the Internets

 ___
 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] Debian recommendation

2009-10-27 Thread Andrew Rodland
On Tuesday 27 October 2009 05:18:32 pm Evan Carroll wrote:
 I simply disapprove of taking
 something knowingly breaking it, and publishing it as if nothing
 happened.

Then I suppose it's a good thing that no such thing happens.

___
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] Debian recommendation

2009-10-27 Thread Evan Carroll
 Then I suppose it's a good thing that no such thing happens.

Sure it happens;
ecarr...@x60s:~$ diff /usr/local/share/perl/5.10.0/XML/SAX.pm
/usr/share/perl5/XML/SAX.pm -C5
*** /usr/local/share/perl/5.10.0/XML/SAX.pm 2008-08-05 07:36:24.0 
-0500
--- /usr/share/perl5/XML/SAX.pm 2009-04-29 08:28:25.0 -0500
***
*** 177,186 
--- 177,195 
  }

  sub save_parsers {
  my $class = shift;

+ ### DEBIAN MODIFICATION
+ print \n;
+ print Please use 'update-perl-sax-parsers(8) to register this
parser.'\n;
+ print See /usr/share/doc/libxml-sax-perl/README.Debian.gz for
more info.\n;
+ print \n;
+
+ return $class; # rest of the function is disabled on Debian.
+ ### END DEBIAN MODIFICATION
+
  # get directory from wherever XML::SAX is installed
  my $dir = $INC{'XML/SAX.pm'};
  $dir = dirname($dir);

  my $file = File::Spec-catfile($dir, SAX, PARSER_DETAILS);
***
*** 204,213 
--- 213,256 
  close $fh;

  return $class;
  }

-- 
Evan Carroll
System Lord of the Internets
http://www.evancarroll.com

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


Re: [Catalyst] Request

2009-10-27 Thread Larry Leszczynski
Hi Octavian -

On Tue, 27 Oct 2009 23:16 +0200, Octavian Râsnita orasn...@gmail.com
wrote:
 From: Larry Leszczynski lar...@emailplus.org
  Hi Octavian -
 
  Is there a Catalyst Request method for getting the path and the
  query_string? (Everything's after the base).
 
  I want to use it in a TT template for changing the current language.
 
  The current URI is something like:
  http://www.site.com/prg?var1=val1var2=val2
 
  The base for this URI is:
  http://www.site.com/en/
  (Because I overwritten prepare_path as in the example given on the Cat
  wiki)
 
  and the URL that should be printed with the new language is:
  http://www.site.com/ro/prg?var1=val1var2=val2
 
  Not sure if this gets you all the way there, but you could call
  c.req.uri with no arguments, that should give you the current request
  including base, path and query string.  Then you could strip off
  c.req.base from the beginning of that string.
 
 Thank you Larry, but the problem is that the base was overwritten and it 
 contains some more than the uri, so I can't cut it from the URI.

It should work fine, we do something very similar.  The trick is that
after the prepare_path fixup (if you did it like in the wiki), when you
stringify c.req.uri, it will reflect the *new* base, not the original. 
Using your example:

   original request url:http://www.site.com/prg?var1=val1var2=val2
   rewritten request url:  
   http://www.site.com/en/prg?var1=val1var2=val2

So you should have:

   [%
  uri  = c.req.uri; #
  http://www.site.com/en/prg?var1=val1var2=val2
  base = c.req.base;# http://www.site.com/en/

  pattern = '^' _ base;# pattern not
  tested...
  path_and_query = uri.replace(pattern, '');
   %]

So it's easy to strip base from the front of uri and get what you
need, without knowing what base is.


 Thank you Evan. Your solution was helpful.
 I didn't know that c.req.uri is not just a string, but an object that has 
 its own methods, and c.req.uri.path_query was the one I needed.

This could work, but given the same original url and prepare_path fixup,
you will have:

   [%
  uri = c.req.uri; #
  http://www.site.com/en/prg?var1=val1var2=val2
  path_and_query = c.req.uri.path_query;   #   
  /en/prg?var1=val1var2=val2
   %]

So now when you build the new url you have to be aware that
path_and_query contains the /en part that needs to be stripped.


Larry

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


Re: [Catalyst] Basic CRUD example failing

2009-10-27 Thread Zbigniew Lukasiak
On Wed, Oct 28, 2009 at 6:07 AM, Jason Dixon ja...@dixongroup.net wrote:
 Hi all,

 Learning Catalyst here.  Following along with the manual and I ran into
 a weird issue.  I assume the documentation is right so it must be
 something with my installation (Catalyst packages on OpenBSD 4.6).

 Following along with the SIMPLE DELETE FEATURE example, I made changes
 to root/src/books/list.tt2.  Alas, the uri is not rendering properly.

 a href=[% c.uri_for(c.controller.action_for('delete'), [book.id]) 
 %]Delete/a

I may have not updated my view knowledge - but I would write that as:
a href=[% c.uri_for(c.controller.action_for('delete'), book.id) %]Delete/a

Why did you use the square brackets around 'book.id'?

-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/

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