Re: cms as an apache incubator project?

2012-01-13 Thread Joe Schaefer
It was written by me under the terms of my contract with the ASF
as a sysadmin.  The rationale document discusses the motivations
for doing the work as part of my work arrangement with Apache
versus as a volunteer contributor.  It is by design a cost-effective,
highly-scalable,enterprise-grade CMS, but fairly bare-bones when compared
to similaropen-sourceCMS's in terms of bundled features.  It is very
sysadminfriendly thowith very few administrative aspects that require
activemanagement.  Other than setting up and tearing down projects and
tweaking svn authz files,it largely manages itself.


I am not all that proficient at HTML/CSS design, so there's certainly
room for improvement in the webgui.  You can check out the current setup
by visiting https://cms.apache.org with user 'anonymous' and empty password.

The mod_perl based code itself is fairly advanced and makes heavy use
of subrequests, so if anything you will learn how to do that properly
in a mod_perl application once you've studied the codebase.  mod_perl

is one of the rare apps that fully supports subrequest calls in a dynamic
language, so this aspect differentiates it from non-mod_perl based
solutions.  IOW what I've done with the webgui simply couldn't be done 
in any other httpd-based programming environment other than C itself,
and that would've taken at least 20X the number of LOC just to write,
much less debug.

HTH


- Original Message -
> From: Jim Schueler 
> To: Joe Schaefer 
> Cc: "modperl@perl.apache.org" 
> Sent: Thursday, January 12, 2012 9:44 AM
> Subject: Re: cms as an apache incubator project?
> 
>T hanks for the quick response, Joe.
> 
> Based on the links you forwarded earlier, I understand that this application 
> was 
> written in-house by ASF operations staff.  Is that you?
> 
> Reading the rationale discussion reminds me of tooth-pulling conversations 
> I've had with managers convinced that there's an out-of-the-box turnkey 
> solution that *exactly* meets their business requirements and has no 
> life-cycle 
> costs.  When these managers eventually concede the need to hire software 
> professionals, the conversation starts all over again.  Essentially:  OK, 
> we'll invest in software development, then we'll release the code to the 
> OS community, where it will be supported and maintained indefinitely by 
> volunteers.  These sunny optimists make it hard to earn a living.
> 
> So while I'm thrilled to participate in an ASF project, I'm trying to 
> establish some justification.  Some examples:
> 
>   1.  Learn best practices in application development
>   2.  Develop marketable expertise in CMS technology
>   3.  Support mod_perl's viability as an enterprise solution
> 
> Where I live, most of the local economy is supported by foundation and 
> government grants.  (Sign of the times.)  I'm sure I know people who could 
> capitalize on the right FOSS project.
> 
> Justification is always the first step in any undertaking.  And I couldn't 
> find it anywhere using your links.  Is there anything else you can send along?
> 
> Thanks again!
> 
> Sincerely,
> 
> Jim Schueler
>


Obtaining the Apache Content-type for a file

2012-01-13 Thread André Warnier

Hello.

re: mod_perl 2.x, httpd 2.x

I have a PerlResponseHandler which processes some kind of "logical document-id" provided 
in a request, locates the corresponding "real document" on the filesystem, and returns it 
to the client via sendfile().
At the moment, this handler uses its own custom logic to determine the MIME type of the 
document and return it to the client as a Content-type HTTP header.


My question is : instead of this custom logic, does there exist a way, via mod_perl, to 
obtain this target file's MIME-type from Apache, using Apache's own logic (mod_mime, 
AddType etc..) for that ?


