Re: Formatted Printing

2002-02-26 Thread Paul Lindner

On Tue, Feb 26, 2002 at 07:12:55PM -0800, Rasoul Hajikhani wrote:
> Hello folks,
> I have just writen an online ordering system for our company using
> mod_perl. The user must also be able to print the form, preserving the
> format. Since we use netscape (4.5) for Irix 6.5, I can't use the print
> button of the browser, the format is not preserved. Any one know of any
> modules/suggestions on this?

One simple thing is to create a PDF file for the printable format.
Make sure you save it in ascii format, and put simple substitution
strings for each field.  Then just search, replace, and output to the
browser.

There are also PDF modules on CPAN if you're not into templates...

If fancy printing is not your thing, or you want full cross-platform
compatibility consider text/plain output..  You can even send that to
that 20 year old daisy wheel printer..

-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org/
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Formatted Printing

2002-02-26 Thread Rasoul Hajikhani

Hello folks,
I have just writen an online ordering system for our company using
mod_perl. The user must also be able to print the form, preserving the
format. Since we use netscape (4.5) for Irix 6.5, I can't use the print
button of the browser, the format is not preserved. Any one know of any
modules/suggestions on this?
Thanks in advance
-r



Re: Can't retrieve form params using post methods, $r->notes and Apache::Request

2002-02-26 Thread Perrin Harkins

Mat wrote:
> Hi all,
>I have the following configuration.
> 
>   SetHandler perl-script
>   PerlAccessHandler MyCheck
>   PerlHandler MyHomePage
> 
> 
> The PerlAccessHandler checks if the user cookie is valid and set a $r->notes()
> entry to pass the user id to the MyHomePage handler which do his work. In the
> MyHomePage hanlder i'm using Apache::Request (my $apr = new
> Apache::Request($r); ) to get the parameters of the form from which i'm
> calling
> the handler.
> 
> If i put the form method in POST, I can't get any parameters, the form is
> reloaded, but if i put the method to GET then everything is fine.
> 
> If I use the following configuration
> 
>   SetHandler perl-script
>   PerlHandler MyHomePage
> 
> and use either the POST or GET for the form everything is fine.
> 
> If I put a PerlAccessHandler not using the $r->notes() method then everything
> is fine.
> 
> So my problem must come from the $r->notes(). Apparently it messes up with the
> POST parameters.

That seems pretty unlikely.  Are you sure you're not trying to read the 
POST content twice?  Maybe you're using a module that reads it?

- Perrin




Re: how to pass data in internal redirects?

2002-02-26 Thread Joachim Zobel

At 16:06 26.02.02 +0100, you wrote:
>So, a controller could in principle perform a call to a template engine
>as yours does, conceptually there is no need to do that internal
>redirect.  In fact, there is no need to have two different files if I
>take the pattern a bit further.  For instance, I believe a page written
>in Embperl or PHP could begin with the controller code and once finished
>the view code could follow, that would be MVC too in my opinion.

Ahem. No. If you do not separate, you do not separate. If you do not have 
separate files, you can not use the same view with different controllers.

I am even using external redirects. This gives more stability against users 
pressing reload - they are only reloading views.

See http://www.catstep.de/zobel/post2redirect.html for details.

Joachim


--
"... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet werden
koennen."- Bertolt Brecht - Leben des Galilei




ANNOUNCE: Apache-AuthenNTLM 0.14

2002-02-26 Thread Gerald Richter

The URL

ftp://ftp.dev.ecos.de/pub/perl/ntlm/Apache-AuthenNTLM-0.14.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/G/GR/GRICHTER/Apache-AuthenNTLM-0.14.tar.gz
  size: 45446 bytes
   md5: 704a1c161d2a308c74b1397e5bca5a1f

The purpose of this module is to perform a user authentication via
Mircosofts NTLM protocol. This protocol is supported by all 
versions of the Internet Explorer and is mainly usefull for intranets. 
Depending on your preferences setting IE will supply your windows 
logon credentials to the web server when the server asks for NTLM 
authentication. This saves the user to type in his/her password again.

