Re: [Catalyst] Encoding UTF8 ?

2011-03-28 Thread John M. Dlugosz

On 3/28/2011 3:16 PM, Bill Moseley moseley-at-hank.org |Catalyst/Allow to home| 
wrote:


Yes, that would be related to not encoding with the plugin.  You need the
plugin to encode output so you don't that that message.

John, you are better off ignoring that Perl is using UTF-8 internally. All
byte data that represents characters must be decoded on input -- and
likewise all characters in Perl must be encoded before writing.


I know I discussed this before, but is there a plan to make decoding and
encoding part of Catalyst core?  Seems to trip people up and it seems like
something that should always be done.


At the very least, low-hanging fruit would be to mention this in the error message.  "See 
FAQ entry #1234 at " when it dies!




___
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] Encoding UTF8 ?

2011-03-28 Thread Bill Moseley
On Mon, Mar 28, 2011 at 1:04 PM, John M. Dlugosz wrote:

> On 3/28/2011 2:51 PM, Andrew Rodland 
> andrew-at-cleverdomain.org|Catalyst/Allow to home| wrote:
>
>>
>> What engine error you noticed before? You broke threading.
>>
>>  "Caught exception in engine "Wide character in syswrite at
> /usr/share/perl5/Catalyst/Engine.pm line 675"


Yes, that would be related to not encoding with the plugin.  You need the
plugin to encode output so you don't that that message.

John, you are better off ignoring that Perl is using UTF-8 internally. All
byte data that represents characters must be decoded on input -- and
likewise all characters in Perl must be encoded before writing.


I know I discussed this before, but is there a plan to make decoding and
encoding part of Catalyst core?  Seems to trip people up and it seems like
something that should always be done.


-- 
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] Encoding UTF8 ?

2011-03-28 Thread John M. Dlugosz
On 3/28/2011 2:51 PM, Andrew Rodland andrew-at-cleverdomain.org |Catalyst/Allow to home| 
wrote:


What engine error you noticed before? You broke threading.

"Caught exception in engine "Wide character in syswrite at 
/usr/share/perl5/Catalyst/Engine.pm line 675"





___
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] Encoding UTF8 ?

2011-03-28 Thread Andrew Rodland
On Monday, March 28, 2011 12:50:00 PM John M. Dlugosz wrote:
> I don't understand why
> 
> |Catalyst::Plugin::Unicode::Encoding|
> 
> is necessary, based on the writup: it takes request arguments and converts
> them from whatever they came in to Perl's native encoding, and likewise
> for the response.
> 
> But Perl is using UTF-8 in its strings anyway.  So what's it have to do
> with the engine error I noticed before?

What engine error you noticed before? You broke threading.

___
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] Encoding UTF8 ?

2011-03-28 Thread John M. Dlugosz
On 3/28/2011 1:25 PM, Jorge Gonzalez jorge.gonzalez-at-daikon.es |Catalyst/Allow to home| 
wrote:


Did you set ENCODING => 'utf-8' in the configuration of your TT View?

Ah, thanks!  That worked.  I looked again carefully at 
 and 
it turns out I was reading about "HTLM::Template Style configuration", which only listed a 
smaller number of items.  When I searched the text of the page, I found ENCODING in the 
previous section.


My bad.

___
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] Encoding UTF8 ?

2011-03-28 Thread Zbigniew Lukasiak
On Mon, Mar 28, 2011 at 7:50 PM, John M. Dlugosz wrote:

>  I don't understand why
>
> Catalyst::Plugin::Unicode::Encoding
> is necessary, based on the writup: it takes request arguments and converts
> them from whatever they came in to Perl's native encoding, and likewise for
> the response.
>
> But Perl is using UTF-8 in its strings anyway.  So what's it have to do
> with the engine error I noticed before?
>

The point is that if they are not marked as UTF-8 then they are treated as
bytes not characters.  In fact you should never think about the internal
storage of strings - it is not part of the API - it can be changed.  You
always need to decode external data if you want to treat it as strings and
not byte streams.

http://perldoc.perl.org/perlunitut.html has all the this introductory info.

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


Re: [Catalyst] Encoding UTF8 ?

2011-03-28 Thread Jorge Gonzalez

El 28/03/11 19:50, John M. Dlugosz escribió:

I don't understand why

|Catalyst::Plugin::Unicode::Encoding|

is necessary, based on the writup: it takes request arguments and 
converts them from whatever they came in to Perl's native encoding, 
and likewise for the response.


But Perl is using UTF-8 in its strings anyway.  So what's it have to 
do with the engine error I noticed before?


Now, with the plugin present, any literal characters in my template 
that take more than one byte in UTF8 are being interpreted as bytes 
and "converted" to UTF-8, improperly.  My template text is already in 
UTF8 !
   


Did you set ENCODING => 'utf-8' in the configuration of your TT View?

___
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] Encoding UTF8 ?

2011-03-28 Thread John M. Dlugosz

I don't understand why

