You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Mongryong <Mo...@sympatico.ca> on 2003/01/21 05:52:10 UTC

Re: [4suite] 4Suite Reliance on ENVIRONMENT & global variables

Well, the new changes form the 4Suite CVS did not help.

Right now, I'm testing mod_python against a modified version of your "I
don't like spam" tutorial example.  It's attached with this email.  You
may try it out at http://rezquest.cjb.net/bin/main .  The correct result
should say "I hate spam" in an XML-aware browser (Mozilla1.0.1).

The strange thing is that if I directly output the XML source without
doing any XSLT processing, the XML source appears correctly.  Somewhere
along the line where the strings are being passed from the python
libraries to the 4Suite libraries (by Py_ParseArgs..???), the strings
are being 'miscommunicated'.  

Now, it might be a Python2.2.2 issue since libxml2/libxslt from the
gnome project are having similar problems as well.  

In 4Suite, do the apps embedd the python interpretor or do the apps
start purely from a python environment? 

It might be good to check to see whether this problem still occurs other
'python embedded' application (ie. uses Py_NewInterpretor from C). I
forget, does the command-line version of python dynamically link to the
python libraries?  If so, I wonder if the command-line version of python
is doing anything special or different when it links up and initializes
the python libraries.

I'm reposting this message on to the Python mailing list to see if
anybody there can help give us a clue.

P.S Has there been any changes in Python2.2.3+ that might possibly fix
this problem?

On Mon, 2003-01-20 at 22:28, Uche Ogbuji wrote:
> On Mon, 2003-01-20 at 14:52, Mongryong wrote:
> > Hi,
> > 
> > I'm having trouble getting the latest 4Suite XML/XSLT tools to work the
> > way I want in mod_python and I know I'm not the first one to experience
> > "out-of-the-box" success.  
> > 
> > I've determined that it's an encoding issue.   Now, with a stand-alone
> > script or CGI script under Apache, 4XSLT works fine.  But under
> > mod_python (which doesn't have access to ENVIRONMENT variables), 4XSLT
> > library decodes the XML source file in a total different encoding.  XSL
> > templates (ie. <xsl:template name="blah">) are never executed because
> > the XML tag is never recognized by the XSL processor.  Hence, you get an
> > empty output.
> > 
> > I've check the default system encoding codec and it returns 'ascii' (ie.
> > sys.getdefaultencoding).  Now, it could be that the python library
> > relies on some ENVIRONMENT variable for its configuration.
> > 
> > Anybody have any ideas what 'parameters' might not be initialized
> > properly under a non-CGI or non-shell environment such as mod_python? 
> > Or, is there a parameter that one can set to change the XML input
> > decoding?  
> 
> I don't think there is any environment variable that could affect this.
> 
> However, there have been a lot of fixes recently, including to some
> endianness bugs.  Do you mind trying again with latest 4Suite CVS and
> telling us if it helps?  Either wait till tomorrow's snapshot, or check
> out current CVS HEAD directly
> 
> http://4suite.org/docs/4SuiteCVS.xml
> 
> If it doesn't help, I hope you'll be able to help us work with you to
> find a solution for mod_python users.
> 
> -- 
> Uche Ogbuji                                    Fourthought, Inc.
> http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
> Python Generators + DOM - http://www.xml.com/pub/a/2003/01/08/py-xml.html
> 4Suite Repository Features - https://www6.software.ibm.com/reg/devworks/dw-x4suite5-i/
> XML class warfare - http://www.adtmag.com/article.asp?id=6965
> MusicBrainz  metadata - http://www-106.ibm.com/developerworks/xml/library/x-think14.html
> 


Re: [4suite] 4Suite Reliance on ENVIRONMENT & global variables

Posted by Mongryong <Mo...@sympatico.ca>.
Ok, I've modified my simple test script so that it can be easily started
from a shell (python main.py) as well as working with mod_python.

Again, here's the url to my server where you can view the mod_python
result: http://rezquest.cjb.net/bin/main