I have searched the online documentation, like 
(http://perl.apache.org/docs/2.0/api/APR/Finfo.html#C_filetype_),

but I am not quite sure that what I found so far is what I am looking for.

Thanks
AW


Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread David Booth
On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
> I have a PerlResponseHandler which processes some kind of "logical 
> document-id" provided 
> in a request, locates the corresponding "real document" on the filesystem, 
> and returns it 
> to the client via sendfile().
> At the moment, this handler uses its own custom logic to determine the MIME 
> type of the 
> document and return it to the client as a Content-type HTTP header.
> 
> My question is : instead of this custom logic, does there exist a way, via 
> mod_perl, to 
> obtain this target file's MIME-type from Apache, using Apache's own logic 
> (mod_mime, 
> AddType etc..) for that ?

This isn't exactly what you asked for, but if you don't need to server
anything else along with it, then perhaps you could use
internal_redirect
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_
and let Apache set the Content-Type for you.  

If you do find the direct answer to your question, please post it, as
I'm interested in this question also.

Thanks!

-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread David Booth
On Fri, 2012-01-13 at 12:09 -0500, David Booth wrote:
> On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
> > I have a PerlResponseHandler which processes some kind of "logical 
> > document-id" provided 
> > in a request, locates the corresponding "real document" on the filesystem, 
> > and returns it 
> > to the client via sendfile().
> > At the moment, this handler uses its own custom logic to determine the MIME 
> > type of the 
> > document and return it to the client as a Content-type HTTP header.
> > 
> > My question is : instead of this custom logic, does there exist a way, via 
> > mod_perl, to 
> > obtain this target file's MIME-type from Apache, using Apache's own logic 
> > (mod_mime, 
> > AddType etc..) for that ?
> 
> This isn't exactly what you asked for, but if you don't need to server
> anything else along with it, then perhaps you could use
> internal_redirect
> http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_
> and let Apache set the Content-Type for you.  
> 
> If you do find the direct answer to your question, please post it, as
> I'm interested in this question also.

P.S. I just noticed lookup_file:
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_file_
I haven't tried it, but it sounds like it *might* do what you want.


-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.



Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread André Warnier

David Booth wrote:

On Fri, 2012-01-13 at 12:09 -0500, David Booth wrote:

On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
I have a PerlResponseHandler which processes some kind of "logical document-id" provided 
in a request, locates the corresponding "real document" on the filesystem, and returns it 
to the client via sendfile().
At the moment, this handler uses its own custom logic to determine the MIME type of the 
document and return it to the client as a Content-type HTTP header.


My question is : instead of this custom logic, does there exist a way, via mod_perl, to 
obtain this target file's MIME-type from Apache, using Apache's own logic (mod_mime, 
AddType etc..) for that ?

This isn't exactly what you asked for, but if you don't need to server
anything else along with it, then perhaps you could use
internal_redirect
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_
and let Apache set the Content-Type for you.  


If you do find the direct answer to your question, please post it, as
I'm interested in this question also.


P.S. I just noticed lookup_file:
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_file_
I haven't tried it, but it sounds like it *might* do what you want.


Thanks.  I will have a look at both.  I don't think I an use the 
internal_redirect in my case,
lookup_file sounds interesting.  I didn't think of looking there.

 but



Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread André Warnier

André Warnier wrote:

David Booth wrote:

On Fri, 2012-01-13 at 12:09 -0500, David Booth wrote:

On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
I have a PerlResponseHandler which processes some kind of "logical 
document-id" provided in a request, locates the corresponding "real 
document" on the filesystem, and returns it to the client via 
sendfile().
At the moment, this handler uses its own custom logic to determine 
the MIME type of the document and return it to the client as a 
Content-type HTTP header.


My question is : instead of this custom logic, does there exist a 
way, via mod_perl, to obtain this target file's MIME-type from 
Apache, using Apache's own logic (mod_mime, AddType etc..) for that ?

This isn't exactly what you asked for, but if you don't need to server
anything else along with it, then perhaps you could use
internal_redirect
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_ 

and let Apache set the Content-Type for you. 
If you do find the direct answer to your question, please post it, as

I'm interested in this question also.


P.S. I just noticed lookup_file:
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_file_ 


I haven't tried it, but it sounds like it *might* do what you want.

Thanks.  I will have a look at both.  I don't think I an use the 
internal_redirect in my case,

lookup_file sounds interesting.  I didn't think of looking there.



I had a look, and it looks a bit like a circular argument..

I can do $r->lookup_file($my_path), but

"lookup_file" is a method of Apache2::SubRequest (and returns an Apache2::SubRequest 
object).  Apache2::SubRequest is a subclass of Apache2::RequestRec.

Apache2::RequestRec has a "finfo" method, which returns an APR::Finfo object.
The APR::Finfo object has wealth of information (see below), unfortunately apparently not 
what I'm after (the MIME type of $mypath, as resolved by mod_mime e.g.).


 $device = $finfo->device; # (stat $file)[0]
  $inode  = $finfo->inode;  # (stat $file)[1]
  # stat returns an octal number while protection is hex
  $prot   = $finfo->protection; # (stat $file)[2]
  $nlink  = $finfo->nlink;  # (stat $file)[3]
  $gid= $finfo->group;  # (stat $file)[4]
  $uid= $finfo->user;   # (stat $file)[5]
  $size   = $finfo->size;   # (stat $file)[7]
  $atime  = $finfo->atime;  # (stat $file)[8]
  $mtime  = $finfo->mtime;  # (stat $file)[9]
  $ctime  = $finfo->ctime;  # (stat $file)[10]
  $csize = $finfo->csize; # consumed size: not portable!
  $filetype = $finfo->filetype; # file/dir/socket/etc
  $fname = $finfo->fname;
  $name  = $finfo->name;  # in filesystem case:

Any other idea anyone ? We're now two to be interested in the answer.


Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread Joe Schaefer
>From the ASF CMS codebase:


    my $subr = $r->lookup_file($file);
    my $content_type = $subr->content_type || "";


an undefined content-type will eventually defer to 
the default content-type if you've set that in your httpd config.


- Original Message -
> From: André Warnier 
> To: mod_perl list 
> Cc: 
> Sent: Friday, January 13, 2012 2:17 PM
> Subject: Re: Obtaining the Apache Content-type for a file
> 
> André Warnier wrote:
>>  David Booth wrote:
>>>  On Fri, 2012-01-13 at 12:09 -0500, David Booth wrote:
  On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
>  I have a PerlResponseHandler which processes some kind of 
> "logical document-id" provided in a request, locates the corresponding 
> "real document" on the filesystem, and returns it to the client via 
> sendfile().
>  At the moment, this handler uses its own custom logic to 
> determine the MIME type of the document and return it to the client as a 
> Content-type HTTP header.
> 
>  My question is : instead of this custom logic, does there exist 
> a way, via mod_perl, to obtain this target file's MIME-type from Apache, 
> using Apache's own logic (mod_mime, AddType etc..) for that ?
  This isn't exactly what you asked for, but if you don't 
> need to server
  anything else along with it, then perhaps you could use
  internal_redirect
 
> http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_
>  
> 
  and let Apache set the Content-Type for you. If you do find the 
> direct answer to your question, please post it, as
  I'm interested in this question also.
>>> 
>>>  P.S. I just noticed lookup_file:
>>> 
> http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_file_ 
>>>  I haven't tried it, but it sounds like it *might* do what you want.
>>> 
>>  Thanks.  I will have a look at both.  I don't think I an use the 
> internal_redirect in my case,
>>  lookup_file sounds interesting.  I didn't think of looking there.
>> 
> 
> I had a look, and it looks a bit like a circular argument..
> 
> I can do $r->lookup_file($my_path), but
> 
> "lookup_file" is a method of Apache2::SubRequest (and returns an 
> Apache2::SubRequest object).  Apache2::SubRequest is a subclass of 
> Apache2::RequestRec.
> Apache2::RequestRec has a "finfo" method, which returns an APR::Finfo 
> object.
> The APR::Finfo object has wealth of information (see below), unfortunately 
> apparently not what I'm after (the MIME type of $mypath, as resolved by 
> mod_mime e.g.).
> 
> $device = $finfo->device;     # (stat $file)[0]
>   $inode  = $finfo->inode;      # (stat $file)[1]
>   # stat returns an octal number while protection is hex
>   $prot   = $finfo->protection; # (stat $file)[2]
>   $nlink  = $finfo->nlink;      # (stat $file)[3]
>   $gid    = $finfo->group;      # (stat $file)[4]
>   $uid    = $finfo->user;       # (stat $file)[5]
>   $size   = $finfo->size;       # (stat $file)[7]
>   $atime  = $finfo->atime;      # (stat $file)[8]
>   $mtime  = $finfo->mtime;      # (stat $file)[9]
>   $ctime  = $finfo->ctime;      # (stat $file)[10]
>   $csize = $finfo->csize; # consumed size: not portable!
>   $filetype = $finfo->filetype; # file/dir/socket/etc
>   $fname = $finfo->fname;
>   $name  = $finfo->name;  # in filesystem case:
> 
> Any other idea anyone ? We're now two to be interested in the answer.
>


Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread André Warnier

