Clear questions and runnable code
get the best and fastest answer
Let the experts do their jobs, or, A Lesson Learned, or, the CPAN coulda saved by buttby Hero Zzyzzx (Curate)
|on Dec 01, 2001 at 02:06 UTC||Need Help??|
Small epiphany of the obvious today. I am implementing/building a Content Management System in mod_perl. One of the things I worked quite a while on was figuring out how to store files on the filesystem but still have them plug into the security system I have.
So, clever me, I used File::MMagic to figure out the mime types of uploaded files and then stored them on the filesytem, along with data about them in a mySQL DB.
Rather proud of myself, I thought "cool. All I have to do is get the mime-type from the DB, open and print the file and voila! It fits into my security system."
A few issues-
Everything was working beautifully- docs on the filesystem were secure, things were humming along.
I started testing- downloading large PDFs (some 4 meg +). It took a little while (no byteserving, you know) but this wasn't a huge issue. Still, something didn't feel quite right about this system.
Then I looked at my HTTPD processes. Some were over 50 meg in size! Oof! This was because I had to slurp the file in and return it, and I'm programming in a persistent mod_perl environment.
Needless to say, I ditched the above system and wrote a mod_perl handler (my first serious one) to take care of access control based on my security system. Now I have byte-serving, sanely-sized HTTPD processes, and a much better solution overall.
When looking at the project at it's start, my intial thought was to write a mod_perl handler or use something like Apache::AuthzDBI, but I dismissed these because I didn't feel comfortable enough in mod_perl using anything beyond Apache::Registry. This was wrong, very wrong. The amount of time I took writing and rewriting was much more than if I had figured out Apache:AuthzDBI.
So, the moral of the story? Use the fruit of OTHER people's labors. Figure out what modules there are that solve your problems and use them. Hand-roll as an academic exercise, or if you absolutely have to.
-Any sufficiently advanced technology is