Re: Application design patterns

2003-07-24 Thread Aaron Ross
Hi Eric,
 
 class. What I'd like is to have my model (as in MVC) objects reuse the 
 process or maybe even server shared objects without doing any of these:
 
 1. Using a singleton utility class
 2. Needing to pass objects to model objects' new() in teh controllers
 3. Instantiating the objects in the model classes themselves

I'm not sure if this violates 3 (the models classes have to know what
resources they need, so i am not sure what wouldn't), but could you use
a singleton for the resource and a factory to access it? The model
classes call a static factory method that handles the configuration,
cache, etc...

This solves the problem of having configuration and resource allocation
code in your model objects. It does mean that you have to write factory
classes for your resources, but they ought to be quite simple. 

package MyModel::SomeObject;

...

sub doSomething {
  ...
  my $dbiHandle = MyDBIHandleFactory-getHandle();
  ...
}

1;

package MyDBIHandleFactory;

sub getHandle {
   if (defined $handle) {
return $handle # implement as singleton
   }
   ... read config or something ...
   $handle = DBI-connect(...);
}

1;

hth, aaron




Re: mod_perl PerlTransHandler weirdness

2003-06-20 Thread Aaron Ross
just fyi, mod_rewrite should be capable of handling those tests. See the
file tests under
http://httpd.apache.org/docs-2.1/en/mod/mod_rewrite.html#rewritecond

HTH, Aaron


On Tue, 2003-06-17 at 08:56, Joel Bernstein wrote:
 Alternatively, can anybody suggest a different way to offer this
 functionality? I don't think mod_rewrite applies, since the tests are
 too complicated, but would stand corrected if somebody knows
 different...
 
 I posted this to london.pm earlier and had no joy.
 
 /joel, getting a bit desperate.
-- 
Aaron Ross  
   company . Alias I, Inc 
  mail . 10 East 39th Street
 New York, NY 10016
 email . [EMAIL PROTECTED]
 phone . 212 696 0690
   fax . 212 696 0626
  cell . 917 753 2323




Re: trouble with using $r-lookup_uri()

2003-05-31 Thread Aaron Ross
 my $uri = $r-uri;
 my $subr = $r-lookup_uri($uri);

Is this recursing? the subrequest will run all phases but the content
handler, so
i would think you'll need to add

return unless $r-is_main();

or something like it at the beginning of the routine.

-- Aaron




Re: Mapping to location /

2002-06-12 Thread Aaron Ross


 Location /
 
 to map to my main mod_perl script. 
 
 The first thing it does is to check if the uri ends
 with a .phtml extension (or www.someserver.com or
 www.someserver.com/...same with subdirectories). If
 there is, I continue processing, otherwise I decline
 it and let Apache handle it. 

Would

 Files *.phtml

 /Files

do the trick?


-- 
Aaron Ross . Alias I, Inc.
 email . [EMAIL PROTECTED]
   web . www.alias-i.com
office . 215 545 6428
mobile . 610 517 2905




RE: MVC advice..?

2002-05-29 Thread Aaron Ross

 Is there a neat way of dynamically loading in the appropriate control
 subclass?  Something proven and widely used.

For what it's worth, I use the eval trick too.  Although it may seem a
little clunky, I believe it is proven and widely used.  The DBI.pm
module uses code like this to load in the DBD drivers:

my $driver_class = DBD::$driver;
eval package DBI::_firesafe; require $driver_class;

I'm not sure this answers your MVC questions, but maybe it will make you
feel more comfortable with your solution.

hth, aaron






Re: Berkeley DB 4.0.14 not releasing lockers under mod_perl

2002-03-21 Thread Aaron Ross

 
 I'm testing with the Perl script below, with the filename ending 
 .mperl (which, in my configuration, causes it to run as a mod_perl 
 registry script).

 I would re-write it as a handler and see if Apache::Registry is partly
to blame.

 hth, aaron





Re: Berkeley DB 4.0.14 not releasing lockers under mod_perl

2002-03-21 Thread Aaron Ross


   I'm testing with the Perl script below, with the filename ending
   .mperl (which, in my configuration, causes it to run as a mod_perl
   registry script).
 
   I would re-write it as a handler and see if Apache::Registry is partly
 to blame.
 
 I tried doing it as a handler, using the configuration below (and the 
 appropriate changes in the source) and the problem persists. So it 
 doesn't seem to be Registry's fault.

 Bummer.  I wish I had a machine to test this code on, but i won't until the
 end of next week. it's ugly, but you could use Devel::Peek to look at why
 garbage collection isn't working, maybe there is a circular reference in
 BerkeleyDB.

 Ugh.  Please keep me informed.

 -- Aaron



