Loading ...
Sorry, an error occurred while loading the content.

Comments on Struts-like mod_perl module

Expand Messages
  • Stuart Moffatt
    All, About a month ago, I was put on a project that was perl-based, but with no framework. As our GUI team develops mostly in java, and now mostly with struts,
    Message 1 of 8 , Dec 4, 2003
    • 0 Attachment
      All,

      About a month ago, I was put on a project that was perl-based, but with no
      framework. As our GUI team develops mostly in java, and now mostly with
      struts, I came to love the MVC architecture. Simple to estimate, design, and
      maintain. I loved struts mvc so much that I implemented a struts-like
      framework in plain old CGI. I used it for the perl project with great
      success: quick, modular development from the client to the API.

      I called it Straps (STRuts - A Perl Substitute). [Struts-developers: Let me
      know if I've broken the rules for embedding Struts in the nickname]. It is a
      bit of a cutesy name, but I didn't want to assume I could use Struts.pm --
      and it really isn't just an interface to a struts-ish servlet, it actually
      replaces one.

      The main controller, rather than a java servlet, is a cgi installed in the
      docroot at /straps/servlet.cgi
      All requests go through this cgi, fire off Actions and ActionForms (just
      like struts), store data in the session. and then land on a resulting cgi
      page that would get the data out of the session and load up an
      HTML::Template for the view. The ActionForms contain our application data
      models.

      All in all, a rudimentary, but working version of a perl implementation of
      struts.

      But like most CGI apps, there were failings (performance, URI control, etc)

      In the last two weeks, I've converted the "servlet" cgi to mod_perl, and
      made it look like a real struts servlet. I have not ported the application
      yet, but I have a new project that is also perl so I will build this app on
      top of the mod_perl version of Straps, which I am tentatively calling
      Apache::Straps. You all know the kinds of speed improvements I've seen
      (100-150x on the loading of the framework alone with a small test
      application), not to mention the hooks into the URI-mapping and request
      cycle that I am ecstatic about.

      Anyway, I thought the Right Thing To Do was get the idea out on this list
      before any upload to CPAN, etc. I suppose at some point I'd have to talk to
      the Struts people to find out if they mind as the framework and config file
      uses the same naming conventions as struts.

      Comments?

      Thanks,
      Stuart

      Stuart Moffatt - smoffatt@...
      Software Developer, User Interface - (613)591-6655 x2009
      http://www.bridgewatersystems.com

      --
      Reporting bugs: http://perl.apache.org/bugs/
      Mail list info: http://perl.apache.org/maillist/modperl.html
    • Ken Y. Clark
      On Thu, Dec 04, 2003 at 12:11:25PM -0500, Stuart Moffatt wrote: [...] ... Stuart, Sounds very interesting! The best place to take up CPAN naming issues is on
      Message 2 of 8 , Dec 4, 2003
      • 0 Attachment
        On Thu, Dec 04, 2003 at 12:11:25PM -0500, Stuart Moffatt wrote:
        [...]
        > Anyway, I thought the Right Thing To Do was get the idea out on this list
        > before any upload to CPAN, etc. I suppose at some point I'd have to talk to
        > the Struts people to find out if they mind as the framework and config file
        > uses the same naming conventions as struts.

        Stuart,

        Sounds very interesting! The best place to take up CPAN naming issues
        is on "module-authors@...." More info:

        http://lists.perl.org/showlist.cgi?name=module-authors

        Try posting your ideas there to clear the namespace.

        ky
      • Stuart Moffatt
        ... Thanks for the tip - I ve looked there before for hints. Which is why I am talking here. But the weirdness of it is that Struts is not a CPAN issue, it s
        Message 3 of 8 , Dec 4, 2003
        • 0 Attachment
          >Ken said:
          >Sounds very interesting! The best place to take up CPAN
          >naming issues is on "module-authors@...." More info:
          >
          > http://lists.perl.org/showlist.cgi?name=module-authors
          >
          >Try posting your ideas there to clear the namespace.
          >
          >ky
          >


          Thanks for the tip - I've looked there before for hints. Which is why I am
          talking here.

          But the weirdness of it is that Struts is not a CPAN issue, it's an Apache
          project (separate and apart from mod_perl)
          So even if I clear the CPAN namespace under Apache::, I think I would still
          want to talk to Struts folks.

          Thanks,
          Stuart

          Stuart Moffatt - smoffatt@...
          Software Developer, User Interface - (613)591-6655 x2009
          http://www.bridgewatersystems.com

          --
          Reporting bugs: http://perl.apache.org/bugs/
          Mail list info: http://perl.apache.org/maillist/modperl.html
        • Stas Bekman
          Stuart Moffatt wrote: [...] ... Apache::Straps sounds unique enough to me, though recently quite a few people have voiced their pain in having core API and
          Message 4 of 8 , Dec 4, 2003
          • 0 Attachment
            Stuart Moffatt wrote:
            [...]
            > In the last two weeks, I've converted the "servlet" cgi to mod_perl, and
            > made it look like a real struts servlet. I have not ported the application
            > yet, but I have a new project that is also perl so I will build this app on
            > top of the mod_perl version of Straps, which I am tentatively calling
            > Apache::Straps. You all know the kinds of speed improvements I've seen
            > (100-150x on the loading of the framework alone with a small test
            > application), not to mention the hooks into the URI-mapping and request
            > cycle that I am ecstatic about.
            >
            > Anyway, I thought the Right Thing To Do was get the idea out on this list
            > before any upload to CPAN, etc. I suppose at some point I'd have to talk to
            > the Struts people to find out if they mind as the framework and config file
            > uses the same naming conventions as struts.

            Apache::Straps sounds unique enough to me, though recently quite a few people
            have voiced their pain in having core API and applications all living in the
            Apache:: namespace. So you may want to consider putting it under
            Apache::App::Straps, or Apache::MVC::Straps, or something else...

            __________________________________________________________________
            Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
            http://stason.org/ mod_perl Guide ---> http://perl.apache.org
            mailto:stas@... http://use.perl.org http://apacheweek.com
            http://modperlbook.org http://apache.org http://ticketmaster.com


            --
            Reporting bugs: http://perl.apache.org/bugs/
            Mail list info: http://perl.apache.org/maillist/modperl.html
          • Chris Winters
            ... It s probably frowned upon by the namespace purists, but FWIW the next version of OpenInteract (another webapp framework with some Struts-inspired
            Message 5 of 8 , Dec 4, 2003
            • 0 Attachment
              Stas Bekman wrote:
              > Apache::Straps sounds unique enough to me, though recently quite a few
              > people have voiced their pain in having core API and applications all
              > living in the Apache:: namespace. So you may want to consider putting it
              > under Apache::App::Straps, or Apache::MVC::Straps, or something else...

              It's probably frowned upon by the namespace purists, but FWIW the
              next version of OpenInteract (another webapp framework with some
              Struts-inspired features) has just the Apache-related stuff in
              the Apache:: namespace. Everything else is in OpenInteract2::.

              Chris

              --
              Chris Winters (chris@...)
              Building enterprise-capable snack solutions since 1988.


              --
              Reporting bugs: http://perl.apache.org/bugs/
              Mail list info: http://perl.apache.org/maillist/modperl.html
            • Stas Bekman
              ... BTW, Per Einar has created this module naming advisory some time ago: http://perl.apache.org/products/apache-modules.html#Module_Naming_Conventions ...
              Message 6 of 8 , Dec 4, 2003
              • 0 Attachment
                Chris Winters wrote:
                > Stas Bekman wrote:
                >
                >> Apache::Straps sounds unique enough to me, though recently quite a few
                >> people have voiced their pain in having core API and applications all
                >> living in the Apache:: namespace. So you may want to consider putting
                >> it under Apache::App::Straps, or Apache::MVC::Straps, or something
                >> else...

                BTW, Per Einar has created this module naming advisory some time ago:
                http://perl.apache.org/products/apache-modules.html#Module_Naming_Conventions

                > It's probably frowned upon by the namespace purists, but FWIW the next
                > version of OpenInteract (another webapp framework with some
                > Struts-inspired features) has just the Apache-related stuff in the
                > Apache:: namespace. Everything else is in OpenInteract2::.

                Why? Sounds perfectly well to me.

                __________________________________________________________________
                Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
                http://stason.org/ mod_perl Guide ---> http://perl.apache.org
                mailto:stas@... http://use.perl.org http://apacheweek.com
                http://modperlbook.org http://apache.org http://ticketmaster.com


                --
                Reporting bugs: http://perl.apache.org/bugs/
                Mail list info: http://perl.apache.org/maillist/modperl.html
              • Gunther Birznieks
                ... I like this as well. How is the performance under CGI though? Do you support an identical config to struts? Which version of struts do you support? Do you
                Message 7 of 8 , Dec 5, 2003
                • 0 Attachment
                  Stuart Moffatt wrote:

                  >All,
                  >
                  >About a month ago, I was put on a project that was perl-based, but with no
                  >framework. As our GUI team develops mostly in java, and now mostly with
                  >struts, I came to love the MVC architecture. Simple to estimate, design, and
                  >maintain. I loved struts mvc so much that I implemented a struts-like
                  >framework in plain old CGI. I used it for the perl project with great
                  >success: quick, modular development from the client to the API.
                  >
                  >
                  >
                  I like this as well. How is the performance under CGI though? Do you
                  support an identical config to struts? Which version of struts do you
                  support?

                  Do you sit on top of wombat? The Perl Servlet API?

                  >I called it Straps (STRuts - A Perl Substitute). [Struts-developers: Let me
                  >know if I've broken the rules for embedding Struts in the nickname]. It is a
                  >bit of a cutesy name, but I didn't want to assume I could use Struts.pm --
                  >and it really isn't just an interface to a struts-ish servlet, it actually
                  >replaces one.
                  >
                  >
                  >
                  Sounds good to me.

                  >The main controller, rather than a java servlet, is a cgi installed in the
                  >docroot at /straps/servlet.cgi
                  >All requests go through this cgi, fire off Actions and ActionForms (just
                  >like struts), store data in the session. and then land on a resulting cgi
                  >page that would get the data out of the session and load up an
                  >HTML::Template for the view. The ActionForms contain our application data
                  >models.
                  >
                  >
                  >
                  Interesting! Do you emulate the Struts widgets in HTML::Template?

                  >All in all, a rudimentary, but working version of a perl implementation of
                  >struts.
                  >
                  >But like most CGI apps, there were failings (performance, URI control, etc)
                  >
                  >In the last two weeks, I've converted the "servlet" cgi to mod_perl, and
                  >made it look like a real struts servlet. I have not ported the application
                  >yet, but I have a new project that is also perl so I will build this app on
                  >top of the mod_perl version of Straps, which I am tentatively calling
                  >Apache::Straps. You all know the kinds of speed improvements I've seen
                  >(100-150x on the loading of the framework alone with a small test
                  >application), not to mention the hooks into the URI-mapping and request
                  >cycle that I am ecstatic about.
                  >
                  >
                  >
                  I think the Apache-specific one should be Apache::App::Straps (similar
                  to Chris' thing) but that you should make this module as Apache-specific
                  as possible but require CGI::Straps or Straps or CGI::App::Straps as the
                  core set of modules that defines straps.

                  If you put this project primarily under the Apache::* namespace, it will
                  be mistakenly branded as being Apache-specific which it shouldn't be IMHO.

                  The best two examples of modules that were created under Apache::*
                  namespace and still (I believe) confuse people into thinking they are
                  only for mod_perl is Apache::Session (which can be used for CGIs) and
                  Apache::DBI (which can be used for other persistent Perl environments).
                  I personally believe you should avoid this problem.

                  In addition, there are many other mechanisms for improving performance
                  of CGI from SpeedyCGI and I think Matt Sergeant has a PersistentPerl
                  interface, and then there is ActiveState's PerlEx (Not greatly supported
                  these days but it does exist )for IIS and Velocigen as a commercial
                  product to embed Perl in Netscape And ISAPI Servers like IIS... etc..

                  So I think if a group of people used SpeedyCGI, you might find your CGI
                  version of Straps having reasonable performance.

                  >Anyway, I thought the Right Thing To Do was get the idea out on this list
                  >before any upload to CPAN, etc. I suppose at some point I'd have to talk to
                  >the Struts people to find out if they mind as the framework and config file
                  >uses the same naming conventions as struts.
                  >
                  >Comments?
                  >
                  >
                  >
                  Where is the website? straps.sourceforge.com? :)

                  Is there a mailing list I can subscribe to? You might want to also cross
                  post to the p5ee mailing list ... as servlet API to some degree falls a
                  little bit under p5ee (servlets being a part of j2ee).

                  Good Luck!
                  Gunther





                  --
                  Reporting bugs: http://perl.apache.org/bugs/
                  Mail list info: http://perl.apache.org/maillist/modperl.html
                • Stuart Moffatt
                  ... The performance under CGI is not too fast as the servlet.cgi is using Location headers to redirect to that action s view script. Plus, because there are no
                  Message 8 of 8 , Dec 10, 2003
                  • 0 Attachment
                    Gunther said:
                    >I like this as well. How is the performance under CGI though? Do you
                    >support an identical config to struts? Which version of struts do you
                    >support?

                    The performance under CGI is not too fast as the servlet.cgi is using
                    Location headers to redirect to that action's view script. Plus, because
                    there are no hooks into manipulating the URI, there are state reload issues.

                    >Do you sit on top of wombat? The Perl Servlet API?

                    Neither. Like I said, this is a simple replacement. The main handler is
                    Servlet.pm which reads the servlet context and action path from the request.
                    The servlet context is already config'd in httpd.conf like this:

                    PerlModule Apache::Straps::Servlet
                    <Location /myapp/
                    SetHandler perl-script
                    PerlHandler Apache::Straps::Servlet
                    PerlSendHeader On
                    </Location>

                    Then when the client hits http://<host>/myapp/get/account.do the Servlet.pm
                    loads a Apache::Straps::Config object (kept as a Storable::File and parsed
                    from corresponding XML at startup) from disk, looks for the action path,
                    loads the action (and action form if necessary), the executes performAction
                    in the action. This returns a success or error, which the servlet then uses
                    to do an internal lookup. Here is what the XML looks like:

                    <action path="/get/account.do">
                    <class>MyOrg::MyApp::client::actions::GetAccountAction</class>
                    <forward name="success" path="/myapp/billing/account.pl" />
                    <forward name="error" path="/myapp/billing/index.pl" />
                    </action>

                    The forward path (ie /myapp/billing/account.pl) does a bit of work setting
                    up a template from Template Toolkit, which is processed and pushed to the
                    client.

                    That's the long way of saying: no wombat, no Perl Servlet API. At least not
                    for this cut ;)

                    >Interesting! Do you emulate the Struts widgets in HTML::Template?

                    My original cgi used HTML::Template, but without Struts-like tiles or
                    taglibs. The mod_perl uses Template Toolkit because it is the best template
                    system around. As far as I know, it is like Struts 1.0, except that I can
                    support multiple servlets just by adding a similar block in httpd.conf with
                    a new location, and mapping the location directive to the same-name config
                    file on disk.

                    >I think the Apache-specific one should be Apache::App::Straps (similar
                    >to Chris' thing) but that you should make this module as
                    >Apache-specific
                    >as possible but require CGI::Straps or Straps or
                    >CGI::App::Straps as the
                    >core set of modules that defines straps.

                    Yeah, that would be nice. If I get the time...

                    >If you put this project primarily under the Apache::*
                    >namespace, it will
                    >be mistakenly branded as being Apache-specific which it
                    >shouldn't be IMHO.
                    >
                    >The best two examples of modules that were created under Apache::*
                    >namespace and still (I believe) confuse people into thinking they are
                    >only for mod_perl is Apache::Session (which can be used for CGIs) and
                    >Apache::DBI (which can be used for other persistent Perl
                    >environments).
                    >I personally believe you should avoid this problem.

                    You're right. I may go with just Straps or if I only release the mod_perl
                    version, then something like Apache::App::Straps.

                    >In addition, there are many other mechanisms for improving performance
                    >of CGI from SpeedyCGI and I think Matt Sergeant has a PersistentPerl
                    >interface, and then there is ActiveState's PerlEx (Not greatly
                    >supported
                    >these days but it does exist )for IIS and Velocigen as a commercial
                    >product to embed Perl in Netscape And ISAPI Servers like IIS... etc..
                    >
                    >So I think if a group of people used SpeedyCGI, you might find
                    >your CGI
                    >version of Straps having reasonable performance.

                    Are you volunteering to make the CGI version work under those kits?

                    >Where is the website? straps.sourceforge.com? :)

                    Not yet. Like all of us, I am swamped at work with other code. Perhaps in
                    January.
                    And thanks for the tip on p5ee. A little overkill for what I need right now,
                    but its good to know about.

                    I'll let the list know when I release Straps. Thanks for all of your
                    comments.

                    [Back into lurk mode to finish some code...]

                    Thanks,
                    Stuart

                    Stuart Moffatt - smoffatt@...
                    Software Developer, User Interface - (613)591-6655 x2009
                    http://www.bridgewatersystems.com

                    --
                    Reporting bugs: http://perl.apache.org/bugs/
                    Mail list info: http://perl.apache.org/maillist/modperl.html
                  Your message has been successfully submitted and would be delivered to recipients shortly.