cvs commit: modperl-2.0/src/modules/perl mod_perl.c

2002-06-12 Thread dougm

dougm   2002/06/12 14:13:11

  Modified:src/modules/perl mod_perl.c
  Log:
  unbuffer STDERR
  
  Revision  ChangesPath
  1.124 +2 -0  modperl-2.0/src/modules/perl/mod_perl.c
  
  Index: mod_perl.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
  retrieving revision 1.123
  retrieving revision 1.124
  diff -u -r1.123 -r1.124
  --- mod_perl.c6 Jun 2002 16:45:41 -   1.123
  +++ mod_perl.c12 Jun 2002 21:13:10 -  1.124
   -129,6 +129,8 
*/
   modperl_require_module(aTHX_ DynaLoader, FALSE);
   #endif
  +
  +IoFLUSH_on(PL_stderrgv); /* unbuffer STDERR */
   }
   
   static void modperl_xs_init(pTHX)
  
  
  



cvs commit: modperl-2.0 Changes

2002-06-12 Thread dougm

dougm   2002/06/12 16:37:55

  Modified:.Changes
  Log:
  update Changes
  
  Revision  ChangesPath
  1.21  +6 -0  modperl-2.0/Changes
  
  Index: Changes
  ===
  RCS file: /home/cvs/modperl-2.0/Changes,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Changes   5 Jun 2002 01:36:37 -   1.20
  +++ Changes   12 Jun 2002 23:37:55 -  1.21
  @@ -10,6 +10,12 @@
   
   =item 1.99_03-dev
   
  +unbuffer STDERR (by turning on autoflush by default)
  +
  +add support for Perl*Handler +Apache::Foo
  +
  +fix open_logs,post_config,child_init hooks to run in the proper order
  +
   adjust to apr_bucket_type_t changes in 2.0.37-dev
   [Mladen Turk [EMAIL PROTECTED]]
   
  
  
  



Re: separating C from V in MVC

2002-06-12 Thread Matt Sergeant

On Wednesday 12 June 2002 4:09 am, Rob Nagler wrote:
 Matt Sergeant writes:
  There's quite a few things that are a lot harder to do with XML in
  plain perl (especially in SAX) than they are in XSLT.

 This assumes you need XML in the first place.

No, it does not. The rest of my post spoke about XML as a data format and set 
of tools, not as a syntax. Please stop thinking about XML as syntax!!

 It's trivial to manipulate Perl data structures in Perl.  It's
 also easy to manipulate XML in Perl.  However, it's impossible(?) to
 manipulate Perl data structures in XSLT.

You seem to speak as someone who has never tried by the sounds of things. This 
is one of the things AxKit's XSP taglibs are designed to provide for.

Matt.



Re: installation problems

2002-06-12 Thread Chris

 will wrote:
 I am trying to install mod perl as part of Apache-ASP and am stuck at
 the following error:
 
 
Apache.exe -k start
 
 are you mixing Apache 2.0 with mod_perl 1.0? -k is an Apache 2.0 option

um ... I use:

c:\apache\apache.exe -k start 

all the time under Apache 1.3.22 for Win32. 

 whenever reporting problems you have to tell us what you are doing and 
 what versions you are using see:
 
http://perl.apache.org/release/docs/1.0/guide/help.html#How_to_Report_Proble
ms
 
http://perl.apache.org/release/docs/2.0/user/help/help.html#Reporting_Proble
ms
 
 Can't locate Cwd.pm in INC (INC contains: .) at (eval 1) line 1.
 
 I've searched the web and haven't found any solutions.
 I have checked the perl INC using 'perl -V' and the path to Cwd.pm is
 there:

INC under perl -V and mod_perl aren't always synonomous. I'm not sure what 
the larger issue you have here is (I've never used/installed Apache::ASP) 
but your error message says that INC contains only '.' and obviously that 
doesn't have the path to the c:/perl/lib or c:/perl/site/lib directories.

Perhaps you tried setting INC at some point in the httpd.conf?

Follow Stas' suggestion of providing more info ... did you build this 
mod_perl yourself or are you using Randy Kobe's PPM? 


-Chris
-- 
[A] Genuinely skillful use of obscenities is uniformly absent on the 
Internet. -Karl Kleinpaste 




RE: OSC early bird and mod_perl T-Shirts

2002-06-12 Thread Joe Breeden

Why hasn't the logo that was voted on been considered? What's the point of a logo if 
you don't use it everywhere?

 -Original Message-
 From: Alfred Vahau [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 11, 2002 4:54 PM
 To: 'mod_perl list'
 Subject: Re: OSC early bird and mod_perl T-Shirts
 
 
 May I suggest a camel with the wings of an eagle or a double 
 humped eagle???
 
 The two icons are associated with the two invaluable 
 references of the Perl
 world and somehow the
 design must incorporate them. I'm not about to suggest which 
 creature gets
 the prominence.
 
 Final point:
 
 I'm 10 hrs ahead of GMT on the other side of the world. In 
 these hard times,
 it's difficult to find a generous sponsor so I won't be 
 attending the OSC.
 But I'd like to have a mod_perl  'T' one day. Please advice 
 how I could go
 about getting one.
 
 Alfred Vahau
 Project Breeeze
 SNPS
 Uni. PNG
 
 Gunther Birznieks wrote:
 
  Maybe this year Randal Schwartz can get his idea 
 implemented. I think he
  had suggested a motto last year that people seemed OK with 
 but then the
  T-Shirts never got done in the end...
 
  Ah, the annual motto vote... :) Just re-read the same thread in the
  archives last year.
 
  Later,
  Gunther
 
  At 06:55 PM 6/11/2002, John Bass wrote:
 
  mod_perl: The camel with wings
  
  John
  
  -Original Message-
  From: Lupe Christoph [mailto:[EMAIL PROTECTED]]
  Sent: 11 June 2002 11:51
  To: Leon Brocard
  Cc: mod_perl list
  Subject: Re: OSC early bird and mod_perl T-Shirts
  
  On Tuesday, 2002-06-11 at 10:44:26 +0100, Leon Brocard wrote:
  
Yup, I have a designer here who is willing to come up 
 with something.
Constructive ideas welcome offlist. Better slogans than 
 modperl: the
only way to fly, modperl: obey your thirst etc. very 
 welcome too
  ;-)
  
  SCNR:
  
  Quetzalcoatl: The Feathered Snake
   mod_perl: The Feathered Camel
  
  Profound excuses,
  Lupe Christoph
  --
  | [EMAIL PROTECTED]   |   
 http://www.lupe-christoph.de/
  |
  | I have challenged the entire ISO-9000 quality assurance team to a
  |
  | Bat-Leth contest on the holodeck. They will not concern us again.
  |
  | http://public.logica.com/~stepneys/joke/klingon.htm
  |
 
  __
  Gunther Birznieks ([EMAIL PROTECTED])
  eXtropia - The Open Web Technology Company
  http://www.eXtropia.com/
  Office: (65) 64791172 Mobile: (65) 96218290
 
 



Re: OSC early bird and mod_perl T-Shirts

2002-06-12 Thread Leon Brocard

Joe Breeden sent the following bits through the ether:

 Why hasn't the logo that was voted on been considered? What's the
 point of a logo if you don't use it everywhere?

OK, I think the new logo is wonderful and it will hopefully take up a
large part of the tshirt design. As Mark said to me on #modperl:

10:09 Trelane^ the thing about branding is, well, you have to brand things

Leon
-- 
Leon Brocard.http://www.astray.com/
Nanoware...http://www.nanoware.org/

... A living example of Artificial Intelligence



mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Vuillemot, Ward W

I was wondering how people are saving state between pages of a session.

There is a Apache::Session which is sufficient to check to see if they are
logged in, et cetera.
But I want to be able to remember the last query so that I can return
results into multple pages along with memory of where in the stack I am at.
The easiest would to be store the query parameters along with the count
information. . .but I do not want to use Apache::Session as I believe that
has too much overhead for this sort of thing.
There are persistent modules, but I am wondering if there is a better way
with Apache and mod_perl -- that ppl have tried and can vouche for its
validity.

Thanks!
Ward



Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Perrin Harkins

Vuillemot, Ward W wrote:
 There is a Apache::Session which is sufficient to check to see if they are
 logged in, et cetera.
 But I want to be able to remember the last query so that I can return
 results into multple pages along with memory of where in the stack I am at.

You can store anything in Apache::Session; it's just a persistent hash 
table.  However, storing query results based on a user's session is not 
a good idea!  What if your users open up two browser windows and tries 
to do a search in each one?  Server-side session data is global to all 
browser windows, so they'll get bizarre and incorrect results.  If you 
check any of the major sites you'll see that they handle multiple 
windows correctly.

My suggestions would be to have a separate cache just for query results. 
  Turn the sorted query parameters into a key.  If someone goes to page 
2 of the results, you just pull them out of the cache.

 There are persistent modules, but I am wondering if there is a better way
 with Apache and mod_perl

There have been a few benchmarks of ways to store a persistent hash. 
I'll have some new numbers on this soon, but for now I'd suggest looking 
at Cache::Cache, MLDBM::Sync, or Cache::Mmap.

- Perrin





Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Ken Y. Clark

On Wed, 12 Jun 2002, Vuillemot, Ward W wrote:

 Date: Wed, 12 Jun 2002 06:58:24 -0700
 From: Vuillemot, Ward W [EMAIL PROTECTED]
 To: 'Peter Bi' [EMAIL PROTECTED], [EMAIL PROTECTED],
  Eric Frazier [EMAIL PROTECTED]
 Subject: mod_perl/passing session information (MVC related, maybe...)

 I was wondering how people are saving state between pages of a session.

 There is a Apache::Session which is sufficient to check to see if
 they are logged in, et cetera.  But I want to be able to remember
 the last query so that I can return results into multple pages along
 with memory of where in the stack I am at.  The easiest would to be
 store the query parameters along with the count information. . .but
 I do not want to use Apache::Session as I believe that has too much
 overhead for this sort of thing.  There are persistent modules, but
 I am wondering if there is a better way with Apache and mod_perl --
 that ppl have tried and can vouche for its validity.

 Thanks!
 Ward

Ward,

I do things like this all the time, though I wonder if I don't do it
the Hard Way.  Basically, I define a MAX_RESULTS per page (like 25)
and return the first set of records to the user.  To make the
clickable links to Previous, Next, and the 1-n pages, I've munged
the query results in Perl and a couple template packages to make each
link contain everything necessary to perform the query again
(including every parameter from the original request) and putting in
the appropriate limit_start number (or whatever you want to call
your limiting variable) for the set.

