Access method for getting id of a user
[diaspy.git] / manual / streams.markdown
1 #### `Stream()` object
2
3 This object is used to represent user's stream on D\*.
4 It is returned by `Client()`'s method `get_stream()` and
5 is basically a list of posts.
6
7 ----
8
9 ##### Getting stream
10
11 To get basic stream you have to have working `Connection()` as
12 this 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
20 Now you have a stream filled with posts (if any can be found on user's stream).
21
22 ----
23
24 ##### `fill()`, `update()` and `more()`
25
26 When you want to refresh stream call it's `fill()` method. It will overwrite old stream
27 contents.
28
29 On the contrary, `update()` will get a new stream but will not overwrite old stream saved
30 in the object memory. It will append every new post to the old stream.
31
32 `more()` complements `update()` it will fetch you older posts instead of newer ones.
33
34 ----
35
36 ##### Length of and iterating over a stream
37
38 Stream's length can be checked by calling `len()` on it.
39
40 len(stream)
41 10
42
43 When you want to iterate over a stream (e.g. when you want to print first *n* posts on
44 the stream) you can do it in two ways.
45
46 First, using `len()` and `range()` functions.
47
48 for i in range(len(stream)):
49 # do stuff...
50
51 Second, iterating directly over the stream contents:
52
53 for post in stream:
54 # do stuff...
55
56
57 ----
58
59 ##### Posting data to stream
60
61 This is described in [`posting`](./posting.markdown) document in this manual.
62
63
64 ----
65
66 ##### Clearing stream
67
68 ##### `clear()`
69
70 This will remove all posts from visible stream.
71
72 ##### `purge()`
73
74 This will scan stream for nonexistent posts (eg. deleted) and remove them.
75
76 ----
77
78 ###### Manual for `diaspy`, written by Marek Marecki