[Apache::ASP] $Request-QueryString-('foo')-Item() support

2000-10-09 Thread joel w. reed

I'm trying to write an ASP app that runs under PerlScript and Apache::ASP.

i've found that with ActivePerl 618 -- $Request-QueryString-('foo')
return a reference to a Win32::OLE hash. 

to get a string from the hash you must write --
$Request-QueryString-('foo')-Item()
or you must use one of the hacks in the OLE.pm docs that come with ActivePerl.

$Request-QueryString-('foo')-Item() however doesn't work
under Apache::ASP. so i'm wondering if something like the patch
below would improve compatibility without hurting performance 
too much.

comments? suggestions? i know the patch below would need work
to support the "array of values" ASP thing...

--- /usr/lib/perl5/site_perl/5.6.0/Apache/ASP.pmTue Aug  1 19:42:18 2000
+++ /home/jreed/tmp/ASP.pm  Mon Oct  9 16:30:21 2000
@@ -2640,6 +2640,25 @@ sub ScriptOnFlush {
 
 1;
 
+package Apache::ASP::QsObj;
+
+sub new { 
+my $class = shift; 
+my $self = {};
+$self-{str} = shift;
+
+bless $self, $class;
+return $self;
+  };
+
+sub Item()
+  {
+my $self = shift;
+return $self-{str};
+  }
+
+1;
+
 # Request Object
 package Apache::ASP::Request;
 
@@ -2794,7 +2813,11 @@ sub Form 
 sub FileUpload 
   { shift-{FileUpload}-Item(@_) }
 sub QueryString 
-  { shift-{QueryString}-Item(@_) }
+  { 
+my $self = shift;
+my $key = shift;
+return new Apache::ASP::QsObj($self-{QueryString}-Item($key));
+  }
 sub ServerVariables 
   { shift-{ServerVariables}-Item(@_) }
 


-- 

Joel W. Reed412-257-3881
--All the simple programs have been written.



 PGP signature


Re: [Apache::ASP] $Request-QueryString-('foo')-Item() support

2000-10-09 Thread Joshua Chamas

$Request-QueryString-('foo')-Item() isn't valid perl syntax, 
is it?  Are you going for $Request-QueryString('foo')-Item() 
support here?

There is already a Collection class that is used to emulate 
this kind of behavior, which can possibly be extended to 
meet this need.  One of the behaviors that this interface
supports is:

  $Request-QueryString-Item('foo')

Do you really need the above interface?  If so, I'll need
to create a config setting I imagine as there will be
a significant performance impact do doing something 
like you suggest.

--Joshua


"joel w. reed" wrote:
 
 I'm trying to write an ASP app that runs under PerlScript and Apache::ASP.
 
 i've found that with ActivePerl 618 -- $Request-QueryString-('foo')
 return a reference to a Win32::OLE hash.
 
 to get a string from the hash you must write --
 $Request-QueryString-('foo')-Item()
 or you must use one of the hacks in the OLE.pm docs that come with ActivePerl.
 
 $Request-QueryString-('foo')-Item() however doesn't work
 under Apache::ASP. so i'm wondering if something like the patch
 below would improve compatibility without hurting performance
 too much.
 
 comments? suggestions? i know the patch below would need work
 to support the "array of values" ASP thing...
 
 --- /usr/lib/perl5/site_perl/5.6.0/Apache/ASP.pmTue Aug  1 19:42:18 2000
 +++ /home/jreed/tmp/ASP.pm  Mon Oct  9 16:30:21 2000
 @@ -2640,6 +2640,25 @@ sub ScriptOnFlush {
 
  1;
 
 +package Apache::ASP::QsObj;
 +
 +sub new {
 +my $class = shift;
 +my $self = {};
 +$self-{str} = shift;
 +
 +bless $self, $class;
 +return $self;
 +  };
 +
 +sub Item()
 +  {
 +my $self = shift;
 +return $self-{str};
 +  }
 +
 +1;
 +
  # Request Object
  package Apache::ASP::Request;
 
 @@ -2794,7 +2813,11 @@ sub Form
  sub FileUpload
{ shift-{FileUpload}-Item(@_) }
  sub QueryString
 -  { shift-{QueryString}-Item(@_) }
 +  {
 +my $self = shift;
 +my $key = shift;
 +return new Apache::ASP::QsObj($self-{QueryString}-Item($key));
 +  }
  sub ServerVariables
{ shift-{ServerVariables}-Item(@_) }
 
 
 --
 
 Joel W. Reed412-257-3881
 --All the simple programs have been written.
 
   
--
Part 1.2Type: application/pgp-signature



Re: [Apache::ASP] $Request-QueryString-('foo')-Item() support

2000-10-09 Thread Greg Williams

At 14:23 -0700 2000/10/09, Joshua Chamas wrote:
$Request-QueryString-('foo')-Item() isn't valid perl syntax,
is it?


perl -c
$Request-QueryString-('foo')-Item()
__END__
- syntax OK

;-)

.g
-- 
Greg Williams, Cnation, (310) 228-6924
"Wow, no intel, no microsoft, sounds like a computer
  that might... dare I say it... work!"  -LHB



Re: [Apache::ASP] $Request-QueryString-('foo')-Item() support

2000-10-09 Thread Joshua Chamas

Greg Williams wrote:
 
 At 14:23 -0700 2000/10/09, Joshua Chamas wrote:
 $Request-QueryString-('foo')-Item() isn't valid perl syntax,
 is it?
 
 perl -c
 $Request-QueryString-('foo')-Item()
 __END__
 - syntax OK

When I execute $Request-Form-('test')-Item()
on a real life code sample, even after building in 
support for $Request-Form('test')-Item(), I get
this error:

  Not a CODE reference at (eval 14) line 10.

I have seen this error before with this syntax...
is this really supposed to work?  I thought it
was not supposed to be supported by perl.  I saw
that it passed compilation, but perl saves some things
for runtime checking.  It works in VBScript because
that language has the notion of a default method for
an object class to cover these instances.

Note, with my current patch to the system, 
$Request-Form('something') no longer works when 
the config PerlSetVar CollectionItem 1 is set.  The
syntax that gets supported is $Request-Form('something')-Item() 
instead.  I was able to hack it so that
$Request-Form-Item('something') works either way.

When CollectionItem is set, reading Form like above
returns a bless ref to a hash like { Item = 'value' }
so that $Request-Form('something')-Item() could also
be written as $Request-Form('something')-{Item}

The config is used to maintain backwards compatibility
with regular faster $Request-Form('something') usage.  
$Request-{Form}{something} will continue to work 
in either case as well for the fastest access albeit
without any error checking that Form is a valid 
Collection for Request.

--Joshua



Re: [Apache::ASP] $Request-QueryString-('foo')-Item() support

2000-10-09 Thread joel w. reed

On Oct 09, [EMAIL PROTECTED] contorted a few electrons to say...
Joshua $Request-QueryString-('foo')-Item() isn't valid perl syntax, 
Joshua is it?  Are you going for $Request-QueryString('foo')-Item() 
Joshua support here?

yes $Request-QueryString('foo')-Item() seems to be the way AP618
wants you to convert the WIN32::OLE object to a perl string as in:

my $uid = $Request-QueryString('foo')-Item();

without the item it fails horribly in PerlScript.

Joshua 
Joshua There is already a Collection class that is used to emulate 
Joshua this kind of behavior, which can possibly be extended to 
Joshua meet this need.  One of the behaviors that this interface
Joshua supports is:
Joshua 
Joshua   $Request-QueryString-Item('foo')

which wouldn't work unfortunately for winblows without

$Request-QueryString-Item('foo')-Item()

Joshua 
Joshua Do you really need the above interface?  If so, I'll need
Joshua to create a config setting I imagine as there will be
Joshua a significant performance impact do doing something 
Joshua like you suggest.

really? that's a bummer. the only other option is to 
throw 

use Win32::OLE qw(in valof with OVERLOAD);

in the ASP pages when they are running under ActivePerl.
which kind of sucks too. (the above is found in the ActivePerl
docs for WIN32::OLE).

jr

-- 

Joel W. Reed412-257-3881
--All the simple programs have been written.



 PGP signature


Re: [Apache::ASP] $Request-QueryString-('foo')-Item() support

2000-10-09 Thread Joshua Chamas


So what you are saying is that either this:

 my $uid = $Request-QueryString('foo')-Item();
 or this 
 $Request-QueryString-Item('foo')-Item()

works natively in PerlScript.  I see, so with the 
CollectionItem Apache::ASP config, I will enable the 
latter to work too.

The other way around from what you are telling me is
in IIS/PerlScript

 use Win32::OLE qw(in valof with OVERLOAD);

which makes things like $Request-QueryString('foo')
work compatible with Apache::ASP.  This is right because
when I implemented the Apache::ASP functionality I was
working to be compatible with above setting.  I believe
that you also need to use the above to get $Session-{item}
functionality which is also native to Apache::ASP.

So either way you are going to have a special config for 
this.  I don't mind putting it in, but it can't be both
ways at the same time unfortunately.

I'll send you a copy which does this separately.

-- Joshua



Re: [Apache::ASP] $Request-QueryString-('foo')-Item() support

2000-10-09 Thread Daniel Chetlin

On Mon, Oct 09, 2000 at 05:03:44PM -0700, Joshua Chamas wrote:
 When I execute $Request-Form-('test')-Item()
 on a real life code sample, even after building in 
 support for $Request-Form('test')-Item(), I get
 this error:
 
   Not a CODE reference at (eval 14) line 10.
 
 I have seen this error before with this syntax...
 is this really supposed to work?  I thought it
 was not supposed to be supported by perl.  I saw
 that it passed compilation, but perl saves some things
 for runtime checking.  It works in VBScript because
 that language has the notion of a default method for
 an object class to cover these instances.

Those syntaxes are saying two separate things.

$Request-Form('test')-Item() calls the method `Form' on the object
`$Request' with argument `test', and calls the method `Item' with no
arguments on the result.

$Request-Form-('test')-Item() calls the method `Form' on the object
`$Request' with no arguments, and calls the return value as a subroutine
with argument `test'. Thus, if `Form' doesn't return a coderef, it will
crash and burn.

-dlc