E.g., if I'm looking for all the records where name=foo and
size=M and I got back 100 results, with a MAX_RESULTS of 25, I'd
have to make four pages.  The second page might look like this:

a href=/search?name=foo;size=M;limit_start=0Previous/a |
a href=/search?name=foo;size=M;limit_start=01/a |
2 |
a href=/search?name=foo;size=M;limit_start=503/a |
a href=/search?name=foo;size=M;limit_start=754/a |
a href=/search?name=foo;size=M;limit_start=50Next/a

Now, that's a lot of stuff to make sure is in your output, and adding
or changing a parameter means a lot of fixing.  However, it is fairly
simple, and I can grok it, so I stick with it.  I'd be happy to hear
of better ways.

FWIW, I do pretty much the same thing to re-sort tables of data by
column headers.  So for a table of shirts with attributes of color
and price, I'd do something like:

FWIW, I do pretty much the same thing to re-sort tables of data by
column headers.  So for a table of shirts with attributes of color
and price, I'd do something like:

tr
...
tha href=/view_shirts?order_by=colorColor/a/th
tha href=/view_shirts?order_by=pricePrice/a/th
...
/tr

Sprinkle in the same code for limiting to a managable result set, and
those are all my tricks.

HTH,

ky




RE: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Jeff AA


 From: Perrin Harkins [mailto:[EMAIL PROTECTED]] 
 Sent: 12 June 2002 15:11

 You can store anything in Apache::Session; it's just a persistent hash

 table.  However, storing query results based on a user's session is
not 
 a good idea!  What if your users open up two browser windows and tries

 to do a search in each one?  Server-side session data is global to all

 browser windows, so they'll get bizarre and incorrect results.

Agreed, but he wasn't talking about storing the results, just the query
parameters and current offset / number of rows, which is a-ok for
putting into a session.

some query session do's and don'ts...

Don't forget that you can have multiple sessions - store the query
params in a session identified by a query_id so that subsequent requests
just say something like: A
HREF='/searchquery_id=123456789action=next'Next/A

Don't mix transient query sessions with a User Session that stores info
about the user's logged in state etc. It would be normal for one user to
have multiple queries in a login session

Don't bother passing the query ids in cookies, they are not browser
session specific. Just use the query_id as a parameter in the
first/next/prev/last links as exampled above. You can then have a web
control page that handles multiple queries simultaneously

Do put the user_id into the query session and check it against the
user_id in the User session to prevent query hijack


 My suggestions would be to have a separate cache just for query
results. 

Or even to use a database that has a decent approach to caching. MySQL
promises automatic cacheable paged queries in the near future. And if
you write your own DB cache, you then need to manage the DB / cache
synch issues, cache size, cache expiry etc etc issues. Good cache is
very hard to do! better to get it from a real data bank.


 From: Vuillemot, Ward W [mailto:[EMAIL PROTECTED]] 
 Sent: 12 June 2002 14:58

 I want to be able to remember the last query so that I can return
 results into multple pages along with memory of where in the stack I
am at.
 The easiest would to be store the query parameters along with the
count
 information. . .but I do not want to use Apache::Session as I believe 
 that has too much overhead for this sort of thing.

Apache::Session is just what you want here! It is an easy peasy way to
remember things on the server, and you can implement it with whatever
type of storage underneath that you want [e.g. database] so that you can
even share sessions when your query is being served by multiple web
servers. If you look through the source, you will see that the overhead
is minimal. You can specialise the session persistence mechanism if you
want to for example store the key = value pairs as visible records in
the DB rather than a serialised blob.


Regards

Jeff





[OT] Programming Language Benchmarks

2002-06-12 Thread Nico Erfurth

http://www.bagley.org/~doug/shootout/

It's nice to see perl compared to php ;)

ciao




RE: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Jeff AA


 From: Ken Y. Clark [mailto:[EMAIL PROTECTED]] 
 Sent: 12 June 2002 15:39

 I've munged the query results in Perl and a couple template 
 packages to make each link contain everything necessary to 
 perform the query again (including every parameter from the 
 original request) and putting in the appropriate limit_start
 number...

Using sessions and a query_id is a shortcut for this, instead of stating
all the complex parameters again, you just issue an id and put that into
the link. 

An advantage of the session/id is that you end up with stateful query
instances, and can remember [at least for a short period!] the total
number of items, so that you can say 'Results 1 to 10 of 34,566' without
having to count all results every time. This is also useful if you want
users to be able to jump to a LAST page, as you can for example calc the
starting point for limit statement easily.

One disadvantage is that you cannot link to the query result pages, as
you will no doubt expire the query sessions eventually. By putting all
the params in the link, Ken's way lets the users link to the results,
remember them in their favourites etc.

Another possible feature is to allow the link to override any of the
current query parameters, so to do a DB resort, you can say something
like A HREF=/query?query_id=12345order=colourSort by Colour/A and
the order param is not lost in amongst lots of other params. Obviously
changes to the where clause, ordering etc may invalidate current row /
page remembered values.

Further variations are readily available. You can create persistent
queries, rather than session queries, store the params in the DB and let
your users have their very own private or shareable searches. If you use
the optional param overide approach, you can store the params once, and
then the options as a separate query that refers to the underlying
query. When users add columns or other bits to the underlying, all child
searches will respect the change.

Regards
Jeff






Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Perrin Harkins

Jeff AA wrote:
 Agreed, but he wasn't talking about storing the results, just the query
 parameters and current offset / number of rows, which is a-ok for
 putting into a session.

No, that's exactly what ISN'T okay for putting into a session.  If a 
user opens two browser windows, does a search in each, and then pages 
forward in each set of results, he will get completely wrong pages if 
you do this.  The query parameters from the first search will be written 
over and lost.

 Don't forget that you can have multiple sessions - store the query
 params in a session identified by a query_id so that subsequent requests
 just say something like: A
 HREF='/searchquery_id=123456789action=next'Next/A

You could do that, with a unique ID for each set of parameters, but you 
might as well just put the parameters right in the link unless they're 
very long.

 Don't mix transient query sessions with a User Session that stores info
 about the user's logged in state etc. It would be normal for one user to
 have multiple queries in a login session

Hold on, I think we actually agree, but you're using the word session 
for a bunch of different things.  What you're saying here sounds like 
the opposite of what you said above.  In common usage, a session is the 
state of the user's interaction with the application.  A cache of query 
data would be something else.

 Or even to use a database that has a decent approach to caching. MySQL
 promises automatic cacheable paged queries in the near future. And if
 you write your own DB cache, you then need to manage the DB / cache
 synch issues, cache size, cache expiry etc etc issues. Good cache is
 very hard to do! better to get it from a real data bank.

MySQL is fast, but usually not as fast as simple disk access. 
Cache::Cache and Cache::Mmap handle the details of the cache stuff for 
you, making it pretty easy.

- Perrin




RE: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Eric Frazier

Hi,

I don't know this term query hijack can you put it in different words?

Thanks,

Eric

At 03:54 PM 2002-06-12 +0100, you wrote:
Do put the user_id into the query session and check it against the
user_id in the User session to prevent query hijack





Re: Internet Explorer sending nothing in subsequent posts

2002-06-12 Thread Drew Taylor

My first guess is that it's caching the results. We just had fun debugging 
a problem w/ an aggressive proxy doing exactly this sort of thing. Try 
holding shift  click reload/refresh and see if the browser actually hits 
the server then. Go to Tools | Internet Options | General Tab | Temporary 
Internet Files - Settings and select every visit to the page to 
effectively disable caching.

Drew

At 10:28 AM 6/12/02 -0400, Harnish, Joe wrote:

When Internet Explorer hits a mod_perl page that uses the post method in 
the form it will run the first time but all the subsequent posts will not 
get anything sent.

Does anyone know why this happens?  Is there a workaround for mod_perl or 
in the Web browser?

==
Drew Taylor  |  Freelance web development using
http://www.drewtaylor.com/   |  perl/mod_perl/MySQL/postgresql/DBI
mailto:[EMAIL PROTECTED]   |  Email jobs at drewtaylor.com
--
Speakeasy.net: A DSL provider with a clue. Sign up today.
http://www.speakeasy.net/refer/29655
==




Re: installation problems

2002-06-12 Thread Randy Kobes

On Mon, 10 Jun 2002, will wrote:

 I am trying to install mod perl as part of Apache-ASP and am stuck at the
 following error:

 Apache.exe -k start
 Can't locate Cwd.pm in INC (INC contains: .) at (eval 1) line 1.

 I've searched the web and haven't found any solutions.
 I have checked the perl INC using 'perl -V' and the path to Cwd.pm is
 there:

 INC:
 C:/Perl/lib
 C:/Perl/site/lib
 .
[ ... ]
I remember seeing this some time ago, though don't
know if the source of the problem was found ... If you're
not altering INC in a startup.pl, try setting the
PERL5LIB environment variable to include C:/Perl/lib
and C:/Perl/site/lib before starting Apache.

best regards,
randy kobes





RE: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Jeff AA


 From: Eric Frazier [mailto:[EMAIL PROTECTED]] 
 Sent: 12 June 2002 16:52

 I don't know this term query hijack can you put it in different
words?

Lets say your user who is the boss makes a query
  'show me everyone's salary'

and your system checks who he is, and because he is the boss, allocates
query_id 1, issues the query and sends back page one with everyone's
salary details.


now some other user in the system can now say
  /query?query_id=1

and hijack the query results - i.e. they will see the results of the
query, even though they should not be allowed to.


If your security model is user centric, at a minimum you should put the
user_id inside the query_id session, and only let the same user get the
results from the saved query parameters. A better approach is to have
the query ALWAYS authenticate the current user, then you won't ever give
out data to the wrong person, and users can share query links that will
work if they have the appropriate rights.


from www.dictionary.com/searchq=hijack

hijack

n : seizure of a vehicle in transit either to rob it or divert it to an
alternate destination [syn: highjack] v : take arbitrarily or by force;
The Cubans commandeered the plane and flew it to Miami [syn:
commandeer, highjack, pirate, expropriate]



Regards
Jeff





Mapping to location /

2002-06-12 Thread md

I'm replacing an exisiting PHP site with mod_perl and
Template-Toolkit.

I normally set up mod_perl to use a location like
this:

Location /something

and set the handler to my mod_perl module.

However, I need to map to / since I'm replacing a
system where there are existing PHP files like
www.someserver.com/index.php or
www.someserver.com/about.php.

I decided to do use

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. 

If I have a .phtml (or a directory index) I check if I
have a template. If I have a template TT takes over,
if not I return DECLINED and let Apache take over.

http.conf
-
Location /
PerlSetVar websrc_root /usr/local/templates
SetHandler  perl-script
PerlHandler Test::MyModule
/Location

