Update mini Twitter example in package docs

This commit is contained in:
Mark Paschal 2009-08-24 14:34:22 -07:00
Родитель 69d1da030d
Коммит f0fcd3f460
3 изменённых файлов: 20 добавлений и 16 удалений

Просмотреть файл

@ -22,24 +22,22 @@ Example
For example, you can build a simplified Twitter API library in the shell::
>>> from remoteobjects import RemoteObject, fields
>>> class Tweeter(remoteobjects.RemoteObject):
>>> from remoteobjects import RemoteObject, fields, ListObject
>>> class Tweeter(RemoteObject):
... name = fields.Field()
... screen_name = fields.Field()
... location = fields.Field()
...
>>> class Tweet(remoteobjects.RemoteObject):
>>> class Tweet(RemoteObject):
... text = fields.Field()
... source = fields.Field()
... tweeter = fields.Object(Tweeter, api_name='user')
...
>>> class Timeline(remoteobjects.ListObject):
>>> class Timeline(ListObject):
... entries = fields.List(fields.Object(Tweet))
... def update_from_dict(self, data):
... super(Timeline, self).update_from_dict({'entries': data})
...
>>> t = Timeline.get('http://twitter.com/statuses/public_timeline.json')
>>> [tweet.tweeter.screen_name for tweet in t.entries[0:3]]
>>> tweets = Timeline.get('http://twitter.com/statuses/public_timeline.json')
>>> [t.tweeter.screen_name for t in tweets.entries[0:3]]
['eddeaux', 'CurtisLilly', '8email8']

8
doc/readme_from_docstring.py Executable file
Просмотреть файл

@ -0,0 +1,8 @@
#!/usr/bin/env python
import remoteobjects
readme = file('README.rst', 'w')
readme.write(remoteobjects.__doc__.strip())
readme.write("\n")
readme.close()

Просмотреть файл

@ -24,24 +24,22 @@ Example
For example, you can build a simplified Twitter API library in the shell::
>>> from remoteobjects import RemoteObject, fields
>>> class Tweeter(remoteobjects.RemoteObject):
>>> from remoteobjects import RemoteObject, fields, ListObject
>>> class Tweeter(RemoteObject):
... name = fields.Field()
... screen_name = fields.Field()
... location = fields.Field()
...
>>> class Tweet(remoteobjects.RemoteObject):
>>> class Tweet(RemoteObject):
... text = fields.Field()
... source = fields.Field()
... tweeter = fields.Object(Tweeter, api_name='user')
...
>>> class Timeline(remoteobjects.ListObject):
>>> class Timeline(ListObject):
... entries = fields.List(fields.Object(Tweet))
... def update_from_dict(self, data):
... super(Timeline, self).update_from_dict({'entries': data})
...
>>> t = Timeline.get('http://twitter.com/statuses/public_timeline.json')
>>> [tweet.tweeter.screen_name for tweet in t.entries[0:3]]
>>> tweets = Timeline.get('http://twitter.com/statuses/public_timeline.json')
>>> [t.tweeter.screen_name for t in tweets.entries[0:3]]
['eddeaux', 'CurtisLilly', '8email8']