1 #### `Connection()` object
3 This is the object that is used by `diaspy`'s internals.
4 It is pushed around and used by various methods and other objects:
6 * `Post()` and `Conversation()` objects require it to authenticate and
8 * `Client()` uses it for loggin in to pod and other stuff,
11 `Connection()` is the most low-level part of `diaspy` and provides everything
12 what is needed to talk to a pod.
14 However, using only `Connection()` would be hard and cumberstone so there are
15 other modules to aid you and you are strongly encouraged to use them.
22 `Client()` object available in `diapsy` will login you automatically - provided
23 you gave it valid pod, username and password.
25 On the other hand, `Connection()` is more stupid and it will not log you in unless
26 you explicitly order it to do so.
27 Logging in with `Connection()` is done via `login()` method.
31 connection = diaspy.connection.Connection(pod='https://pod.example.com')
32 connection.login('user', 'password')
36 connection = diaspy.connection.Connection(pod='https://pod.example.com',
42 In the example above two ways of logging in were shown.
43 In the first one only *pod* is passed to the object and
44 *username* and *password* were passed to `login()` method.
46 In the second one everything is passed directly to the object being
47 created and `login()` is called without any arguments.
49 Both ways are valid and will result in exactly the same connection.
50 But consider the following example:
53 connection = diaspy.connection.Connection(pod='https://pod.example.com',
56 connection.login(username='loser', password='passphrase')
58 This code will result in connection with username `loser` and
59 password `passphrase` because data passed to `login()` overrides data
60 passed directly to object.
62 **Remember:** if you pass something to `login()` it will not only *override* but
63 also *overwrite* the username and password!
70 `Connection()` provides functionality for switching pods on the fly.
71 This can be achieved with `podswitch()` method.
73 If login to a new pod is successful your connection is just changed
74 overwritten but if it fails everything else also fails and the current
80 If you want to write your own interface or client for D\*
81 `Connection()` will be the only object you need.