Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Which Web Solution?

by sth (Priest)
on Jan 07, 2003 at 14:05 UTC ( #224972=perlquestion: print w/ replies, xml ) Need Help??
sth has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

Let me explain the situation first, unfortunately my knowledge of the project is limited. Basically there will be a web front-end to a demographic database. The user will be able to pick certain criteria, which will involve drilling down into other web pages. There is a push to use Java/Jsp's, but most of our web work has been with cgi and we use Perl on a daily basis here. So a co-worker is making an argument for using Perl, no ramp-up time. I am not a web guy, but I explained to him that with Apache::DBI, ModPerl, and Html::Mason, ....etc that he could have fast product that allows embedding perl in pages, blah blah. The one thing he is concerned about is having persistent objects(could be any data structure) that stores the user data as they go through the different pages, much like a javabean. I'm sure this has been done numerous times. I am looking for links, software that already does this, ...etc, so that I can point him in the right direction.

Thanks,
STH

Comment on Which Web Solution?
Re: Which Web Solution?
by derby (Abbot) on Jan 07, 2003 at 14:48 UTC

      On top of using CGI::Session and/or Apache::Session, persistent data is very easily handled in multiple ways.

      You can store all relevant session data at the client, or you can store that data on the server. There are tradeoffs both ways:

      On the client, you lighten server load. This can be an issue for heavily trafficed applications. It's also a potential security problem if someone learns how to edit their cookies. In a closed environment (Intranet) this is usually not such a problem.

      You can also store that data server-side. Either in a flat file or a database... flat-files are extremely easy (Just name the file with the session id you toss to the client in a cookie) and flexible - it's easy to add data to them. Databases scale up to better load, but require more planning and architecture. They're also less flexible.

      I prefer the second solution. This is pseudocode, something I use for "flowcharting" during the development process:

      get sessionId from browser; if (no sessionId) create session id; hand to browser; create datastore; put relevant data in store (username, password, browser, etc) else get relevant data from datastore;

      Pretty simple. Without knowing what kind of data you're needing to be persistent, that's about the best I can do. One other library you may be interested in is CGI::Application. It uses HTML::Template to separate code from the presentation layer (HTML), which may be a different paradigm than you're looking for, but it helps you maintain state between pages.

        You can roll your own with DBI (and your favorite DBD::), Digest::MD5 (to generate your session ids... just one way to do it), and Data::Serializer. I use these together in a custom session object that follows the same flow as you have.
        • create and store session id with browser(through cookie, url, or hidden form fields)
        • use session id as map to key/identity in your db store
        • serialize your data structure with Data::Serializer right into the db
        If you can't map the session id, assume its a new session and regen a new session id. You should track your session data by last access time (so your write/commit method might update a timestamp for example).

        With Data::Serializer, you can get fancy and have deep nested hashrefs and blessed objects. Be careful though that your blessed objects are refreshed when thawed. Otherwise you will have a good long time debugging stale data. =]
Re: Which Web Solution?
by IlyaM (Parson) on Jan 07, 2003 at 18:15 UTC
Re: Which Web Solution?
by sth (Priest) on Jan 07, 2003 at 23:09 UTC

    Thanks for the replies. I passed the info on. I know I could just search CPAN, but I wanted direction from someone that has done this.

    Thanks Again, STH

Re: Which Web Solution?
by Starky (Chaplain) on Jan 08, 2003 at 04:10 UTC
    This is not a direct answer to your question of object persistance, but you may also want to check out the PageKit application server project. It handles session management, authentication, form validation and prepopulation, page caching, nice templating and XML support (useful for cobranding, localization or dual HTML/WAP page generation among other things) along with a variety of other features in a mod_perl environment. It basically glues together a number of Perl web tools in a nice package.

    The documentation is sparse, but my experience with it is that once you get everything figured out, it is rock-solid, lightning fast, and very extensible. Particularly to Perl developers who otherwise don't want to think about the sundry details of an application server. My experience with it has been very positive.

    Hope this helps!

Re: Which Web Solution?
by agentv (Friar) on Jan 08, 2003 at 04:39 UTC
    ...excellent job one and all!

    This is why I tell people (especially new Perl students) that PM is like a search engine in which the database is held in the brains of the citizens. Someone comes in here with a question and a dozen links pop up pre-filtered by the experience and pragmatism of the posters.

    I'm sendin' a dollar right now! :-)

    Seriously, isn't this a lot more effective than the standard response, "1,800,00 documents match your query. Have a nice life."

    ...All the world looks like -well- all the world, when your hammer is Perl.
    ---v

      You mean we're all pigeons? ;-)

      Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://224972]
Approved by Mr. Muskrat
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2014-07-13 17:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (250 votes), past polls