[Catalyst] Re: Questions If You Please

2012-03-05 Thread A. Pagaltzis
* James D Bearden  [2012-03-02 21:55]:
>  4) Finally, our current system relies on a more or less stock SSL over
> TCP socket for secure transport. I already have the conversion from
> a TCP socket connection to stateless HTTP working with minimal
> impact to our current codebase, but not the SSL to HTTPS. I see
> there is a module to require a secure connection, but is there no
> module to actually provide the secure connection? In other words, to
> use HTTPS do I need to proxy through a web server because there is
> no way for something like starman to do that by itself? What is
> complicating matters is our client is a thick Java application, so
> if there is no way then I would rather just build in some sort of
> mechanism to disable HTTPS for development rather than set up a
> HTTPS capable development web server.

I believe Starman has an unreleased branch that adds SSL support.

You can use App::TLSMe as a stopgap solution in the meantime.

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


[Catalyst] Re: Chained and exceptions

2013-05-14 Thread A. Pagaltzis
Hi Dimitar,

* Dimitar Petrov  [2013-05-14 12:35]:
> That's the proposition based on Bill's answer:
> https://github.com/dpetrov/catalyst-runtime/commit/391a98ed4e386af9ef11a3d4ea979f1e6a3c51f4

not sure why you’re replying to me, I don’t see a warning there.

> Any thoughts?

Needs a more specific name than `detach_on_die`. In my fork I called
the option `abort_dispatch_in_chains_on_exception`.

> On Tue, May 14, 2013 at 6:35 AM, Aristotle Pagaltzis wrote:
>
> > * Tomas Doran  [2013-05-10 19:55]:
> > > We should make it a config variable that defaults to the old behaviour
> > > but adjust -Devel to default it to true in new apps.
> > >
> > > This keeps back compat, but makes new apps behave 'correctly'.
> > >
> > > +1 from me.
> >
> > Should there be a warning in old apps when an exception gets swallowed?
> >
> > Regards,
> > --
> > Aristotle Pagaltzis // 

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


[Catalyst] Re: Catalyst Unicode woes ctd.

2007-10-06 Thread A. Pagaltzis
* Bill Moseley <[EMAIL PROTECTED]> [2007-10-03 16:15]:
> INSERT uses load() and from my quick look load() doesn't call
> _decode_unicode() and that's where the BOM and ENCODING checks
> happen.

I know I’m not very constructive here… but have I mentioned that
TT2 sucks?

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: uri_for() behaviour

2007-10-06 Thread A. Pagaltzis
* Peter Karman <[EMAIL PROTECTED]> [2007-10-03 16:55]:
> The main reason I used uri_for() for external URIs was for the
> nice uri-escaping features when dealing with params.

URI::FromHash

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: Encoding problem - ?fastcgi?

2007-10-08 Thread A. Pagaltzis
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.

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

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


[Catalyst] Re: connecting to a remote sqlite

2007-10-15 Thread A. Pagaltzis
* Matt S Trout <[EMAIL PROTECTED]> [2007-10-14 19:00]:
> Kill me now.

*blam*

Pains me to have had to do it, but he was too far gone.

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: returning empty 200 response

2007-10-28 Thread A. Pagaltzis
Hi Devo,

* Devo Coran <[EMAIL PROTECTED]> [2007-10-26 21:30]:
> This is probably a basic question but after playing
> around for a few hours and going through the docs I
> haven't been able to figure it out.

that’s because you’re looking at the wrong layer. :-)

> Appreciate it if maybe someone could point me in the right
> direction for docs.

http://tools.ietf.org/html/rfc2616

> Basically I'm doing an ajax save from a text area, so all I
> care about is that I get a 200 back from the framework I don't
> need a body, my text hasn't gone anywhere.

You want 204, not 200; cf. RFC 2616 sec. 10.2.5:

== 204 No Content ==

The server has fulfilled the request but does not need to
return an entity-body, and might want to return updated
metainformation. […] If the client is a user agent, it SHOULD
NOT change its document view from that which caused the
request to be sent. This response is primarily intended to
allow input for actions to take place without causing a
change to the user agent's active document view […] The 204
response MUST NOT include a message-body, and thus is always
terminated by the first empty line after the header fields.

Note that RenderView will just DWYM if you set the status to 204
(cf. Jonathan’s reply), leaving the body empty and skipping the
template rendering phase with no further action on your part.

Some unsolicited advice, not really addressed at you in
particular: anyone who develops web apps should take the time at
some point to read RFC 2616, the HTTP specification, in full. It
is pretty modest in length and easily comprehensible, if a bit
dry as specs are wont to be. (Make sure to understand how MAY,
SHOULD and MUST are used in RFCs though; they are defined in
RFC 2119 (which is *very* short).) HTTP is not merely a low-layer
implementation detail like TCP: it’s an application protocol.
Know your way around it well, and know how the concepts of the
framework you use translate to it.

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: Hypothetical Site and Scalability Planning