Beginning of MyModule.pm
-
# Get the uri
my($uri, $uri2);
$uri = $uri2 = $r-uri;
$uri2 =~ s[^/][];  # remove the leading '/'

# We only want to see .phtml files, or urls that end
with '/'
# or where the stuff past the last '/' doesn't contain
any '.'s.
# We'll check the later two case for a template and
then
# decline it if no template is found.
unless ($uri =~ /\.phtml$/ or
$uri =~ m!/$! or
$uri =~ m!.*/[^\.]+$!) {
return DECLINED;
}

Is this the best way to do this?

--
Thanks

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



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: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread James G Smith

John Siracusa [EMAIL PROTECTED] wrote:
On 6/12/02 12:17 PM, Perrin Harkins wrote:
 James G Smith wrote:
 The nice thing about the context then is that customers can have
 multiple ones for multiple windows and they can have more than they
 have windows.
 
 How do you tie a context to a window?  I don't see any reliable way to
 do it.  The only way to maintain state for a window (as opposed to
 global state for a session) is to pass ALL the state data on every link.

Nah, you could just shove a context param into all forms and links on each
page, and store the actually (possibly large) context server-side, keyed by
context id (and session id, see below)

a href=/foo/bar?context_id=2.../a
...
input type=hidden name=context_id value=2
...

Note the tiny context id.  If you lookup contexts using both the context id
and the (cookie-stored) session id, you can get really short context ids :)
Just an idea...

I haven't worked this part out yet, though that is one way I thought
of.  This is similar to how Twig handles contexts.

Another way I was thinking about was making it part of the URL.  For
example:

  https://x.y.z.edu/contextid/rest/of/url.html

The session would be with a cookie.  This would allow cutting and
pasting of URLs for help tickets and such while preserving the
context.  This would also make coding easier by using relative URLs.

Of course, this has all the problems of storing the session ID in the
URL in the same manner.  We might also have to look for links that
open a new browser window and give them a new context.

I'm still working out the details.

I could be really evil and make the URLs 32-hex strings that map to a
context and URL combination :)  Obfuscated web site with no hope of
deep linking
-- 
James Smith [EMAIL PROTECTED], 979-862-3725
Texas AM CIS Operating Systems Group, Unix



RE: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Rob Nagler

Jeff AA writes:
 An advantage of the session/id is that you end up with stateful query
 instances,

Stateful instances are also problematic.  You have essentially two
paths through the code: first time and subsequent time.  If you write
the code statelessly, there is only one path.  Fewer bugs, smaller
code, less development.

Sessions are caches.  Add them only when you know you need them.

 and can remember [at least for a short period!] the total
 number of items, so that you can say 'Results 1 to 10 of 34,566' without
 having to count all results every time.

Maybe this is just because we are using Oracle, but if you do a query:

SELECT count(*) FROM bla, bla...

followed up by:

SELECT field1, field2, ... FROM bla, bla...

Oracle will cache the query compilation and results so it is very fast
(basically a round-trip to database server) for the second query.
We execute these two queries on every paged list on every request.

One of the advantages of a declarative OR mapping is that you can do
things like sort to select asfields and order queries consistently.
Oracle takes advantage of this.  I don't know of mySQL or Postgres do,
too, but they probably will someday.

It's a bit slow (seconds) with Oracle's Context engine, which we've
been considering replacing.  Most of our queries are not text searches
iwc Oracle queries take less than 20ms per query.

We're not a large site (peak 50K views/day), and we have enough
hardware (two front ends, two middle tier, one db).  Our smaller sites
(e.g. bivio.biz) run on minimal hardware and use Postgres.  They use
the same code, and it seems to work fine.

Rob





Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Per Einar Ellefsen

At 18:20 12.06.2002, John Siracusa wrote:
On 6/12/02 12:17 PM, Perrin Harkins wrote:
  James G Smith wrote:
  The nice thing about the context then is that customers can have
  multiple ones for multiple windows and they can have more than they
  have windows.
 
  How do you tie a context to a window?  I don't see any reliable way to
  do it.  The only way to maintain state for a window (as opposed to
  global state for a session) is to pass ALL the state data on every link.

Nah, you could just shove a context param into all forms and links on each
page, and store the actually (possibly large) context server-side, keyed by
context id (and session id, see below)

But what if someone opens one of the links in a different window, and 
continue on the same pages as in the original window, but with different 
parameters? The session ID would be the same, the context id would be the 
same, but the params would be different, right?


-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread John Siracusa

On 6/12/02 12:57 PM, Per Einar Ellefsen wrote:
 But what if someone opens one of the links in a different window, and
 continue on the same pages as in the original window, but with different
 parameters? The session ID would be the same, the context id would be the
 same, but the params would be different, right?

Well, then things break I guess... :)  Maybe you could do some magic based
on what browsers send as the referrer when users explicitly open a link in a
new tab or window?  Probably not worth it...

-John




Re: Mapping to location /

2002-06-12 Thread Per Einar Ellefsen

At 18:41 12.06.2002, md wrote:
I'm replacing an exisiting PHP site with mod_perl and
Template-Toolkit.

I normally set up mod_perl to use a location like
this:

Location /something

and set the handler to my mod_perl module.

However, I need to map to / since I'm replacing a
system where there are existing PHP files like
www.someserver.com/index.php or
www.someserver.com/about.php.

I decided to do use

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.

Can't you just drop the Location and use
Files *.phtml
   SetHandler 
/Files
or something like that? Seems like it would avoid some overhead for you.
However, I'm not sure if I understand what you mean with
  $uri =~ m!.*/[^\.]+$!) {

If I have a .phtml (or a directory index) I check if I
have a template. If I have a template TT takes over,
if not I return DECLINED and let Apache take over.

Hmm, but if you don't have a template, then you have nothing to serve, right?

httpd.conf
-
Location /
 PerlSetVar websrc_root /usr/local/templates
SetHandler  perl-script
 PerlHandler Test::MyModule
/Location

Beginning of MyModule.pm
-
# Get the uri
my($uri, $uri2);
$uri = $uri2 = $r-uri;
$uri2 =~ s[^/][];  # remove the leading '/'

# We only want to see .phtml files, or urls that end
with '/'
# or where the stuff past the last '/' doesn't contain
any '.'s.
# We'll check the later two case for a template and
then
# decline it if no template is found.
unless ($uri =~ /\.phtml$/ or
 $uri =~ m!/$! or
 $uri =~ m!.*/[^\.]+$!) {
 return DECLINED;
}

Is this the best way to do this?

-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: Mapping to location /

2002-06-12 Thread md


--- Aaron Ross [EMAIL PROTECTED] wrote:

 Would
 
  Files *.phtml
 
  /Files
 
 do the trick?

No...the files don't actually exist under htdocs since
I'm using Template-Toolkit.

Thanks though.

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



Re: Mapping to location /

2002-06-12 Thread Per Einar Ellefsen

At 19:08 12.06.2002, md wrote:

--- Aaron Ross [EMAIL PROTECTED] wrote:

  Would
 
   Files *.phtml
 
   /Files
 
  do the trick?

No...the files don't actually exist under htdocs since
I'm using Template-Toolkit.

Oh, so your .phtml things are really just TT templates?
What about:

Location .*\.phtml|/
...
/Location
complete the regex with what you want.


-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Perrin Harkins

John Siracusa wrote:
 On 6/12/02 12:57 PM, Per Einar Ellefsen wrote:
 
But what if someone opens one of the links in a different window, and
continue on the same pages as in the original window, but with different
parameters? The session ID would be the same, the context id would be the
same, but the params would be different, right?
 
 
 Well, then things break I guess... :)  Maybe you could do some magic based
 on what browsers send as the referrer when users explicitly open a link in a
 new tab or window?  Probably not worth it...

Right, which is why you shouldn't try to store server-side state for 
anything that could be different in multiple browser windows.  Only 
store global browser information on the server-side.  Everything else 
has to go into the links and forms.

- Perrin




Re: Mapping to location /

2002-06-12 Thread md


--- Per Einar Ellefsen [EMAIL PROTECTED] wrote:
 Can't you just drop the Location and use
 Files *.phtml
SetHandler 
 /Files
 or something like that? Seems like it would avoid
 some overhead for you.