A lot of ideas and information are taken from the similar Apache module
mod_ntlm, which can be found at http://sourceforge.net/projects/modntlm/

The main advantage of the Perl implementaion is, that it can be easily
extented to verfiy the user/password against other sources than a 
windows domain controller. The default implementaion is to go to 
the domain controller for the given domain and verify the user. If 
you want to verify the user against another source, you can inherit 
from Apache::AuthenNTLM and override it's methods.

To support users that aren't using Internet Explorer, Apache::AuthenNTLM 
can also perform basic authentication depending on it's configuration.

Enjoy

Gerald

Changes since 0.11:

 0.14  26. Feb 2002

   - fixed a problem that page content of Perl sometimes goes to the
 stderr instead of stdout

 0.13  9. Jan 2002

- return mapped username, when second request on same connection, 
  instead of unmapped

 0.12  8. Jan 2002 

- fix broken Authen::Smb::authen function in Authen::Smb 0.92 that
  ships with Apache::AuthenNTLM

 0.11  8. Jan 2002

- Initial public release



-
Gerald Richterecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:   Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925131
WWW:http://www.ecos.de  Fax:  +49 6133 925152
-






RE: Deleting a PerlSetVar variable

2002-02-26 Thread Stathy G. Touloumis

See chapter 8 of the Eagle book (Apache Modules in Perl/C) for complete
coverage of hooking into the apache configuration.  It really allows you to
do some pretty nifty stuff and would easily allow you to perform what you
want.  At first it seems overkill to know but once you do it opens many
doors for configuring and maintaining your apps IMHO.

There will be some code changes for accessing your configuration directives
but not anything more complex than accessing via PerlSetVar.

> What you have suggested can solve the problem... i'm however, preferably
> looking at deleting a set var via my apache config file, and don't have
> a '$r' /request_object available there.
>
> Doug et al, can i please suggest the addition of a:
>
>   * PerlDelVar or PerlUnsetVar
>
> to delete/unset a variable in the apache config file.
> I would make the changes and send in a patch, but i don't under the code
> (with my limited knowledge of C) well enough to do that.
>
> cheers,
>
> simran.
>
>
> On Tue, 2002-02-26 at 00:03, Geoffrey Young wrote:
> > simran wrote:
> > >
> > > Hi All,
> > >
> > > I could not find references on how to delete a varaible once set via
> > > PerlSetVar.
> > >
> > > I am setting a global 'PerlSetVar AuthNameExpires +24h' variable in my
> > > httpd.conf and want to be able to set it back to "expire at end of
> > > session" for some virtual hosts.
> > >
> > > If i could delete that variable, i could achieve that as per the spec,
> > > if the browser is not given a expiry time, the cookies lasts only for
> > > the session, however i so far have not been able to figure out how to
> > > delete a variable once set - anyone... ???
> > >
> >
> > you can use the Apache::Table interface for deleting (or setting or
> > manipulating) PerlSetVar
> >
> > $r->dir_config->unset('AuthNameExpires');
> >
> > see the latter part of recipe 3.14 in the cookbook for some additional
> > details on using the Apache::Table interface for dir_config, as well
> > as the Apache::Table manpage...
> >
> > HTH
> >
> > --Geoff
> >
>




Re: how to pass data in internal redirects?

2002-02-26 Thread Perrin Harkins

F. Xavier Noria wrote:
> For example, in the
> hangman game in O'Reilly's book a controller would load a session from
> the cookie, process user's guest, modify the state and redirect the
> request internally to the view.

It would probably be orders of magnitude faster to just call a template 
engine from your controller to render the view.

- Perrin




Re: How to get a remote user from the mod_perl + SSL?

2002-02-26 Thread Geoffrey Young

