Re: [Catalyst] Cache of unchanging content

2011-03-03 Thread Octavian Rasnita
From: will trillich 
  Here's our current dev-to-deploy approach -- we use mercurial and a 
three-step staging process:
  



  I think that it could be helpful to add a page to the Cat site that describe 
the workflow for deployment because it is not clear which are the 
possible/recommended methods.

  Octavian




___
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::RunAfterRequest and Catalyst::View::Email?

2011-03-03 Thread Chakkit Ngamsom
Thanks Steve, problem solved now.

 

--

Chakkit

 

From: Steve Kleiman [mailto:st...@prodhub.com] 
Sent: Thursday, March 03, 2011 04:34 AM
To: The elegant MVC web framework
Subject: Re: [Catalyst] Catalyst::Plugin::RunAfterRequest and
Catalyst::View::Email?

 

See mst note below. Worked for me.

 

 

On Mar 2, 2011, at 12:12 PM, Chakkit Ngamsom wrote:





Hi All,

 

My plan is to use Catalyst::Plugin::RunAfterRequest for sending email via
Catalyst::View::Email as the background.

Due to sometimes mail server got lag and the page waiting for it or sending
a notification after slow processes have been completed e.g. import/export.

 

I'm not sure it's a bug or the limitation of the plugin.

I setup the code something like this:

 

$c-run_after_request(

  sub {

$c-stash-{email} = {

  from = $from,

  to = $to,

  body = $body,

  header = [

Subject = 'some localized subject',

  ],

};

$c-forward( $c-view('Email') );

  }

);

 

After running it, it showed an error like this:
[error] Caught exception in engine Modification of non-creatable array
value attempted, subscript -1 at
C:/strawberry/perl/site/lib/Catalyst/Dispatcher.pm line 278.

 

As a trial, the error caused from this line: $c-forward( $c-view('Email')
);.

Finally, I noticed it worked well with other forwarding except view.

 

Please kindly let me know how to fix this issue or another solution that
matches to the requirements.

 

Thanks in advance,

Chakkit

 

 

 

 

 

 

 

Begin forwarded message:





From: Matt S Trout m...@shadowcat.co.uk

Date: May 2, 2010 12:49:32 PM PDT

To: The elegant MVC web framework catalyst@lists.scsys.co.uk

Subject: Re: [Catalyst] RunAfterRequest/delayed Catalyst view

Reply-To: The elegant MVC web framework catalyst@lists.scsys.co.uk

 

On Fri, Apr 30, 2010 at 02:38:50PM -0700, Steve Kleiman wrote:



Here goes...hopefully a simple test case for the RunAfterRequest oddness.





The code below with the forward INSIDE 'run_after_request' subroutine throws
the error:

[error] Caught exception in engine Modification of non-creatable array
value attempted, subscript -1 at
/usr/local/lib/perl5/site_perl/5.10.1/Catalyst/Dispatcher.pm line 278.


I think that's probably $c-stack being empty because there's no request
anymore.

I *think* that

$c-view('Email')-process($c);

would work, since that doesn't rely on the action call stack.

That error message is fucking awful though, and almost certainly my fault.

Proposal: first you try the -process-by-hand approach to confirm that I'm
an idiot the way I think I am. Second we discuss how to either (a) fix this
or (b) make sure it produces a non-awful error.

(even if you've already rewritten the code it'd be much appreciated if you
could try this out and see if it does the right thing - also, you then get
to
point and laugh at me with a bit of luck, which may or may not be an added
incentive ;)

-- 
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a
clue

http://shadowcat.co.uk/blog/matt-s-trout/
  http://twitter.com/shadowcat_mst/

Email me now on mst (at) shadowcat.co.uk and let's chat about how our
Catalyst
commercial support, training and consultancy packages could help your team.

___
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] Cache of unchanging content

2011-03-03 Thread John M. Dlugosz

 On 3/3/2011 1:58 AM, Octavian Rasnita orasnita-at-gmail.com |Catalyst/Allow to 
home| wrote:

From: will trillich
   Here's our current dev-to-deploy approach -- we use mercurial and a 
