Python web development, really
rjones at ekit-inc.com
Tue Jan 21 06:58:41 CET 2003
On Tue, 21 Jan 2003 4:16 am, Afanasiy wrote:
> I would love to use Python instead of PHP for web development, but
> I have so far been confused by the options, or perhaps lack thereof,
> given my strict requirements. I would appreciate suggestions.
> I've looked at some Python options and have experience in quite a
> few platforms previously. I have always disliked PHP as a language,
> but at the same time have found it very accessible and useful.
> Possible solutions should do 99% of the following :
> * Run on the same hardware I use currently
> * Be as fast or faster than Apache+PHP
> (I'm sorry to say Zope/Roxen are not)
> (This might mean it must use Apache)
Not much is going to be faster than Apache+PHP. Python can certainly reach the
same or similar speeds though.
> * Use a similar amount of memory
> (ie. not Java/.NET related)
This is pretty open-ended. Suffice to say though that Python doesn't consume
wads of memory on its own. The rest is up to your application.
> * Provide a fairly equivalent framework w/ sessions, cookies, get, post
> (Described in http://www.boddie.org.uk/python/web_frameworks.html)
> (eg. I should not have to write code to parse query strings, etc.)
> (PHP is somewhat unique in the ways it can bring in post variables)
I'm confused. A number of the frameworks on the page you link there support
all of the above. Are you stating that this is a requirement that isn't met
(which it clearly is) or that it _is_ met?
> * Allow all errors to be caught and handled so users never see them
> (I currently send them to an email address)
> (Users are notified an error occurred and a developer contacted)
Built into Python. try/except is part of the language itself.
> * Allow sending of email
Built into Python. Use the smtplib module.
> * Allow sending of raw binary data, for restricted file downloading
> (eg. http://example.com/sendfile.php?id=A6DE12FAB3...etc)
> (This requires header manipulation, specifically the mime type)
> (That sort of thing should be part of the framework 3 bullets up)
Any of the frameworks you reference above can do this. Python can do this by
itself with no framework:
print "Content-Type: image/png"
> * Allow SSL secured authorize.net credit card processing
> (I currently use PHP's libcurl+ssl module)
I presume by the reference to libcurl you want to make a request of an SSL
website. This is built into python. Use the urllib2 module.
> * Allow similarly powerful regex capabilities
> (I currently use PHP's pcre module)
Built into Python. Use the re module.
> * Big plus, but optional, auto prepend/append files
> (eg. Apache+PHP has .htaccess directives like this )
> ( php_value auto_prepend_file "_header.php" )
> ( php_value auto_append_file "_footer.php" )
> (granular down to the directory
That would be dependent on the framework you chose, but they would all support
some version of this.
> * Finally, very optional plus, global application scoped variables
> (PHP does NOT allow this, but I know why)
> (I do not want to hear why you think this is bad)
> (I know why it is good, I know why it can be bad)
Most of the frameworks will support this in some manner. If they don't, then
using the stand-alone ZODB would be a trivial addition to your application.
Or you could use a relational database. It's up to you.
More information about the Python-list