"Wong, Connie" wrote:
> 
> Hello,
> 
> I'm running mod_perl with Apache-SSL on Solaris 8.
> I setup a self-certificate for the basic authentication.
> I want to get the login name from the client (REMOTE_USER).
> In CGI, there is an environment variable $ENV{REMOTE_USER} that I can use.
> In mod_perl with SSL, how do I get the remote user after the user was
> validated?
> Can someone provide an example how to get it?

you can use that same environment variable under Apache::Registry...
just put

PerlSetupEnv On

in your httpd.conf, such as


  SetHandler perl-script
  PerlHandler Apache::Registry
  PerlSetupEnv On
  ...


if you mean by using the mod_perl API you can use 

my $remote_user = $r->user;

I'm fairly certain that the steps are the same, regardless of your SSL
settings.

HTH

--Geoff



Re: Calling an Apache::ASP page from an Apache::Registry script

2002-02-26 Thread Perrin Harkins

Andrew Ho wrote:
> I've been investigating other template systems to try to find similar
> functionality in an existing package for a non-Tellme related project and
> haven't been able to find any embedded-Perl solutions that can be called
> from a .pl and still have the benefits of template caching.

Apache::ASP doesn't seem like the best fit for this, if you really don't 
want to use pages as controllers.  You can use Text::Template (just keep 
a cache of the templates in a global hash) or Template Toolkit for this 
(yes, it does allow in-line Perl).  It also may be possible to do this 
with Mason.

- Perrin




Re: how to pass data in internal redirects?

2002-02-26 Thread F . Xavier Noria

On Tue, 26 Feb 2002 08:32:37 -0500
"Henigan, Timothy" <[EMAIL PROTECTED]> wrote:

: I don't know if this is the best design, but it works for this application.
: If you made it this far into the email, you might be interested in some
: sample code...let me know.  If you have comments, please speak up.  I'm the
: only developer on the project, so if I've gone off the deep end, I might not
: notice.

Yeah, I am surely biased because in my company everything is done with
Java where servlets act as controllers and forward requests to JSPs. 
Here people basicaly put data in the session object, for instance a User
associated with the session. You have static data shared by everybody...
it's a bit different as you probably know [*].

But I want to learn the multi-processes way of program with Apache and
his related technologies.  I believe, for instance, the Java people here
at work do not completly realize they use the session object both to
store state _and_ as a cache mechanism sometimes.  You are not aware of
what you are taking for granted until you play with other techniques.

So, a controller could in principle perform a call to a template engine
as yours does, conceptually there is no need to do that internal
redirect.  In fact, there is no need to have two different files if I
take the pattern a bit further.  For instance, I believe a page written
in Embperl or PHP could begin with the controller code and once finished
the view code could follow, that would be MVC too in my opinion.

Well, just sharing thoughts.

-- fxn

[*] If needed, load balancing is done taking sessions into account.



Re: [QUESTION][BUG] apache dies with SIGSEGV

2002-02-26 Thread Mark P. Fister

On Tue, Feb 26, 2002 at 11:36:39AM +0100, gaston wrote:
> Hi list
> 
> I wrote a small perl module using perl/Expat for parsing XML-files. 
> With apache 1.3.19 and perl 5.6.0 and Expat 2.27 it works fine. 
> In my new configuration (apache 1.3.20, perl 5.6.1 and Expat 2.30) 
> apache dies with an SIGSEGV on loading.
> 
> The error occured during the function call ParseStream() in Expat.pm.
> When i checked the core file with gdb i get this:

Scope this:

http://groups.yahoo.com/group/modperl/message/39557

So try switching to Apache 1.3.23 (the latest)?

Hope this helps! :)

-- 
\_/} Mark P. Fister Java, Java, everywhere, and all\_/}
\_/} eBay, Inc. the cups did shrink; Java, Java\_/}
\_/} Austin, TX everywhere, nor any drop to drink! \_/}



How to get a remote user from the mod_perl + SSL?

2002-02-26 Thread Wong, Connie

Hello,