three-step staging process:
   



   I think that it could be helpful to add a page to the Cat site that describe 
the workflow for deployment because it is not clear which are the 
possible/recommended methods.

   Octavian







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

I'll second that.

___
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] Fwd: Catalyst::View::PDF::Reuse generates empty PDF

2011-03-03 Thread Victor Churchill
I am taking my first steps from Base Camp 1 of the Catalyst learning
curve. I am trying to add PDF capability to the standard Books app of
the tutorial. The PDF view appears to be running but is not returning
any content.

As per the C::V::P::R docs, I have:

In ~/Catalyst/MyApp, run  script/myapp_create.pl view PDF::Reuse PDF::Reuse

In ~/Catalyst/MyApp/lib/MyApp.pm, added:

# Configure PDF generator view
__PACKAGE__-config('View::PDF::Reuse' = {
   INCLUDE_PATH = __PACKAGE__-path_to('root','src','books')
                   });

In ~/Catalyst/MyApp/lib/MyApp/Controller/Books.pm, added:

sub pdf :Local {
   my ($self, $c) = @_;
   my $log = $c-log;
   $log-debug('*** in sub pdf ***');
   # Retrieve all of the book records as book model objects and store
   # in the stash where they can be accessed by the TT template that
   # will generate the PDF
   $c-stash(books = [$c-model('DB::Book')-all]);

   # Set PDF parameters
   $c-stash-{fontname} = 'Helvetica-Bold';
   $c-stash-{fontsize} = '20';

   # Set the TT template to use and go. (Overriddeen during debug for
simplicity)
   #$c-stash-{pdf_template} = 'list_pdf.tt2';
   $c-stash-{pdf_template} = 'hello_pdf.tt2';
   $c-stash-{pdf_filename}    = 'booklist.pdf';

   $log-debug('*** forwarding to View::PDF::Reuse ***');
   $c-forward('View::PDF::Reuse');
}

In ~/Catalyst/MyApp/root/src/books/hello_pdf.tt2 :

[% pdf.prFile() %]
[% pdf.prText(100,100,'Hello, World') %]
[% pdf.prEnd %]