True...but the files don't actually exist. The
path/filename is used to map to a template.

 However, I'm not sure if I understand what you mean
 with
   $uri =~ m!.*/[^\.]+$!) {

This may not be the best regex..but what I was trying
to do was to match something like
/directory/subdirectory which would normally be
redirected back to
/directory/subdirectory/index.html (or whatever is
set as DirectoryIndex files). I want to check for a
/directory/subdirectory/index.phtml file.

 Hmm, but if you don't have a template, then you have
 nothing to serve, right?

I'd like to also have other mod_perl handlers mapped
to other Locations like normal, so for example
/something I may not have a corresponding template
but I would have a
Location /something.

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



Anti caching and auto refresh problem

2002-06-12 Thread Steve Walker

I'm setting the following headers with mod_perl and there seems to be a bug
in the way netscape 4.7 handles them. The page is being auto refreshed by
Netscape if the document in cache is compared to document on network
preference is set to every time.  I've tried IE and I don't seem to have the
problem, but haven't had a chance to test on any other platforms.  I've
tried removing the Expires header, but that didn't make a difference.  I've
searched the archives and bug databases but nothing has turned up.

Here is an example header:

HTTP/1.1 200 OK
Date: Wed, 12 Jun 2002 15:28:59 GMT
Server: Apache/1.3.22 (Unix) mod_perl/1.26
Pragma: no-cache
Cache-Control: no-cache
Connection: close
Content-Type: image/gif
Expires: Wed, 12 Jun 2002 15:28:59 GMT

I know it might be a bit off topic but I was wondering if anyone else has
run into this problem?  

Thanks,
Steve






RE: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Jeff AA


 From: Perrin Harkins [mailto:[EMAIL PROTECTED]] 
 Sent: 12 June 2002 16:29

 Agreed, but he wasn't talking about storing the results, just the
query
 parameters and current offset / number of rows, which is a-ok for
 putting into a session.

 No, that's exactly what ISN'T okay for putting into a session.  If a 
 user opens two browser windows, does a search in each, and then pages 
 forward in each set of results, he will get completely wrong pages if 
 you do this.  The query parameters from the first search will be
written 
 over and lost.

Please - s/session/Apache::Session/g above


 You could do that, with a unique ID for each set of parameters, but
you 
 might as well just put the parameters right in the link unless they're

 very long.

The [Apache::]session approach makes it easy to store and change lots of
params to the query. It also lets you keep track of [recommendedly]
minimal info about the Query on the server, without having to re-execute
it, and it lets you pick up a previous query, with minor tweaks things
like /query?query_id=12345order=value+desc where the tweak doesn't get
lost in the params.


 Don't mix transient query sessions with a User Session that stores
info
 about the user's logged in state etc. It would be normal for one user
to
 have multiple queries in a login session
 
 Hold on, I think we actually agree, but you're using the word session 
 for a bunch of different things.  What you're saying here sounds like 
 the opposite of what you said above.  In common usage, a session is
the 
 state of the user's interaction with the application.  A cache of
query 
 data would be something else.

Again, please s/session/Apache::Session/g 

 MySQL is fast, but usually not as fast as simple disk access. 
 Cache::Cache and Cache::Mmap handle the details of the cache stuff for

 you, making it pretty easy.

RANT

I do agree that disk access _can_ be faster, but disagree with the
implication that caching DB results outside the db is a cool trick. I
would assert that in all general circumstances caching DB results is a
Common Mistake. Special circumstances do exist, but in my experience
very rarely, and that's why we have MI6. I can imagine a circumstance
where a cache may prove useful - a large number of concurrent users, all
wanting exactly the same data, slow db connection, non-optimisable
query. This doesn't seem to be the case here where the question was
about a faster Apache::Session.

Interestingly MySQL and other DBs are often as fast as simple disk
access - contrary to popular wisdom, most DB engines actually cache in
memory, with more data access information and hence effective cache
memory usage than is available to external cache components. Yes,
Network transference can be an issue - but hey! be a masochist, buy a
switch!

I recall an impressive chap at a bank, who was asked to address
performance issues. He immediately identified DB queries as taking far
too long, and proceeded to hand craft a mega-smart shareable multi-user
in-memory cache server in C. He ran into dozens of issues, which were
ingeniously solved using the tersest possible sin tax. After about six
months of effort, the performance problem still existed,  - the DB
resided entirely in memory anyway! A tweak of the schema [i.e. about 2
hours including test and release] by a DB admin took the problematic
process from 2 hours down to 120 seconds. We spent cash for cache, and
lived to rue the day.

I parse 'use a cache for db stuff' as 'my XYZ cache component is way
smarter than all the guys at 'Oracle|Sybase|MySQL' combined', or 'I know
my data better than the database, cos I'm a kewl Koder'. Actually, I
really parse 'use a cache for db stuff' as 'I don't really understand
databases, 3NF and indexing, and can't be bothered learning to use them
well'.

/RANT

But ok then, use a cache for your mod_perl query parameters, but don't
call it an [Apache::]Session.

8-)





Re: Mapping to location /

2002-06-12 Thread Per Einar Ellefsen

At 19:14 12.06.2002, Per Einar Ellefsen wrote:
Location .*\.phtml|/

Sorry, make that LocationMatch

...
/Location

And /LocationMatch of course.


-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Perrin Harkins

Rob Nagler wrote:
 Stateful instances are also problematic.  You have essentially two
 paths through the code: first time and subsequent time.  If you write
 the code statelessly, there is only one path.  Fewer bugs, smaller
 code, less development.

I find you can tie this cache stuff up inside of your data access 
objects and make it all transparent to the other code.  That worked 
really well for me.  There are hooks for this in some of the O/R mapping 
modules on CPAN.

 Sessions are caches.

One of the things Java programmers often do wrong is cache general data 
in the session, because the servlet API makes it so easy to do.  But 
most data that people cache (as we're seeing in this discussion about 
search params) is not user-specific and thus doesn't belong in the 
session (i.e. everyone who searches for foosball gets the same result).

A session is useful for very limited things, like remembering if this 
user is logged in and linking him to a user_id.  Almost everything else 
belongs either in separate database tables or in the query args passed 
on each page.

 Oracle will cache the query compilation and results so it is very fast
 (basically a round-trip to database server) for the second query.
 We execute these two queries on every paged list on every request.

Although Oracle can be fast, some data models and application 
requirements make it hard to do live queries every time and still have 
decent performance.  This is especially true as traffic starts to climb. 
  That's when you can add in some caching and take a lot of stress off 
the database.  There are a million ways to implement caching, from 
denormalized tables to replicated databases to BerkeleyDB to mod_proxy 
and most web applications have some data that is read-only or close to 
it.  (I know that yours deals with financial data, so in your case it 
may actually have to be all real-time data.)

- Perrin




Re: Mapping to location /

2002-06-12 Thread md


--- Per Einar Ellefsen [EMAIL PROTECTED] wrote:
 At 19:14 12.06.2002, Per Einar Ellefsen wrote:
 Location .*\.phtml|/
 
 Sorry, make that LocationMatch
 
 ...
 /Location
 
 And /LocationMatch of course.

That should work...thanks.

For the most part *all* .phtml pages will be doing the
same thing, taking session data and parsing out
templates. 

In some cases I may need something entirely different
as far as logic goes, like a message board or a reg
form, but still using TT and session data. That's
where I'll be using a different Location, TT Plugins
or Stas's suggestion...or any other suggestions I may
receive. HTML::Mason would probably be a closer match
to what I'm trying to do (replacing PHP), but we use
TT for everything :)

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Perrin Harkins

Jeff AA wrote:
 Interestingly MySQL and other DBs are often as fast as simple disk
 access - contrary to popular wisdom, most DB engines actually cache in
 memory, with more data access information and hence effective cache
 memory usage than is available to external cache components. Yes,
 Network transference can be an issue - but hey! be a masochist, buy a
 switch!

It's a simple rule: if you do less work, you will finish faster. 
Reading a file will go to the file system code in the kernel, which uses 
some sort of in-memory cache on any modern OS.  That means that for any 
frequent access data you are reading it from memory using system-level 
calls.  By contrast, MySQL has to deal with network transfers and SQL 
parsing before it reaches that stage.  It's not a huge difference, but 
it is a difference.  I'll have numbers on this stuff soon as part of my 
article on data sharing with mod_perl, so that people can compare and 
see if it's worth the effort for them.

The more important reason to cache is scalability.  Every time you don't 
hit the database, that means more resources are available to handle the 
queries that can't be cached.  On a site with heavy traffic, that's very 
important.

 I parse 'use a cache for db stuff' as 'my XYZ cache component is way
 smarter than all the guys at 'Oracle|Sybase|MySQL' combined', or 'I know
 my data better than the database, cos I'm a kewl Koder'. Actually, I
 really parse 'use a cache for db stuff' as 'I don't really understand
 databases, 3NF and indexing, and can't be bothered learning to use them
 well'.

I've worked with some good DBAs, but there is a limit to what they can 
do.  Ultimately, a database is designed to always give 100% correct 
up-to-date results, but in most web applications people would prefer to 
get slightly out-of-date results if they can get them much faster. 
Databases don't know how to do that.  Why should you go to MySQL every 
time someone hits the front page of Slashdot just to give them the very 
latest count on comments?  Caching that page for 1 minute takes a ton of 
load off the database and doesn't really impact the user experience.

I fully agree that optimizing the database and SQL is the first step, 
but correct use of caching can make a huge difference on high-volume sites.

- Perrin




Re: Anti caching and auto refresh problem

2002-06-12 Thread Geoffrey Young



Steve Walker wrote:

 I'm setting the following headers with mod_perl and there seems to be a bug
 in the way netscape 4.7 handles them. The page is being auto refreshed by
 Netscape if the document in cache is compared to document on network
 preference is set to every time.  I've tried IE and I don't seem to have the
 problem, but haven't had a chance to test on any other platforms.  I've
 tried removing the Expires header, but that didn't make a difference.  I've
 searched the archives and bug databases but nothing has turned up.
 
 Here is an example header:
 
 HTTP/1.1 200 OK
 Date: Wed, 12 Jun 2002 15:28:59 GMT
 Server: Apache/1.3.22 (Unix) mod_perl/1.26
 Pragma: no-cache
 Cache-Control: no-cache
 Connection: close
 Content-Type: image/gif
 Expires: Wed, 12 Jun 2002 15:28:59 GMT
 
 I know it might be a bit off topic but I was wondering if anyone else has
 run into this problem?  


I'm not really sure what you're asking - are you saying that you 
_want_ NS to use its cache?  if so, removing the Pragma and 
Cache-Control headers with $r-no_cache(0) should do that (and remove 
the Expires header as well, IIRC).

If you _don't want_ netscape to use its cache, it looks like you're 
doing the right thing.

There are some methods in Apache::File (like $r-set_last_modified) 
that you may want to look at as well in order to help clients make a 
more intelligent decision.

HTH

--Geoff







Re: Internet Explorer sending nothing in subsequent posts

2002-06-12 Thread Slava Bizyayev
Title: Internet Explorer sending nothing in subsequent posts



Please, could you give us details about your MSIE: 
version, platform, User-Agent mask?
Thanks,
Slava


  - Original Message - 
  From: 
  Harnish, Joe 
  To: '[EMAIL PROTECTED]' 
  Sent: Wednesday, June 12, 2002 9:28 
  AM
  Subject: Internet Explorer sending 
  nothing in subsequent posts
  
  When Internet Explorer hits a mod_perl page that uses the post 
  method in the form it will run the first time but all the subsequent posts 
  will not get anything sent.
  Does anyone know why this happens? Is there a workaround 
  for mod_perl or in the Web browser? 
  Thanks 
  Joe 


Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Issac Goldstand

- Original Message -
From: John Siracusa [EMAIL PROTECTED]
To: Mod Perl Mailing List [EMAIL PROTECTED]
Sent: Wednesday, June 12, 2002 8:06 PM
Subject: Re: mod_perl/passing session information (MVC related, maybe...)


 On 6/12/02 12:57 PM, Per Einar Ellefsen wrote:
  But what if someone opens one of the links in a different window, and
  continue on the same pages as in the original window, but with different
  parameters? The session ID would be the same, the context id would be
the
  same, but the params would be different, right?

 Well, then things break I guess... :)  Maybe you could do some magic based
 on what browsers send as the referrer when users explicitly open a link in
a
 new tab or window?  Probably not worth it...

 -John

Wait a second!  But then what are you gaining out of your context ID?  If
you can't amke new contexts for new windows, when WILL you make contexts?
That's coming back to the original problem of session IDs, isn't it?
  Issac




Re: Apache Error Log

2002-06-12 Thread Randy Kobes

On Wed, 12 Jun 2002, Jaberwocky wrote:

 No, all I really want to do is print to STDERR

As Stas mentioned, it'd be helpful to see a short snippet to
illustrate your problem ... But the fact that you don't see the
messages in the logs until a server shutdown/restart suggests
some buffering going on ... Does the same problem occur if you
use $r-log-warn(This is a message)?

