Manual updated for posting and stream
[diaspy.git] / manual / stream.mdown
CommitLineData
7a31b4aa
MM
1#### `Stream()` object
2
3This object is used to represent user's stream on D\*.
4It is returned by `Client()`'s method `get_stream()` and
8b013ef4 5is basically a list of posts.
7a31b4aa
MM
6
7----
8
9##### Getting stream
10
11To get basic stream you have to have working `Connection()` as
12this is required by `Stream()`'s constructor.
13
14 c = diaspy.connection.Connection(pod='https://pod.example.com',
15 username='foo',
16 password='bar')
17 c.login()
18 stream = diaspy.models.Stream(c)
19
20Now you have a stream filled with posts (if any can be found on user's stream).
21
22----
23
cdbe5f4e
MM
24##### `fill()` and `update()`
25
26When you want to refresh stream call it's `fill()` method. It will overwrite old stream
27contents.
28
29On the contrary, `update()` will get a new stream but will not overwrite old stream saved
30in the object memory. It will append every new post to the old stream.
31
32----
33
34##### Length of and iterating over a stream
7a31b4aa
MM
35
36Stream's length can be checked by calling `len()` on it.
37
38 len(stream)
39 10
cdbe5f4e
MM
40
41When you want to iterate over a stream (e.g. when you want to print first *n* posts on
42the stream) you can do it in two ways.
43
44First, using `len()` and `range()` functions.
45
46 for i in range(len(stream)):
47 # do stuff...
48
49Second, iterating directly over the stream contents:
50
51 for post in stream:
52 # do stuff...
53
54
8b013ef4
MM
55----
56
57##### Posting data to stream
58
59This is described in [`posting`](./posting.mdown) document in this manual.
60
cdbe5f4e
MM
61----
62
63###### Manual for `diaspy`, written by Marek Marecki