I tried adding
[%# check the template is being read %]
[% pdf.junk-should-fail %]
[%# that line makes no difference %]

but there was no change to the output, which seems odd. I do think the
template is being read because I can break the view by using prLog -
see addendum below.

The controller is involed form the book listing page in
~/Catalyst/MyApp/root/src/books/list.tt2 thus:
[% # A link for a PDF of the booklist %]
pa href=[% c.uri_for(c.controller.action_for('pdf')) %]PDF list/a/p

In all cases I see this in the server log:

[debug] GET request for books/pdf from 81.109.243.248
[debug] Path is books/pdf
[debug] Found sessionid 652adf37e1e9e9254463c75c63f2530fc1ff2b93 in cookie
[debug] Restored session 652adf37e1e9e9254463c75c63f2530fc1ff2b93
[debug] *** in sub pdf ***
[debug] *** forwarding to View::PDF::Reuse ***
[debug] Rendering template SCALAR(0xbf2b210)
[debug] Response Code: 200; Content-Type: application/pdf; Content-Length: 546
[info] Request took 0.033116s (30.197/s)
.+---.
| Action                                                     | Time      |
++---+
| /auto                                                      | 0.000291s |
| /books/pdf                                                 | 0.027157s |
|  - MyApp::View::PDF::Reuse-process                       | 0.024822s |
| /end                                                       | 0.000182s |
'+---'

The size (546) is always the same.
The data returned is recognised by the browser as a PDF file which it
shows as an empty page. Examining the PDF file I see

victor@pan2:/tmp$ ls -l booklist.pdf
-r 1 victor victor 546 2011-03-02 17:23 booklist.pdf

victor@pan2:/tmp$ file booklist.pdf
booklist.pdf: PDF document, version 1.4

victor@pan2:/tmp$ head -1 booklist.pdf
%PDF-1.4

victor@pan2:/tmp$ tail -n 1 !$
tail -n 1 booklist.pdf
%%EOF

I am evidently missing something very basic and obvious ;-( but not to
me) and am struggling to get into this to see what's going wrong.
Normal debug methods do not seem to apply in Catalyst land!

Any suggestions very much appreciated. Please let me know if there is
any other information I can provide. Thanks!!

Addendum - I also tried adding to the hello_pdf.tt2 template some log requests:

[% pdf.prLogDir('/tmp') %]
[% pdf.prLog('call prFile') %]
etc., but got this runtime error:

Couldn't render template undef error -  You have to give a directory
for the logfiles first : prLogDir dir , aborts
 More information might be found in error.log       [.. it wasn't]
 at /usr/local/lib/perl/5.10.1/Template/Plugin/Procedural.pm line 55

But I think this is a different issue.

___
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] Fwd: Catalyst::View::PDF::Reuse generates empty PDF

2011-03-03 Thread Jorge Gonzalez

El 03/03/11 14:47, Victor Churchill escribió:

I am taking my first steps from Base Camp 1 of the Catalyst learning
curve. I am trying to add PDF capability to the standard Books app of
the tutorial. The PDF view appears to be running but is not returning
any content.

As per the C::V::P::R docs, I have:

In ~/Catalyst/MyApp, run  script/myapp_create.pl view PDF::Reuse PDF::Reuse

In ~/Catalyst/MyApp/lib/MyApp.pm, added:

# Configure PDF generator view
__PACKAGE__-config('View::PDF::Reuse' =  {
INCLUDE_PATH =  __PACKAGE__-path_to('root','src','books')
});

   
I think INCLUDE_PATH should not include the last 'books' path part. It's 
taken from the controller name.


If your template base is root/src, the controller is Books.pm, the 
action id pdf, the template should be in root/src/books/pdf.tt


This works for me :-)
regards
J.



___
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] What text editor to use?

2011-03-03 Thread Mesdaq, Ali
I have been using Komodo for years and its the best Perl editor I have found. 
Not just perl it understands everything I have thrown at it and has a lot of 
perl specific features. It also integrates into various source control 
management systems like svn, p4, git, etc. The only thing is that its not free 
but to me its well worth the money. Oh yeah and its cross platform. Aside from 
having to pay for the full version of the editor I cant think of a reason not 
to use it from a technical or feature perspective. 

List of a few features I find most useful
- Visual Source code browser with list of funtions in heirarchy in all open 
files
- Embedded perl/python/php/ruby interperter
- Debug perl/python/php/ruby with break points and full inspection of variables
- Remote debugging of perl applications
- Regex Toolkit for quick regex development or quick extraction/cleanup of data
- Import various JavaScript libraries like jquery and get auto complete and 
prototypes of functions
- Visual notification of source control files that may be out of sync with depot

The only downside I have noticed is in certian situations its really slow on 
linux boxes when switching tabs when many tabs are open but that problem has 
slowly been getting better with the newer releases.


From: John M. Dlugosz [wxju46g...@snkmail.com]
Sent: Wednesday, March 02, 2011 3:10 AM
To: catalyst@lists.scsys.co.uk
Subject: [Catalyst] What text editor to use?

  What's a good text editor to use for Catalyst/TT development?

The editor I really like for C++ doesn't handle XML well.  I've been using 
Notepad++ for
windows, but the syntax highlighting doesn't understand mixing TT inside the 
base
language, and it has tabs only instead of multiple visible windows.

I would entertain both Windows and Linux solutions.

TIA,
--John


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


 To report this as spam, please forward to s...@websense.com.  Thank you.

 Protected by Websense Hosted Email Security -- www.websense.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] What text editor to use?

2011-03-03 Thread Cliff Green

On 3/3/2011 9:27 AM, Mesdaq, Ali wrote:

I have been using Komodo for years and its the best Perl editor I
have found.

I wondered if anyone was going to mention Komodo.

FWIW, it looks like Ali is talking about KomodoIDE (which I also own), 
not the free KomodoEdit, which is fundamentally the same editor, sans 
source code management (svn, etc.).  On the other hand, it does allow 
one to open and save files remotely (I use scp), which is convenient.

...