best regards,
randy kobes




Re: apache 2 mod_perl 2 Apache::DBI

2002-06-12 Thread Randy Kobes

On Sun, 9 Jun 2002, Yuri A. Kabaenkov wrote:

 Hello,
   How can i install Apache::DBI module with mod_perl 2?


I'm not sure what the current status of this is, but see
the discussion of Apache::DBIPool at
http://perl.apache.org/release/docs/2.0/user/overview/overview.html.

best regards,
randy kobes




RE: Internet Explorer sending nothing in subsequent posts

2002-06-12 Thread Harnish, Joe
Title: Internet Explorer sending nothing in subsequent posts



I am 
running IE 5.50.4807.2300 on Win2k, all defaults. 

  -Original Message-From: Slava Bizyayev 
  [mailto:[EMAIL PROTECTED]]Sent: Wednesday, June 12, 2002 2:06 
  PMTo: Harnish, Joe; [EMAIL PROTECTED]Subject: Re: 
  Internet Explorer sending nothing in subsequent posts
  Please, could you give us details about your 
  MSIE: version, platform, User-Agent mask?
  Thanks,
  Slava
  
  
- Original Message - 
From: 
Harnish, Joe 
To: '[EMAIL PROTECTED]' 
Sent: Wednesday, June 12, 2002 9:28 
AM
Subject: Internet Explorer sending 
nothing in subsequent posts

When Internet Explorer hits a mod_perl page that uses the 
post method in the form it will run the first time but all the subsequent 
posts will not get anything sent.
Does anyone know why this happens? Is there a 
workaround for mod_perl or in the Web browser? 
Thanks 
Joe 


Re: Mapping to location /

2002-06-12 Thread darren chamberlain

* md [EMAIL PROTECTED] [2002-06-12 13:15]:
 --- Per Einar Ellefsen [EMAIL PROTECTED] wrote:
  Can't you just drop the Location and use
  Files *.phtml
 SetHandler 
  /Files
  or something like that? Seems like it would avoid
  some overhead for you.
 
 True...but the files don't actually exist. The
 path/filename is used to map to a template.

You definitely want to do this in the translation phase; that's what
it's there for.  

  However, I'm not sure if I understand what you mean
  with
$uri =~ m!.*/[^\.]+$!) {
 
 This may not be the best regex..but what I was trying to do was to
 match something like /directory/subdirectory which would normally be
 redirected back to /directory/subdirectory/index.html (or whatever
 is set as DirectoryIndex files). I want to check for a
 /directory/subdirectory/index.phtml file.

If you use a translation handler, you can just return DECLINED for
everything you aren't specifically handling, and let mod_dir do it's
thing, instead of emulating it.

I think what you want is something like this:

  package Foo;  # or whatever

  use strict;
  use Apache::Constants qw(OK DECLINED);

  sub handler {
  my $r = shift;

  return DECLINED unless $r-uri =~ /\.phtml$/;

  # Figure out which template to use here
  my $template_name = get_template_name($r);
  $r-filename($template_name);

  return OK;
  }
  1;OK;

(darren)

-- 
Reisner's Rule of Conceptual Inertia:
If you think big enough, you'll never have to do it.



Re: separating C from V in MVC

2002-06-12 Thread Fran Fabrizio


Ok, thanks to you all and this great discussion I want to try to make 
our current project into an MVC-style app, so what now?  This MVC 
discussion could not have come at a better time - our little app is all 
grown up now and needs a real architecture.  I have read the MVC threads 
in depth now, and I have questions.  

WHERE WE ARE NOW
--  

We have a multiuser application that has about oh, I dunno, 100 
different screens to the interface.  They can be roughly divided into 
the following areas - status, admin, registration, reports, and graphs. 
 Most of the actions involve either retrieving data from a database or 
processing a form and inserting into a database (in other words, it's a 
very typical web application).  This application started as a CGI 
script.  For performance reasons, we installed mod_perl and use 
Apache::Registry to run it now.  It's pretty much still a dumb CGI 
script with a mod_perl wrapper, but I did develop a couple of modules to 
do user authentication with AuthCookie-based solutions and tied that 
into Apache::Session for state maintenance between requests.  The CGI 
script has grown to accomodate these ~ 100 actions and is now basically 
a 4,000 line if statement.  The script decides which request to do based 
on a target= parameter passed in (in other words, target=summary or 
target=doctoractivity, etc...).  For sanity's sake, many months ago, we 
switched to HTML::Template (our view) to define our screens, which has 
worked well to date.  On the back end we have PostgreSQL with a healthy 
sized schema of around 150 tables or so that has ~ 350 megs of data and 
on the order of 500,000 transactions a day (lots of data turnover, some 
tables get UPDATEd so frequently as to have 100% data turnover within 15 
minutes).  Anyways, back to the perl part

Basic code structure:

[snip]
my $dbh = DBI-connect( $r-dir_config('RMSDBI_DSN') , 
$r-dir_config('RMSDBI_user') , $r-dir_config('RMSDBI_password') );

# giant if statement - closest thing I have to a controller, I suppose
if ($target = 'summary') {
  my $tmpl = getTemplate('summary');
  doSummary($dbh,$tmpl);
  print header . $tmpl-output();
} elsif ($target = 'doctoractivity') {
  my $tmpl = getTemplate('doctoractivity');
  doDoctorActivity($dbh,$tmpl);
  print header . $tmpl-output();
} elsif ...

[snip]

# lots of subs basically one per target, closest thing I have to a 
model, I suppose
sub doSummary {
  ($dbh, $tmpl) = shift;
  $sth = $dbh-prepare(SQL STATEMENT HARD-CODED HERE);
  # process result set into hashes and arrays of hashes such as summary 
that HTML::Template wants
  [snip]
  $tmpl-param(summary = summary);
}

sub doDoctorActivity {
  ($dbh, $tmpl) = shift;
  $sth = $dbh-prepare(SQL STATEMENT HARD-CODED HERE);
  # process result set into hashes and arrays of hashes such as summary 
that HTML::Template wants
  [snip]
  $tmpl-param(summary = summary);
}

etc

This basic pattern repeated ad infinitum.  It's grown way out of 
control, is a pain to work with, and just feels wrong, very wrong. :-) 
 To be fair, it grew very fast and it was all we (by we I mean the two 
of us that were this entire dept. back then) could do to keep up with 
the feature requests, let alone worry about proper architecting of the 
software.  We're paying for it now, of course.

WHERE WE WANT TO BE
--

I would like to introduce some semblance of organisation, sanity, 
maintainability, separation of logic, etc to this project.  In other 
words, MVC would be a good fit.  

Some of the concrete, basic questions I have are:
1.  Is there one Controller or many?  Should I have one for each main 
area of my site?  /myapp/admin/ goes to an Admin Controller, 
/myapp/reports to another controller, etc...
2.  Does the first part of my code above even remotely resemble a 
Controller?  I mean, it takes the input, calls essentially a 'model' 
object (but passing it the view object, nice, eh? =), but then seems to 
break the model nicely by doing things like printing out the HTML from 
the Controller, etc...
3.  How do you prevent a Controller from just becoming another big if 
statement, or is this their purpose in life?
4.  In the case of a form, what perl structure is used to pass the data 
into the model?
5.  Do you create an actual class for each form?
6.  Do you need to create objects at all?  Is OO a prerequisite to MVC?
6.5.  (thought of while proofreading :-)  Is the statement there is one 
set of controllers for each defined view correct?  In other words, if 
we someday want to output the reports section of the site as Excel 
spreadsheets in addition to HTML, would we define a new set of 
controllers or how would that work?

Now onto the model, I think I have a little better grasp of the model 
compared to the controller, but I have questions...
7a.  Is it insane to leave my SQL hard-coded in there?  The queries 
don't change all that much, and it's nice to have the query in 

Re: Mapping to location /

2002-06-12 Thread md


--- darren chamberlain [EMAIL PROTECTED]
wrote:

 If you use a translation handler, you can just
 return DECLINED for
 everything you aren't specifically handling, and let
 mod_dir do it's
 thing, instead of emulating it.

I still would like to check first if there is an
index.phtml template instead of going directly to the
directory index files like index.html. Can I add my
virtual index.phtml to DirectoryIndex so I don't
have to look for it in my handler? I'm not quite clear
on this one...but it might be once I read the guide on
translation handlers :)
 
 I think what you want is something like this:

I'll try this...thanks.


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



RE: separating C from V in MVC

2002-06-12 Thread Jeff



 From: Fran Fabrizio [mailto:[EMAIL PROTECTED]] 
 Sent: 12 June 2002 21:48

Nothing indepth, just a quick response, but it looks like your huge if
statement can be replaced using a hash. Maybe something like:

# just an eg, this data is static and can be required from
# your startup.pl so that all child get a shared copy
%global::dispatch = (
  summary = { template = 'summary', actions = [ 'doSummary',
'doOther' ] },
  doctor  = { template = 'docact,   actions = [ 'healthyself', ] },
)

# In your generic Controller / Handler
if ( exists $global::dispatch{$template} ) {
  my $dispatch = $global::dispatch{$template};
  my $tmpl = getTemplate( $despatch-{template} );
  foreach my $function ( @{$dispatch-{actions} ) {
$function($dbh,$tmpl);
  }
  print header . %tmpl-output();
} else {
  unavailable();
}

The nice thing about this is you end up with a generic Controller, and
can separate the config off somewhere else. The Controller will probably
change much less than your config, so separation makes sense.

I don't really see an issue with the Controller being responsible for
returning the response, after all it fielded the request in the first
place. I would try hard to keep ALL HTML in the View world - whether you
create a View class or use a templating approach. 

0.02c

Regards
Jeff





Idiot question: headers at the base of the page.

2002-06-12 Thread Rafiq Ismail (ADMIN)

I'm doing squinty eyed coding and need someone to knock common sense into
me.  In the right order - as far as I can see - I have my content_type
;send_http_headers; $r-print'ed.  With loads of poo in between.  Under
what circumstances would my page render, dumping the HTTP headers at the
base?  Other than their being sequentially out of order, that is.

It's probably one of those look at it again in the morning questions.

Someone hit me over the head with a hammer please.







RE: separating C from V in MVC

2002-06-12 Thread Jim Martinez

On Jun 12  Jeff wrote:

 
 
  From: Fran Fabrizio [mailto:[EMAIL PROTECTED]] 
  Sent: 12 June 2002 21:48
 
 Nothing indepth, just a quick response ...

I too am using mod_perl just for Apache::Registry, and would also like to
look for alternatives.

Answers the questions posed by Fran would also help me and I bet other 
lurkers (L).  Even just 

Jim

JampL
aka
Japh wannabe





Re: Mapping to location /

2002-06-12 Thread Per Einar Ellefsen

At 23:06 12.06.2002, md wrote:

--- darren chamberlain [EMAIL PROTECTED]
wrote:

  If you use a translation handler, you can just
  return DECLINED for
  everything you aren't specifically handling, and let
  mod_dir do it's
  thing, instead of emulating it.

I still would like to check first if there is an
index.phtml template instead of going directly to the
directory index files like index.html. Can I add my
virtual index.phtml to DirectoryIndex so I don't
have to look for it in my handler? I'm not quite clear
on this one...but it might be once I read the guide on
translation handlers :)

I'm not quite sure about this, been wondering about it, but in theory you 
should be able to use
DirectoryIndex index.phtml
and like that you won't have to worry about / etc anymore.
Try it out..


-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: Apache Error Log

2002-06-12 Thread Doug MacEachern

On Wed, 12 Jun 2002, Jaberwocky wrote:
 
 No, all I really want to do is print to STDERR

you can use warn() instead which writes to stderr and always autoflushes.

or turn on autoflush of STDERR yourself, from perlfunc.pod:
$oldfh = select(STDERR); $| = 1; select($oldfh);

or update modperl-2.0 from cvs which turns on autoflush of STDERR by 
default.





Re: Internet Explorer sending nothing in subsequent posts

2002-06-12 Thread Slava Bizyayev
Title: Internet Explorer sending nothing in subsequent posts



Are you using content compression over the 
SSL?


  - Original Message - 
  From: 
  Harnish, Joe 
  To: 'Slava Bizyayev' ; [EMAIL PROTECTED] 
  Sent: Wednesday, June 12, 2002 2:42 
  PM
  Subject: RE: Internet Explorer sending 
  nothing in subsequent posts
  
  I am 
  running IE 5.50.4807.2300 on Win2k, all defaults. 
  
-Original Message-From: Slava Bizyayev 
[mailto:[EMAIL PROTECTED]]Sent: Wednesday, June 12, 2002 2:06 
PMTo: Harnish, Joe; [EMAIL PROTECTED]Subject: 
Re: Internet Explorer sending nothing in subsequent 
posts
Please, could you give us details about your 
MSIE: version, platform, User-Agent mask?
Thanks,
Slava


  - Original Message - 
  From: 
  Harnish, Joe 
  To: '[EMAIL PROTECTED]' 
  
  Sent: Wednesday, June 12, 2002 9:28 
  AM
  Subject: Internet Explorer sending 
  nothing in subsequent posts
  
  When Internet Explorer hits a mod_perl page that uses the 
  post method in the form it will run the first time but all the subsequent 
  posts will not get anything sent.
  Does anyone know why this happens? Is there a 
  workaround for mod_perl or in the Web browser? 
  Thanks 
  Joe 



Re: separating C from V in MVC

2002-06-12 Thread kyle dawkins


Fran (et al)

I've stayed out of the MVC chitchat for a long time (very interesting 
thread) because it's such a deep topic.  But seeing as how Fran has 
some concrete questions...

 3.  How do you prevent a Controller from just becoming another big if
 statement, or is this their purpose in life?

See Jeff's previous mail.  Your structure is crying out for a dispatch 
table; Jeff suggests building this out of a hash that defines what 
actions to perform based on what your query values are.  That's a great 
place to start.   GET RID OF YOUR BIG IF STATEMENT ASAP.

 6.  Do you need to create objects at all?  Is OO a prerequisite to
 MVC? 

No, but it makes it a lot easier in most cases.  Passing objects between 
the M, the C and the V is way easier than building crappy hashes by 
hand and calling a zillion param methods.

 7a.  Is it insane to leave my SQL hard-coded in there?  The queries
 don't change all that much, and it's nice to have the query in the
 same place as the processing of the result set so you can kind of
 see the structure of the result set better.  This helps our
 less-experienced developers.

OK, strong words here.  REMOVE YOUR SQL.  Move it into a layer that 
deals with the DB and vends consistently formed data (objects if you 
can manage it).Your controller shouldn't know anything about your 
DB, so create a class that essentially is every entry and exit point to 
and from your DB, and have that keep the database handle as a class 
variable.  What's easier for your newbie programmers... your code as it 
is now, or this:

sub doDoctorActivity {
  my $tmpl = shift;
  my results = DataStore::objectsForDoctorActivity();
  ViewManager::someMungingMethod($tmpl, \@results);
  return $tmpl;
}

Think of how clean your code is with no more $dbh references or ifs.  
Think how many fewer lines of code you will have to maintain.   Fewer 
lines is good.  Remember that.

It is a HUGE gain to isolate your DB entry points and place them in one 
carefully controlled class.

I am often amazed at how blind some developers can be about SQL.  Most 
of the people on this list realise that mixing HTML and perl is bad, 
and most of us can see why.  But I am constantly depressed that not 
nearly as many people appreciate that it is THE SAME FOR PERL AND SQL.  
SQL intermixed with Perl is just nasty and you need to move it into a 
limited space that you can easily control.  Obviously, it's necessary; 
you need your perl to talk to your DB.  But  it should be very very 
carefully managed and moved somewhere where its impact on the source is 
minimal. Right now I have the evil task of optimising a zillion lines 
of bad perl code written by a company I used to work for.  They have 
asked me to come back and save the project... and it's a frigging mess 
because of all the SQL.  THere are so few places where you can cache 
query results, for example, because there are pages and pages of crap 
like

$sql .=  AND some_other_stupid_table.id = 
another_dumbass_table.stupid_table_id;
if ($myAssIsBlue) {
 $sql .=  AND some_table.my_ass IN ('BLUE','BLUISH','CYAN');
}

ad nauseum.  What a load of utter shite.

 7d.  Or do I -really- want an object/structure that represents every
 result set we need to get back from the database?

If I were you I would create a parent class that represents a basic DB 
row and use that.  When you need custom behaviour, subclass it and 
bless the rows into the subclass.  Adding an Object Structure can be 
as simple as blessing your hashes that come back from the DB into a 
class, remember that.

 8a.  What structures are used to pass back the data from the model
 through the controller to the view?
 8b.  The view is expecting HTML::Template style hashes and arrays, do
 I form these in the model (which seems to be too much knowledge of
 the view while still in the model) or does the controller convert it
 to the structures expected by the HTML::Template view?
 8c.  The model is getting DBI record sets from the db.  I have to put
 this data into -something-, why not the exact format that
 HTML::Template view needs rather than process it twice?

Well, pretend you actually had objects coming back from your DB.  Surely 
your controller should pass those objects to your view as is...?  
That's the whole point.   Your view should be responsible for 
displaying them.  I have seen a lot of talk about HTML::Template being 
a View layer.  It's not.  It's the bottom of the View layer.  You 
need to write the top of the view layer yourself, that takes your data 
(objects, whatever) and vends it to HTML::Template in the right way.

Kyle Dawkins
Central Park Software




Re: tutorials (was: Re: rfc Apache::Dynagzip)

2002-06-12 Thread Slava Bizyayev


From: Stas Bekman [EMAIL PROTECTED]
Subject: Re: tutorials (was: Re: rfc Apache::Dynagzip)


 Probably the best post it here first, so we can get it reviewed and
 commented on before we add it to the docs.

Since now the draft tutorial Features of Content Compression for Different
Web Clients (for Part IV: Client side facts and bugs) is available for
preview and discussion at
http://devl4.outlook.net/devdoc/Dynagzip/ContentCompressionClients.html .

I strongly hope to make it much better with your help prior to submit for
publishing. Any comments will be highly appreciated.

Thanks in advance,
Slava





Re: tutorials (was: Re: rfc Apache::Dynagzip)

2002-06-12 Thread Per Einar Ellefsen

At 00:04 13.06.2002, Slava Bizyayev wrote:

From: Stas Bekman [EMAIL PROTECTED]
Subject: Re: tutorials (was: Re: rfc Apache::Dynagzip)


  Probably the best post it here first, so we can get it reviewed and
  commented on before we add it to the docs.

Since now the draft tutorial Features of Content Compression for Different
Web Clients (for Part IV: Client side facts and bugs) is available for
preview and discussion at
http://devl4.outlook.net/devdoc/Dynagzip/ContentCompressionClients.html .

I strongly hope to make it much better with your help prior to submit for
publishing. Any comments will be highly appreciated.

Looks great Slava! Seems to integrate the needed info. I guess those who 
know more about Gzip encoding can tell you more technically-wise, but as 
far as the general look it seems ok to me.


-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: Mapping to location /

2002-06-12 Thread darren chamberlain

* md [EMAIL PROTECTED] [2002-06-12 17:05]:
 --- darren chamberlain [EMAIL PROTECTED] wrote:
  If you use a translation handler, you can just return DECLINED for
  everything you aren't specifically handling, and let mod_dir do it's
  thing, instead of emulating it.
 
 I still would like to check first if there is an index.phtml template
 instead of going directly to the directory index files like
 index.html. Can I add my virtual index.phtml to DirectoryIndex so I
 don't have to look for it in my handler? I'm not quite clear on this
 one...but it might be once I read the guide on translation handlers :)

You can add something to the effect of:

  return DECLINED
if ($r-uri =~ /\.phtml$/ 
-e File::Spec-catfile($r-document_root, $r-uri));
  
in there.

(darren)

-- 
Any technology indistinguishable from magic is insufficiently advanced.



RE: Apache Error Log

2002-06-12 Thread Jim Morrison [Mailinglists]

Sorry.. Haven't read / Can't find the whole thread..  But...

Surely just:

print STDERR Hello World;


... I always just stick this in my code...

### DEBUGGER
sub debug{
  my $message = shift;
  if ($debug){
print STDERR $message\n;
  }
}

So my code is full of:

debug(Here is something going on);


Which works a treat...  Then just tail -f the error log and watch it
all happening (breaking!)

($debug is a global var, used to simply switch the error loggin on and
off..)

Is this what you're after?

Kindest,

J

-Original Message-
From: Doug MacEachern [mailto:[EMAIL PROTECTED]] 
Sent: 12 June 2002 22:12
To: Jaberwocky
Cc: Stas Bekman; [EMAIL PROTECTED]
Subject: Re: Apache Error Log


On Wed, 12 Jun 2002, Jaberwocky wrote:
 
 No, all I really want to do is print to STDERR

you can use warn() instead which writes to stderr and always
autoflushes.

or turn on autoflush of STDERR yourself, from perlfunc.pod:
$oldfh = select(STDERR); $| = 1; select($oldfh);

