Trying to PUT an updated blog not working

3 views
Skip to first unread message

sujit

unread,
Feb 15, 2009, 7:39:51 PM2/15/09
to GData Python Client Library Contributors
I saw a similar post which Ryan said was fixed, but I am still getting
it. I am using gdata.py-1.2.4.

Here is a trace from my console. I am trying to update a blog post
from the contents of a local text file (which contains well-formed
HTML which would be under a HTML body tag, ie the contents of the
entry element.

sujit@sirocco:~$ python
Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:56)
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gdata
>>> from gdata import service
>>> from gdata import atom
>>> bs = service.GDataService('my_email','my_pass')
>>> bs.source = 'mygdata-bloggerclient-0.1'
>>> bs.service='blogger'
>>> bs.account_type='GOOGLE'
>>> bs.server='www.blogger.com'
>>> bs.ProgrammaticLogin()
>>> q = service.Query()
>>> q.feed='/feeds/7583720/posts/default'
>>> q.published_min='2009-01-25T20:02:00.000-08:00'
>>> q.published_max='2009-01-25T20:03:00.000-08:00'
>>> q.max_results=1000
>>> feed = bs.Get(q.ToUri())
>>> feed.entry
[<gdata.GDataEntry object at 0x10866d0>]
>>> e = feed.entry[0]
>>> f = open('my_text_file','rb')
>>> ncontent = f.read()
>>> f.close()
>>> e.content = atom.Content('html',ncontent)
>>> bs.Put(e, '/feeds/7583720/posts/default/7439698622276152424')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/gdata/service.py", line 1304,
in Put
media_source=media_source, converter=converter)
File "/usr/lib/python2.5/site-packages/gdata/service.py", line 1267,
in PostOrPut
'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': '[Line 1336,
Column 17, element ns0:content] Malformed MIME type', 'reason': 'Bad
Request'}
>>>

Would appreciate some help with this.

Thanks very much,
Sujit

Jeff S

unread,
Feb 23, 2009, 9:12:30 PM2/23/09
to GData Python Client Library Contributors
Hi Sujit,

Could I see the content which you are sending? I imagine this is
probably a data formatting issue.

Thank you,

Jeff

Sujit Pal

unread,
Feb 24, 2009, 2:49:18 PM2/24/09
to gdata-python-client-...@googlegroups.com
Hi Jeff,

Thanks for your email, but I doubt that this is a data formatting issue,
because I was able to use the Java API to upload the file. Which also
means that its no longer a burning issue for me -- until the next time I
build another python client, that is.

Not sure if this will help, but in the iteration before this one, I
tried using libxml2 and httplib directly to do a PUT and it hung forever
(I thought maybe I wasn't giving it all info that it needed). So if you
are not able to replicate this problem, then it could be my httplib
thats broken.

Cant see a way to attach a file in here, but its the body of this post
(this was my test case):
http://sujitpal.blogspot.com/2009/01/scala-mock-interview-oo-design.html
(I've also sent the file as an attachment directly to your email
address).

What I was trying to do was to take all my pre blocks with code in it
and pass it through pygments to produce colorized output and stick it
back into the post. So the ncontent you see is being read from a file
whose pre blocks have been replaced by table blocks by pygments.

Thanks
Sujit
Reply all
Reply to author
Forward
0 new messages