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

OT: (slightly) RAD RDBMS tools for perl/Apache::ASP

Expand Messages
  • Jim Helm
    This isn t specific to Apache:ASP, but I ve seen a lot of good advice here, and hopefully someone has already been through this. I was just wondering if anyone
    Message 1 of 14 , Mar 20, 2002
    • 0 Attachment
      This isn't specific to Apache:ASP, but I've seen a lot of good advice
      here, and hopefully someone has already been through this.

      I was just wondering if anyone had used/knows of anything for perl
      similar to phpLens. I haven't actually used it, but it looks pretty
      impressive. I'd prefer to stick with perl, though. I've searched
      through CPAN, and on google, and haven't found anything obviously like
      phpLens for perl, but there's a lot out there and I may have just missed
      it. The closest I think I've seen so far is DBIx::HTMLView, but it's
      only for mySQL and mSQL (needs some extra coding for other DBD drivers -
      I think).

      Basically, I'm just looking for some tools for generating things like
      master/detail editing forms and backends. I'm not looking to avoid
      coding entirely, just for something to make life easier. I don't need
      all the bells and whistles of phpLens - though they would be nice. And
      I need to be able to make updates - simply displaying data is fairly
      trivial, and I wouldn't need to ask for tools to do that - they are a
      dime a dozen (though not all of the same quality!).

      My alternative will probably be to use Oracle Forms (since we have a
      site license for nearly every Oracle product for internal use only), but
      I really want stick to perl if I can - mostly so I'm not tied to
      Oracle's RDBMS in the future. If you've read this far thanks. If you
      have suggestions, thanks a lot!

      I suppose if there's nothing like phpLens, I'll either have to use
      Forms, roll my own perlLens, or switch to PHP and buy phpLens.

      Thanks again,

      Jim

      -----Original Message-----
      From: constfilin [mailto:constfilin@...]
      Sent: Monday, March 18, 2002 5:58 PM
      To: asp@...
      Subject: A newbie question


      greetings -

      Let me start with a confession that I'm a newbie to perl and
      modules although I've got truckloads of experience on Windows ASP side.
      Anyway, I need a bit of wizdom on how to use
      packages with Apache::ASP. Please read on.

      In my httpd.conf I have

      PerlSetVar UseStrict 1
      PerlSetVar UniquePackages 0

      then I have a script - called "Login.pl" - that goes like this:

      <html>
      <% $Response->Include($Server->MapPath("/pls/Common/consts.pl"),"");
      $Response->Write(blabla()."<BR>");
      $Response->Write("A_VARIABLE=".$A_VARIABLE."<BR>");
      %>
      </html>

      The contents of /pls/Common/consts.pl is

      <%
      our $A_VARIABLE = "whatever";
      sub blabla {
      "blabla";
      }
      %>

      Now, when I execute Login.pl, I get this error in errors_log
      "Variable "$A_VARIABLE" is not imported at Login.pl line 5."

      I would like to get rid of this error without having
      "PerlSetVar UseStrict 0" in httpd.conf. But how? Using
      "no strict" in Login.pls does not help, and all perl
      keywords "local", "my", and "our" are scoped to the current
      file, eval or block. Using no keyword at all to declare
      $A_VARIABLE gives the same error, but now in file consts.pl.

      Should I really make a separate Perl package out of consts.pl and then
      import the variables from package consts into Login.pl? This seems a
      little absurd because per "PerlSetVar UniquePackages
      0" in httpd.conf, both Login.pl and consts.pl are in the same
      package, and there should be a simple way for any script in
      the package to use variables declared in other scripts of the
      package. Or am I wrong? Please let me know.

      Thank you in advance

      Constantine



      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...


      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    • Ellers
      ... Its a good question... I haven t seen anything myself which suprised me. It would have been really handy for me too. With DBI/DBD I would ve thought a set
      Message 2 of 14 , Mar 20, 2002
      • 0 Attachment
        At 6:56 PM -0800 20/3/02, Jim Helm wrote:
        >This isn't specific to Apache:ASP, but I've seen a lot of good advice
        >here, and hopefully someone has already been through this.
        >...
        >Basically, I'm just looking for some tools for generating things like
        >master/detail editing forms and backends. I'm not looking to avoid
        >coding entirely, just for something to make life easier.


        Its a good question... I haven't seen anything myself which suprised
        me. It would have been really handy for me too. With DBI/DBD I
        would've thought a set of classes could be designed to make it
        easy(er) to browse and edit rows.

        e.g.

        <% # browse_books.asp #

        use DBD::Forms;

        ### prepare a Forms RowBrowser - note that the database
        ### handle could be oracle, mysql, etc...
        my $browser = new DBD::Forms::RowBrowser( $dbh );

        ### prepare the browser to look at rows from the book table
        $browser->prepare(
        Table => 'Book',
        SelectColumns => [qw/ title isbn authorlist year/],
        SortColumn => 'title',
        RowsPerPage => 10
        );

        ### format the title column as a link to book details
        $browser->format(
        Column => 'title',
        FormatSub => sub {
        my ( $title, $hashRef ) = @_;
        my $isbn = $hashref->{ 'isbn' };
        my $url = $Server->URL( 'details.asp', { isbn => $isbn });
        return "<a href=\"$url\">$title</a>";
        },
        CellCSS => 'data',
        );

        ### print 10 rows from the table... could use default layout or
        ### templates (a'la CGI::FormBuilder)
        print $browseRows->printHTML( Template => 'table_template.html' );

        %>


        I had a quick go at it when I first started the current project but
        the deadlines made it very hard to spend the time needed to keep it
        generic and intuitive. I had to go back to doing the app-specific
        version :(


        Ellers


        ---------------------------------------------------------------------
        To unsubscribe, e-mail: asp-unsubscribe@...
        For additional commands, e-mail: asp-help@...
      • Joshua Chamas
        ... I have always rolled by own application by application, but my apps have always had to be pretty tight to the database for high performance with mixed
        Message 3 of 14 , Mar 21, 2002
        • 0 Attachment
          Jim Helm wrote:
          >
          > This isn't specific to Apache:ASP, but I've seen a lot of good advice
          > here, and hopefully someone has already been through this.
          >
          > I was just wondering if anyone had used/knows of anything for perl
          > similar to phpLens. I haven't actually used it, but it looks pretty
          > impressive. I'd prefer to stick with perl, though. I've searched
          > through CPAN, and on google, and haven't found anything obviously like
          > phpLens for perl, but there's a lot out there and I may have just missed
          > it. The closest I think I've seen so far is DBIx::HTMLView, but it's
          > only for mySQL and mSQL (needs some extra coding for other DBD drivers -
          > I think).
          >

          I have always rolled by own application by application, but my
          apps have always had to be pretty tight to the database for
          high performance with mixed OLAP/OLTP environments.

          If you feel that RAD does not have to be GUI RAD, I might look
          at these:

          CGI::FormBuilder ( promises 4x code reduction )
          DBIx::XHTML_Table

          If you want something closer do the database, and don't mind doing
          your own HTML, check out:

          DBIx::Recordset
          Alzabo

          They at least abstract DBI slightly away from you.

          > all the bells and whistles of phpLens - though they would be nice. And
          > I need to be able to make updates - simply displaying data is fairly
          > trivial, and I wouldn't need to ask for tools to do that - they are a

          phpLens looks nice. You you want something that is more of a CMS in perl,
          you can try Bricolage or Mason:

          http://bricolage.thepirtgroup.com/
          http://www.masonhq.com/

          Sorry, I don't think any of these quite hit it on the head for
          you, but I thought I'd try! Best of luck, and if you find anything
          interesting please share it with the rest of us, as it seems
          to be a fairly common problem. Also, you might try the mod_perl
          list & I am sure you will get some opinions :)

          --Josh
          _________________________________________________________________
          Joshua Chamas Chamas Enterprises Inc.
          NodeWorks Founder Huntington Beach, CA USA
          http://www.nodeworks.com 1-714-625-4051

          ---------------------------------------------------------------------
          To unsubscribe, e-mail: asp-unsubscribe@...
          For additional commands, e-mail: asp-help@...
        • Kulp, David
          I must admit that there s nothing that s really it in CPAN. A few months ago I spent a lot of time looking through the modules that Joshua described and
          Message 4 of 14 , Mar 21, 2002
          • 0 Attachment
            I must admit that there's nothing that's really "it" in CPAN. A few months
            ago I spent a lot of time looking through the modules that Joshua described
            and never found what I wanted. I didn't know about phpLens until now, but
            it looks sweet. Instead, I've been writing some Apache::ASP tags that, if I
            do say so myself, nicely abstract away a lot of the database code. I'm only
            concerned with view and search (not editting (data entry), which I believe
            to be a separate can of worms for all but the simplest databases). I hope
            to release it some day.

            The basic idea is

            <dbb:form>
            <dbb:table table="foo" DSN=$DSN />
            </dbb:form>

            and it magically inserts a paginated, CSS savvy, searchable table to your
            HTML document.
            It relies on simple meta-data in the database to control things like layout
            of numerics, etc. and you can write your own little perl "rendering" methods
            to display a cell of a table however you like. Additional tags
            <dbb:selection> and <dbb:qset> allow for exporting a selection set or the
            results of a query to a tab delimited or Excel output.

            Sound interesting to anyone besides me? If so, I might put more energy into
            making a releasable package.

            -d

            > -----Original Message-----
            > From: Joshua Chamas [mailto:joshua@...]
            > Sent: Thursday, March 21, 2002 6:08 PM
            > To: Jim Helm
            > Cc: asp@...
            > Subject: Re: OT: (slightly) RAD RDBMS tools for perl/Apache::ASP
            >
            >
            > Jim Helm wrote:
            > >
            > > This isn't specific to Apache:ASP, but I've seen a lot of
            > good advice
            > > here, and hopefully someone has already been through this.
            > >
            > > I was just wondering if anyone had used/knows of anything for perl
            > > similar to phpLens. I haven't actually used it, but it looks pretty
            > > impressive. I'd prefer to stick with perl, though. I've searched
            > > through CPAN, and on google, and haven't found anything
            > obviously like
            > > phpLens for perl, but there's a lot out there and I may
            > have just missed
            > > it. The closest I think I've seen so far is
            > DBIx::HTMLView, but it's
            > > only for mySQL and mSQL (needs some extra coding for other
            > DBD drivers -
            > > I think).
            > >
            >
            > I have always rolled by own application by application, but my
            > apps have always had to be pretty tight to the database for
            > high performance with mixed OLAP/OLTP environments.
            >
            > If you feel that RAD does not have to be GUI RAD, I might look
            > at these:
            >
            > CGI::FormBuilder ( promises 4x code reduction )
            > DBIx::XHTML_Table
            >
            > If you want something closer do the database, and don't mind doing
            > your own HTML, check out:
            >
            > DBIx::Recordset
            > Alzabo
            >
            > They at least abstract DBI slightly away from you.
            >
            > > all the bells and whistles of phpLens - though they would
            > be nice. And
            > > I need to be able to make updates - simply displaying data is fairly
            > > trivial, and I wouldn't need to ask for tools to do that -
            > they are a
            >
            > phpLens looks nice. You you want something that is more of a
            > CMS in perl,
            > you can try Bricolage or Mason:
            >
            > http://bricolage.thepirtgroup.com/
            > http://www.masonhq.com/
            >
            > Sorry, I don't think any of these quite hit it on the head for
            > you, but I thought I'd try! Best of luck, and if you find anything
            > interesting please share it with the rest of us, as it seems
            > to be a fairly common problem. Also, you might try the mod_perl
            > list & I am sure you will get some opinions :)
            >
            > --Josh
            > _________________________________________________________________
            > Joshua Chamas Chamas Enterprises Inc.
            > NodeWorks Founder Huntington Beach, CA USA
            > http://www.nodeworks.com 1-714-625-4051
            >
            > ---------------------------------------------------------------------
            > To unsubscribe, e-mail: asp-unsubscribe@...
            > For additional commands, e-mail: asp-help@...
            >

            ---------------------------------------------------------------------
            To unsubscribe, e-mail: asp-unsubscribe@...
            For additional commands, e-mail: asp-help@...
          • Ellers
            ... Definitely sounds interesting to me ;) I m sure others would be too Ellers ... To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org For additional
            Message 5 of 14 , Mar 21, 2002
            • 0 Attachment
              >...
              >
              ><dbb:form>
              ><dbb:table table="foo" DSN=$DSN />
              ></dbb:form>
              >
              >and it magically inserts a paginated, CSS savvy, searchable table to your
              >HTML document.
              >...
              >
              >Sound interesting to anyone besides me? If so, I might put more energy into
              >making a releasable package.

              Definitely sounds interesting to me ;)

              I'm sure others would be too

              Ellers


              ---------------------------------------------------------------------
              To unsubscribe, e-mail: asp-unsubscribe@...
              For additional commands, e-mail: asp-help@...
            • Jim Helm
              Looks like CGI::FormBuilder/Template::Toolkit combined with DBIx::Recordset is probably my best bet. I knew about them individually, but for some reason just
              Message 6 of 14 , Mar 21, 2002
              • 0 Attachment
                Looks like CGI::FormBuilder/Template::Toolkit combined with
                DBIx::Recordset is probably my best bet. I knew about them
                individually, but for some reason just didn't think to use them in
                combination to achieve 95% of what I wanted... I'll still have to code,
                but if I didn't have to code anything, what fun would it be! And if I
                ever do find anything better I'll be sure to pass it along. FormBuilder
                is pretty impressive looking so far - wish I head read over it more
                thoroughly before asking the question. Though it was a good exercise, I
                think.

                Thanks for the virtual whack upside the head. (doh!)

                Jim

                -----Original Message-----
                From: Joshua Chamas [mailto:joshua@...]
                Sent: Thursday, March 21, 2002 6:08 PM
                To: Jim Helm
                Cc: asp@...
                Subject: Re: OT: (slightly) RAD RDBMS tools for perl/Apache::ASP


                Jim Helm wrote:
                >
                > This isn't specific to Apache:ASP, but I've seen a lot of good advice
                > here, and hopefully someone has already been through this.
                >
                > I was just wondering if anyone had used/knows of anything for perl
                > similar to phpLens. I haven't actually used it, but it looks pretty
                > impressive. I'd prefer to stick with perl, though. I've searched
                > through CPAN, and on google, and haven't found anything obviously like

                > phpLens for perl, but there's a lot out there and I may have just
                > missed it. The closest I think I've seen so far is DBIx::HTMLView,
                > but it's only for mySQL and mSQL (needs some extra coding for other
                > DBD drivers - I think).
                >

                I have always rolled by own application by application, but my
                apps have always had to be pretty tight to the database for
                high performance with mixed OLAP/OLTP environments.

                If you feel that RAD does not have to be GUI RAD, I might look at these:

                CGI::FormBuilder ( promises 4x code reduction )
                DBIx::XHTML_Table

                If you want something closer do the database, and don't mind doing your
                own HTML, check out:

                DBIx::Recordset
                Alzabo

                They at least abstract DBI slightly away from you.

                > all the bells and whistles of phpLens - though they would be nice.
                > And I need to be able to make updates - simply displaying data is
                > fairly trivial, and I wouldn't need to ask for tools to do that - they

                > are a

                phpLens looks nice. You you want something that is more of a CMS in
                perl, you can try Bricolage or Mason:

                http://bricolage.thepirtgroup.com/
                http://www.masonhq.com/

                Sorry, I don't think any of these quite hit it on the head for you, but
                I thought I'd try! Best of luck, and if you find anything interesting
                please share it with the rest of us, as it seems to be a fairly common
                problem. Also, you might try the mod_perl list & I am sure you will get
                some opinions :)

                --Josh _________________________________________________________________
                Joshua Chamas Chamas Enterprises Inc.
                NodeWorks Founder Huntington Beach, CA USA
                http://www.nodeworks.com 1-714-625-4051


                ---------------------------------------------------------------------
                To unsubscribe, e-mail: asp-unsubscribe@...
                For additional commands, e-mail: asp-help@...
              • Ellers
                ... Getting more off topic now, but thought I d mention about FormBuilder... I find CGI::FormBuilder really useful and have come to prefer it to use CGI
                Message 7 of 14 , Mar 22, 2002
                • 0 Attachment
                  At 11:27 PM -0800 21/3/02, Jim Helm wrote:
                  >Looks like CGI::FormBuilder/Template::Toolkit combined with
                  >DBIx::Recordset is probably my best bet.


                  Getting more off topic now, but thought I'd mention about FormBuilder...

                  I find CGI::FormBuilder really useful and have come to prefer it to
                  use CGI methods or HTML code directly.

                  To use it effectively in Apache::ASP several settings are useful:

                  javascript => 0,
                  header => 0,

                  Although the javascript one can sometimes be useful, I found it made
                  life more difficult than it was worth.

                  Also, with multistage forms (e.g. purchaser details on page 1,
                  product details page 2, card details page 3 etc) I came up with a few
                  tricks which I can post if anyone is interested.

                  Most of the time I used FormBuilder's inbuilt $form->render() method
                  because it was easier than doing a template; it dawned on me that it
                  would make sense to add another template method for FormBuilder,
                  something like:

                  $form->render( ASPInclude => 'inc_user_details.asp' )

                  or whatever, and instead of HTML::Template variables,
                  CGI::FormBuilder could just supply a hashref to the include file
                  allowing stuff like:

                  [inc_user_details.asp]

                  <p>User Name: <%= $cgiform->{'field_user_name'} %>

                  etc


                  This isn't existing functionality in FormBuilder, but if anyone else
                  thinks its a worthy idea it could be recommended to the author.

                  Ellers


                  >
                  >-----Original Message-----
                  >From: Joshua Chamas [mailto:joshua@...]
                  >Sent: Thursday, March 21, 2002 6:08 PM
                  >To: Jim Helm
                  >Cc: asp@...
                  >Subject: Re: OT: (slightly) RAD RDBMS tools for perl/Apache::ASP
                  >
                  >
                  >Jim Helm wrote:
                  >>
                  >> This isn't specific to Apache:ASP, but I've seen a lot of good advice
                  >> here, and hopefully someone has already been through this.
                  >>
                  >> I was just wondering if anyone had used/knows of anything for perl
                  >> similar to phpLens. I haven't actually used it, but it looks pretty
                  >> impressive. I'd prefer to stick with perl, though. I've searched
                  >> through CPAN, and on google, and haven't found anything obviously like
                  >
                  >> phpLens for perl, but there's a lot out there and I may have just
                  >> missed it. The closest I think I've seen so far is DBIx::HTMLView,
                  >> but it's only for mySQL and mSQL (needs some extra coding for other
                  >> DBD drivers - I think).
                  >>
                  >
                  >I have always rolled by own application by application, but my
                  >apps have always had to be pretty tight to the database for
                  >high performance with mixed OLAP/OLTP environments.
                  >
                  >If you feel that RAD does not have to be GUI RAD, I might look at these:
                  >
                  > CGI::FormBuilder ( promises 4x code reduction )
                  > DBIx::XHTML_Table
                  >
                  >If you want something closer do the database, and don't mind doing your
                  >own HTML, check out:
                  >
                  > DBIx::Recordset
                  > Alzabo
                  >
                  >They at least abstract DBI slightly away from you.
                  >
                  >> all the bells and whistles of phpLens - though they would be nice.
                  >> And I need to be able to make updates - simply displaying data is
                  >> fairly trivial, and I wouldn't need to ask for tools to do that - they
                  >
                  >> are a
                  >
                  >phpLens looks nice. You you want something that is more of a CMS in
                  >perl, you can try Bricolage or Mason:
                  >
                  > http://bricolage.thepirtgroup.com/
                  > http://www.masonhq.com/
                  >
                  >Sorry, I don't think any of these quite hit it on the head for you, but
                  >I thought I'd try! Best of luck, and if you find anything interesting
                  >please share it with the rest of us, as it seems to be a fairly common
                  >problem. Also, you might try the mod_perl list & I am sure you will get
                  >some opinions :)
                  >
                  >--Josh _________________________________________________________________
                  >Joshua Chamas Chamas Enterprises Inc.
                  >NodeWorks Founder Huntington Beach, CA USA
                  >http://www.nodeworks.com 1-714-625-4051
                  >
                  >
                  >---------------------------------------------------------------------
                  >To unsubscribe, e-mail: asp-unsubscribe@...
                  >For additional commands, e-mail: asp-help@...


                  ---------------------------------------------------------------------
                  To unsubscribe, e-mail: asp-unsubscribe@...
                  For additional commands, e-mail: asp-help@...
                • Jim Helm
                  Actually, using asp includes for the templating sounds great... I haven t looked at the code, but I wouldn t think it would be that hard to add. It d be
                  Message 8 of 14 , Mar 22, 2002
                  • 0 Attachment
                    Actually, using asp includes for the templating sounds great... I
                    haven't looked at the code, but I wouldn't think it would be that hard
                    to add. It'd be great not to have to learn yet another pseudo-language
                    to accomplish this (Template::Toolkit or HTML::Toolkit) when Apache::ASP
                    is something I already know! I'll start looking at the FormBuilder
                    hooks, and see how involved it is - don't know if I have the time to
                    actually implement it, but it's a great idea.

                    I'm cc'ing Nate on this too, see what he thinks.

                    Jim

                    > -----Original Message-----
                    > From: Ellers [mailto:ellers@...]
                    |
                    |
                    > Most of the time I used FormBuilder's inbuilt $form->render() method
                    > because it was easier than doing a template; it dawned on me that it
                    > would make sense to add another template method for FormBuilder,
                    > something like:
                    >
                    > $form->render( ASPInclude => 'inc_user_details.asp' )
                    >
                    > or whatever, and instead of HTML::Template variables,
                    > CGI::FormBuilder could just supply a hashref to the include file
                    > allowing stuff like:
                    >
                    > [inc_user_details.asp]
                    >
                    > <p>User Name: <%= $cgiform->{'field_user_name'} %>
                    >
                    > etc
                    >
                    >
                    > This isn't existing functionality in FormBuilder, but if anyone else
                    > thinks its a worthy idea it could be recommended to the author.
                    >
                    > Ellers
                    >
                    >


                    ---------------------------------------------------------------------
                    To unsubscribe, e-mail: asp-unsubscribe@...
                    For additional commands, e-mail: asp-help@...
                  • Nathan Wiger
                    Sure, the more templating engines the better! :-) The only caveat here is that I definitely don t have the time to implement this, and besides, I don t know
                    Message 9 of 14 , Mar 22, 2002
                    • 0 Attachment
                      Sure, the more templating engines the better! :-)

                      The only caveat here is that I definitely don't have the time to implement this,
                      and besides, I don't know ASP. Andy Wardley sent me a big patch to enable
                      Template Toolkit support, so if somebody wants to take a whack at this and send
                      me a corresponding patch, I will gladly add it. Look near the bottom of
                      render(), where there are some if/elsif/else statements looking for the type of
                      template specified. This shouldn't be too hard to slot in there.

                      -Nate

                      ----- Original Message -----
                      From: "Jim Helm" <jjhelm@...>
                      To: "'Ellers'" <ellers@...>
                      Cc: <asp@...>; <nate@...>
                      Sent: Friday, March 22, 2002 4:36 PM
                      Subject: RE: OT: (slightly) RAD RDBMS tools for perl/Apache::ASP -> FormBuilder


                      > Actually, using asp includes for the templating sounds great... I
                      > haven't looked at the code, but I wouldn't think it would be that hard
                      > to add. It'd be great not to have to learn yet another pseudo-language
                      > to accomplish this (Template::Toolkit or HTML::Toolkit) when Apache::ASP
                      > is something I already know! I'll start looking at the FormBuilder
                      > hooks, and see how involved it is - don't know if I have the time to
                      > actually implement it, but it's a great idea.
                      >
                      > I'm cc'ing Nate on this too, see what he thinks.
                      >
                      > Jim
                      >
                      > > -----Original Message-----
                      > > From: Ellers [mailto:ellers@...]
                      > |
                      > |
                      > > Most of the time I used FormBuilder's inbuilt $form->render() method
                      > > because it was easier than doing a template; it dawned on me that it
                      > > would make sense to add another template method for FormBuilder,
                      > > something like:
                      > >
                      > > $form->render( ASPInclude => 'inc_user_details.asp' )
                      > >
                      > > or whatever, and instead of HTML::Template variables,
                      > > CGI::FormBuilder could just supply a hashref to the include file
                      > > allowing stuff like:
                      > >
                      > > [inc_user_details.asp]
                      > >
                      > > <p>User Name: <%= $cgiform->{'field_user_name'} %>
                      > >
                      > > etc
                      > >
                      > >
                      > > This isn't existing functionality in FormBuilder, but if anyone else
                      > > thinks its a worthy idea it could be recommended to the author.
                      > >
                      > > Ellers
                      > >
                      > >
                      >


                      ---------------------------------------------------------------------
                      To unsubscribe, e-mail: asp-unsubscribe@...
                      For additional commands, e-mail: asp-help@...
                    • Joshua Chamas
                      ... Sounds pretty cool to me. I do not have my head around sharing taglibs like this easily yet, but you might break some ground here if you pursue this work.
                      Message 10 of 14 , Mar 22, 2002
                      • 0 Attachment
                        "Kulp, David" wrote:
                        >
                        > I must admit that there's nothing that's really "it" in CPAN. A few months
                        > ago I spent a lot of time looking through the modules that Joshua described
                        > and never found what I wanted. I didn't know about phpLens until now, but
                        > it looks sweet. Instead, I've been writing some Apache::ASP tags that, if I
                        > do say so myself, nicely abstract away a lot of the database code. I'm only
                        > concerned with view and search (not editting (data entry), which I believe
                        > to be a separate can of worms for all but the simplest databases). I hope
                        > to release it some day.
                        >
                        > The basic idea is
                        >
                        > <dbb:form>
                        > <dbb:table table="foo" DSN=$DSN />
                        > </dbb:form>
                        >

                        Sounds pretty cool to me. I do not have my head around sharing taglibs
                        like this easily yet, but you might break some ground here if you pursue
                        this work. Though flexible the XMLSubsMatch is kind of limiting in that
                        someone cannot just "register" their XMLSubs namespace on the fly. If you
                        did pursue this we could look at how these packages could be easily
                        installed with CPAN like ease. If we had enough "standard" extensions
                        like this, Apache::ASP could be an ever increasingly useful platform.

                        --Josh
                        _________________________________________________________________
                        Joshua Chamas Chamas Enterprises Inc.
                        NodeWorks Founder Huntington Beach, CA USA
                        http://www.nodeworks.com 1-714-625-4051

                        ---------------------------------------------------------------------
                        To unsubscribe, e-mail: asp-unsubscribe@...
                        For additional commands, e-mail: asp-help@...
                      • Ellers
                        I ve done a first cut at modifying CGI::FormBuilder to use ASP s $Response- Include() as a templating mechanism. In an ASP file your form is created:
                        Message 11 of 14 , Mar 26, 2002
                        • 0 Attachment
                          I've done a first cut at modifying CGI::FormBuilder to use ASP's $Response->Include() as a templating mechanism.

                          In an ASP file your form is created:

                          <<<

                          <html>
                          <head>
                          <title>Try Formbuilder with ASP</title>
                          </head>
                          <body>
                          <h2>A really simple CGI::FormBuilder example using ASP</h2>
                          <!-- before ASP/CGI::FormBuilder stuff -->
                          <%

                          require CGI::FormBuilder;

                          my $form = CGI::FormBuilder->new
                          (
                          header => 0,
                          method => 'GET',
                          fields => [qw/email /],
                          javascript => 0,
                          reset => 0,
                          required => [qw/email /],
                          validate => { email => 'EMAIL' },
                          sticky => 1, # 0 or 1
                          );

                          $form->field ( name => 'email', validate => 'EMAIL', size => 25 );

                          if ( $form->submitted( ) && $form->validate( ) )
                          {
                          print $form->confirm( );
                          }
                          else
                          {
                          print $form->render
                          (
                          submit => 'Submit',
                          template => {
                          type => 'ASPInclude',
                          template => 'inc_show_params.asp',
                          response => $Response,
                          }
                          );

                          }
                          %>

                          >>>



                          Note, in particular, the $form->render() method at the bottom. I pass $Response as a parameter as its a simple and effective way to ensure
                          that CGI::FormBuilder gets the appropriate $Response object (which may be in some odd namespace).

                          The file inc_show_params.asp is a demo that just dumps the parameters:

                          <<<
                          <p>This is my asp file

                          <p>Below is a dump of all arguments:
                          <p><hr>
                          <p><pre>
                          <%

                          use Data::Dumper;
                          $Data::Dumper::Indent = 1;

                          my ( @args ) = @_;
                          print $Server->HTMLEncode( Data::Dumper->Dump([@args], [qw(*args)]));

                          %>
                          </pre></p><hr>
                          >>>


                          The code below is a more-or-less replacement using ASP for the default CGI::FormBuilder style:

                          <<<
                          <p>This is a demo form - this content is in a separate ASP file included by CGI::FormBuilder.
                          <p>Fields marked with "*" must be supplied.

                          <%

                          my ( $formRef ) = @_;

                          my ( $fieldsArrayRef ) = $formRef->{ 'fields' };

                          if ( $formRef->{'invalid'}) { %>

                          <p><b>There were <%= $formRef->{'invalid'} %> error<%= ( $formRef->{'invalid'} > 1 ? 's' : '' ) %> in your submission.</b></p>

                          <%
                          }
                          %>

                          <p>
                          <%= $formRef->{ 'start' } %>
                          <table border="1" cellpadding="5">

                          <%

                          foreach my $fieldRef ( @{$fieldsArrayRef}) {

                          %>

                          <tr>
                          <td>
                          <%= ( $fieldRef->{ 'invalid' } ? '<font color="red">' : '' ) %>
                          <%= $fieldRef->{ 'label' } %>
                          <%= ( $fieldRef->{ 'required' } ? '*' : '' ) %>
                          <%= ( $fieldRef->{ 'invalid' } ? '</font>' : '' ) %>
                          </td>
                          <td><%= $fieldRef->{ 'field' } %>
                          </td>
                          </tr>

                          <% } %>

                          <tr>
                          <td colspan="2" align="center">
                          <%= $formRef->{ 'reset' } %>
                          <%= $formRef->{ 'submit' } %>
                          </td>
                          </tr>
                          </table>
                          <%= $formRef->{ 'end' } %>
                          >>>



                          Phew... hope this post isn't too long!


                          To achieve all this was surprisingly easy:

                          > diff /usr/local/lib/site_perl/CGI/FormBuilder.pm /my/dodgy/CGI/Customised_FormBuilder.pm

                          953c955
                          < if (ref $args{template} eq 'HASH' && $args{template}{type} eq 'TT2') {
                          ---
                          > if (ref $args{template} eq 'HASH' && $args{template}{type} =~ m/^(TT2|ASPInclude)$/ ) { # added by Ellers
                          1178a1183,1207
                          >
                          > } elsif ($tmpltype eq 'ASPInclude') { # Added by Ellers
                          >
                          > eval { require Apache::ASP };
                          > puke "Can't use templates because the Apache::ASP is not installed!" if $@;
                          >
                          > my ( $aspFile, $aspResponse, $aspContentRef, $aspArgRef );
                          > $aspFile = $tmplopt{template}
                          > || puke "ASP Include not specified";
                          > $aspResponse = $tmplopt{response}
                          > || puke "ASP Response not specified";
                          >
                          > # special fields
                          > $tmplvar{'start'} = $formtag;
                          > $tmplvar{'submit'} = $submit;
                          > $tmplvar{'reset'} = $reset;
                          > $tmplvar{'end'} = '</form>';
                          > $tmplvar{'jshead'} = $jsfunc;
                          > $tmplvar{'invalid'} = $self->{state}{invalid};
                          > $tmplvar{'fields'} = [ map $tmplvar{field}{$_},
                          > @{ $self->{field_names} } ];
                          > $aspArgRef = \%tmplvar;
                          >
                          > $aspContentRef = $aspResponse->TrapInclude( $aspFile, $aspArgRef );
                          > $outhtml = $header . $$aspContentRef;


                          If that's a bit cumbersome, I've uploaded various files including my dodgy modified FormBuilder.pm:

                          http://members.iinet.net.au/~ellers/cgi-formbuilder/

                          PLEASE NOTE:
                          1. I've done a few other changes to the above, such as spaces between multiple submit buttons etc, but it should be ok...
                          2. The server above doesn't run Apache::ASP so best to save the files and run on your own server

                          TODO:
                          - check templating work for $form->confirm()
                          - add overall doco, etc


                          It'd be great if anyone who is interested in this work could give it a go and send comments through. If/when its reliable enough I can
                          submit it as a patch to the 'real' thing.

                          Ellers



                          ---------------------------------------------------------------------
                          To unsubscribe, e-mail: asp-unsubscribe@...
                          For additional commands, e-mail: asp-help@...
                        • Jim Helm
                          Great work! I started to take that approach and decided to try a callback, or passing a hashref that would get populated, instead of calling another page. That
                          Message 12 of 14 , Mar 26, 2002
                          • 0 Attachment
                            Great work!

                            I started to take that approach and decided to try a callback, or
                            passing a hashref that would get populated, instead of calling another
                            page. That would make the render function more adaptable to other
                            frameworks, instead of having to add in specific code for each one. I
                            have done much yet, but it's essentially what you have except instead of
                            calling $Response->Include at the end of render, it just assigns that
                            tmplvar hash to the hashref I pass in so all the various html chunks can
                            be used directly by the main asp script - I'm a mininalist, so main.asp
                            calling render calling another form.asp script going against my grain a
                            bit (please, no flames here - it's just a personal preference!).
                            Hopefully I'll have time to work on it today and post the results.

                            Jim


                            ---------------------------------------------------------------------
                            To unsubscribe, e-mail: asp-unsubscribe@...
                            For additional commands, e-mail: asp-help@...
                          Your message has been successfully submitted and would be delivered to recipients shortly.