I'm running mod_perl with Apache-SSL on Solaris 8. 
I setup a self-certificate for the basic authentication.
I want to get the login name from the client (REMOTE_USER). 
In CGI, there is an environment variable $ENV{REMOTE_USER} that I can use.
In mod_perl with SSL, how do I get the remote user after the user was
validated?
Can someone provide an example how to get it?

Thanks in advance,
Connie





Re: how to pass data in internal redirects?

2002-02-26 Thread Jon Robison

$r->pnotes persist across internal_redirects, I believe.

--Jon Robison

Igor Sysoev wrote:
> 
> On Tue, 26 Feb 2002, F. Xavier Noria wrote:
> 
> > I suppose that controllers would use internal redirects to call the
> > views, is there a way to pass Perl data this way?  For example, in the
> > hangman game in O'Reilly's book a controller would load a session from
> > the cookie, process user's guest, modify the state and redirect the
> > request internally to the view.  Ideally the view shouldn't read the
> > data to display from the database again... could it be passed somehow by
> > the first content handler?
> 
> As far as I know r->notes() do not persist across internal redirections.
> You can try r->err_header_out() but clean up it in second handler
> before content output.
> 
> Igor Sysoev



Re: Apache::Session

2002-02-26 Thread Jon Robison

As an add-on to this, does anyone know if one could use MySQL HEAP
(memory resident) tables for the session table?

--Jon Robison

Rob Bloodgood wrote:
> 
> > I am using Apache::Session with Postgresql. Unfortunately I had
> > never worked with a huge amount of data before I started to program
> > something like a (little) web application. I happily packed
> > everything in the "session"(s-table) that might be of any use. It
> > hit me hard that it takes a veeey long time to get all the stuff
> > out of the "session"(s-table) each time the client sends another
> > request.
> 
> Sorry if this is obvious, but
> do you have an index on your sessions table, on the sessionid column?
> Because, without an index, PG will have to do a full table read for each
> request.  Which means the more sessions you get, the slower each lookup is
> going to be.  Whereas, if you index SESSIONID (or SESSION_ID or whatever it
> is), it can go right to the row in question and return it immediately.
> 
> L8r,
> Rob
> 
> #!/usr/bin/perl -w
> use Disclaimer qw/:standard/;



[BUG?] PerlFreshRestart gives undef. subs (not the one in FAQ !!)

2002-02-26 Thread Sreeji K Das

Hi All,
I had been banging my head on this problem for a while
& finally I guess I've found a solution.

Following was the problem:
I had

PerlFreshRestart On
PerlRestartHandler Apache::Symbol

in my conf. I needed the restart func. & didn't want
to use other alternates (like Apache::Reload, StatINC
..etc.). Whenever I did a kill -USR1 I used to get
random 'Undefined subroutine xyz called at..'.
Following seems to be the problem:

mod_perl does something like the following on restart:
while (($k, $v) = each(%INC))
{
 delete($INC{$k}); eval("require $k");
}

Now assume that %INC has keys a.pm, File::Basename in
that order in %INC.
So following is the sequence:
delete a.pm from %INC
require a.pm

Now let's say a.pm does a 'use File::Basename' & then
calls basename($temp) (ie. some func in Basename.pm).
However 'use File::Basename' will not happen, since
perl sees that it exists in %INC (see man perldoc &
the entry of use/require/do). However, the truth is
All functions in File::Basename had been undef'd by
Apache::Symbol (this needs to be done, otherwise I get
a func. redefined for all functions on restart).
So the call basename($temp) fails with a fatal error
'Undefined subroutine File::Basename::basename called
at ...' !!

Since %INC is a hash, each time you'd get a different
'Undefined sub' message. For eg. in the above example,
if File::Basename had come b4 a.pm in %INC, then we
wouldn't have got any errors.

So the work around that I did is to undef %INC after
making a copy. Now perl would load all modules
properly. I went back in time (!) for a while & found
that mod_perl-1.19 implements things correctly.

Attached simple patch corrected my problem. Would some
mod_perl guru do a proper fix (I dunno the internals
much) & release a version ?