or update modperl-2.0 from cvs which turns on autoflush of STDERR by 
default.




Using Active Directory and mod_perl

2002-06-12 Thread John Whitnack

Is there a way to access Active Directory with mod_perl ?

John Whitnack



Re: SEGV in bleadperl@17165 under mod_perl

2002-06-12 Thread Andreas J. Koenig

 On Wed, 12 Jun 2002 17:18:53 +0100, Nick Ing-Simmons 
[EMAIL PROTECTED] said:

   Is this apache running multi-threaded? or just serially ?

So far only tested with -Dusemultiplicity -Duseperlio.

   IIRC the back trace the SEGV was in stdio rather than in perl itself,
   suggesting that something else (the child?, another thread?) had done
   something nasty to the FILE *.

Currently I have a testcase that is still 7300 lines of perl code for
the server (after all these are in one file) but only 50 lines for the
client. I hope to cut that down to a reasonable size tomorrow.

   Does it work with PERLIO=perlio or  Configure -Ud_stdstdio ? 

Neither nor.

-- 
andreas



PerlTransHandler problem

2002-06-12 Thread Rasoul Hajikhani

Hello folks,
I am trying to implement a simple PerlTransHandler to change:

http://myserver/

to 

http://myserver.rhythm.com/

And here is my code:

package MIS::GENERAL::FixURL;

use Apache::Constants qw(DECLINED);

use strict;

sub handler
{
my $r   = shift;
my $uri = $r-uri;

return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)

$uri=~ s/^(.+)/$1\.rhythm\.com/;
$r-uri($uri);

return DECLINED;
}

1;

Here is my https.conf entry:
PerlTransHandler MIS::GENERAL::FixURL

And here is my error when I type: s7.rhythm.com

Invalid URI in request GET / HTTP/1.0

But I get no error with: http://s7/

Can some one tell me what am I doing wrong?

Thanks in advance
-r



Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks



Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
 Hello folks,
 I am trying to implement a simple PerlTransHandler to change:
 
 http://myserver/
 
 to 
 
 http://myserver.rhythm.com/
 
 And here is my code:
 
 package MIS::GENERAL::FixURL;
 
 use Apache::Constants qw(DECLINED);
 
 use strict;
 
 sub handler
 {
 my $r   = shift;
 my $uri = $r-uri;
 
 return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)

IIRC, the $r-uri method is normally not going yield the hostname or 
scheme (unless this is a proxy request).

So for a request to http://www.rhythm.com/test/myfile.html 

$r-uri is going to return only

/test/myfile.html


You may want to do some logging to verify.

Add  

use Apache::Log ();

then inside your handler...

my $log = $r-server-log;

$log-debug(Processing request  . $r-uri);


Hope that helps.

 
 $uri=~ s/^(.+)/$1\.rhythm\.com/;
 $r-uri($uri);
 
 return DECLINED;
 }
 
 1;
 
 Here is my https.conf entry:
 PerlTransHandler MIS::GENERAL::FixURL
 
 And here is my error when I type: s7.rhythm.com
 
 Invalid URI in request GET / HTTP/1.0
 
 But I get no error with: http://s7/
 
 Can some one tell me what am I doing wrong?
 
 Thanks in advance
 -r



Re: tutorials (was: Re: rfc Apache::Dynagzip)

2002-06-12 Thread Slava Bizyayev

Sorry folks,

I experience some access problems with devl4. Server is down temporarily.
I'll let you know when ready to continue.

Slava

- Original Message -
From: Slava Bizyayev [EMAIL PROTECTED]
To: Stas Bekman [EMAIL PROTECTED]; modperl list [EMAIL PROTECTED]
Sent: Wednesday, June 12, 2002 5:04 PM
Subject: Re: tutorials (was: Re: rfc Apache::Dynagzip)



 From: Stas Bekman [EMAIL PROTECTED]
 Subject: Re: tutorials (was: Re: rfc Apache::Dynagzip)


  Probably the best post it here first, so we can get it reviewed and
  commented on before we add it to the docs.

 Since now the draft tutorial Features of Content Compression for
Different
 Web Clients (for Part IV: Client side facts and bugs) is available for
 preview and discussion at
 http://devl4.outlook.net/devdoc/Dynagzip/ContentCompressionClients.html .

 I strongly hope to make it much better with your help prior to submit for
 publishing. Any comments will be highly appreciated.

 Thanks in advance,
 Slava







Re: PerlTransHandler problem

2002-06-12 Thread Randal L. Schwartz

 Rasoul == Rasoul Hajikhani [EMAIL PROTECTED] writes:

Rasoul I am trying to implement a simple PerlTransHandler to change:

Rasoul http://myserver/

Rasoul to 

Rasoul http://myserver.rhythm.com/

Both of those are / as far as as $r-uri is concerned.

What are you *really* trying to do?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler problem

2002-06-12 Thread Rasoul Hajikhani

I am realy trying to make sure that all requests for 
http://myserver/
are treated as
http://myserver.rhythm.com/
so that my other applications that depend on reading cookies down the
request chain could actually do so...
-r

Randal L. Schwartz wrote:
 
  Rasoul == Rasoul Hajikhani [EMAIL PROTECTED] writes:
 
 Rasoul I am trying to implement a simple PerlTransHandler to change:
 
 Rasoul http://myserver/
 
 Rasoul to
 
 Rasoul http://myserver.rhythm.com/
 
 Both of those are / as far as as $r-uri is concerned.
 
 What are you *really* trying to do?
 
 --
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
 See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler problem

2002-06-12 Thread Rasoul Hajikhani

A funny thing is happening with my PerlTransHandler...
It is not being called at all... :(
I have added warn messages but they never appear in the error log.
I am at a loss and hoping that some one may have an answer...
-r

Lyle Brooks wrote:
 
 Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
  Hello folks,
  I am trying to implement a simple PerlTransHandler to change:
 
  http://myserver/
 
  to
 
  http://myserver.rhythm.com/
 
  And here is my code:
 
  package MIS::GENERAL::FixURL;
 
  use Apache::Constants qw(DECLINED);
 
  use strict;
 
  sub handler
  {
  my $r   = shift;
  my $uri = $r-uri;
 
  return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)
 
 IIRC, the $r-uri method is normally not going yield the hostname or
 scheme (unless this is a proxy request).
 
 So for a request to http://www.rhythm.com/test/myfile.html
 
 $r-uri is going to return only
 
 /test/myfile.html
 
 You may want to do some logging to verify.
 
 Add
 
 use Apache::Log ();
 
 then inside your handler...
 
 my $log = $r-server-log;
 
 $log-debug(Processing request  . $r-uri);
 
 Hope that helps.
 
 
  $uri=~ s/^(.+)/$1\.rhythm\.com/;
  $r-uri($uri);
 
  return DECLINED;
  }
 
  1;
 
  Here is my https.conf entry:
  PerlTransHandler MIS::GENERAL::FixURL
 
  And here is my error when I type: s7.rhythm.com
 
  Invalid URI in request GET / HTTP/1.0
 
  But I get no error with: http://s7/
 
  Can some one tell me what am I doing wrong?
 
  Thanks in advance
  -r



Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks

You are only going to have Transhandlers defined in the main server or
virtual host, not in any Location or Directory containers.

Check and see if you have any other Transhandlers defined earlier in
your httpd.conf file.   If an earlier Transhandler returns OK, then
later ones won't be called.

Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
 A funny thing is happening with my PerlTransHandler...
 It is not being called at all... :(
 I have added warn messages but they never appear in the error log.
 I am at a loss and hoping that some one may have an answer...
 -r
 
 Lyle Brooks wrote:
  
  Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
   Hello folks,
   I am trying to implement a simple PerlTransHandler to change:
  
   http://myserver/
  
   to
  
   http://myserver.rhythm.com/
  
   And here is my code:
  
   package MIS::GENERAL::FixURL;
  
   use Apache::Constants qw(DECLINED);
  
   use strict;
  
   sub handler
   {
   my $r   = shift;
   my $uri = $r-uri;
  
   return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)
  
  IIRC, the $r-uri method is normally not going yield the hostname or
  scheme (unless this is a proxy request).
  
  So for a request to http://www.rhythm.com/test/myfile.html
  
  $r-uri is going to return only
  
  /test/myfile.html
  
  You may want to do some logging to verify.
  
  Add
  
  use Apache::Log ();
  
  then inside your handler...
  
  my $log = $r-server-log;
  
  $log-debug(Processing request  . $r-uri);
  
  Hope that helps.
  
  
   $uri=~ s/^(.+)/$1\.rhythm\.com/;
   $r-uri($uri);
  
   return DECLINED;
   }
  
   1;
  
   Here is my https.conf entry:
   PerlTransHandler MIS::GENERAL::FixURL
  
   And here is my error when I type: s7.rhythm.com
  
   Invalid URI in request GET / HTTP/1.0
  
   But I get no error with: http://s7/
  
   Can some one tell me what am I doing wrong?
  
   Thanks in advance
   -r



.htaccess errors

2002-06-12 Thread Darren Ward

Hi All

I'm having trouble with an Apache+modssl+mod_perl installation.

Mod_perl itself is working great as I can access the /perl-status location
and read of the modules/memory use etc but after setting up a subdirectory
to use Apache::AuthenDBI I successfully received the login window on the
subdirectory but I decided to cancel as the password seemed to be incorrect
in te SQL database.

As soon as I did that I got the 403 forbidden as I knew I would howeveer now
all I get is the 403 screen and the logs are complaining that I do not have
a .htaccess file in the docroot or that it's unreadable!

This has got me stumped as I never put a .htaccess file in there but for the
sake of trying to fix it I did place one there but it's still complaining
that one doesn't exist even though it's set readable etc etc

Any help or thoughts?

Darren

TRACE:

[Thu Jun 13 07:56:05 2002] [crit] [client 203.45.30.4] (13)Permission
denied: /usr/local/www/data/.htaccess pcfg_openfile: unable to check
htaccess file, ensure it is readable

-rw-r--r--  1 www  www  599 Jun 11 17:57 /usr/local/www/data/.htaccess

^^
Of course these permissions are only for testing.




Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks

Sounds like it's more of a DNS issue than a modperl issue.

Depending on what your motivation for requiring the full name, you
may also explicitly set

