|
Alberto Ruiz
el_z0rr07 at yahoo.com
Tue Apr 4 17:06:32 EDT 2006
I see.
I also tried the following that I found on a newsgroup and it also worked:
class File:
""" Like a file, but also has headers and filename
"""
def sim_methods(self, obj):
return filter(lambda s, t=obj:
type(getattr(t, s)) == BuiltinMethodType, dir(obj))
def __init__(self, field):
# steal all the file-like methods
#for m in field.file.__methods__:
# self.__dict__[m] = getattr(field.file, m)
for m in self.sim_methods(field.file):
self.__dict__[m] = getattr(field.file, m)
self.headers = field.headers
self.filename = field.filename
Thanks again for all your help. I really impressed on how quickly you guys respond.
Graham Dumpleton <grahamd at dscpl.com.au> wrote: Instead of:
for k in field.file.__dict__:
try:
for k in dir(field.file):
Grahamd
On 04/04/2006, at 11:25 PM, Alberto Ruiz wrote:
> Ok I modified the publisher.py code but I got the following:
>
> Traceback (most recent call last):
>
> File "/usr/local/lib/python2.4/site-packages/mod_python/
> apache.py", line 193, in Dispatch
> result = object(req)
>
> File "/usr/local/lib/python2.4/site-packages/mod_python/
> publisher.py", line 106, in handler
> val = File(field)
>
> File "/usr/local/lib/python2.4/site-packages/mod_python/
> publisher.py", line 324, in __init__
> for k in field.file.__dict__:
>
> AttributeError: 'file' object has no attribute '__dict__'
>
>
> So __dict__ is also not supported on newer versions of Python? It
> doesn't make sense. I just did the following edit:
>
> class File:
> """ Like a file, but also has headers and filename
> """
>
> def __init__(self, field):
>
> # steal all the file-like methods
> #for m in field.file.__methods__:
> # self.__dict__[m] = getattr(field.file, m)
> for k in field.file.__dict__:
> if k[:2] != '__':
> v = getattr(field.file, k)
> if callable(v):
> self.__dict__[k] = v
>
> self.headers = field.headers
> self.filename = field.filename
>
>
> Graham Dumpleton wrote: See mailing list
> archives. There were two responses.
>
> http://www.modpython.org/pipermail/mod_python/2006-April/020756.html
> http://www.modpython.org/pipermail/mod_python/2006-April/020757.html
>
> Graham
>
> Alberto Ruiz wrote ..
> > I apologyze for sending this email again, but my server is under
> a DDOS
> > attack and I'm not sure if this email went through. If it did can
> somebody
> > please forward me or post the replies again. I had to subscribe
> again
> > to the mailing list with a different account. Thanks.
> >
> > Like I mentioned in earlier threads, this code used to work in a
> Debian
> > system, but now it doesn't work on FreeBSD with modpython 2.7.11.
> > I'm getting the following error.
> >
> > Mod_python error: "PythonHandler mod_python.publisher"
> >
> > Traceback (most recent call last):
> >
> > File "/usr/local/lib/python2.4/site-packages/mod_python/apache.py",
> > line 193, in Dispatch
> > result = object(req)
> >
> > File "/usr/local/lib/python2.4/site-packages/mod_python/
> publisher.py",
> > line 106, in handler
> > val = File(field)
> >
> > File "/usr/local/lib/python2.4/site-packages/mod_python/
> publisher.py",
> > line 322, in __init__
> > for m in field.file.__methods__:
> >
> > AttributeError: 'file' object has no attribute '__methods__'
> >
> >
> >
> > It is hard to pin point the problem, since it doesn't show where
> in my
> > code is happening. But my guess is that it is somewhere in this code
> > snippet:
> >
> > for p in photo:
> > phpath='/data/webroot/propman/propphotos/'
> > F= open(phpath+str("tempprop"+id+"-"+p.name[-1:]+p.filename
> [-4:]),'wb')
> > F.write(p.file.read())
> > F.flush()
> > os.system("convert "+phpath+str("tempprop"+id
> > +"-"+p.name[-1:]+p.filename[-4:])+" -resize 400x300 "+phpath
> > +""+str("prop"+id+"-"+p.name[-1:]+p.filename[-4:]))
> > com="convert "+phpath+str("tempprop"+id
> > +"-"+p.name[-1:]+p.filename[-4:])+" -resize 80x60 "+phpath
> > +"thm"+str("prop"+id+"-"+p.name[-1:]+p.filename[-4:])
> > R.write("\n\n"+com+"\n\n")
> > os.system(com)
> > if p.name[-1:]=="1":
> > com="convert "+phpath+str("tempprop"+id
> > +"-"+p.name[-1:]+p.filename[-4:])+" -resize 220x165\! "+phpath
> > +"bthm"+str("prop"+id+"-"+p.name[-1:]+p.filename[-4:])
> > R.write("\n\n"+com+"\n\n")
> > os.system(com)
> >
> > Sorry about the indentation, it got missed up while pasting in the
> > email.
> >
> > My guess is in 'p.file.read()
> >
> > How do I implemented for 2.7.11? or do I need to configure my Apache
> > conf file.
> >
> >
> >
> > ---------------------------------
> > Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously
> low rates.
>
>
> How low will we go? Check out Yahoo! Messengers low PC-to-Phone
> call rates.
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060404/b0eae54b/attachment.html
|