|Catalyst::Plugin::Unicode::Encoding|

is necessary, based on the writup: it takes request arguments and converts them from 
whatever they came in to Perl's native encoding, and likewise for the response.


But Perl is using UTF-8 in its strings anyway.  So what's it have to do with the engine 
error I noticed before?


Now, with the plugin present, any literal characters in my template that take more than 
one byte in UTF8 are being interpreted as bytes and "converted" to UTF-8, improperly.  My 
template text is already in UTF8 !
___
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] Setting Model Class Variable from Catalyst Config

2011-03-28 Thread David Schmidt
On Mon, Mar 28, 2011 at 6:49 PM, Derek Wueppelmann  wrote:
> I want to be able to setup a configuration variable in my Catalyst config
> that will then be set as the value for one of my model's class variables.
> I have a model that will want to use a base path to store some files, However
> the Model doesn't know how to access Catalyst and so it can't get the data it
> needs. The other issue is that I need it as a class variable so that all of
> the instances of a particular class can access the same value once set. I'm
> thinking about calling an after method in the root Catalyst app module to set
> the variable, but I'm not sure which one I should modify.
>
> Anybody with some suggestions?
>
> --
>  o)   Derek Wueppelmann           (o
> (D .   dwuep...@gmail.com          D).
> ((`     http://www.monkeynet.ca   ( ) `
>
>
> ___
> 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/
>

Usually that's achieved by adding an attribute to your model and then
providing the value at model instantiation time

Example:
http://wiki.catalystframework.org/wiki/wikicookbook/configpass2schema

___
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] Setting Model Class Variable from Catalyst Config

2011-03-28 Thread Derek Wueppelmann
I want to be able to setup a configuration variable in my Catalyst config
that will then be set as the value for one of my model's class variables.
I have a model that will want to use a base path to store some files, However
the Model doesn't know how to access Catalyst and so it can't get the data it
needs. The other issue is that I need it as a class variable so that all of
the instances of a particular class can access the same value once set. I'm
thinking about calling an after method in the root Catalyst app module to set
the variable, but I'm not sure which one I should modify.

Anybody with some suggestions?

-- 
 o)   Derek Wueppelmann   (o
(D .   dwuep...@gmail.com  D).
((` http://www.monkeynet.ca   ( ) `


___
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] Response Headers

2011-03-28 Thread Denny
On Mon, 2011-03-28 at 08:12 -0500, John M. Dlugosz wrote:
> Where is Content-Type being set?
> 
> I'd like to send it instead as application/xhtml+xml, if the Accept header of 
> the request 
> claims to take that.

Catalyst::View::TT::XHTML

Regards,
Denny



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/


[Catalyst] Response Headers

2011-03-28 Thread John M. Dlugosz

Where is Content-Type being set?

I'd like to send it instead as application/xhtml+xml, if the Accept header of the request 
claims to take that.  I found this example of rewriting it in Apache, but it would be far 
easier to target the necessary pages, not to mention more elegant, if I did this within 
Catalyst.


|   AddType text/html .xhtml
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml\s*;\s*q=0
RewriteCond %{REQUEST_URI} \.xhtml$
RewriteCond %{THE_REQUEST} HTTP/1\.1
RewriteRule .* - [T=application/xhtml+xml]|



___
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] Sending Email from Page?

2011-03-28 Thread John M. Dlugosz

On 3/27/2011 12:22 PM, Tomas Doran bobtfish-at-bobtfish.net |Catalyst/Allow to 
home| wrote:


And I would say that sending an email is a state change, and behavior of the application 
domain here.
That's a stretch, because you can argue that any side-effect is a change of state to the 
universe at large and there happens to be no accessor to read the results of the change.  
It clearly matches "side effect", not "state", unless you stretch the definition to make 
all side effects into state and lose all distinction.




An arbitrary helper subroutine used by the Controller is not a Model.  Since it is 
side-effect only, it matches one of the links in the graph (Controller TO Model) so it 
"fits" in the architecture provides the proper connectivity.  But that is a kludge, not 
its proper usage.


Again, I think that the sending of email from the application is _very much_ behavior. 
If "behavior" includes causing side effects, sure.  That is certainly something the 
Controller is allowed to do, and is the Controller's responsibility.



In future you may want to replace the implementation of it, or wrap it with extra 
functionality (e.g. to count the number of emails sent), or reuse it in an application 
context beyond the web app (e.g. sending email from a batch script).


So?  That is an argument for encapsulation and abstraction, not for making it a 
Model.



With a model all of these things are not only possible, they're easy, and you've got a 
framework for the abstraction and use outside Catalyst already provided...


I think we are in agreement that using the auto-discovery/loading, and the dissemination 
of settings, and whatever else a Catalyst component does for you, might be handy for 
writing helper code, as opposed to making it a plain Perl module.


But that doesn't make it a "Model".  Saying it is (to promote auto-discovery and loading) 
is just a hack, done for that purpose only.


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