2007-10-28 Thread A. Pagaltzis
* Robert Mah <[EMAIL PROTECTED]> [2007-10-28 15:00]:
> Memcached is not distributed.

What are you talking about?

> Thus, you can't support distributed session state with it.

Well, you can’t put sessions in it because it doesn’t guarantee
that things you put in it will stay in it (it’s a cache, not a
persistence layer), but that has nothing to do with what you’re
saying.

> Having only one server is obviously bad from a scalability and
> reliability point of view. 

Not sure, again, what you are talking about. In May this year
Facebook reported that their memcached installation comprises
about 200 16GB 4-core AMD64 servers:


Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: "Save as..."

2007-11-10 Thread A. Pagaltzis
* Octavian Rasnita <[EMAIL PROTECTED]> [2007-11-09 15:47]:
> 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.

That’s not something you can affect from HTTP. It’s the way your
browser implements that aspect of HTTP. Apparently if you don’t
explicitly tell it that you want to save something under a
different name from the one in the URI (or the header, in this
case), it won’t ask you for a name.

I admit, I personally like that. I remember the days when the
“Save As” dialog was routinely popped up, and how that made it
much more of a hassle to download things.

I think most browsers can be configured to ask if you really want
them to. I never bothered to look for such a setting though.

> Can you tell me what other headers do I need to print,

There is no way to do that with HTTP headers. Even the
Content-Disposition thing is really just a MIME thing that HTTP
inherited from internet mail. In mail, it doesn’t make sense to
have an part of the mail that prompts you for printing instead
of being displayed as an attachment.

On HTML pages, you can use Javascript to invoke the browser’s
print dialog. Many “printable version” templates on sites on the
internet have that. For other media types, you’re out of luck.

> 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)?

Well, you already can. It’s just the browser vendor decided not
to offer UI to change the filename in such a case…

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: difficulty in assigning an array to a stash

2007-11-11 Thread A. Pagaltzis
* Mark Smith <[EMAIL PROTECTED]> [2007-11-11 19:15]:
> While you're at it, try "perldoc perlreftut" and "perldoc
> perlref" for more information on references.

Also `perldoc perllol` and `perldoc perldsc`.

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: difficulty in assigning an array to a stash

2007-11-12 Thread A. Pagaltzis
* Carl Johnstone <[EMAIL PROTECTED]> [2007-11-12 12:10]:
> jagdish eashwar wrote:
>> I am getting only the last value in the tt2 template. 
> You're actually getting the number of items in the list,
> because that's what you get when you turn a list into a single
> value.

No, that’s what you get from an array in scalar context. Lists
and arrays are not the same.

$ perl -le'@_=("a"..."z"); print [EMAIL PROTECTED]; print [EMAIL PROTECTED]'
26
z

(I didn’t just say `$_=("a".."z")` because that puts the
right-hand side in scalar context, where the `..` operator is
a flip-flop, not a range.)

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: need JSON converter which supports unquoted strings

2007-11-19 Thread A. Pagaltzis
* Moritz Onken <[EMAIL PROTECTED]> [2007-11-19 15:30]:
> sorry, a bit off topic, but I'm looking for a
> perl-object-to-JSON converter which supports unquoted strings.

Derived though from Javascript as it may be, JSON is not
Javascript, and there is no such thing in JSON as an unquoted
(or single-quoted) string.

> Modules like JSON::Any quote everything except true and false.

Now you know why.

> But I need to pass unquoted strings to let JavaScript run some
> functions.
> 
> Any suggestions?

Dump your data structure to JSON incrementally and interpolate
the JSON snippets into a template that generates Javascript which
does whatever you need to build the final data structure. (You’re
generating Javascript and not JSON anyway.)

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: BBC's "Perl on Rails" nuttiness

2007-12-03 Thread A. Pagaltzis
http://iamseb.com/seb/2007/12/perl-on-rails-why-the-bbc-fails-at-the-internet/

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


[Catalyst] Re: [patch] Catalyst::Engine::HTTP exec() options

2007-12-04 Thread A. Pagaltzis
* Chisel Wright <[EMAIL PROTECTED]> [2007-12-05 00:00]:
> -exec $^X . ' "' . $0 . '" ' . join( ' ', @{ $options->{argv} } );
> +exec $^X . ' "' . $0 . '" ' . join( ' ', map(qq{'$_'},@{ 
> $options->{argv} }) );

That’s brittle. A single quote in any of the arguments will break
it. It’s like “fixing” an SQL injection hole by putting quotes
around interpolated variables. Just as in that scenario, the
robust fix is to actually shell-quote the variables:

q{'} . ( join q{'\\''}, split /'/, $_, -1 ) . q{'}

But unless the command line is *supposed* to be interpreted by
shell (and that seems unlikely to me), that’s still the wrong
fix. The right fix is to use the list form of `exec`, which keeps
the shell entirely out of the picture:

exec $^X, $0, @{ $options->{argv} };

Hey lookit, that’s simpler to write too! :-)

