Hello Praween Kumar - 
I would make a pythonscript on the zope 
like'locahost:8080/starinstance/myscript', taking 3 parameters, id, titleand 
file.
remember to give it manager proxy rights (proxy in top of python scriptedit 
screen, chose manager)
script should be something like:
"""
container['bin'].manage_addFile(id=id, title=title, file=file)
"""
I havent tested, sorry;-), but at least the direction should besomething like 
this.
then change addfileurl to:

addfileurl='http://localhost:8080/starinstance/myscript'

kind regards jorgen / denmark


Praveen Kumar wrote:Dear all,
I want to save the file on filebased system. i am using urllib
  
here i tried with this code
  
  import urllib
  
# fill these in
user='admin'
password='admin1'
addfileurl='http://localhost:8080/starinstance/bin/manage_addFile'
useragent="upload.py/0.1"
filename='/home/praveen/Desktop/text.jpeg'
filetitle='a nice test picture'
  
class MyUrlOpener(urllib.FancyURLopener):
   def prompt_user_passwd(self, host, realm):
        return (user,password)
   def __init__(self, *args):
      self.version = useragent
      urllib.FancyURLopener.__init__(self,*args)
  
def main():
       # use authentication and set the user agent
       urllib._urlopener = MyUrlOpener()
  
       # read the contents of filename into filebody
       f=open(filename)
       filebody=f.read()
       f.close
  
       # urlencode the id, title and file
       params = urllib.urlencode({'id': filename,
       'title':filetitle,
       'file':filebody})
  
       # send the file to zope
       f=urllib.urlopen(addfileurl, params)
  
if __name__ == '__main__':
   main()
  
when i compile this file with simple python demo.py it gives me error
Traceback (most recent call last):
  File "demo.py", line 36, in ?
    main()
  File "demo.py", line 33, in main
    f=urllib.urlopen(addfileurl, params)
  File "/usr/lib/python2.4/urllib.py", line 84, in urlopen
    return opener.open(url, data)
  File "/usr/lib/python2.4/urllib.py", line 192, in open
    return getattr(self, name)(url, data)
  File "/usr/lib/python2.4/urllib.py", line 272, in open_http
    import httplib
  File "/usr/lib/python2.4/httplib.py", line 70, in ?
    import mimetools
  File "/usr/lib/python2.4/mimetools.py", line 6, in ?
    import tempfile
  File "/usr/lib/python2.4/tempfile.py", line 33, in ?
    from random import Random as _Random
  File "/usr/lib/python2.4/random.py", line 43, in ?
    from math import log as _log, exp as _exp, pi as _pi, e as _e
ImportError: /usr/lib/python2.4/lib-dynload/math.so: undefined symbol:PyFPE_jbuf
  
so i compiled with this command python2.4demo.py it does not give any error
but it does not give me output to when i check my directory where i amtrying to 
save my jpeg file http://localhost:8080/starinstance/bin/manage_addFile  there 
i do not find that file it means it is not able to storethat file.
  
i do not know what i am trying to do..could any one please give me ideahow may 
i store the file on file system.
i created a html page
     <form name="demo" method="post" ENCTYPE="multipart/form-data"ACTION="">
    <fieldset style="width:20%">
  
        Id:<input type="text" name="title"id="title"/><br><br>
        Name:<input type="text" name="name"id="name"/><br><br>
        Keywords:<input type="text" name="keywords"id="keywords"/><br><br>
        <input type="file" name="upload"id="upload"/><br><br>
        <input type="submit" name="submit" value="Save"id="submit"/><br>
    </fieldset>
     </form>
once if user select any file it should store to specific location 
http://localhost:8080/starinstance/bin/manage_addFile
  
  Any suggestion will be appreciable
  
Thanks.
-- 
Praveen Kumar
Software Engineer
Mahiti Infotech Pvt. Ltd.
# 33-34, Hennur Cross
Hennur Main Road
Bangalore, India - 560043
Mobile:  +91 9343297314
            +91 9739854134
  http://www.mahiti.org
  
  

---------------------------------
_______________________________________________BangPypers mailing [EMAIL 
PROTECTED]://mail.python.org/mailman/listinfo/bangpypers  

       
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to