[maemo-users] micro blogging from nokia tablets

From: Jayesh Salvi jayesh at altfrequency.com
Date: Wed Jan 9 05:53:13 EET 2008
On 1/8/08, Daniel Martin Yerga <dyerga at gmail.com> wrote:
> Hash: SHA1
> On Mon, 7 Jan 2008 22:26:26 -0800
> "Jayesh Salvi" <jayesh at altfrequency.com> wrote:
> > Thanks. maemo-wordpy looks like a great software. Maybe I should make
> > a patch for it to add blogger.com backend.
> Thanks.
> I had thought to add support for other blogging systems, among them
> blogger.com, in future versions. But if you can do a patch for blogger
> it will be welcome, of course.
> In the SVN is the most updated version it still has some bugs. It
> has only few comments, so if you have some question you don't
> hesitate to do it.

Hey Daniel,

I looked at the maemo-wordpy source code.  It is pretty big for me to go
through and patch. Comparatively the blogger.com specific code is extremely

In fact I will paste in this email the source code that will get it working.
It is so small, because the GData library is packaged separately. I have
created the .deb installable for it and you can find it

Assuming that above library is installed all you need is following class

  from xml.etree import ElementTree # for Python 2.5 users
  from elementtree import ElementTree

from gdata import service
import gdata
import atom

class Blogger:

  def __init__(self, email, password):
    """Creates a GDataService and provides ClientLogin auth details to it.
    The email and password are required arguments for ClientLogin.  The
    'source' defined below is an arbitrary string, but should be used to
    reference your name or the name of your organization, the app name and
    version, with '-' between each of the three values."""

    # Authenticate using ClientLogin.
    self.service = service.GDataService(email, password)
    self.service.source = 'Blogger_Python_Sample-1.0'
    self.service.service = 'blogger'
    self.service.server = 'www.blogger.com'

    # Get the blog ID for the first blog.
    feed = self.service.Get('/feeds/default/blogs')
    self_link = feed.entry[0].GetSelfLink()
    if self_link:
      self.blog_id = self_link.href.split('/')[-1]

  def CreatePost(self, title, content, author_name, is_draft):
    """This method creates a new post on a blog.  The new post can be stored
    a draft or published based on the value of the is_draft parameter.  The
    method creates an GDataEntry for the new post using the title, content,
    author_name and is_draft parameters.  With is_draft, True saves the post
    a draft, while False publishes the post.  Then it uses the given
    GDataService to insert the new post.  If the insertion is successful,
    added post (GDataEntry) will be returned.

    # Create the entry to insert.
    entry = gdata.GDataEntry()
    entry.title = atom.Title(title_type='xhtml', text=title)
    entry.content = atom.Content(content_type='html', text=content)
    if is_draft:
      control = atom.Control()
      control.draft = atom.Draft(text='yes')
      entry.control = control

    # Ask the service to insert the new entry.
    return self.service.Post(entry,
      '/feeds/' + self.blog_id + '/posts/default')

if __name__ == '__main__':
        blogger = Blogger(username,password)
        content = 'Here goes the blog's content'
        title = 'Title'
        post = blogger.CreatePost(title,content,username,is_draft=False)

        if post:
            print  post.title.text


The above example will just post on blog. If you want to do other things
like list all posts, comments, etc., then you can take a look at this

Hope that helps. Let me know if you need any other help.


The SVN version needs flickrapi, for some flickr options, but
> commenting these lines it can work without flickrapi (except the flickr
> part).
> Also in chinook it needs python-gtkhtml that it's in the garage
> (https://garage.maemo.org/projects/python-gtkhtml2/) or in the
> extras-devel repository.
> Best Regards.
> - --
> Daniel Martin Yerga
> http://yerga.net
> Version: GnuPG v1.4.6 (GNU/Linux)
> iD8DBQFHg59PcnvB1T3xmfMRAlwNAJ4hXzjLhPiOgEnJ0z2dfuKCjNgR/QCfQPfs
> DJ1Jr0mZamtocCJnjRDZ1yo=
> =6n8l

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maemo.org/pipermail/maemo-users/attachments/20080108/0c4a525e/attachment.htm 
More information about the maemo-users mailing list