BTW, there was another bug in Apache::Symbol. ie. the
following
perl -MDevel::Symdump -e '$t = new Devel::Symdump;
foreach ($t->packages) { print "$_\n"; "'
prints  as one of the packages (Only in perl
5.6.1). A work around for the same is also attached.


Hope I've made things clear. I can prepare some test
scripts to demo these problems, if some1 really
requires that.

Thanx
Sreeji

Attached is the patch 


__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


patch.mod_perl
Description: patch.mod_perl


patch.symbol
Description: patch.symbol


Can't retrieve form params using post methods, $r->notes and Apache::Request

2002-02-26 Thread Mat

Hi all,
   I have the following configuration.

  SetHandler perl-script
  PerlAccessHandler MyCheck
  PerlHandler MyHomePage


The PerlAccessHandler checks if the user cookie is valid and set a $r->notes()
entry to pass the user id to the MyHomePage handler which do his work. In the
MyHomePage hanlder i'm using Apache::Request (my $apr = new
Apache::Request($r); ) to get the parameters of the form from which i'm
calling
the handler.

If i put the form method in POST, I can't get any parameters, the form is
reloaded, but if i put the method to GET then everything is fine.

If I use the following configuration

  SetHandler perl-script
  PerlHandler MyHomePage

and use either the POST or GET for the form everything is fine.

If I put a PerlAccessHandler not using the $r->notes() method then everything
is fine.

So my problem must come from the $r->notes(). Apparently it messes up with the
POST parameters.

Does somebody have an idea why it doesn't work with the POST method ? I've
lost quite a lot of time with that, even if it works with the GET i'd like to
understand.

Regards, 
   Mat

ps: OS: Linux 2.4.14
Apache 1.3.20
mod_perl 1.26
perl 5.6.1



Re: how to pass data in internal redirects?

2002-02-26 Thread Henigan, Timothy

I am also implementing a MVC pattern under mod_perl for an internal project
at work.  The app collects process data from our manufacturing processes and
makes it available on the internal network.  Here's a quick overview of the
way I've done it.

Model:
  The model consists of a backend database (MySQL) and a set of perl classes
that interact with it.  Each perl class encapsulates the data and methods
associated with an entity in the application (like an Assembly, Company,
etc).  These classes know nothing of mod_perl.  The only other thing worth
mentioning is that each entity has a method called "to_hash" that creates a
hash representation of itself that can be plugged directly into a HTML
template (see View below).

View:
  The view consists of a set of templates developed using the Template
Toolkit.  I strongly believe that templates should only display data, not
generate it (no dbase calls).  The controller creates the dynamic data,
stuffs it into the template, and sends it back to the user.

Controller:
  The core controller (an Apache handler) is responsible for authorization,
gathering user input, performing any actions, and returning the appropriate
view to the user.Whenever it performs an action, the controller needs to
create and monkey with a rather large set of Entity classes.  To simplify
the code in the controller, I developed a set of Facade classes that are
responsible for chunks of related actions.  So, the controller instantiates
a Facade and calls it's methods.  The results are plugged directly into a
template.

Only Entity classes speak SQL.  Only templates speak HTML.  Everything else
works with object methods or hashes.

Whenever I need an internal redirect, I use CGI encoded URLs, just as Dom
mentioned in his email.

I don't know if this is the best design, but it works for this application.
If you made it this far into the email, you might be interested in some
sample code...let me know.  If you have comments, please speak up.  I'm the
only developer on the project, so if I've gone off the deep end, I might not
notice.

Thanks,
Tim


On Tue, 26 Feb 2002, F. Xavier Noria wrote:

> As an exercise studying mod_perl I am trying to see how could the MVC
> pattern be implemented.  I've thought a possible approach would be to
> write the model using normal Perl classes, and controllers and views
> with Apache modules.
>
> I suppose that controllers would use internal redirects to call the
> views, is there a way to pass Perl data this way?  For example, in the
> hangman game in O'Reilly's book a controller would load a session from
> the cookie, process user's guest, modify the state and redirect the
> request internally to the view.  Ideally the view shouldn't read the
> data to display from the database again... could it be passed somehow by
> the first content handler



