Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
NOTE: please don't flame me for the following ;)

Too late, I'm getting down voted, aaahhh ;) oh well...

I recently wrote a web app in *duck* Python *peek**duck again*, in which I did exactly that, and it worked out quite nicely. I had a module for the sql, one for the html, a config module, a content module which was basically a Super class of a web page which was then subclassed for each page on the site. The url to get the code would be http://members.home.com/m.v.wilson.

The sql module probably could have been split up some, but due to Python's lack of anything close to mod_perl, I couldn't get persistent db connections, so the sql module's constructor created the database connection, the destructor broke it down. That way I only had one database connection per page. Each thing I wanted to do was represented by a method of that class (from that module). So, even down the road as I add pages, I can simply create a new method, and create the subclass with that method in it. Plus, I tried to keep a lot of the methods fairly generic so that I didn't _always_ have to create new ones.

I had actually written that app in Perl previously (should have stuck with it ;)), but everything was hardcoded, the html, sql, and everything else. It was quite ugly and every time I wanted to say...change the color of some part of the page, I had to edit 8 different cgi's. (that was my first perl project, so it wasn't too clean ;)).

Modularizing everything is great for say, producing apps which can have a console/gui/html interface, the logic is seperated out from everything else, so you just pull in what you need.

Another upside to the way that I wrote the python app is that I only had one cgi that was ever called. Even if someone could see the cgi source, they would never be able to get the database username and password, etc. 'cuz it was in a module outside of the chroot jail. That cgi was more or less just a traffic cop with a couple big if statements that created an instance of a class depending on what the specified "action" was.

In reply to RE: Object Oriented SQL by BastardOperator
in thread Object Oriented SQL by eak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-05-24 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?