The only downside I have noticed is in certian situations its really
slow on linux boxes when switching tabs when many tabs are open but
that problem has slowly been getting better with the newer releases.

I've noticed it's mostly slow on startup, but reasonable after that.

c
--
Cliff Green


___
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] [ANNOUNCE] Catalyst-Runtime-5.89002-TRIAL PSGI Catalyst - third development release

2011-03-03 Thread Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
Fernan Aguero ✍:
 what plack/psgi is and/or why I should care
I hear that often, so here's the elevator pitch I'm usually telling to convey 
the basic idea.

Catalyst is a Web framework that runs on several Web servers. The different 
parts necessary to make this work are separated out into adapter classes such 
as Catalyst::Engine::Apache2::MP20. There are quite a number of them.

Then framework X comes along and has to implement these adapters suitable for 
its codebase, too, and so on for every new framework.

This repetition is not a good thing, and the frameworks want to get rid of it. 
The various adapters are written just once, outside of the frameworks, and 
with a standardised interface. The frameworks now only need exactly one 
adapter each, adhering to that interface.

That interface spec is called PSGI; the implementation is called Plack.

Apart from less code for each framework, there is the other advantage that 
adding support for a new Web server (e.g. Plack::Handler::Mongrel2) 
automatically enables this Web server for any PSGI-compliant framework.

While it has been possible to run Catalyst 5.8 on top of PSGI-enabled Web 
servers with Catalyst::Engine::PSGI, Catalyst 5.9 goes native and cuts out one 
layer of indirection.

Now that you know that, you should be able to answer the Question 2 
questions yourself.


signature.asc
Description: This is a digitally signed message part.
___
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] What text editor to use?

2011-03-03 Thread Mesdaq, Ali
Yeah the free version is disappointing and I would never recommend that version 
to anyone. There are plenty of other editors that are free with more features. 
However the full version should be fully customizable. It even supports xpi 
plugins so you can customize every aspect of the editor. Even without xpi 
plugins you can customize almost everything in the editor. Any specific 
customization you are looking to do? 


From: John M. Dlugosz [wxju46g...@snkmail.com]
Sent: Thursday, March 03, 2011 8:11 AM
To: catalyst@lists.scsys.co.uk
Subject: Re: [Catalyst] What text editor to use?

  On 3/3/2011 9:24 AM, Cliff Green green-at-umdnj.edu |Catalyst/Allow to home| 
wrote:
 On 3/3/2011 9:27 AM, Mesdaq, Ali wrote:
 I have been using Komodo for years and its the best Perl editor I
 have found.
 I wondered if anyone was going to mention Komodo.

 FWIW, it looks like Ali is talking about KomodoIDE (which I also own), not 
 the free
 KomodoEdit, which is fundamentally the same editor, sans source code 
 management (svn,
 etc.).  On the other hand, it does allow one to open and save files remotely 
 (I use
 scp), which is convenient.
 

I already checked out the free Komodo editor.
It was quite disappointing.  Basically no configuration possible.

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


 To report this as spam, please forward to s...@websense.com.  Thank you.

 Protected by Websense Hosted Email Security -- www.websense.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] What text editor to use?

2011-03-03 Thread Ashley Pond V
Let's end this thread; 23 messages is enough and the topic is barely
more relevant to Catalyst than What kind of lunch should I have?

___
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] [ANNOUNCE] Catalyst-Runtime-5.89002-TRIAL PSGI Catalyst - third development release

2011-03-03 Thread Dave Rolsky

On Thu, 3 Mar 2011, Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯 wrote:


Apart from less code for each framework, there is the other advantage that
adding support for a new Web server (e.g. Plack::Handler::Mongrel2)
automatically enables this Web server for any PSGI-compliant framework.

While it has been possible to run Catalyst 5.8 on top of PSGI-enabled Web
servers with Catalyst::Engine::PSGI, Catalyst 5.9 goes native and cuts out one
layer of indirection.


The other advantage is that you can put functionality in the interface 
layer (Plack middleware), which means that you have an ecosystem of 
plugins _shareable across frameworks_.



-dave