-- 
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // 

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


[Catalyst] Re: State of the art in form validation; opinion poll… Model based forms/validation?

2007-12-05 Thread A. Pagaltzis
* Bill Moseley <[EMAIL PROTECTED]> [2007-12-05 05:45]:
> The Rose form code is very cool. That's what I based my forms
> on.

Disclaimer: I haven’t used Form::Processor. However from what
I have seen so far, it seems to solve the *right* problem, with
the right level of abstraction for common things and tweakability
for individual needs, so it currently seems like the most likely
validation framework to work for me.

> I don't find automatic form markup creation that useful -- the
> forms always seem to need customization.

Template system of choice + HTML::FillInForm works for me and
keeps things reasonably low-effort.

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: trouble with model->dbic resultset

2007-12-06 Thread A. Pagaltzis
* Michael Higgins <[EMAIL PROTECTED]> [2007-12-05 22:40]:
> Isn't that some general principle, you find the error just
> after emailing a whole bunch of people?

Another effective [debugging] technique is to explain your
code to someone else. This will often cause you to explain
the bug to yourself. Sometimes it takes no more than a few
sentences, followed by an embarrassed “Never mind. I see
what’s wrong. Sorry to bother you.” This works remarkbly
well; you can even use non-programmers as listeners. One
university computer center kept a teddy bear near the help
desk. Students with mysterious bugs were required to explain
them to the bear before they could speak to a human
counselor.

—Brian W Kernighan, Rob Pike, “The Practice of Programming”

Reportedly, this noticably reduced the load on the understaffed
centre.

Regards,
-- 
Aristotle Pagaltzis // 

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


[Catalyst] Re: retrieving multiple values from forms

2007-12-17 Thread A. Pagaltzis
* Andrew Rodland <[EMAIL PROTECTED]> [2007-12-17 22:40]:
> On Monday 17 December 2007 03:01:53 pm Matt S Trout wrote:
> > On Sat, Dec 15, 2007 at 01:10:52PM -0600, Andrew Rodland wrote:
> > > See the perldoc for Catalyst::Request -- the 'param' method
> > > comes in handy here.
> > >
> > > @values = $c->req->param('whatever');
> >
> > No it doesn't.
> >
> > That method is there for CGI.pm compatibility. Don't use it
> > in new code.
> 
> It's also the only one that has a sensible semantic. "Might be
> an unblessed scalar or an arrayref" is silly for something
> that's naturally a _list_. If param wasn't there I would have
> to write a method that did the same thing, and use that.

None of these interfaces is sane. The problem with CGI.pm’s
interface is this:

Foo->new(
bar => $q->param( 'bar' ),
baz => $q->param( 'baz' ),
);

Now if someone sends you this query string:

?bar=1;baz=2;baz=is_admin;baz=1

the call evaluates to


Foo->new(
bar => 1,
baz => 2, 'is_admin', 1,
);

Woops.

So CGI.pm forces you to pepper your code with `scalar`s to make
it safe:

Foo->new(
bar => scalar $q->param( 'bar' ),
baz => scalar $q->param( 'baz' ),
);

Catalyst’s interface avoids that. However, Catalyst’s way of
“either you get an arrayref or a scalar” isn’t sane either since
it forces you to pepper your code just as much if not more, if
you want it to react predictably regardless of how many arguments
were passed.

The *sane* thing is neither.

The sane thing is to have *TWO* methods, one that *always*
returns a scalar, and one that *always* returns a list. (Or
rather, an arrayref, because if it’s just a list, it is easy to
improperly treat it like a scalar, whereas if it’s an arrayref
it’s impossible to forget to unpack the array when you meant to
do that.)

Then you can say what you mean, you can say it *easily* either
way, and the result is always completely determined by what the
code says and not at all by what the data looks like. Sanity.

-- 
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // 

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


[Catalyst] Re: javascript in Catalyst using Template Toolkit

2007-12-22 Thread A. Pagaltzis
* Daniel McBrearty <[EMAIL PROTECTED]> [2007-12-22 00:30]:
> on the other hand, if you are running your app on a server that you
> own and do admin for, and don't have such admin problems to negotiate,
> it would be fine, eh? horses for courses and all that.

Is it appreciably less work to omit the `[% c.uri_for('') %]`?

It less than 20 extra characters up front. If you omit then, you
won’t even notice the saved effort. But believe you me, if you
ever do need to deploy to a location you didn’t anticipate, and
you’re faced with updating *all* the links you wrote *at once*,
you *will* notice that effort, many times over.

It’s like cheating a cashier out of a three pennies.

Regards,
-- 
Aristotle Pagaltzis // 

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



[Catalyst] Re: process stand alone css file with TT?

2008-07-24 Thread A. Pagaltzis
* Kyle Godbold <[EMAIL PROTECTED]> [2008-07-24 22:20]:
> Is there any way to use Template Toolkit to render a stand
> alone css page that can be linked in with  ?

Use Static::Simple instead?

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