Using Python for my web site

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Diez B. Roggisch

    #16
    Re: Using Python for my web site

    northband schrieb:
    So seems the best approach would be a MVC model rather than server
    scripting? Currently our site is built with a closed source hypertext
    preprocessor much like PHP. So it would be easier for us to script
    another site, but if we would gain performance via a MVC model, then
    that's what we need.
    MVC and server side scripting are two totally orthogonal things - you
    don't do the one and ditch the other as a consequence of that.

    MVC is a pattern of software design. It won't affect the performance
    itself, at least not the system performance. It most probably will boost
    your developing performance, as following the clear separation of data
    (model), application logic (controller) and view-logic (view) will help
    maintaining the codebase and make changes easier.

    And MVC doesn't depend on the language used - you can even do that in
    PHP, albeit it makes things much more dependent on discipline.

    Diez

    Comment

    • Bruno Desthuilliers

      #17
      Re: Using Python for my web site

      northband a écrit :
      So seems the best approach would be a MVC model rather than server
      scripting?
      This is still "server-scripting" - at least since on the server-side and
      is done with something frequently labelled as a "script language" !-)
      Currently our site is built with a closed source hypertext
      preprocessor much like PHP. So it would be easier for us to script
      another site,
      Depends on how your app is written - one can do MVC with PHP too.
      but if we would gain performance via a MVC model,
      This won't change anything to performances. What you can gain is a
      better design, well-decoupled code, hence far less maintenance problems.
      >
      I am not very familiar with developing via MVC, any good tutorials out
      there or good places to start?
      Do the Django tutorial. They actually name things differently (ie they
      call controllers views and views templates), which can be a bit
      misleading, but that's really MVC.

      Comment

      • Cliff Wells

        #18
        Re: Using Python for my web site

        On Mon, 2006-07-31 at 15:06 -0700, northband wrote:
        Makes sense, I will follow your advice. Sounds like more time invest
        upfront will equal time saved over the long run. I am defitely
        interested in proxy caching and load balancing. Which do you
        recommend? I have used #Pound while working for a university.
        I currently use Pound, mostly for proxying to virtual hosts on my shared
        hosting systems, but for heavy page hits and dynamic content, Squid is
        probably of more interest since Pound doesn't do caching.

        Regards,
        Cliff


        Comment

        • Bruno Desthuilliers

          #19
          Re: Using Python for my web site

          northband a écrit :
          Just spoke with my department and looks like we still want to go with a
          server scripting method. Although MVC may be better fit, for the sake
          of the learning curve, we want to use a PSP style method.
          I really don't think the learning curve will be a problem. We learned
          Django while using it for an app, and the app was completed and
          delivered within a week (total 8 man/day). Granted, it was a dead simple
          app, but it would have take as much time doing it in PHP. The last one
          we did was not trivial, and was ready to deliver in 2 weeks - one week
          before schedule. This very first release is still running, and we didn't
          have a single bug report. Not to say that Django is a silver-bullet, but
          it's actually the best tool we found for sql-based web apps so far.
          So as of now we are looking at using FreeBSD, MySQL, and some form of
          Python that will allow us to achieve great performance serving
          30million page loads / month.
          FWIW, when it comes to web apps, and given a reasonnably well
          designe/implemented app, "performanc e" is more a matter of
          tuning/hardware/etc than anything else.

          Comment

          • Gerhard Fiedler

            #20
            Re: Using Python for my web site

            On 2006-07-31 18:23:17, Cliff Wells wrote:
            My point is to stop FUD right at that comment. I don't doubt your
            research from "a few years ago", but ancient research is entirely
            irrelevant for making a decision *today*.
            That's exactly the reason why I added this information. It might not be for
            you, but it is interesting for me (and might be for someone else) to see
            that I get a different feedback now than I got a few years ago. It tells
            something about the dynamic of the process that the mere status of today
            doesn't tell.

            Besides, "claimed to have" and "seemed to have" are not really FUD inducing
            terms :)

            Anyway, I appreciate you sharing your experience (which in that area
            certainly is more than mine).

            Gerhard

            Comment

            • Cliff Wells

              #21
              Re: Using Python for my web site

              On Mon, 2006-07-31 at 21:57 -0300, Gerhard Fiedler wrote:
              On 2006-07-31 18:23:17, Cliff Wells wrote:
              >
              My point is to stop FUD right at that comment. I don't doubt your
              research from "a few years ago", but ancient research is entirely
              irrelevant for making a decision *today*.
              >
              That's exactly the reason why I added this information. It might not be for
              you, but it is interesting for me (and might be for someone else) to see
              that I get a different feedback now than I got a few years ago. It tells
              something about the dynamic of the process that the mere status of today
              doesn't tell.
              Well, perhaps I misunderstood your intent. Sorry if I was short.
              Besides, "claimed to have" and "seemed to have" are not really FUD inducing
              terms :)
              Taken in a vacuum, they can certainly add to an overall negative
              impression. PostgreSQL, in the past, has certainly had some hurdles
              that made it a suboptimal choice for many people: performance and
              difficulty in installation and management, among other things (I've
              personally not had stability issues), lack of a native Win32 version,
              etc, have made it the runner up in deployment to MySQL.
              Today, that's all changed. PostgreSQL is comparable in performance to
              MySQL (although I expect each outperforms the other in certain areas),
              *easier* to install and maintain than MySQL, and its stability is
              outstanding. Release 8 also saw a native Windows version. For many
              reasons, MySQL seems to be on the reverse track, sacrificing
              performance, stability and ease of use in an attempt to catch up to
              PostgreSQL in features.
              Nevertheless, there remains rumors and myths that stem from those old
              days that cause many people to fear deploying PostgreSQL. This is part
              of the reason I'm always quick to jump on statements such as yours. I
              feel it's a disservice to the community to let those myths continue and
              perhaps dissuade others from discovering what is today *the* premier
              FOSS relational database.
              Anyway, I appreciate you sharing your experience (which in that area
              certainly is more than mine).
              I'm glad I was able to add to the pool of knowledge (or at least the mud
              puddle of anecdote).

              Cliff

              --

              Comment

              • Luis M. González

                #22
                Re: Using Python for my web site

                I don't have experience with Django or any other python framework, but
                I have used bare-bones mod_python and it rocks.
                I wouldn't use PSP though...
                It is not very polished, and they way it handles the "indentatio n
                problem" in python is a little bit confussing.

                IMHO the best way of using mod_python is with its publisher handler.
                It let's you code your applications in a MVC (model view controller)
                style.
                This way you can cleanly separate presentation and logic, making your
                code more concise, clear and mantainable.

                With publisher, every function defined in your script represents a web
                page in your site, and the html code can be moved to a template, that
                could be PSP itself or Cheetah, for example (Cheetah is very good).

                A very simple example:

                #mysite.py

                def index(req):
                req.content_typ e = 'text/html'
                req.write("""
                <form action = mysite.py/printMyName method = post>
                <input type = text name = myname>
                <input type = submit>
                """)

                def printMyName(req , myname):
                req.content_typ e = 'text/html'
                req.write(mynam e)

                # end of mysite.py

                In this script, the function "index" is executed by default when you go
                to http://yourserver/mysite.py, and it displays a text box and a submit
                button.
                (The first line indicates that the output will be in html format, and
                "req.write" is equivalent to "print".)

                If you enter your name and hit the submit button, your name is passed
                to the "printMyNam e" function and printed in your browser's screen.

                This way, both functions can be viewed like two separate pages within
                your site.
                So, with only one script, you can write a whole site if you want.

                For more complex pages where html is used, you can place this
                presentation code in templates, and then import them into your main
                script.
                Or else, you could simple use "req.write" to print your html directly
                (as I did in "index").
                Hope this helps...

                Luis







                northband wrote:
                Hi, I am interested in re-writing my website in Python vs PHP but have
                a few questions. Here are my specs, please advise as to which
                configuration would be best:
                >
                1.Dell Poweredge Server, w/IIS, currently Windows but considering
                FreeBSD
                2. Site consists of result pages for auctions and items for sale (100
                per page)
                3. MySQL (Dell Poweredge w/AMD) database server connected to my web
                server
                4. Traffic, 30 million page loads/month
                >
                I am trying to have the fastest page loads, averaging 100 items per
                result page. I have read about using Apache's mod_python so I could
                use PSP. Any help or tips are appreciated.
                >
                -Adam

                Comment

                • Cliff Wells

                  #23
                  Re: Using Python for my web site

                  On Mon, 2006-07-31 at 22:25 -0700, Luis M. González wrote:
                  I don't have experience with Django or any other python framework, but
                  I have used bare-bones mod_python and it rocks.
                  I wouldn't use PSP though...
                  It is not very polished, and they way it handles the "indentatio n
                  problem" in python is a little bit confussing.
                  >
                  IMHO the best way of using mod_python is with its publisher handler.
                  It let's you code your applications in a MVC (model view controller)
                  style.
                  While I agree (or at least consider the point moot) that this is
                  possibly the best way to use plain mod_python, I'd disagree that it's a
                  good way to develop modern web applications in Python. By the time
                  you've decided on every bit of framework to use, and made all the little
                  decisions that go into turning a fresh, clean spot on your hard drive
                  into an application, what you've done is reinvent TurboGears rather than
                  develop your application. Worse, you've probably reinvented it poorly.
                  I've done so many times and am well aware of what a time-waster it is.

                  You say that you haven't tried Django or any other Python framework.
                  Perhaps you should. You seem to have at least the start of the right
                  idea about web application organization, so I think you'd be pleasantly
                  surprised with what you'll find already done for you by the major Python
                  frameworks and how much time you'll stop wasting on code that isn't part
                  of your application.

                  Regards,
                  Cliff

                  Comment

                  • bryanjugglercryptographer@yahoo.com

                    #24
                    Re: Using Python for my web site


                    northband wrote:
                    Hi, I am interested in re-writing my website in Python vs PHP but have
                    a few questions. Here are my specs, please advise as to which
                    configuration would be best:
                    >
                    1.Dell Poweredge Server, w/IIS, currently Windows but considering
                    FreeBSD
                    2. Site consists of result pages for auctions and items for sale (100
                    per page)
                    3. MySQL (Dell Poweredge w/AMD) database server connected to my web
                    server
                    4. Traffic, 30 million page loads/month
                    >
                    I am trying to have the fastest page loads, averaging 100 items per
                    result page. I have read about using Apache's mod_python so I could
                    use PSP. Any help or tips are appreciated.
                    So if I'm reading this correctly: you have a system that's
                    working, and the main purpose of the re-write is faster page
                    responses to users. Do I have that right?

                    Have you determined where the time is spent? For some web apps,
                    speed is all about the database, and if that's true of your system
                    then changing scripting language isn't going to provide the
                    performance boost you seek.

                    Another interesting question is how response time changes with
                    increasing load. Of course with the real website, those 30 million
                    page loads per month are not uniformly distributed. What is your
                    peak rate? Is rush-hour speed mostly what motivates the project?


                    --
                    --Bryan

                    Comment

                    • Paul Boddie

                      #25
                      Re: Using Python for my web site

                      bryanjugglercry ptographer@yaho o.com wrote:
                      northband wrote:
                      [Specifications]
                      I am trying to have the fastest page loads, averaging 100 items per
                      result page. I have read about using Apache's mod_python so I could
                      use PSP. Any help or tips are appreciated.
                      >
                      So if I'm reading this correctly: you have a system that's
                      working, and the main purpose of the re-write is faster page
                      responses to users. Do I have that right?
                      Performance is clearly important, but later on the questioner says...

                      QCurrently our site is built with a closed source hypertext
                      Qpreprocessor much like PHP.

                      That sounds like a good enough reason for migration, depending on how
                      unportable, unsustainable or unmaintainable the technology platform has
                      proven itself to be. Still, at least the questioner isn't seeking
                      performance by wanting to rewrite everything in C++...

                      Paul

                      Comment

                      • northband

                        #26
                        Re: Using Python for my web site

                        Awesome response, thanks. I am definitely interested in the MVC and am
                        looking into it now.

                        Yes, we are migrating to Python mainly because we want unicode support,
                        more stability, and faster performance than what we are getting now.
                        We were going to move to php but seem python is the better choice, plus
                        php 5.0 still doesn't support unicode.

                        -Adam O

                        Comment

                        • Luis M. González

                          #27
                          Re: Using Python for my web site


                          Cliff Wells wrote:
                          On Mon, 2006-07-31 at 22:25 -0700, Luis M. González wrote:
                          I don't have experience with Django or any other python framework, but
                          I have used bare-bones mod_python and it rocks.
                          I wouldn't use PSP though...
                          It is not very polished, and they way it handles the "indentatio n
                          problem" in python is a little bit confussing.

                          IMHO the best way of using mod_python is with its publisher handler.
                          It let's you code your applications in a MVC (model view controller)
                          style.
                          >
                          While I agree (or at least consider the point moot) that this is
                          possibly the best way to use plain mod_python, I'd disagree that it's a
                          good way to develop modern web applications in Python. By the time
                          you've decided on every bit of framework to use, and made all the little
                          decisions that go into turning a fresh, clean spot on your hard drive
                          into an application, what you've done is reinvent TurboGears rather than
                          develop your application. Worse, you've probably reinvented it poorly.
                          I've done so many times and am well aware of what a time-waster it is.
                          >
                          You say that you haven't tried Django or any other Python framework.
                          Perhaps you should. You seem to have at least the start of the right
                          idea about web application organization, so I think you'd be pleasantly
                          surprised with what you'll find already done for you by the major Python
                          frameworks and how much time you'll stop wasting on code that isn't part
                          of your application.
                          >
                          Regards,
                          Cliff
                          Well... yes, you're right.
                          I guess that the reason for not having used a framework already is
                          laziness...
                          I have experience with Karrigell, which rocks too, but it lacks some
                          deployment options (no mod_python, no fastcgi, etc).

                          And as far as I could see in the Django docs, I should learn many new
                          things to do exactly the same, such as yet another templating language
                          or how to map urls with regular expressions (I still couldn't wrap my
                          head around regex... I find them very boring to learn...). But you are
                          absolutely right. I should definetely try Django sometime.
                          I guess I'll do it when I have a real need to do some serious web
                          stuff.

                          As for TurboGears, I'm not very impressed...
                          This is a pile of different components picked by someone according to
                          his liking, very well glued together. Althouh its quality may be good,
                          why should I stick with a number of components chosen according the
                          criteria of some other guy?
                          For example, why kid instead of Cheetah? Why CherryPy?
                          Really, it isn't that hard to install cheetah and, if you want an
                          object relational mapper, sqlobject. Once you have them, using raw
                          mod_python is just a pleasure.
                          I feel I'm in front of a white clean canvas and I just start coding.
                          I like the flexibility of being able to choose each part of "my own
                          framework".
                          I even created a small script that does the automatic crud stuff for me
                          (not as polished as Django for sure, but it works like a charm).

                          Anyway, there's still an issue with using these frameworks:
                          Availability. It's very hard, if not impossible, to find a decent web
                          host at an affordable price. Although I guess many of those who use
                          Django, for example, run their own host.
                          Being able to use raw mod_python gives you an advantage here.

                          Luis

                          Comment

                          • Gerhard Fiedler

                            #28
                            Re: Using Python for my web site

                            On 2006-08-01 04:11:18, Cliff Wells wrote:
                            You say that you haven't tried Django or any other Python framework.
                            Perhaps you should. You seem to have at least the start of the right
                            idea about web application organization, so I think you'd be pleasantly
                            surprised with what you'll find already done for you by the major Python
                            frameworks and how much time you'll stop wasting on code that isn't part
                            of your application.
                            I've checked it out quickly, and it seems that it is not possible to
                            install e.g. TurboGears on a typical shared host -- as a normal user. You
                            seem to run a shared hosts farm (IIRC). What's your point of view of
                            hosting TurboGears or Django on a shared host? Is that (reasonably)
                            possible?

                            Thanks,
                            Gerhard

                            Comment

                            • Cliff Wells

                              #29
                              Re: Using Python for my web site

                              On Tue, 2006-08-01 at 10:41 -0300, Gerhard Fiedler wrote:
                              On 2006-08-01 04:11:18, Cliff Wells wrote:
                              >
                              You say that you haven't tried Django or any other Python framework.
                              Perhaps you should. You seem to have at least the start of the right
                              idea about web application organization, so I think you'd be pleasantly
                              surprised with what you'll find already done for you by the major Python
                              frameworks and how much time you'll stop wasting on code that isn't part
                              of your application.
                              >
                              I've checked it out quickly, and it seems that it is not possible to
                              install e.g. TurboGears on a typical shared host -- as a normal user. You
                              seem to run a shared hosts farm (IIRC). What's your point of view of
                              hosting TurboGears or Django on a shared host? Is that (reasonably)
                              possible?
                              There's quite a few actually:



                              That's just a few picks Kevin made, there are many more. As I
                              understand it textdrive also supports TG.

                              For myself, I handle user-installation of TurboGears pretty much like I
                              do all user-installed Python packages: using setuptools. Any user who
                              uses easy_install or 'python setup.py install' gets their packages
                              automatically installed into a subdirectory of their home directory and
                              that takes precedence over the system installed packages. Works like a
                              charm.

                              Regards,
                              Cliff

                              --

                              Comment

                              • Cliff Wells

                                #30
                                Re: Using Python for my web site

                                On Tue, 2006-08-01 at 06:38 -0700, Luis M. González wrote:
                                Well... yes, you're right.
                                I guess that the reason for not having used a framework already is
                                laziness...
                                Trust me, I'm quite familiar with the laziness problem =)
                                I have experience with Karrigell, which rocks too, but it lacks some
                                deployment options (no mod_python, no fastcgi, etc).
                                >
                                And as far as I could see in the Django docs, I should learn many new
                                things to do exactly the same, such as yet another templating language
                                or how to map urls with regular expressions (I still couldn't wrap my
                                head around regex... I find them very boring to learn...). But you are
                                absolutely right. I should definetely try Django sometime.
                                I guess I'll do it when I have a real need to do some serious web
                                stuff.
                                >
                                As for TurboGears, I'm not very impressed...
                                This is a pile of different components picked by someone according to
                                his liking, very well glued together. Althouh its quality may be good,
                                why should I stick with a number of components chosen according the
                                criteria of some other guy?
                                For example, why kid instead of Cheetah? Why CherryPy?
                                Really, it isn't that hard to install cheetah and, if you want an
                                object relational mapper, sqlobject. Once you have them, using raw
                                mod_python is just a pleasure.
                                Agreed. But on the other hand, it isn't always about having "the best"
                                of each (why didn't they use Twisted rather than CherryPy would be *my*
                                question), but rather having a complete development stack that's
                                pre-integrated and is *good enough*. And mind you, the integration work
                                is quite substantial. Also, TurboGears has definitely proven the "a
                                rising tide lifts all boats" maxim, TurboGears has marketing and
                                community and all the projects that comprise TurboGears have benefited
                                from it.

                                Ultimately a framework is about helping you get *your* job done. If
                                your job is assembling frameworks or evaluating which ORM is best, then
                                that's no help ;-) But I suspect those people are in the minority and
                                most people just want to get their sites done without trying to figure
                                out which is "best" and then trying to figure out how to integrate that
                                with other components.

                                Also, TurboGears supports template plugins (I wrote one to support
                                Nevow's Stan, and there is a Cheetah plugin as well), and work is being
                                done to support alternate ORMs (SQLAlchemy is working now, although not
                                all the TG addons support it yet). The goal is to at least offer people
                                the opportunity to replace certain components in the framework if they
                                object to some part of TG. That's not the *ultimate* goal, but Kevin is
                                a pragmatic guy and recognizes that component bias can hurt TurboGears'
                                adoption and so is trying to address that in some fashion.
                                I feel I'm in front of a white clean canvas and I just start coding.
                                I like the flexibility of being able to choose each part of "my own
                                framework".
                                I even created a small script that does the automatic crud stuff for me
                                (not as polished as Django for sure, but it works like a charm).
                                Sure, and if you are doing it as a hobby, or to learn or to perhaps take
                                over the world with a new ORM, then that's great. But if someone is
                                paying you by the hour to develop a website for them and you are writing
                                an ORM when there's already half dozen out there, then someone probably
                                isn't getting their money's worth. This is the problem frameworks were
                                meant to address: putting your focus back on your web application rather
                                than all the details that go into it. Do you lose some flexibility?
                                You bet. Not a lot, but a noticeable amount. Of course the flip side
                                is that you can turn out a pretty sophisticated web app *by yourself* in
                                a few days.

                                I saw DHH of Ruby on Rails fame at FOSCON last year and he really
                                impressed me with is no-nonsense philosophy about web frameworks. His
                                approach is the antithesis of Zope, Joomla, et al. Django and TurboGears
                                are no-nonsense in the same vein: they aren't about providing every
                                feature under the sun or blazing performance or ultimate
                                configurability . They are about eliminating the time-consuming details
                                that you face every time you start a project.
                                Anyway, there's still an issue with using these frameworks:
                                Availability. It's very hard, if not impossible, to find a decent web
                                host at an affordable price. Although I guess many of those who use
                                Django, for example, run their own host.
                                Not true. As I posted elsewhere there are many hosts who will run
                                frameworks (I suspect the pressure of Ruby on Rails really pushed open
                                the door). Here's a short list from the TurboGears site:


                                And from the Django site:


                                WebFaction (formerly python-hosting) even has a control panel that will
                                install the framework of your choice with a mouse-click.



                                Regards,
                                Cliff

                                --

                                Comment

                                Working...