André Warnier wrote:

André Warnier wrote:

David Booth wrote:

On Fri, 2012-01-13 at 12:09 -0500, David Booth wrote:

On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
I have a PerlResponseHandler which processes some kind of "logical 
document-id" provided in a request, locates the corresponding "real 
document" on the filesystem, and returns it to the client via 
sendfile().
At the moment, this handler uses its own custom logic to determine 
the MIME type of the document and return it to the client as a 
Content-type HTTP header.


My question is : instead of this custom logic, does there exist a 
way, via mod_perl, to obtain this target file's MIME-type from 
Apache, using Apache's own logic (mod_mime, AddType etc..) for that ?

This isn't exactly what you asked for, but if you don't need to server
anything else along with it, then perhaps you could use
internal_redirect
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_ 

and let Apache set the Content-Type for you. If you do find the 
direct answer to your question, please post it, as

I'm interested in this question also.


P.S. I just noticed lookup_file:
http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_file_ 


I haven't tried it, but it sounds like it *might* do what you want.

Thanks.  I will have a look at both.  I don't think I an use the 
internal_redirect in my case,

lookup_file sounds interesting.  I didn't think of looking there.



I had a look, and it looks a bit like a circular argument..

I can do $r->lookup_file($my_path), but

"lookup_file" is a method of Apache2::SubRequest (and returns an 
Apache2::SubRequest object).  Apache2::SubRequest is a subclass of 
Apache2::RequestRec.
Apache2::RequestRec has a "finfo" method, which returns an APR::Finfo 
object.
The APR::Finfo object has wealth of information (see below), 
unfortunately apparently not what I'm after (the MIME type of $mypath, 
as resolved by mod_mime e.g.).


 $device = $finfo->device; # (stat $file)[0]
  $inode  = $finfo->inode;  # (stat $file)[1]
  # stat returns an octal number while protection is hex
  $prot   = $finfo->protection; # (stat $file)[2]
  $nlink  = $finfo->nlink;  # (stat $file)[3]
  $gid= $finfo->group;  # (stat $file)[4]
  $uid= $finfo->user;   # (stat $file)[5]
  $size   = $finfo->size;   # (stat $file)[7]
  $atime  = $finfo->atime;  # (stat $file)[8]
  $mtime  = $finfo->mtime;  # (stat $file)[9]
  $ctime  = $finfo->ctime;  # (stat $file)[10]
  $csize = $finfo->csize; # consumed size: not portable!
  $filetype = $finfo->filetype; # file/dir/socket/etc
  $fname = $finfo->fname;
  $name  = $finfo->name;  # in filesystem case:

Any other idea anyone ? We're now two to be interested in the answer.


Aaaah, maybe I'm being too complicated here.
If I do

my $subr = $r->lookup_file($my_path);
my $mime = $subr->content_type();

would be what I need.  I'll try that.



Re: Obtaining the Apache Content-type for a file

2012-01-13 Thread André Warnier

Thanks. I just got the same illumination while you were writing..
:-)

Joe Schaefer wrote:

From the ASF CMS codebase:



my $subr = $r->lookup_file($file);
my $content_type = $subr->content_type || "";


an undefined content-type will eventually defer to 
the default content-type if you've set that in your httpd config.



- Original Message -

From: André Warnier 
To: mod_perl list 
Cc: 
Sent: Friday, January 13, 2012 2:17 PM

Subject: Re: Obtaining the Apache Content-type for a file

André Warnier wrote:

 David Booth wrote:

 On Fri, 2012-01-13 at 12:09 -0500, David Booth wrote:

 On Fri, 2012-01-13 at 16:06 +0100, André Warnier wrote:
 I have a PerlResponseHandler which processes some kind of 
"logical document-id" provided in a request, locates the corresponding 
"real document" on the filesystem, and returns it to the client via 
sendfile().
 At the moment, this handler uses its own custom logic to 
determine the MIME type of the document and return it to the client as a 
Content-type HTTP header.
 My question is : instead of this custom logic, does there exist 