Re: inheritance and Apache::Request

2002-02-15 Thread Aaron Ross


 
 sub new {
  my ($class, $r) = @_;
 
  return bless { r  = Apache::Request-new($r),
}, $class;
 }


 or

 sub new { 
my ($class,$r) = @_;
my $self = $class-SUPER::new($r);
# do your own init ...
return $self
}

TMTOWTDI, aaron

-- 
aaron ross . alias i, inc
 email . [EMAIL PROTECTED]
 phone . 215 545 6428




Re: Multiple authentication methods

2002-02-13 Thread Aaron Ross

shouldn't stacked handlers be the right solution here?  are stacked auth
handlers not allowed or something?

aaron

On Wed, 2002-02-13 at 09:02, darren chamberlain wrote:
 Quoting Marcel Weber [EMAIL PROTECTED] [12 Feb-02 16:15]:
  I don't get the point why it did not work the other way round,
  but now everything is just fine now :
 
 Make it a little more generic:
 
 package Apache::MultiAuthen;
 
 use strict;
 use Apache::Constants qw(:common);
 
 sub handler {
 my $r = shift;
 my($res, $sent_pw) = $r-get_basic_auth_pw;
 return $res if $res != OK;
 
 # Tweak this; unsure about dir_config returning an array
 my @auth_modules = $r-dir_config(AuthModules);
 
 for my $am (@auth_modules) {
 load($am);
 
 if ($@) {
 $r-log(Error loading module '$am': $@);
 next;
 }
 
 my $handler = \{$am\::handler};
 if ($handler-($r) == OK) {
 $r-log_reason($am return OK);
 return OK
 }
 
 $r-log_reason($am not OK);
 }
 
 $r-note_basic_auth_failure;
 return AUTH_REQUIRED;
 }
 
 sub load {
 my $module = @_;
 $module  =~ s[::][/]g;
 $module .= '.pm';
 
 eval { require $module; };
 
 return $@ ? 1 : 0;
 }
 
 1;
 
 __END__
 
 (darren)
 
 -- 
 Never attribute to malice that which is adequately explained by
 incompetence.
 -- Napolean Bonaparte
-- 
aaron ross . alias intelligence, inc
 email . [EMAIL PROTECTED]
 phone . 215 545 6428




Re: Multiple authentication methods

2002-02-12 Thread Aaron Ross


 
 Location /test
AuthName Test
AuthType Basic
PerlSetVar myPDC SAMBA
PerlSetVar myDOMAIN ARBEITSGRUPPE
PerlAuthenHandler Apache::AuthenSmb Apache::AuthSybase
require valid-user
 /Location


is mod_perl compiled with STACKED HANDLERS?

the first module to run will need to return DECLINED for the second to
ever see the request.  You may need a simple AuthHandler that always
fails at the end. Try AuthenSmb, DECLINED or OK, try AuthSybase,
DECLINED or OK, then AuthFailed, always returned FORBIDDEN.

HTH, aaron

-- 
aaron ross . alias intelligence, inc
 email . [EMAIL PROTECTED]
 phone . 215 545 6428




[OT] callisto software graphics

2002-02-07 Thread Aaron Ross

http://callistocms.com v http://w.moreover.com/ 


hmmm

-- 
aaron ross . alias i, inc
 email . [EMAIL PROTECTED]
 phone . 215 545 6428




Re: [OT] callisto software graphics

2002-02-07 Thread Aaron Ross

 
 It just shows off the power of Orange...

 i, for one, believe in the power of orange.


 Nanoware...http://www.nanoware.org/

 can i place a request for some orange nanoware?

-- 
aaron ross . alias i, inc
 email . [EMAIL PROTECTED]
 phone . 215 545 6428




Re: RFC: DBI::Prof

2000-11-28 Thread Aaron Ross

On Tue, 28 Nov 2000, Stas wrote:
 possible SQL calls manually, so I wrote this simple profiler. Take a look
 and tell me if you think it worths releasing on CPAN...