/*
http://VegGuide.org   http://blog.urth.org
Your guide to all that's veg  House Absolute(ly Pointless)
*/___
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] Is Anyone Else Having Trouble With Updated IE8 and Sessions?

2011-03-03 Thread Andy Dorman
We use (and love) Catalyst for our AnteSpam user interface pages.  Specifically 
we use Catalyst::Plugin::Session and Session::Store with a memcache layer on top.


A day or two after Microsoft released a security update on Jan 11, 2011, our 
users that use IE8 started experiencing session-mismatch problems when they 
would try to log in.


The problems all looked as if their session had timed out.  Even after 
completely closing and reopening their browser, they would log in with a valid 
address and password and the sessions IDs would not match.


And the truly strange thing is we stumbled on a work around that works for 
almost every IE8 user.  Keep trying to log in.  The sessions will finally match 
and the log in succeed on the second or third try.  In a few cases, using SSL 
via https also works without requiring three login attempts.


And after succeeding on the second or third try, the log in problems disappeared 
and did not recur, even after logging out or rebooting.


I am just trying to see if anyone else has experienced any similar issues with 
IE* since mid January this year.  If so, did you ever discover what MS changed 
that caused this lunacy?  And if not, then we will have to keep looking for the 
cause.


Thank you,

--
Andy Dorman
FanMail.com
Ironic Design, Inc.
AnteSpam.com, HomeFreeMail.com, ComeHome.net

___
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] Fwd: Catalyst::View::PDF::Reuse generates empty PDF

2011-03-03 Thread Wes Cravens

On 3/3/2011 10:58 AM, Victor Churchill wrote:

However. I did get some PDF eventually! It turned out that the problem
was : I was using [% pdf.prFile ... %] at the start of the template.


I fell into exactly this same hole earlier today in fact.  I'm not 
exactly sure why this is set in the stash rather than the template, or 
why the template setting seems to be ignored (or something). I've not 
had the time to investigate further... but from the docs...


$ perldoc Catalyst::View::PDF::Reuse
snip
The filename and content disposition (inline or attachment) can be
controlled by putting the following values in the stash:

$c-stash-{pdf_disposition} = 'attachment';  # Default is 'inline'
$c-stash-{pdf_filename}= 'myfile.pdf';
/snip






If your template base is root/src, the controller is Books.pm, the action id
pdf, the template should be in root/src/books/pdf.tt

This works for me :-)
regards
J.



___
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] Fwd: Catalyst::View::PDF::Reuse generates empty PDF

2011-03-03 Thread Victor Churchill
On 3 March 2011 21:49, Wes Cravens wcrav...@cortex-it.com wrote:
 I fell into exactly this same hole earlier today in fact.  I'm not exactly
 sure why this is set in the stash rather than the template, or why the
 template setting seems to be ignored (or something). I've not had the time
 to investigate further... but from the docs...

 $ perldoc Catalyst::View::PDF::Reuse
 snip
 The filename and content disposition (inline or attachment) can be
 controlled by putting the following values in the stash:

 $c-stash-{pdf_disposition} = 'attachment';  # Default is 'inline'
 $c-stash-{pdf_filename}    = 'myfile.pdf';
 /snip

Yes, I have not investigated {pdf_disposition} but {pdf_filename}
DEWISOTT (and you do need it, otherwise you get an error). Regarding
an initial pdf.prFile, it seems that if you use that in your template
then it closes a file prevoiusly 'opened' by CVPR and whatever you put
in thereafter is lost.

___
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] URI-new() with utf8 string and Unicode::Encoding will not work (but URI-new() with utf8 octets will work)

2011-03-03 Thread Erik Wasser
Hello list,

I'm was looking for some unicode/utf8/encoding problem during my problem
and I've discovered a strange thing.

URLs provided with an unicode character will be not correctly encoded by
the Unicode::Encoding plugin.

Here's the simple test case:

1) Create the application and cd into it:
% catalyst.pl MyApp
% cd MyApp

2) Add the plugin Unicode::Encoding in lib/MyApp.pm

3) Replace the 'sub index { ...}' in 'lib/MyApp/Controller/Root.pm' with
the following code:

- B -

