<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>hi all</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>i m very new to python.. but i m very much interested in learnin this laguage.. i have worked only on C.. so kindly suggest from where should i start learnin.. i want to do some small projects using python.. please help me with this..<BR><BR>--- On <B>Thu, 6/11/08, Praveen Kumar <I><praveen@mahiti.org></I></B> wrote:<BR></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">From: Praveen Kumar <praveen@mahiti.org><BR>Subject: [BangPypers] file save from python script<BR>To: "Python Community" <bangpypers@python.org><BR>Date: Thursday, 6 November, 2008, 4:50 PM<BR><BR>
<DIV id=yiv1660907544>Dear all,<BR>I want to save the file on filebased system. i am using urllib<BR><BR>here i tried with this code<BR><BR><B>import urllib<BR><BR># fill these in<BR>user='admin'<BR>password='admin1'<BR>addfileurl='<A href="http://localhost:8080/starinstance/bin/manage_addFile" target=_blank rel=nofollow>http://localhost:8080/starinstance/bin/manage_addFile</A>'<BR>useragent="upload.py/0.1"<BR>filename='/home/praveen/Desktop/text.jpeg'<BR>filetitle='a nice test picture'<BR><BR>class <SPAN style="COLOR: rgb(0,102,0)">MyUrlOpener</SPAN>(<SPAN style="COLOR: rgb(0,0,153)">urllib.FancyURLopener</SPAN>):<BR> def prompt_user_passwd(self, host, realm):<BR> return (user,password)<BR> def __init__(self, *args):<BR> self.version = useragent<BR> <SPAN style="COLOR: rgb(0,102,0)">urllib.FancyURLopener.__init__(self, *args)</SPAN><BR><BR>def main():<BR>
# use authentication and set the user agent<BR> urllib._urlopener = MyUrlOpener()<BR><BR> # read the contents of filename into filebody<BR> f=open(filename)<BR> filebody=f.read()<BR> f.close<BR><BR> # urlencode the id, title and file<BR> params = urllib.urlencode({'id': filename,<BR> 'title':filetitle,<BR> 'file':filebody})<BR><BR> # send the file to zope<BR> f=urllib.urlopen(addfileurl, params)<BR><BR>if __name__ == '__main__':<BR> main()</B><BR><BR>when i compile this file with simple python demo.py it gives me error<BR>Traceback (most recent call last):<BR> File "demo.py", line 36, in ?<BR> main()<BR> File
"demo.py", line 33, in main<BR> f=urllib.urlopen(addfileurl, params)<BR> File "/usr/lib/python2.4/urllib.py", line 84, in urlopen<BR> return opener.open(url, data)<BR> File "/usr/lib/python2.4/urllib.py", line 192, in open<BR> return getattr(self, name)(url, data)<BR> File "/usr/lib/python2.4/urllib..py", line 272, in open_http<BR> import httplib<BR> File "/usr/lib/python2.4/httplib.py", line 70, in ?<BR> import mimetools<BR> File "/usr/lib/python2.4/mimetools.py", line 6, in ?<BR> import tempfile<BR> File "/usr/lib/python2..4/tempfile.py", line 33, in ?<BR> from random import Random as _Random<BR> File "/usr/lib/python2.4/random.py", line 43, in ?<BR> from math import log as _log, exp as _exp, pi as _pi, e as _e<BR>ImportError: /usr/lib/python2.4/lib-dynload/math.so:
undefined symbol: PyFPE_jbuf<BR><BR>so i compiled with this command <B style="COLOR: rgb(153,0,0)">python2.4 demo.py</B> it does not give any error<BR>but it does not give me output to when i check my directory where i am trying to save my jpeg file <B><A href="http://localhost:8080/starinstance/bin/manage_addFile" target=_blank rel=nofollow>http://localhost:8080/starinstance/bin/manage_addFile</A> </B>there i do not find that file it means it is not able to store that file.<BR><BR>i do not know what i am trying to do..could any one please give me idea how may i store the file on file system.<BR>i created a html page<BR> <form name="demo" method="post" ENCTYPE="multipart/form-data" ACTION=""><BR> <fieldset style="width:20%"><BR><BR> Id:<input type="text" name="title" id="title"/><br><br><BR>
Name:<input type="text" name="name" id="name"/><br><br><BR> Keywords:<input type="text" name="keywords" id="keywords"/><br><br><BR> <input type="file" name="upload" id="upload"/><br><br><BR> <input type="submit" name="submit" value="Save" id="submit"/><br><BR> </fieldset><BR> </form><BR>once if user select any file it should store to specific location <B><A href="http://localhost:8080/starinstance/bin/manage_addFile" target=_blank rel=nofollow>http://localhost:8080/starinstance/bin/manage_addFile</A><BR><BR></B>Any suggestion will be appreciable<BR><BR>Thanks.<BR>-- <BR>Praveen Kumar<BR>Software Engineer<BR>Mahiti Infotech Pvt. Ltd.<BR># 33-34, Hennur Cross<BR>Hennur Main Road<BR>Bangalore, India -
560043<BR>Mobile: +91 9343297314<BR> +91 9739854134<BR><A href="http://www.mahiti.org/" target=_blank rel=nofollow>http://www.mahiti.org</A><BR><BR></DIV><PRE>_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers
</PRE></BLOCKQUOTE></td></tr></table><br>
<!--6--><hr size=1></hr> Add more friends to your messenger and enjoy! <a href="http://in.rd.yahoo.com/tagline_messenger_6/*http://messenger.yahoo.com/invite/"> Invite them now.</a>