Definitely release it! It is a very elegant solution to a problem that I'm 
guessing many of us have dealt with.  I've always _tried_ to write a db
abstraction layer, so this kind of profiling would be easy. But I can easily 
think of two cases where i was trying to track down bad queries and this 
little trick would have saved me a lot of time.

[ couldn't you have telepathically told me how to do this a year ago?? ]

it would be a nice addition to the guide too.

aaron


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: premature TCP termination

2000-11-13 Thread Aaron Ross

at a time earlier than now, [EMAIL PROTECTED] wrote:
 Hi,
 I wonder if there is some sort of notification my module can receive if
 the user has terminated HTTP transaction(ie dowloading of a search
 result), by closing TCP link, or the Apache's connection has timed out... 
 URLs, pointers would be excellent.

 see the Apache::Connection class...  $con-aborted() is what you want i 
 believe.

 Aaron



Re: Apache::ASP HTTP's validation model

2000-02-12 Thread Aaron Ross

hi Dmitry!

 Wouldn't it be great it someone came up with a general solution for this...
some kind of logical class from which you could inherit and implement the
necessary methods. 

 There was an interesting thread about this problem with Mason. I'm sure it's 
come up before with ASP. The mod_perl guide has a great section on it.. so
what's missing for a mod_perl handler? what would it take to make a general 
solution... Well a general framework. Is that even possible?

 Just Curious,
Aaron

 (Joshua, promise to let me know when you get tired of my "ideas" and I'll 
 stop :-)
 
 No, this wouldn't make sense for most scripts which will
 contain dynamic parts.
 
 What about a situation when the content is been dynamically generated from 
 a source that doesn't change often, but in an unpredictable fashion (e.g. a 
 guest book or such)?  I realize that it impossible for ASP itself to know 
 when the actual source has been changed, but it should be able to make an 
 educated guess with some help from the author.
 
 My original thought was to have a way to define file dependencies for an 
 .asp file.  If any of these files has an mtime greater then 
 'If-Modified-Since,' then the .asp file gets processed, otherwise, the 
 client gets NOT_MODIFIED.  Then I realized that the datasource may not 
 necessarily be a file.  The data could be coming from a database, from 
 another web server, etc., so a more general mtime discovery mechanism would 
 be needed.  (perhaps a callback into the script?)
 
 Any thoughts?
 
 Regards
 Dmitry



Re: $r-content_type clobbering outgoing headers

2000-02-10 Thread Aaron Ross

hi Tim!

 tried it. didn't work.

 what difference were you thinking that might make? maybe there is another
way to achieve it.