sub index : Regex('^test$')
{
my ( $self, $c, $parameter ) = @_;

$c-response-body( 'length = ' . length($parameter) );
}

- B -

4) Add a test script t/04encoding.t like this:

- B -

#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests = 4;
use Test::Deep;

use HTTP::Status;
use HTTP::Request;
use Data::Dumper;

BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
BEGIN { use_ok 'MyApp::Controller::Root' }

foreach my $u ('http://localhost/test/%E3%81%8B',
http://localhost/test/\x{304b}; )
{
my $request = HTTP::Request-new(
'GET'= $u, [ 'Content-Type' = 'text/html; charset=utf8', ],
);
print $request-as_string();
my $response = request( $request );
is( $response-content, 'length = 1', 'length = 1' );
}

- B -

5) Start the test script

% perl t/04encoding.t

The first call will give the correct answer 'length = 1' because the 3
arabian octets were encoded correctly to one character.

The second call will give the wrong answer 'length = 3'.

Please note that the statement print $request-as_string() will print
the same http header:

 GET http://localhost/test/%E3%81%8B
 Content-Type: text/html; charset=utf8

My 2 cents:  Further investigation brought me to
Catalyst::Plugin::Unicode::Encoding::prepare_action().
The problem is that the second URL from above is already an utf8 string,
means that Encode::is_utf8( $_ ) in the named method returns true and
nothing will be done by the plugin.

Before I do some silly stuff I want to hear a second opinion from the list.

Is this fixable? Is catalyst here the problem? I think not. According
to the Bug in URI (Ticket #43859, should be _utf8_off -ed raw data
before URI encoding,
https://rt.cpan.org/Ticket/Display.html?id=43859) the problem may be
within URI.

But maybe it's possible to fix this issue in the testsuite of catalyst.

Any thoughts?

-- 
So long... Fuzz

___
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] URI-new() with utf8 string and Unicode::Encoding will not work (but URI-new() with utf8 octets will work)

2011-03-03 Thread Bill Moseley
Does this help?

On Thu, Mar 3, 2011 at 2:38 PM, Erik Wasser erik.was...@iquer.net wrote:

 foreach my $u ('http://localhost/test/%E3%81%8B',
 http://localhost/test/\x{304b}; )
 {
my $request = HTTP::Request-new(
'GET'= *encode_utf8($u)*, [ 'Content-Type' = 'text/html;
 charset=utf8', ],
);
print $request-as_string();
my $response = request( $request );
is( $response-content, 'length = 1', 'length = 1' );
 }


-- 
Bill Moseley
mose...@hank.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] What text editor to use?

2011-03-03 Thread John M. Dlugosz

 On 3/3/2011 11:28 AM, Cliff Green green-at-umdnj.edu |Catalyst/Allow to home| 
wrote:

On 3/3/2011 11:11 AM, John M. Dlugosz wrote:

On 3/3/2011 9:24 AM, Cliff Green green-at-umdnj.edu |Catalyst/Allow to
home| wrote:

On 3/3/2011 9:27 AM, Mesdaq, Ali wrote:

I have been using Komodo for years and its the best Perl editor I
have found.

I wondered if anyone was going to mention Komodo.

FWIW, it looks like Ali is talking about KomodoIDE (which I also own),
not the free KomodoEdit, which is fundamentally the same editor, sans
source code management (svn, etc.). On the other hand, it does allow
one to open and save files remotely (I use scp), which is convenient.



I already checked out the free Komodo editor.
It was quite disappointing. Basically no configuration possible.


Under the heading of ymmv...

What kind if configuration was lacking?

c
I don't remember the details now.  Only that I was disappointed and underwhelmed based on 
the hype.


___
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] URI-new() with utf8 string and Unicode::Encoding will not work (but URI-new() with utf8 octets will work)

2011-03-03 Thread Eisenberger Tamás
Hy!

Yes using encode_utf8 makes the test works.

But anyway, this looks like a problem with the test, because we have
tests to compare the entire captures / arguments / params strings with
their originals, and if these tests pass the length of the strings must
be ok!

So Erik, can you please review your test, or explain a real word
situation of the problem you facing?