So, now the test outputs the XML source as just a string and as dom node
from NonvalidatingReader.

You should clearly see the difference between the standalone and
mod_python results.

On Tue, 2003-01-21 at 00:23, Michael Olson wrote:
> 
> > The strange thing is that if I directly output the XML source without
> > doing any XSLT processing, the XML source appears correctly.  Somewhere
> > along the line where the strings are being passed from the python
> > libraries to the 4Suite libraries (by Py_ParseArgs..???), the strings
> > are being 'miscommunicated'.
> >
> 
> By "output the XML source" do you mean just print it out (or fetch it 
> from the file system) ro do you mean parse it into DOM, and print it 
> out?
> 
> If not the later, can you try that instead of XSLT to see if this works.
> 
> Thanks
> Mike
> 
> > Now, it might be a Python2.2.2 issue since libxml2/libxslt from the
> > gnome project are having similar problems as well.
> >
> > In 4Suite, do the apps embedd the python interpretor or do the apps
> > start purely from a python environment?
> >
> > It might be good to check to see whether this problem still occurs 
> > other
> > 'python embedded' application (ie. uses Py_NewInterpretor from C). I
> > forget, does the command-line version of python dynamically link to the
> > python libraries?  If so, I wonder if the command-line version of 
> > python
> > is doing anything special or different when it links up and initializes
> > the python libraries.
> >
> > I'm reposting this message on to the Python mailing list to see if
> > anybody there can help give us a clue.
> >
> > P.S Has there been any changes in Python2.2.3+ that might possibly fix
> > this problem?
> >
> > On Mon, 2003-01-20 at 22:28, Uche Ogbuji wrote:
> >> On Mon, 2003-01-20 at 14:52, Mongryong wrote:
> >>> Hi,
> >>>
> >>> I'm having trouble getting the latest 4Suite XML/XSLT tools to work 
> >>> the
> >>> way I want in mod_python and I know I'm not the first one to 
> >>> experience
> >>> "out-of-the-box" success.
> >>>
> >>> I've determined that it's an encoding issue.   Now, with a 
> >>> stand-alone
> >>> script or CGI script under Apache, 4XSLT works fine.  But under
> >>> mod_python (which doesn't have access to ENVIRONMENT variables), 
> >>> 4XSLT
> >>> library decodes the XML source file in a total different encoding.  
> >>> XSL
> >>> templates (ie. <xsl:template name="blah">) are never executed because
> >>> the XML tag is never recognized by the XSL processor.  Hence, you 
> >>> get an
> >>> empty output.
> >>>
> >>> I've check the default system encoding codec and it returns 'ascii' 
> >>> (ie.
> >>> sys.getdefaultencoding).  Now, it could be that the python library
> >>> relies on some ENVIRONMENT variable for its configuration.
> >>>
> >>> Anybody have any ideas what 'parameters' might not be initialized
> >>> properly under a non-CGI or non-shell environment such as mod_python?
> >>> Or, is there a parameter that one can set to change the XML input
> >>> decoding?
> >>
> >> I don't think there is any environment variable that could affect 
> >> this.
> >>
> >> However, there have been a lot of fixes recently, including to some
> >> endianness bugs.  Do you mind trying again with latest 4Suite CVS and
> >> telling us if it helps?  Either wait till tomorrow's snapshot, or 
> >> check
> >> out current CVS HEAD directly
> >>
> >> http://4suite.org/docs/4SuiteCVS.xml
> >>
> >> If it doesn't help, I hope you'll be able to help us work with you to
> >> find a solution for mod_python users.
> >>
> >> -- 
> >> Uche Ogbuji                                    Fourthought, Inc.
> >> http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
> >> Python Generators + DOM - 
> >> http://www.xml.com/pub/a/2003/01/08/py-xml.html
> >> 4Suite Repository Features - 
> >> https://www6.software.ibm.com/reg/devworks/dw-x4suite5-i/
> >> XML class warfare - http://www.adtmag.com/article.asp?id=6965
> >> MusicBrainz  metadata - 
> >> http://www-106.ibm.com/developerworks/xml/library/x-think14.html
> >>
> >
> > <main.py>
> Mike Olson                                Principal Consultant
> mike.olson@fourthought.com                +1 303 583 9900 x 102
> Fourthought, Inc.                         http://Fourthought.com
> PO Box 270590,                            http://4Suite.org
> Louisville, CO 80027-5009, USA
> XML strategy, XML tools, knowledge management
> 
> _______________________________________________
> 4suite mailing list
> 4suite@lists.fourthought.com
> http://lists.fourthought.com/mailman/listinfo/4suite


Re: 3.0.2 has been tagged

Posted by Geert Jansen <ge...@boskant.nl>.
On Thu, Feb 27, 2003 at 11:51:47PM -0500, Gregory (Grisha) Trubetskoy wrote:
> 
> I've tagged what we have release-3-0-2. Please test it out and let me
> know. The simples way to do this is the usual ./configure ; make ; make
> install, then cd into test subdirectory and do "python test.py".

Hi Grisha,

I have been busy lately but tomorrow I'll check it out and see how it goes
with Draco. I'm getting lots of request of people that want to use it
with Apachew/mod_python3.

Greetings,
Geert

Re: 3.0.2 has been tagged

Posted by Geert Jansen <ge...@boskant.nl>.
On Sat, Mar 01, 2003 at 11:37:58PM -0500, Gregory (Grisha) Trubetskoy wrote:

Hi Grisha,

> I'll have to take a closer look at this, but in the context of 3.0.2
> release - I don't think this bug (if it is a bug) is a show stopper? Any
> opinions?

the bug is rather serious IMHO because it basically prevents you from using an
access handler... This is a rather large restriction.

Were you able to reproduce this bug using the configuration I included?

Greetings,
Geert

Re: 3.0.2 has been tagged

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
I'll have to take a closer look at this, but in the context of 3.0.2
release - I don't think this bug (if it is a bug) is a show stopper? Any
opinions?

Grisha

On Sat, 1 Mar 2003, Geert Jansen wrote:

> On Thu, Feb 27, 2003 at 11:51:47PM -0500, Gregory (Grisha) Trubetskoy wrote:
> >
> > I've tagged what we have release-3-0-2. Please test it out and let me
> > know. The simples way to do this is the usual ./configure ; make ; make
> > install, then cd into test subdirectory and do "python test.py".
>
> Hi Grisha,
>
> I just checked out 3.0.2 and is now almost works with Draco! There is one
> problem left: sometimes, headers that I set don't show up in the response. I
> investigated the problem further, and it seems that this only happens in the
> combination of the following circumstances:
>
> 1. The URL requested is a directory, which is mapped to a file using the
>    DirectoryIndex directive.
> 2. There is a PythonAccessHandler directive defined for the URL. It doesn't
>    seem to matter if the handler file actually defines a handler function.
>
> This is my configuration:
>
>   <Directory /home/www/test>
>     AddHandler python-program .py
>     PythonHandler mptest
>     PythonAccessHandler mptest
>     DirectoryIndex mptest.py
>   </Directory>
>
> This is my mptest.py program:
>
>   from mod_python import apache
>
>   def handler(req):
>       req.headers_out.add('Set-Cookie', 'blaat=test')
>       req.write('Hello, world!\n')
>       return apache.OK
>
> This shows that the Set-Cookie header is not part of the response:
>
>   geertj@cristina:~$ telnet cristina 8080
>   Trying 192.168.2.16...
>   Connected to cristina.
>   Escape character is '^]'.
>   GET / HTTP/1.0
>
>   HTTP/1.1 200 OK
>   Date: Sat, 01 Mar 2003 12:10:54 GMT
>   Server: Apache/2.0.44 (Unix) mod_ssl/2.0.44 OpenSSL/0.9.6g mod_python/3.0.2 Python/2.2.2
>   Connection: close
>   Content-Type: text/plain
>
>   Hello, world!
>   Connection closed by foreign host.
>
> I'll try to see if I can find the error. I thought I'd let you know of my
> findings asap so we can stilll fix this before 3.0.2.
>
> Greetings,
> Geert Jansen
>


Re: 3.0.2 has been tagged

Posted by Geert Jansen <ge...@boskant.nl>.
On Thu, Feb 27, 2003 at 11:51:47PM -0500, Gregory (Grisha) Trubetskoy wrote:
> 
> I've tagged what we have release-3-0-2. Please test it out and let me
> know. The simples way to do this is the usual ./configure ; make ; make
> install, then cd into test subdirectory and do "python test.py".

Hi Grisha,

I just checked out 3.0.2 and is now almost works with Draco! There is one
problem left: sometimes, headers that I set don't show up in the response. I
investigated the problem further, and it seems that this only happens in the
combination of the following circumstances:

1. The URL requested is a directory, which is mapped to a file using the
   DirectoryIndex directive.
2. There is a PythonAccessHandler directive defined for the URL. It doesn't
   seem to matter if the handler file actually defines a handler function.

This is my configuration:

  <Directory /home/www/test>
    AddHandler python-program .py
    PythonHandler mptest
    PythonAccessHandler mptest
    DirectoryIndex mptest.py
  </Directory>

This is my mptest.py program:

  from mod_python import apache

  def handler(req):
      req.headers_out.add('Set-Cookie', 'blaat=test')
      req.write('Hello, world!\n')
      return apache.OK

This shows that the Set-Cookie header is not part of the response:

  geertj@cristina:~$ telnet cristina 8080
  Trying 192.168.2.16...
  Connected to cristina.
  Escape character is '^]'.
  GET / HTTP/1.0

  HTTP/1.1 200 OK
  Date: Sat, 01 Mar 2003 12:10:54 GMT
  Server: Apache/2.0.44 (Unix) mod_ssl/2.0.44 OpenSSL/0.9.6g mod_python/3.0.2 Python/2.2.2
  Connection: close
  Content-Type: text/plain

  Hello, world!
  Connection closed by foreign host.

I'll try to see if I can find the error. I thought I'd let you know of my
findings asap so we can stilll fix this before 3.0.2.

Greetings,
Geert Jansen

3.0.2 has been tagged

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
I've tagged what we have release-3-0-2. Please test it out and let me
know. The simples way to do this is the usual ./configure ; make ; make
install, then cd into test subdirectory and do "python test.py".

Grisha


Re: 3.0.2 ?

Posted by Geert Jansen <ge...@boskant.nl>.
On Sat, Jan 25, 2003 at 11:40:54PM -0500, Gregory (Grisha) Trubetskoy wrote:

Hi Grisha,

> > - server.port is always 0
> 
> This is because it really is 0 in the underlying C structure. I'm not sure
> why, but I added a note in the docs that connection.local_addr will give
> you the port number if you need it.

Ok, I see.

> > - `None' is inserted in sys.path. This break a lot of code from the standard
> >   library.
> 
> Could you elaborate on this one? I don't remember it for whatever reason.

I investigated the problem a bit more and it seems to occur only when a
Python*Handler directive is given outside a <Directory> context, e.g.
directly inside a <VirtualHost>. I figured it should be possible to import
global python modules this way. The mod_python docs seem to allow this.

I put the code fragment below in a global python module name "mptest.py":

import sys
from mod_python import apache

def handler(req):
    req.write('PATH: %s' % repr(sys.path))
    return apache.OK

And then I put a directive "PythonHandler mptest" in the <VirtualHost>
section of my apache config. The output is:

PATH: [None, '/usr/local/lib/python2.2',
'/usr/local/lib/python2.2/plat-linux2','/usr/local/lib/python2.2/lib-tk',
'/usr/local/lib/python2.2/lib-dynload',
'/usr/local/lib/python2.2/site-packages',
'/usr/local/lib/python2.2/site-packages/numarray']

When I put the "PythonHandler" mptest in a <Directory> context, and put the
file "mptest.py" in that directory, the problem does not occur. The output
is:

PATH: ['/home/www/test/', '/usr/local/lib/python2.2',
'/usr/local/lib/python2.2/plat-linux2', '/usr /local/lib/python2.2/lib-tk',
'/usr/local/lib/python2.2/lib-dynload',
'/usr/local/lib/python2.2/site-packages',
'/usr/local/lib/python2.2/site-packages/numarray']

I hope this will help you track down the problem.

Greetings,
Geert Jansen

Re: 3.0.2 ?

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
On Sat, 25 Jan 2003, Geert Jansen wrote:

> - request.headers_out doesn't seem to work. Headers added to this table never
>   make it into the request.

I added a test to the test suite, and it seems to work fine, I can see the
headers in the output.

Are you sure that there is no error? (If there is an error, i.e. your
handler returns something other than apache.OK, then the
req.err_headers_out are used instead of req.headers_out)

And, of course, make sure that you change the table before the first byte
of output has been written.

Grisha


Re: 3.0.2 ?

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
On Sat, 25 Jan 2003, Geert Jansen wrote:

> I just checked the current CVS version and there are still some bugs left:
>
> - server.port is always 0

This is because it really is 0 in the underlying C structure. I'm not sure
why, but I added a note in the docs that connection.local_addr will give
you the port number if you need it.

> - `None' is inserted in sys.path. This break a lot of code from the standard
>   library.

Could you elaborate on this one? I don't remember it for whatever reason.

> - request.headers_out doesn't seem to work. Headers added to this table never
>   make it into the request.

Interesting, I'll have to test this.

Grisha


Re: 3.0.2 ?

Posted by Geert Jansen <ge...@boskant.nl>.
On Wed, Jan 22, 2003 at 11:25:33PM -0500, Gregory (Grisha) Trubetskoy wrote:
> 
> I think I've got all the problems reported so far fixed, there is more
> details in the NEWS file, plus we have a distutils based windows
> installer.
> 
> Anyone have any objections to tagging what's currently there 3.0.2?

I just checked the current CVS version and there are still some bugs left:

- server.port is always 0
- `None' is inserted in sys.path. This break a lot of code from the standard
  library.
- request.headers_out doesn't seem to work. Headers added to this table never
  make it into the request.

Greetings,
Geert Jansen

Re: 3.0.2 ?

Posted by Justin Erenkrantz <je...@apache.org>.
--On Wednesday, January 22, 2003 23:25:33 -0500 "Gregory (Grisha) 
Trubetskoy" <gr...@apache.org> wrote:

> I think I've got all the problems reported so far fixed, there is more
> details in the NEWS file, plus we have a distutils based windows
> installer.
>
> Anyone have any objections to tagging what's currently there 3.0.2?

Nope.

The only thing is that this time I'd like to ensure that there are 3 +1s on 
this list for a release (after you post a suitable release candidate). 
Since there are only three committers, I'd be satisfied if we just get 3 
recorded +1s.

This sort of follows the HTTP Server guidelines:

http://httpd.apache.org/dev/release.html

Not all of it applies to mod_python, but it gives you a general idea of the 
policies.  If you have any questions, please holler.

And, I'd also like to see you point at our mirrors in the 
announcements/website rather than directly at /dist/httpd/.  =)  -- justin

3.0.2 ?

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
I think I've got all the problems reported so far fixed, there is more
details in the NEWS file, plus we have a distutils based windows
installer.

Anyone have any objections to tagging what's currently there 3.0.2?

Grisha


Re: [4suite] 4Suite Reliance on ENVIRONMENT & global variables

Posted by Michael Olson <Mi...@fourthought.com>.
> The strange thing is that if I directly output the XML source without
> doing any XSLT processing, the XML source appears correctly.  Somewhere
> along the line where the strings are being passed from the python
> libraries to the 4Suite libraries (by Py_ParseArgs..???), the strings
> are being 'miscommunicated'.
>

By "output the XML source" do you mean just print it out (or fetch it 
from the file system) ro do you mean parse it into DOM, and print it 
out?

If not the later, can you try that instead of XSLT to see if this works.

Thanks
Mike

> Now, it might be a Python2.2.2 issue since libxml2/libxslt from the
> gnome project are having similar problems as well.
>
> In 4Suite, do the apps embedd the python interpretor or do the apps
> start purely from a python environment?
>
> It might be good to check to see whether this problem still occurs 
> other
> 'python embedded' application (ie. uses Py_NewInterpretor from C). I
> forget, does the command-line version of python dynamically link to the
> python libraries?  If so, I wonder if the command-line version of 
> python
> is doing anything special or different when it links up and initializes
> the python libraries.
>
> I'm reposting this message on to the Python mailing list to see if
> anybody there can help give us a clue.
>
> P.S Has there been any changes in Python2.2.3+ that might possibly fix
> this problem?
>
> On Mon, 2003-01-20 at 22:28, Uche Ogbuji wrote:
>> On Mon, 2003-01-20 at 14:52, Mongryong wrote:
>>> Hi,
>>>
>>> I'm having trouble getting the latest 4Suite XML/XSLT tools to work 
>>> the
>>> way I want in mod_python and I know I'm not the first one to 
>>> experience
>>> "out-of-the-box" success.
>>>
>>> I've determined that it's an encoding issue.   Now, with a 
>>> stand-alone
>>> script or CGI script under Apache, 4XSLT works fine.  But under
>>> mod_python (which doesn't have access to ENVIRONMENT variables), 
>>> 4XSLT
>>> library decodes the XML source file in a total different encoding.  
>>> XSL
>>> templates (ie. <xsl:template name="blah">) are never executed because
>>> the XML tag is never recognized by the XSL processor.  Hence, you 
>>> get an
>>> empty output.
>>>
>>> I've check the default system encoding codec and it returns 'ascii' 
>>> (ie.
>>> sys.getdefaultencoding).  Now, it could be that the python library
>>> relies on some ENVIRONMENT variable for its configuration.
>>>
>>> Anybody have any ideas what 'parameters' might not be initialized
>>> properly under a non-CGI or non-shell environment such as mod_python?
>>> Or, is there a parameter that one can set to change the XML input
>>> decoding?
>>
>> I don't think there is any environment variable that could affect 
>> this.
>>
>> However, there have been a lot of fixes recently, including to some
>> endianness bugs.  Do you mind trying again with latest 4Suite CVS and
>> telling us if it helps?  Either wait till tomorrow's snapshot, or 
>> check
>> out current CVS HEAD directly
>>
>> http://4suite.org/docs/4SuiteCVS.xml
>>
>> If it doesn't help, I hope you'll be able to help us work with you to
>> find a solution for mod_python users.
>>
>> -- 
>> Uche Ogbuji                                    Fourthought, Inc.
>> http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
>> Python Generators + DOM - 
>> http://www.xml.com/pub/a/2003/01/08/py-xml.html
>> 4Suite Repository Features - 
>> https://www6.software.ibm.com/reg/devworks/dw-x4suite5-i/
>> XML class warfare - http://www.adtmag.com/article.asp?id=6965
>> MusicBrainz  metadata - 
>> http://www-106.ibm.com/developerworks/xml/library/x-think14.html
>>
>
> <main.py>
Mike Olson                                Principal Consultant
mike.olson@fourthought.com                +1 303 583 9900 x 102
Fourthought, Inc.                         http://Fourthought.com
PO Box 270590,                            http://4Suite.org
Louisville, CO 80027-5009, USA
XML strategy, XML tools, knowledge management