Login Script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Faulkner

    Login Script

    I have written a small Python web database which was initially just
    used in house.

    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?

    If not should I roll my own from a cookie and a MySQL table?

    Any advice...


    Simon
    (PS I know that I should probably be using Zope but I don't really
    understand it yet...)
  • Gerhard Häring

    #2
    Re: Login Script

    Simon Faulkner wrote:[color=blue]
    > I have written a small Python web database which was initially just
    > used in house.[/color]

    Is this a CGI-based solution?
    [color=blue]
    > 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?[/color]

    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.
    [color=blue]
    > If not should I roll my own from a cookie and a MySQL table?[/color]

    Ouch, MySQL. Sounds like you're using CGI as well :-P
    [color=blue]
    > Any advice...[/color]

    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.
    [color=blue]
    > Simon
    > (PS I know that I should probably be using Zope but I don't really
    > understand it yet...)[/color]

    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

    Comment

    • Simon Faulkner

      #3
      Re: Login Script

      Big thanks for this comprehensive reply.

      I am well versed with MySQL so that's my backend.

      Any particular favorites for a front end?

      Simon

      Comment

      Working...