Re: Deleting a PerlSetVar variable

2002-02-26 Thread Geoffrey Young

simran wrote:
> 
> Thanks Geoff.
> 
> What you have suggested can solve the problem... i'm however, preferably
> looking at deleting a set var via my apache config file, and don't have
> a '$r' /request_object available there.

but you do have an Apache::Server object...

Apache::Server->dir_config->unset('foo');

see Recipe 17.1 in the Cookbook for a discussion if dir_config() from
the Apache::Server object (as well as it's limitations)

> 
> Doug et al, can i please suggest the addition of a:
> 
>   * PerlDelVar or PerlUnsetVar
> 
> to delete/unset a variable in the apache config file.
> I would make the changes and send in a patch, but i don't under the code
> (with my limited knowledge of C) well enough to do that.

you're probably better off setting the value you want for each vhost
rather than relying on unsetting a global.  the decision for
PerlUnsetVar is probably best left to Doug...

HTH

--Geoff

> 
> cheers,
> 
> simran.
> 
> On Tue, 2002-02-26 at 00:03, Geoffrey Young wrote:
> > simran wrote:
> > >
> > > Hi All,
> > >
> > > I could not find references on how to delete a varaible once set via
> > > PerlSetVar.
> > >
> > > I am setting a global 'PerlSetVar AuthNameExpires +24h' variable in my
> > > httpd.conf and want to be able to set it back to "expire at end of
> > > session" for some virtual hosts.
> > >
> > > If i could delete that variable, i could achieve that as per the spec,
> > > if the browser is not given a expiry time, the cookies lasts only for
> > > the session, however i so far have not been able to figure out how to
> > > delete a variable once set - anyone... ???
> > >
> >
> > you can use the Apache::Table interface for deleting (or setting or
> > manipulating) PerlSetVar
> >
> > $r->dir_config->unset('AuthNameExpires');
> >
> > see the latter part of recipe 3.14 in the cookbook for some additional
> > details on using the Apache::Table interface for dir_config, as well
> > as the Apache::Table manpage...
> >
> > HTH
> >
> > --Geoff
> >



[QUESTION][BUG] apache dies with SIGSEGV

2002-02-26 Thread gaston

Hi list

I wrote a small perl module using perl/Expat for parsing XML-files. 
With apache 1.3.19 and perl 5.6.0 and Expat 2.27 it works fine. 
In my new configuration (apache 1.3.20, perl 5.6.1 and Expat 2.30) 
apache dies with an SIGSEGV on loading.

The error occured during the function call ParseStream() in Expat.pm.
When i checked the core file with gdb i get this:

#0  0x4012d861 in kill () from /lib/libc.so.6
#1  0x4041a65e in Perl_apply () from /usr/lib/apache/libperl.so
#2  0x40412f38 in Perl_pp_kill () from /usr/lib/apache/libperl.so
#3  0x403e1730 in Perl_runops_standard () from
/usr/lib/apache/libperl.so
#4  0x403a210a in S_call_body () from /usr/lib/apache/libperl.so
#5  0x403a1cb1 in perl_call_sv () from /usr/lib/apache/libperl.so
#6  0x403dd9ac in Perl_sighandler () from /usr/lib/apache/libperl.so
#7  
#8  0x4017a06d in memmove () from /lib/libc.so.6
#9  0x08075f49 in XML_GetBuffer ()
#10 0x40e33570 in parse_stream ()
   from
/usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/XML/Parser/Expat/Expat.so
#11 0x40e3707c in XS_XML__Parser__Expat_ParseStream ()
   from
/usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/XML/Parser/Expat/Expat.so
#12 0x403e6f8d in Perl_pp_entersub () from /usr/lib/apache/libperl.so
#13 0x403e1730 in Perl_runops_standard () from
/usr/lib/apache/libperl.so
#14 0x403a210a in S_call_body () from /usr/lib/apache/libperl.so
#15 0x403a2261 in perl_eval_sv () from /usr/lib/apache/libperl.so
#16 0x40389827 in perl_do_file () from /usr/lib/apache/libperl.so
#17 0x40389883 in perl_load_startup_script () from
/usr/lib/apache/libperl.so
#18 0x40384dc6 in perl_cmd_require () from /usr/lib/apache/libperl.so
#19 0x08055e57 in ap_clear_module_list ()
#20 0x0805626b in ap_handle_command ()
#21 0x080562d1 in ap_srm_command_loop ()
#22 0x080568f6 in ap_process_resource_config ()
#23 0x08057112 in ap_read_config ()
#24 0x08060f42 in main ()
#25 0x4011c7ee in __libc_start_main () from /lib/libc.so.6 

When i'm running the program in perl (standalone) it works 
fine. 
 
-- 
Mit freundlichen Grüßen

Jürgen Magin

**
##   
#  OCTOSOFT GmbH Mannheim http://www.octo-soft.de#
##
#  Jürgen Magin. Einsteinstr. 11, D 68519 Viernheim  #
##
#  Tel   : +49 6204/914874   #
#  Fax   : +49 6204/914875   #
#  EMail : [EMAIL PROTECTED]   #
##
**



Re: how to pass data in internal redirects?

2002-02-26 Thread Rafiq Ismail (ADMIN)

Surprisingly I'm actually doing a proof of principle on the same theme.
I'm developing a set of MVC classes which tie in with either tt2 or mason.

I've got abstract Model, View and Controller classes.  View can be
subclassed into HTML, XML, whatever.  I'm using normal classes at the
moment, but if I get the go ahead, I'll be replacing these with some sort
of pseudo-hash framework.

My controller object would use the request object and the environment to
determine a framework/templates and which overloaded Controller to
generate.

There is a generic events handler in the base class, which gets overloaded
and which specialises the associated model object for the particular view
subclass.  I haven't looked at pre-reading the model and passing it into
the first content handler, since in my case the model is likely to emerge
from a large dataset.

Once possible idea, floating in my head is to follow a principle adopted
by the first company i was with, in that I could have a transitory daemon
through which the data is called - this could possibly cache models
requests, preventing second re-reads; also checking to see if the
underlying model has changed, as per the original MVC paper.

I guess that we can then reaccess the model at any point thereafter
so that the the controller doesn't need to reaccess the data.

Another point would be to cache the final generated templates, so that
the view and controller override interaction with the model, where this
data is already persistant.  Got my basic framework in place - might make
it my first cpan release if I can figure out how - want to share ideas?

fiq

On Tue, 26 Feb 2002, F. Xavier Noria wrote:

> As an exercise studying mod_perl I am trying to see how could the MVC
> pattern be implemented.  I've thought a possible approach would be to
> write the model using normal Perl classes, and controllers and views
> with Apache modules.
>
> I suppose that controllers would use internal redirects to call the
> views, is there a way to pass Perl data this way?  For example, in the
> hangman game in O'Reilly's book a controller would load a session from
> the cookie, process user's guest, modify the state and redirect the
> request internally to the view.  Ideally the view shouldn't read the
> data to display from the database again... could it be passed somehow by
> the first content handler?
>
> -- fxn
>
>




Re: how to pass data in internal redirects?

2002-02-26 Thread dom

> I suppose that controllers would use internal redirects to call the
> views, is there a way to pass Perl data this way?

  For the project I work on (a WWW-enabled PKI), we simply use CGI-encoded
URLs. This way, we can do the controllers in Perl and the views in
PHP, which is great for security (PHP is easier to sandbox) besides
all other engineering advantages of MVC.

  There are quite a lot of Perl modules on CPAN that are convenient
for turning structured Perl data into strings and back - please read
the last two weeks' worth of list archives.

-- 
Dominique QUATRAVAUX   Ingénieur développeur sénior
01 44 42 00 35 IDEALX