Aaron

 Try retrieving the content type and then working on that scalar.
 
 my $ct = $r-content_type;
 return -1 if ((-e $r-finfo)  $ct  ($ct !~ m|^text/|i));
 
 
 Thanks,
 
 Tim Tompkins
 --
 Programmer / IS Technician
 http://www.arttoday.com/
 
 
 - Original Message -
 From: Aaron Ross [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, February 10, 2000 10:16 AM
 Subject: $r-content_type clobbering outgoing headers
 
 
  Hi!
 
   I have an access handler that uses $r-headers_out-add to add a
 set-cookie
  header:
 
$r-headers_out-add("Set-cookie"=$sesc);
 
   If i try to access this in my ContentHandler, actually HTML::Mason, i
 find
  a strange problem: Calling $r-content_type wipes out the header!
 
  From the handler.pl:
 
   sub handler
   {
  my ($r) = @_;
 
  $r-headers_out-do(sub { my ($k,$v) = @_; $r-log_error("OUT:
 $k=$v"); 1; });
 
  return -1 if -e $r-finfo  $r-content_type  $r-content_type !~
 m|^text/|i;
 
  $r-headers_out-do(sub { my ($k,$v) = @_; $r-log_error("OUT:
 $k=$v"); 1; });
 
    snip 
 
   }
 
   The first do call works fine returning something like this:
 
  [Thu Feb 10 12:11:47 2000] [error] OUT:
 Set-cookie=MF_Session=14950202707; domain=.mathforum.com; path=/
 
   The second returns nothing at all.
 
   Commenting out the content-type line fixes the problem... However, I like
  that line and want it to stay!!!
 
   TIA,
Confused in Swarthmore, aka Aaron
 
 



Re: $r-content_type clobbering outgoing headers

2000-02-10 Thread Aaron Ross

hi all!

 the problem is me. the handler works fine with a full, existing path. the
problem occurs when i think that a request for a directory is just like a 
request for a file, which is isn't. 
 basically, i need to handle setting cookies with a redirect, then this 
problem along with a related one for images go away.

 sorry to bother you all, 

aaron 

 

 hi Tim!
 
  tried it. didn't work.
 
  what difference were you thinking that might make? maybe there is another
 way to achieve it.
 
 Aaron
 
  Try retrieving the content type and then working on that scalar.
  
  my $ct = $r-content_type;
  return -1 if ((-e $r-finfo)  $ct  ($ct !~ m|^text/|i));
  
  
  Thanks,
  
  Tim Tompkins
  --
  Programmer / IS Technician
  http://www.arttoday.com/
  
  
  - Original Message -
  From: Aaron Ross [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, February 10, 2000 10:16 AM
  Subject: $r-content_type clobbering outgoing headers
  
  
   Hi!
  
I have an access handler that uses $r-headers_out-add to add a
  set-cookie
   header:
  
 $r-headers_out-add("Set-cookie"=$sesc);
  
If i try to access this in my ContentHandler, actually HTML::Mason, i
  find
   a strange problem: Calling $r-content_type wipes out the header!
  
   From the handler.pl:
  
sub handler
{
   my ($r) = @_;
  
   $r-headers_out-do(sub { my ($k,$v) = @_; $r-log_error("OUT:
  $k=$v"); 1; });
  
   return -1 if -e $r-finfo  $r-content_type  $r-content_type !~
  m|^text/|i;
  
   $r-headers_out-do(sub { my ($k,$v) = @_; $r-log_error("OUT:
  $k=$v"); 1; });
  
 snip 
  
}
  
The first do call works fine returning something like this:
  
   [Thu Feb 10 12:11:47 2000] [error] OUT:
  Set-cookie=MF_Session=14950202707; domain=.mathforum.com; path=/
  
The second returns nothing at all.
  
Commenting out the content-type line fixes the problem... However, I like
   that line and want it to stay!!!
  
TIA,
 Confused in Swarthmore, aka Aaron
  
  



$r-content_type clobbering outgoing headers

2000-02-10 Thread Aaron Ross

Hi!
 
 I have an access handler that uses $r-headers_out-add to add a set-cookie
header:

  $r-headers_out-add("Set-cookie"=$sesc);

 If i try to access this in my ContentHandler, actually HTML::Mason, i find
a strange problem: Calling $r-content_type wipes out the header!

From the handler.pl:

 sub handler
 {
my ($r) = @_;

$r-headers_out-do(sub { my ($k,$v) = @_; $r-log_error("OUT: $k=$v"); 1; });

return -1 if -e $r-finfo  $r-content_type  $r-content_type !~ m|^text/|i;

$r-headers_out-do(sub { my ($k,$v) = @_; $r-log_error("OUT: $k=$v"); 1; });
 
  snip 

 }

 The first do call works fine returning something like this:

[Thu Feb 10 12:11:47 2000] [error] OUT: Set-cookie=MF_Session=14950202707; 
domain=.mathforum.com; path=/

 The second returns nothing at all.

 Commenting out the content-type line fixes the problem... However, I like
that line and want it to stay!!!

 TIA,
  Confused in Swarthmore, aka Aaron




Re: Apach::Session with Sybase?

2000-02-09 Thread Aaron Ross

hi David!

 i remember that i couldn't get Sybase to work with Apache::Session b/c the
prepare statements use placeholders. you cannot use placeholders with a text
field in sybase. from the DBD::Sybase docs:

 Note that IMAGE or TEXT datatypes can not be passed as
 parameters when using ?-style placeholders, and ?-style
 placeholders can't refer to TEXT or IMAGE columns.

 if you got past this problem, please tell me how! i'd love to see this work!

Aaron

 Dear Mr. Baker:
 
 I am trying to use Apache::Session module with a Sybase 11 server, but can't get it 
to work. I think the problem is with the a_session field type. I tried with text, 
varchar, varbinary, and binary types but without much luck. Can someone give me some 
help on this, or point me to the right direction? Thank you very much!
 
 Here is the error message from the error log.
  
 [Tue Feb  8 11:33:16 2000] [error] Magic number checking on perl storable failed at 
blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 214, at 
/usr/lib/perl5/site_perl/5.005/Apache/Session/DBIStore.pm line 198
 
 -
 David Huang
 Macquarium
 404-554-4214
 
 -
 David Huang
 Macquarium
 404-554-4214
 
 



CGI::Cookie parse

2000-02-04 Thread Aaron Ross

Hi!
  I'm trying to write an AccessHandler. I'm using CGI::Cookie to, you got it,
create and parse Cookies.  However, I'm getting an error that I don't totally
understand. ( This is mod_perl related... just hold on. )

  If i call 
CGI::Cookie-parse($r-headers_in-get('Cookie'));
  I will get this error:
Can't call method "register_cleanup" on an undefined value at 
/usr/lib/perl5/5.00503/CGI.pm line 262.

  Now that is on this line in the CGI.pm constructor:

   if ($MOD_PERL) {
---Apache-request-register_cleanup(\CGI::_reset_globals);
undef $NPH;
}

  Why does that fail? I'm running under mod_perl.. I mean this is failing when
it is called from a PerlAccessHandler!

  My second question is why does CGI::Cookie create CGI object just to get a
url! The call to CGI::new is becuase of this call in CGI::Cookie-new():

# IE requires the path and domain to be present for some reason.
$path   = CGI::url(-absolute=1) unless defined $path;
# $path = "/" unless defined $path;

  removing the call to CGI::url fixes the error. 

 So.. any advice or explanation?

Aaron




Re: CGI::Cookie parse

2000-02-04 Thread Aaron Ross

 Thanks for your help!

 I'll look at Apache::Cookie, too. Although I don't really see the big
difference in simplicity.

Aaron

 On Fri, 4 Feb 2000, Aaron Ross wrote:
 
  Hi!
I'm trying to write an AccessHandler. I'm using CGI::Cookie to, you got it,
  create and parse Cookies.  However, I'm getting an error that I don't totally
  understand. ( This is mod_perl related... just hold on. )
  
If i call 
  CGI::Cookie-parse($r-headers_in-get('Cookie'));
I will get this error:
  Can't call method "register_cleanup" on an undefined value at 
/usr/lib/perl5/5.00503/CGI.pm line 262.
  
Now that is on this line in the CGI.pm constructor:
  
 if ($MOD_PERL) {
  ---Apache-request-register_cleanup(\CGI::_reset_globals);
  undef $NPH;
  }
  
Why does that fail? I'm running under mod_perl.. I mean this is failing when
  it is called from a PerlAccessHandler!
 
 The solution is to add to Ihttpd.conf:
 
   PerlPostReadRequestHandler 'sub { Apache-request(shift) }'
 
 
 
 ___
 Stas Bekmanmailto:[EMAIL PROTECTED]  http://www.stason.org/stas
 Perl,CGI,Apache,Linux,Web,Java,PC http://www.stason.org/stas/TULARC
 perl.apache.orgmodperl.sourcegarden.org   perlmonth.comperl.org
 single o- + single o-+ = singlesheavenhttp://www.singlesheaven.com



403 Custom Response?

2000-01-31 Thread Aaron Ross

Hi!
 I can't get Apache::AuthCookie to work without causing a login box to popup.
I'm hoping someone else has had this problem and can help me clean up my 
configuration.  can anyone point me to configuration directives that might 
be causing this problem? Here is my .htaccess file:

 # Protect All Files in this directory
 PerlAuthenHandler ForumCookieAuth-identify
 PerlAuthzHandler ForumCookieAuth-authorize
 require valid-user

 and here is my httpd.conf entry for the protected directory:

Directory /protected
  AuthType ForumCookieAuth
  AuthName MathForum
  PerlSetVar AuthCookieDebug 3
  PerlSetVar MathForumPath /
  PerlSetVar MathForumLoginScript /signup.html
/Directory


 The module return 403 after setting custom_response. I get a pop up box and
then if i cancel, i get the login script that was set as the custom response. 

 I thought the mailing-list archives would have yielded something, but if it's
there i can't find it.

TIA,
Aaron



Re: 403 Custom Response?

2000-01-31 Thread Aaron Ross

hi Gerald!

 you rock

thanks, aaron

 
  Hi!
   I can't get Apache::AuthCookie to work without causing a login
  box to popup.
  I'm hoping someone else has had this problem and can help me clean up my
  configuration.  can anyone point me to configuration directives
  that might
  be causing this problem?
 
 I recently run into this problem. It's not an configuration issue. Your
 login page must alter the http status to 200 (OK)
 
 Put something like the following at the top of your login page:
 
 $r-status(200) ;
 
 
 Gerald