ServerName  myserver.rhythm.com
UseCanonicalName off
 
Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
 I am realy trying to make sure that all requests for 
 http://myserver/
 are treated as
 http://myserver.rhythm.com/
 so that my other applications that depend on reading cookies down the
 request chain could actually do so...
 -r
 
 Randal L. Schwartz wrote:
  
   Rasoul == Rasoul Hajikhani [EMAIL PROTECTED] writes:
  
  Rasoul I am trying to implement a simple PerlTransHandler to change:
  
  Rasoul http://myserver/
  
  Rasoul to
  
  Rasoul http://myserver.rhythm.com/
  
  Both of those are / as far as as $r-uri is concerned.
  
  What are you *really* trying to do?
  
  --
  Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
  [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
  Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
  See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



[OT] Q:MVC and FuseBox methodology A?

2002-06-12 Thread Jim Helm


Does anyone know how MVC maps to the fusebox methodology?  I haven't
used it under PHP, but the adaptation to ASP applies almost directly to
Apache::ASP, and at least seems like it's well thought out and
practical.  Maybe it's really just the Controller aspect of MVC.  I'm
still trying to wrap my head around this too.

Wonderful knowledge transfer going on, BTW!

--Jim





Re: PerlTransHandler problem

2002-06-12 Thread Lyle Brooks

Quoting Lyle Brooks ([EMAIL PROTECTED]):
 Sounds like it's more of a DNS issue than a modperl issue.
 
 Depending on what your motivation for requiring the full name, you
 may also explicitly set
 
 ServerName  myserver.rhythm.com
 UseCanonicalName off

errr... should be

UseCanonicalName On


  
 Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
  I am realy trying to make sure that all requests for 
  http://myserver/
  are treated as
  http://myserver.rhythm.com/
  so that my other applications that depend on reading cookies down the
  request chain could actually do so...
  -r
  
  Randal L. Schwartz wrote:
   
Rasoul == Rasoul Hajikhani [EMAIL PROTECTED] writes:
   
   Rasoul I am trying to implement a simple PerlTransHandler to change:
   
   Rasoul http://myserver/
   
   Rasoul to
   
   Rasoul http://myserver.rhythm.com/
   
   Both of those are / as far as as $r-uri is concerned.
   
   What are you *really* trying to do?
   
   --
   Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
   [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
   Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
   See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: PerlTransHandler problem

2002-06-12 Thread simran

What it sounds like you want is: 

PerlTransHandler Whatever::CheckName

and in CheckName.pm

sub handler {
  my $r = instance Apache::Request(shift);

  if ($r-hostname !~ /rhythm\.com/) {
$r-header_out(Location = http://myserver.rhythm.com.$r-uri);
return REDIRECT;
  }
  else {
redirect DECLINED;
  }
}

---

A redirect rule (using the Rewrite Engine) would probably be easier and
better yet. 

simran.



   Quoting Rasoul Hajikhani ([EMAIL PROTECTED]):
Hello folks,
I am trying to implement a simple PerlTransHandler to change:
   
http://myserver/
   
to
   
http://myserver.rhythm.com/
   
And here is my code:
   
package MIS::GENERAL::FixURL;
   
use Apache::Constants qw(DECLINED);
   
use strict;
   
sub handler
{
my $r   = shift;
my $uri = $r-uri;
   
return DECLINED if ($uri =~ m/^.+\.rhythm\.com$/)
   
   IIRC, the $r-uri method is normally not going yield the hostname or
   scheme (unless this is a proxy request).
   
   So for a request to http://www.rhythm.com/test/myfile.html
   
   $r-uri is going to return only
   
   /test/myfile.html
   
   You may want to do some logging to verify.
   
   Add
   
   use Apache::Log ();
   
   then inside your handler...
   
   my $log = $r-server-log;
   
   $log-debug(Processing request  . $r-uri);
   
   Hope that helps.
   
   
$uri=~ s/^(.+)/$1\.rhythm\.com/;
$r-uri($uri);
   
return DECLINED;
}
   
1;
   
Here is my https.conf entry:
PerlTransHandler MIS::GENERAL::FixURL
   
And here is my error when I type: s7.rhythm.com
   
Invalid URI in request GET / HTTP/1.0
   
But I get no error with: http://s7/
   
Can some one tell me what am I doing wrong?
   
Thanks in advance
-r
 
 




Re: separating C from V in MVC

2002-06-12 Thread Perrin Harkins

Wow, this is a long one.  As usual, everyone has slightly different
ideas about how to do MVC, so keep a grain of salt handy.

 This basic pattern repeated ad infinitum.  It's grown way out of
 control, is a pain to work with, and just feels wrong, very wrong. :-)

We've all been there.

 1.  Is there one Controller or many?

Usually there are many.

 Should I have one for each main
 area of my site?  /myapp/admin/ goes to an Admin Controller,
 /myapp/reports to another controller, etc...

That's how I would do it.  The idea is to group the things that are
related together, since they tend to change at the same time.

 2.  Does the first part of my code above even remotely resemble a
 Controller?

Sort of.  It does choose a view and it does parse some user input, but a
controller is more than just a dispatcher.  It would include some of the
code that you're currently putting into your doDoctorActivity() sub.
The idea is that the model objects represent just the data in your
application (the nouns) and the controller understands how to translate
user input into a series of method calls on the model objects to carry
out the user's request.

It's hard to give a good example that is short, but let's say you were
building an application to sell concert tickets.  The act of buying the
ticket might involve model objects representing a concert, a user, a
form of payment, etc.  The concert object knows how to reserve a
specific seat (or call a seat object to do that).  The payment object
knows how to verify and charge a credit card.  The user object has a
mailing address.  The controller knows how to turn the user's form data
into a bunch of method calls on these objects that accomplish reserving
the ticket and charging the user.  If you find yourself writing a
BuyTicket module, that's a controller not a model object.

 3.  How do you prevent a Controller from just becoming another big if
 statement, or is this their purpose in life?

If you break up your app into multiple controllers, there will probably
only be a few different actions that each one handles.  That's a pretty
small if statement, or you could use a dispatch table.  Modules like
CGI::Application have already written the dispatch table code for you,
so you just provide the configuration that maps actions to subroutines.

 4.  In the case of a form, what perl structure is used to pass the
data
 into the model?

You don't pass a form directly to a model object.  You parse the form,
then you use the API provided by the model object.  Remember, we want to
be able to use these same model objects from a cron job.

my $hospital = $apr-param('hospital');
$doctor-set_hospital($hospital);

 5.  Do you create an actual class for each form?

Similar to #1, each form might have it's own controller class, or you
might group some related forms (that act on the same data) together in a
single controller.

 6.  Do you need to create objects at all?  Is OO a prerequisite to
MVC?

Modelling your data as objects is sort of an underlying assumption in
MVC.  You could do a clean design without using OO, but it would be a
little odd and the model objects might not be very reusable.

 6.5.  (thought of while proofreading :-)  Is the statement there is
one
 set of controllers for each defined view correct?

No.

 In other words, if
 we someday want to output the reports section of the site as Excel
 spreadsheets in addition to HTML, would we define a new set of
 controllers or how would that work?

You would make your existing controllers understand the piece of user
input or context that means they want Excel format, and have them pass
the model data to a different view in that case.

 7a.  Is it insane to leave my SQL hard-coded in there?

You're going to have SQL somewhere, but if you wrap it up into objects
that represent your data, it's easier to maintain.  It hides all of that
specific database knowledge from the rest of the application and avoids
repitition.

At eToys we had a tremendous amount of data associated with each
product.  It spanned many tables and was not very easy to work with.
However, once I had written an object representing a product, the search
code, shopping cart code, product page code, etc. could all use it.
When we added new properties, I only had to do it one place.

OO modelling is a big subject and lots of good books have been written
on it, so I won't say more about it here.

 7b.  Should I really investigate real object persistence like
discussed
 at the POOP site (I have used Tangram with some success on tiny side
 projects but nothing remotely this size)?

Only if you like what it does for you.  I generally prefer to write the
SQL myself because of the tuning opportunities it affords, but this is
the sort of topic that many people have strong opinions on.  Anyway,
objects that contain hand-coded SQL are just as real as objects that use
a POOP module to generate the SQL for them.

 Begging the question, should
 I really be migrating to 

Re: .htaccess errors

2002-06-12 Thread Brian Reichert

On Thu, Jun 13, 2002 at 10:39:28AM +1000, Darren Ward wrote:
 This has got me stumped as I never put a .htaccess file in there but for the
 sake of trying to fix it I did place one there but it's still complaining
 that one doesn't exist even though it's set readable etc etc
 
 Any help or thoughts?

Is the directory that .htaccess file is in readable and executable
by the web server?

 
 Darren
 
 TRACE:
 
 [Thu Jun 13 07:56:05 2002] [crit] [client 203.45.30.4] (13)Permission
 denied: /usr/local/www/data/.htaccess pcfg_openfile: unable to check
 htaccess file, ensure it is readable
 
 -rw-r--r--  1 www  www  599 Jun 11 17:57 /usr/local/www/data/.htaccess
 
 ^^

In this case what does 'ls -ld /usr/local/www/data' show?

-- 
Brian 'you Bastard' Reichert[EMAIL PROTECTED]
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA Intel architecture: the left-hand path



Fooey. Can't compile mod_perl.

2002-06-12 Thread southernstar

Hi,

I can't compile mod_perl 1.27 on Cygwin with apache 1.3.24-5 src no matter what 
I do. At first it complained (make complained) that it didn't know how to make 
httpd.h etc, so I made them dummy targets with .PHONEY. OK, fine. Then it 
couldn't find them in apache_inc.h - so I put the path in for it. Now in os.h 
(from apache) it can't find ap_config.h, whatever that is.

Has mod_perl EVER compiled on Cygwin? If so, how do I get it to build? (I have 
the latest net release of cygwin, everything installed).

I really want mod_perl!!! *temper tantrum*

Thanks! :-)

James





Re: mod_perl/passing session information (MVC related, maybe...)

2002-06-12 Thread Rob Nagler

Perrin Harkins writes:
 I find you can tie this cache stuff up inside of your data access 
 objects and make it all transparent to the other code.

Absolutely.

 A session is useful for very limited things, like remembering if this 
 user is logged in and linking him to a user_id.

We store this information in the cookie.  I don't see how it could be
otherwise.  It's the browser that maintains the login state.

Consider the following scenario:

* User logs in.
* Site Admin decides to delete the user.
* In our stateless servers, the user_id is invalidated immediately.
* Next request from User, he's implicitly logged out, because the user_id
  is verified on every request.

In the case of a session-based server, you have to delete the user and
invalidate any sessions which the user owns.

 Although Oracle can be fast, some data models and application 
 requirements make it hard to do live queries every time and still have 
 decent performance.  This is especially true as traffic starts to
 climb.

I've tried to put numbers on some of this.  I've never worked on a
1M/day site, so I don't know if this is the point where you need
sessions.  What sites other than etoys needs this type of session
caching?

Rob