You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by constfilin <co...@yahoo.com> on 2002/03/19 02:57:44 UTC

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@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: OT: (slightly) RAD RDBMS tools for perl/Apache::ASP -> FormBuilder

Posted by Nathan Wiger <na...@wiger.org>.
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" <jj...@att.net>
To: "'Ellers'" <el...@iinet.net.au>
Cc: <as...@perl.apache.org>; <na...@wiger.org>
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@iinet.net.au]
> |
> |
> > 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@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


RE: OT: (slightly) RAD RDBMS tools for perl/Apache::ASP -> FormBuilder

Posted by Jim Helm <jj...@att.net>.
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@iinet.net.au] 
|
|
> 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@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


RE: OT: (slightly) RAD RDBMS tools for perl/Apache::ASP -> FormBuilder

Posted by Ellers <el...@iinet.net.au>.
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@chamas.com]
>Sent: Thursday, March 21, 2002 6:08 PM
>To: Jim Helm
>Cc: asp@perl.apache.org
>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@perl.apache.org
>For additional commands, e-mail: asp-help@perl.apache.org


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


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

Posted by Jim Helm <jj...@att.net>.
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@chamas.com] 
Sent: Thursday, March 21, 2002 6:08 PM
To: Jim Helm
Cc: asp@perl.apache.org
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@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


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

Posted by Joshua Chamas <jo...@chamas.com>.
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@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


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

Posted by Ellers <el...@iinet.net.au>.
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@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


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

Posted by Jim Helm <jj...@att.net>.
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@yahoo.com] 
Sent: Monday, March 18, 2002 5:58 PM
To: asp@perl.apache.org
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@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


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