passing of - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: passing of

On Thursday, 24 December 2015 17:39:04 UTC, Scott Bryce  wrote:
Quoted text here. Click to load it

Firstly, there was a typo in my post. The shebang line should be "/usr/bin/env plackup". Sorry about that.

Secondly, many people use the extension .psgi.


Re: passing of writes:
Quoted text here. Click to load it

Ugh. If that's the idea "plack people" of have 'sensibly structured
application code', the only possible course of action is "Keep calm and
run away screaming".

PSGI doesn't require an application to be an unstructured mess of
hundreds or even thousands of sequentially executed statements, it just
needs a file which can be loaded and which returns a subroutine
reference (according to the documentation).

Re: passing of

On Thursday, 24 December 2015 18:51:52 UTC, Rainer Weikusat  wrote:
Quoted text here. Click to load it

I'm not sure how you can decide that this is badly structured code from these few lines. It's simply a basic example showing how you might convert an existing CGI program to PSGI.

Quoted text here. Click to load it

That's correct. And usually everything would be neatly packaged in classes. Often a PSGI will look like:

  use strict;
  use warnings;
  use lib '/path/to/your/app/classes';

  use My::App::Class;

  my $app = My::App::Class->to_app;

to_app() is fast becoming the standard name for a class method with returns your app's anonymous sub.

You seem pretty determined to find fault in my posts about PSGI. No-one is saying that you must use it. Only that it will almost certainly make your life easier. But if you're happy to carry on using your current technologies then that's fine too.


Re: passing of writes:
Quoted text here. Click to load it

And considering that that's almost exactly what Apache::Registry does in
order to run 'existing CGI programs', it will neatly duplicate all the
terrible problems you warned about "not that long ago" should it ever be
deployed in an environment where the compile code is persistent. A text
documenting these is available here,

IOW, this is a simple example of how PSGI/ Plack buys you exactly
nothing wrt 'portability to different web application execution
environment'. The only purpose of the above is really to find a way to
include Plack in the execution path for the purpose of including it.

Quoted text here. Click to load it

Perl is not Java and referring to a module which isn't used as a class
as 'class' is a bit strange.

A sensibly structured non-trivial application will have some kind of
'top-level entry point' (similar to the main function of a C program). I
usually use a 'nameless' block for that as this implies the 'main
program' gets it's own lexical scope different from the lexical scope
used for shared my-variables. The simple way to turn something like this
into a PSGI application is to have a 'main program' at the end of the
file which looks like this

# main program code

instead. Assigning this to a my variable for no particular reason is
very likely not necessary (the PSGI documentation mentions that an
application should return a subroutine when executed via do).

With such an approach, there'll still be possible issues with lexically
scoped, shared variables as these will keep their values and more than
one instance of 'the program' might exist at runtime (if mod_perl is
being used, one for each Perl interpreter, eg, Apache process) but at
least, invoking the 'application subroutine' will not create a new set
of supposed-to-be-shared my variables used by 'the main program code'
while all subroutines defined by that will continue using the old ones.


Quoted text here. Click to load it

In order for something to be found, it must exist in the first place and
I surely didn't write your texts. Also, that you wrote them and that
they're supposed to be about PSGI isn't really of concern to me, just
the content.

Re: passing of

Quoted text here. Click to load it

Do what I am doing, Dancer2

Site Timeline