mod_python

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

    #1

    mod_python

    Today I was busy to install mod_python.

    I have put the line

    LoadModule python_module libexec/mod_python.so

    into the httpd.conf file.
    It Works!
    Apache load mod_python /3.2.2.b Python2.4

    But my problem is where I have to place te following code in de
    httpd.conf?

    <Directory C:\Program Files\Apache Group\Apache2\h tdocs\project\>
    AddHandler mod_python .py
    PythonHandler mptest
    PythonDebug On
    </Directory>

    Because al the tutorials write this. But where?

    If I try to put the code some where,
    apache give the following message by testing the configure:
    Multiple <Directory> arguments not (yet) supported
    But what i have to change or replace.

    I test with the next file:

    C:\Program Files\Apache Group\Apache2\h tdocs\project\
    mptest.py

    from mod_python import apache

    def handler(req):
    req.content_typ e = 'text/plain'
    req.send_http_h eader()
    req.write('mpte st.py\n')
    return apache.OK

    Is this code enough for testing?

  • deelan

    #2
    Re: mod_python

    Python_it wrote:
    (...)[color=blue]
    > But my problem is where I have to place te following code in de
    > httpd.conf?
    >
    > <Directory C:\Program Files\Apache Group\Apache2\h tdocs\project\>
    > AddHandler mod_python .py
    > PythonHandler mptest
    > PythonDebug On
    > </Directory>
    >
    > Because al the tutorials write this. But where?[/color]

    try put it at the end of your http.conf file.
    [color=blue]
    >
    > If I try to put the code some where,
    > apache give the following message by testing the configure:
    > Multiple <Directory> arguments not (yet) supported
    > But what i have to change or replace.[/color]

    just an idea, try:

    <Directory "C:\Program Files\Apache Group\Apache2\h tdocs\project">
    ....
    </Directory>

    because it sounds like apache parser gets confused
    with all those slashes.
    [color=blue]
    >
    > I test with the next file:
    >
    > C:\Program Files\Apache Group\Apache2\h tdocs\project\
    > mptest.py
    >
    > from mod_python import apache
    >
    > def handler(req):
    > req.content_typ e = 'text/plain'
    > req.send_http_h eader()
    > req.write('mpte st.py\n')
    > return apache.OK
    >
    > Is this code enough for testing?
    >[/color]

    i believe so.

    also check this:
    "Getting mod_python Working"
    <http://www.dscpl.com.a u/articles/modpython-001.html>

    --
    deelan <http://www.deelan.com/>




    Comment

    • Python_it

      #3
      Re: mod_python

      Thanks for your replay.
      I put the handler code at the end of the file.
      No error!
      But if I go to my localhost\proje ct\mptest.py
      The code of my function appears.
      I solve this by put the following code in the confige file:

      <Directory ..........>
      AllowOverride FileInfo
      </Directory>

      Comment

      • Peter

        #4
        Re: mod_python

        deelan wrote:
        [color=blue]
        >Python_it wrote:
        >(...)
        >
        >[color=green]
        >>But my problem is where I have to place te following code in de
        >>httpd.conf?
        >>
        >> <Directory C:\Program Files\Apache Group\Apache2\h tdocs\project\>
        >> AddHandler mod_python .py
        >> PythonHandler mptest
        >> PythonDebug On
        >> </Directory>
        >>
        >>Because al the tutorials write this. But where?
        >>
        >>[/color]
        >
        >try put it at the end of your http.conf file.
        >[color=green]
        > >
        > > If I try to put the code some where,
        > > apache give the following message by testing the configure:
        > > Multiple <Directory> arguments not (yet) supported
        > > But what i have to change or replace.[/color]
        >
        >
        >
        >just an idea, try:
        >
        ><Directory "C:\Program Files\Apache Group\Apache2\h tdocs\project">
        >...
        ></Directory>
        >
        >because it sounds like apache parser gets confused
        >with all those slashes.
        >
        >
        >[/color]
        I could be wrong, but i think i read something about apache expecting
        you to use forward slashes instead of backslashes when i was using
        windows...
        I seem to recall it being in the readme. ...?
        [color=blue][color=green]
        >>I test with the next file:
        >>
        >>C:\Program Files\Apache Group\Apache2\h tdocs\project\
        >>mptest.py
        >>
        >>from mod_python import apache
        >>
        >>def handler(req):
        >> req.content_typ e = 'text/plain'
        >> req.send_http_h eader()
        >> req.write('mpte st.py\n')
        >> return apache.OK
        >>
        >>Is this code enough for testing?
        >>
        >>
        >>[/color]
        >
        >i believe so.
        >
        >also check this:
        >"Getting mod_python Working"
        ><http://www.dscpl.com.a u/articles/modpython-001.html>
        >
        >
        >[/color]
        HTH,
        Peter

        Comment

        • Jim Gallacher

          #5
          Re: mod_python

          Python_it wrote:[color=blue]
          > Today I was busy to install mod_python.
          >
          > I have put the line
          >
          > LoadModule python_module libexec/mod_python.so
          >
          > into the httpd.conf file.
          > It Works!
          > Apache load mod_python /3.2.2.b Python2.4
          >
          > But my problem is where I have to place te following code in de
          > httpd.conf?
          >
          > <Directory C:\Program Files\Apache Group\Apache2\h tdocs\project\>
          > AddHandler mod_python .py
          > PythonHandler mptest
          > PythonDebug On
          > </Directory>
          >
          > Because al the tutorials write this. But where?
          >
          > If I try to put the code some where,
          > apache give the following message by testing the configure:
          > Multiple <Directory> arguments not (yet) supported
          > But what i have to change or replace.[/color]

          Your problem is not related to the location of the <Directory> section.
          Apache doesn't like spaces in <Directory>, so try quoting your path.
          Also, the Apache docs state that "forward slashes should always be used
          as the path separator in Apache, even for Windows".

          So try the following in your config file:
          <Directory "C:/Program Files/Apache Group/Apache2/htdocs/project/">.
          [color=blue]
          > I test with the next file:
          >
          > C:\Program Files\Apache Group\Apache2\h tdocs\project\
          > mptest.py
          >
          > from mod_python import apache
          >
          > def handler(req):
          > req.content_typ e = 'text/plain'
          > req.send_http_h eader()
          > req.write('mpte st.py\n')
          > return apache.OK
          >
          > Is this code enough for testing?
          >[/color]

          Yes.

          You are more likely to get timely help on the mod_python mailing list.
          See http://www.modpython.org/ for subscription information. Personally I
          only read c.l.p when I'm looking for cheap entertainment. Some people on
          this list just crack me up. :)

          Regards,
          Jim

          Comment

          Working...