Simon said:
I have written a small Python web database which was initially just
used in house.
Is this a CGI-based solution?
Now we want people to be able to read some pages from outside so I
need to implement some sort of security.
Does Python have sessions like PHP?
The cgi module doesn't include anything for sessions, but there are tons
of third-party solutions for sessions.
All Python web frameworks should have integrated support for sessions.
I'm right now using Quixote to create a web frontend for a custom
PostgreSQL-backed hosting solution I've developed. It needs sessions,
because each user can configure her or his mailboxes and HTTP domains.
If not should I roll my own from a cookie and a MySQL table?
Ouch, MySQL. Sounds like you're using CGI as well
The quick solution is to grab an existing standalone session module. I
believe you could use the one from Jonpy. Rolling your own with Cookies
and a persistent database isn't that hard either.
My advice is that if you plan to do more web development with Python,
that you start using a web framework. Perhaps Jonpy is a good candidate
for you (
http://jonpy.sourceforge.net/).
Here's an overwhelming resource for web programming solutions for
Python:
http://www.python.org/cgi-bin/moinmoin/WebProgramming
These seem to be particularly popular: Albatross, Webware, Quixote,
Jonpy. All of them can work with standalone CGI scripts as well.
Simon
(PS I know that I should probably be using Zope but I don't really
understand it yet...)
Nah. You don't need to use something as complex as ZOPE to get sessions.
Nor do you need to use something as primitive as the cgi module. There
are lots of solutions which are in-between in complexity and features.
-- Gerhard