a way, via mod_perl, to obtain this target file's MIME-type from Apache, 
using Apache's own logic (mod_mime, AddType etc..) for that ?
 This isn't exactly what you asked for, but if you don't 

need to server

 anything else along with it, then perhaps you could use
 internal_redirect

http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_internal_redirect_ 

 and let Apache set the Content-Type for you. If you do find the 

direct answer to your question, please post it, as

 I'm interested in this question also.

 P.S. I just noticed lookup_file:

http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_file_ 

 I haven't tried it, but it sounds like it *might* do what you want.

 Thanks.  I will have a look at both.  I don't think I an use the 

internal_redirect in my case,

 lookup_file sounds interesting.  I didn't think of looking there.


I had a look, and it looks a bit like a circular argument..

I can do $r->lookup_file($my_path), but

"lookup_file" is a method of Apache2::SubRequest (and returns an 
Apache2::SubRequest object).  Apache2::SubRequest is a subclass of 
Apache2::RequestRec.
Apache2::RequestRec has a "finfo" method, which returns an APR::Finfo 
object.
The APR::Finfo object has wealth of information (see below), unfortunately 
apparently not what I'm after (the MIME type of $mypath, as resolved by 
mod_mime e.g.).


$device = $finfo->device; # (stat $file)[0]
  $inode  = $finfo->inode;  # (stat $file)[1]
  # stat returns an octal number while protection is hex
  $prot   = $finfo->protection; # (stat $file)[2]
  $nlink  = $finfo->nlink;  # (stat $file)[3]
  $gid= $finfo->group;  # (stat $file)[4]
  $uid= $finfo->user;   # (stat $file)[5]
  $size   = $finfo->size;   # (stat $file)[7]
  $atime  = $finfo->atime;  # (stat $file)[8]
  $mtime  = $finfo->mtime;  # (stat $file)[9]
  $ctime  = $finfo->ctime;  # (stat $file)[10]
  $csize = $finfo->csize; # consumed size: not portable!
  $filetype = $finfo->filetype; # file/dir/socket/etc
  $fname = $finfo->fname;
  $name  = $finfo->name;  # in filesystem case:

Any other idea anyone ? We're now two to be interested in the answer.







Re: Problem with long http request generation time - process restarting

2012-01-13 Thread Andrew Merton (subscriptions)

On 17/12/2011 7:20 a.m., Randolf Richardson wrote:

Thanks for the responses :)

However - I just read another thread somewhere that made me think of
looking in the Event log.

It appears that the culprit is Oracle - there are errors
naming OraOCIEI11.dll as the "Faulting Module name".

That's very interesting.  Windows Event Viewer is a good place to
look (I keep forgetting about it as I'm used to /var/log/messages in
Unix/Linux and similar environments).
Well.  It turns out that in this case the event log was actually a red 
herring. By creating another Apache instance (to avoid breaking the 
"production" server :)) and stripping out all references to Oracle, DBI, 
DBD etc from both httpd.conf and the Perl, I have determined that the 
problem has nothing to do with Oracle.


After doing that, I was getting exception code 0xC0FD (Stack 
overflow) in Classify.dll (Params::Classify?) so I tried setting the 
ThreadStackSize to 2MB, and now I get 0xC005 and the module is 
unknown according to the Event log.


I think I'm going mad.

Is there a way to make Apache/mod_perl (on Windows 7) give me a stack 
dump when the child process exits?  Al I get in the log is the "Parent: 
child process exited ..." message, which is not very helpful.  I have 
downloaded the -symbols.zip files from ActiveState and installed them in 
the proper directories (alongside their .dlls), but then realised that 
I'm not getting the equivalent of a core dump file to analyze.  The 
Event log points to a directory containing only a text file (*.wer) 
which doesn't have anything useful AFAICS...


Andrew