[mod_python] problem with publisher.py File class w/ possible fix

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon May 14 17:25:07 EST 2001


Marc -

Do you have any more details so I could reproduce this error? I am having
a hard time understanding why it would insist on m being an integer.
Perhaps you have the piece of code that caused it?

Grisha


On Wed, 21 Mar 2001, Marc Fiuczynski wrote:

> Hi,
>
> I am having a problem with the publisher.py File class, which I have fixed,
> but I would like your approval.
>
> My configuration is as follows:
> mod_python 2.7.2
> python 2.0
> apache 1.3.14
> Red Hat Linux 7.0
>
> I am using mod python to do http_post operations with files.  This uses the
> publisher.py File class.  The __init__ method of that class steals all of
> the file-like methods, as shown below:
>
>         # steal all the file-like methods
>         methods = field.file.__methods__
>         for m in methods:
>             self.__dict__[m] = methods[m]
>
> I was getting an error in that last line saying that 'm' needed to be an
> int.  (Sorry, I forget the actual error).  I found some other code that was
> doing the exact same thing and noticed that they were assigning the methods
> in a different manner (using setattr).  See below:
>
>         # steal all the file-like methods
>         file = field.file
>         for method in file.__methods__:
>             setattr(self, method, getattr(file, method))
>
> This seems to work.  I am too nascent to Python to understand the history of
> the built-in __xyz__ fields in objects, and whether this is something
> specific to Python 2.0 versus an older version of Python.  Please review and
> if it is the right thing, then feel free to incorporate this change into
> your mod_python code base.
>
> Cheers,
> Marc
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
>




More information about the Mod_python mailing list