Yet Another Python Web Programming Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Bickett

    Yet Another Python Web Programming Question

    This post started as an incredibly long winded essay, but halfway
    through I decided that was a terribly bad idea, so I've trimmed it
    down dramatically, and put it in the third person (for humor's sake).

    Once upon a time a boy named Hypothetical programmed in PHP and made
    many a web application.

    It would be a long while before he would find Python, and since that
    time he would have no desire to ever touch PHP again.

    He would, however, be compelled to write a web application again, but
    in Python now, of course.

    He would read the documentation of Nevow, Zope, and Quixote, and would
    find none of them to his liking because:

    * They had a learning curve, and he was not at all interested, being
    eager to fulfill his new idea for the web app. It was his opinion that
    web programming should feel no different from desktop programming.

    * They required installation (as opposed to, simply, the placement of
    modules), whereas the only pythonic freedom he had on his hosting was
    a folder in his /home/ dir that was in the python system path.

    * See the first point, over and over again.

    All he really wanted was something that managed input (i.e. get, post)
    and output (i.e. headers: "Content-type:"), and he would be satisfied,
    because he wasn't an extravagant programmer even when he used PHP.

    Python using CGI, for example, was enough for him until he started
    getting 500 errors that he wasn't sure how to fix.

    He is also interested in some opinions on the best/most carefree way
    of interfacing with MySQL databases.

    Thanks for your time,
    --
    Daniel Bickett
    dbickett at gmail.com

  • Devan L

    #2
    Re: Yet Another Python Web Programming Question

    Take some time to learn one of the web frameworks. If your host doesn't
    already have it, ask your host if they would consider adding it.

    Comment

    • Jonathan Ellis

      #3
      Re: Yet Another Python Web Programming Question

      Daniel Bickett wrote:[color=blue]
      > He would read the documentation of Nevow, Zope, and Quixote, and would
      > find none of them to his liking because:
      >
      > * They had a learning curve, and he was not at all interested, being
      > eager to fulfill his new idea for the web app. It was his opinion that
      > web programming should feel no different from desktop programming.[/color]

      If you're coming from a PHP background, you'll find Spyce's learning
      curve even shallower.

      Spyce - Python Server Pages: a server-side language that supports simple and efficient Python-based dynamic HTML generation.


      -Jonathan

      Comment

      • Luis M. Gonzalez

        #4
        Re: Yet Another Python Web Programming Question

        Try Karrigell ( http://karrigell.sourceforge.net ).
        And let me know what you think...

        Cheers,
        Luis

        Comment

        • and-google@doxdesk.com

          #5
          Re: Yet Another Python Web Programming Question

          Daniel Bickett wrote:
          [color=blue]
          > Python using CGI, for example, was enough for him until he started
          > getting 500 errors that he wasn't sure how to fix.[/color]

          Every time you mention web applications on this list, there will
          necessarily be a flood of My Favourite Framework Is X posts.

          But you* sound like you don't want a framework to take over the
          architecture of your app and tell you what to do. And, indeed, you
          don't need to do that. There are plenty of standalone modules you can
          use - even ones that are masquerading as part of a framework.

          I personally use my own input-stage and templating modules, along with
          many others, over standard CGI, and only bother moving to a faster
          server interface which can support DB connection pooling (such as
          mod_python) if it's actually necessary - which is, surprisingly, not
          that often. Hopefully if WSGI catches on we will have a better
          interface available as standard in the future.

          Not quite sure what 500 Errors you're getting, but usually 500s are
          caused by unhandled exceptions, which Apache doesn't display the
          traceback from (for security reasons). Bang the cgitb module in there
          and you should be able to diagnose problems more easily.
          [color=blue]
          > He is also interested in some opinions on the best/most carefree way
          > of interfacing with MySQL databases.[/color]

          MySQLdb works fine for me:

          Download MySQL for Python for free. MySQL database connector for Python programming. MySQLdb is a Python DB API-2.0-compliant interface; see PEP-249 for details.


          (* - er, I mean, Hypothetical. But Hypothetical is a girl's name!)

          --
          Andrew Clover
          mailto:and@doxd esk.com


          Comment

          • Daniel Bickett

            #6
            Re: Yet Another Python Web Programming Question

            I neglected to mention an important fact, and that is the fact that I
            am limited to Apache, which elminates several suggestions (that are
            appreciated none-the-less).
            --
            Daniel Bickett
            dbickett at gmail.com

            Comment

            • Jorey Bump

              #7
              Re: Yet Another Python Web Programming Question

              Daniel Bickett <dbickett@gmail .com> wrote in
              news:mailman.15 56.1120970289.1 0512.python-list@python.org :
              [color=blue]
              > I neglected to mention an important fact, and that is the fact that I
              > am limited to Apache, which elminates several suggestions (that are
              > appreciated none-the-less).[/color]

              "Limited to Apache" is not the same as "using apache in a restricted
              environment", so we may need more clarification.

              If you are looking for a solution that sits on top of apache somehow, and
              you have system administrative access, there are a lot of choices,
              including ones that use mod_python. If something is not intended to
              interface directly with apache, it can still be proxied through apache
              while it runs on an alternate local port (a standalone app with an
              embedded web server, for example).

              If you mean that you're in a typical hosted environment with insufficient
              privileges to install or configure much of anything, you might be stuck
              with CGI. Since you mention in your original post that you have a folder
              in your home directory that's in sys.path, your provider is trying to do
              something to support python applications (hopefully, the path is specific
              to your virtual host, to avoid namespace collisions). In any case, if
              this was done to support mod_python, you can meet some of your criteria
              with mod_python.publ isher, but you will almost certainly want to use a
              staging platform to develop your apps beforehand, since it is necessary
              to either restart apache or touch imported modules after editing.

              BTW, this is how I use Python for web applications myself: Each virtual
              host gets a special directory prepended to the PYTHONPATH, in which the
              bulk of my applications are created as packages. Then I use
              mod_python.publ isher to publish single modules that serve as interfaces,
              converting values from requests and passing them on to the packages,
              which I try to make web agnostic (in fact, I develop most of the backend
              code locally before even trying it out on the web, so I can use it in
              other application domains).

              I've looked at other offerings, but as soon as I see proprietary markup
              or commands embedded in HTML, I lose interest, so I feel your pain.

              Comment

              • Sybren Stuvel

                #8
                Re: Yet Another Python Web Programming Question

                Daniel Bickett enlightened us with:[color=blue]
                > It would be a long while before he would find Python, and since that
                > time he would have no desire to ever touch PHP again.[/color]

                My thoughts exactly.
                [color=blue]
                > He would, however, be compelled to write a web application again,
                > but in Python now, of course.[/color]

                Same here :)
                [color=blue]
                > * They required installation (as opposed to, simply, the placement
                > of modules), whereas the only pythonic freedom he had on his hosting
                > was a folder in his /home/ dir that was in the python system path.[/color]

                I can't help you here. For instance, if you want to get a proper
                performance, you should install something like mod_python to get
                Python functionality in Apache.
                [color=blue]
                > Python using CGI, for example, was enough for him until he started
                > getting 500 errors that he wasn't sure how to fix.[/color]

                Check the web server's error logs.


                My solution was to take a look at Cheetah. It's a template engine
                that's written in Python. I've written a mod_python handler for it so
                I can easily create & edit my website using Cheetah as a template
                engine. Check out http://www.unrealtower.org/mycheetah if you want to
                read more about the handler & other stuff I wrote. Perhaps you can
                even help me improve it!

                Sybren
                --
                The problem with the world is stupidity. Not saying there should be a
                capital punishment for stupidity, but why don't we just take the
                safety labels off of everything and let the problem solve itself?
                Frank Zappa

                Comment

                • Thomas Bartkus

                  #9
                  Re: Yet Another Python Web Programming Question

                  "Daniel Bickett" <dbickett@gmail .com> wrote in message
                  news:mailman.15 48.1120941799.1 0512.python-list@python.org ...
                  <snip>[color=blue]
                  > It was his opinion that
                  > web programming should feel no different from desktop programming.[/color]
                  <snip>

                  Should that ever become even remotely possible -

                  I'll be interested in web programming myself.
                  Thomas Bartkus


                  Comment

                  Working...