I actually use utf8 strings in url's now without problems :)
-- 
Eisenberger Tamás ta...@eisenberger.hu

On Thu, 2011-03-03 at 21:33 -0800, Bill Moseley wrote:
 Does this help?
 
 On Thu, Mar 3, 2011 at 2:38 PM, Erik Wasser erik.was...@iquer.net
 wrote:
 foreach my $u ('http://localhost/test/%E3%81%8B',
 http://localhost/test/\x{304b}; )
 {
my $request = HTTP::Request-new(
'GET'= encode_utf8($u), [ 'Content-Type' =
 'text/html; charset=utf8', ],
);
print $request-as_string();
my $response = request( $request );
is( $response-content, 'length = 1', 'length = 1' );
 }
 
 
 -- 
 Bill Moseley
 mose...@hank.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/


smime.p7s
Description: S/MIME cryptographic signature
___
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] URI-new() with utf8 string and Unicode::Encoding will not work (but URI-new() with utf8 octets will work)

2011-03-03 Thread Francisco Obispo
I believe what's happening is that Catalyst is converting the UTF-8 string into 
perl format (decoding), and in that particular example, is working for you 
because the string is forced back into UTF-8 with the encode_utf8 function.

This is a code I wrote and use to test unicode issues:

#!/usr/bin/env perl
use Encode;

#my @list = Encode-encodings(q{:all});

#printf(Encodings Available:\n);
#map {printf(\t-%s\n,$_)}@list;


foreach (@ARGV) {
  printf( Word is %s\n, $_ );
  my $i = 0;
  my $string=decode('utf8',$_);
  my @chr = split( q{}, $string);
  printf( Length decoded is %d\n, length(decode_utf8($_)) );
  printf( Length as bytes is %d\n, length($_) );
  map {
printf( '%d] +U%.4X - %2$04d - %s' . \n,
++$i, ord($_), encode_utf8($_) )
  } @chr;
}

In order to get the correct length, I have to decode the UTF-8 string into 
internal Perl's format, otherwise it will just count bytes:

$ ./test_unicode.pl español
Word is español
Length decoded is 7
Length as bytes is 8
1] +U0065 - 0101 - e
2] +U0073 - 0115 - s
3] +U0070 - 0112 - p
4] +U0061 - 0097 - a
5] +U00F1 - 0241 - ñ
6] +U006F - 0111 - o
7] +U006C - 0108 - l

As you can see, perl interprets the string (len()) as either a UTF-8 string or 
as bytes depending whether the string has been decoded or not.

So, if you don't decode the string, the result is a disaster when using string 
functions (such as split()).

Hope this helps.

Francisco


On Mar 3, 2011, at 11:26 PM, Eisenberger Tamás wrote:

 Hy!
 
 Yes using encode_utf8 makes the test works.
 
 But anyway, this looks like a problem with the test, because we have
 tests to compare the entire captures / arguments / params strings with
 their originals, and if these tests pass the length of the strings must
 be ok!
 
 So Erik, can you please review your test, or explain a real word
 situation of the problem you facing?
 
 I actually use utf8 strings in url's now without problems :)
 -- 
 Eisenberger Tamás ta...@eisenberger.hu
 
 On Thu, 2011-03-03 at 21:33 -0800, Bill Moseley wrote:
 Does this help?
 
 On Thu, Mar 3, 2011 at 2:38 PM, Erik Wasser erik.was...@iquer.net
 wrote:
foreach my $u ('http://localhost/test/%E3%81%8B',
http://localhost/test/\x{304b}; )
{
   my $request = HTTP::Request-new(
   'GET'= encode_utf8($u), [ 'Content-Type' =
'text/html; charset=utf8', ],
   );
   print $request-as_string();
   my $response = request( $request );
   is( $response-content, 'length = 1', 'length = 1' );
}
 
 
 -- 
 Bill Moseley
 mose...@hank.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/

Francisco Obispo 
Hosted@ Programme Manager
email: fobi...@isc.org
Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
Key fingerprint = 532F 84EB 06B4 3806 D5FA  09C6 463E 614E B38D B1BE





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