----
-#### Version `0.4.1` (2013-09-):
+#### Version `0.4.2` (2013-09-):
+
+This version has some small incompatibilities with `0.4.1` so read Changelog carefully.
* __new__: `diaspy.people.User._fetchstream()` method,
+* __new__: `diaspy.people.Me()` object representing current user,
+* __rem__: `diaspy.people.Me.getInfo()` (moved from `diaspy.connection.Connection.getUserInfo()`),
+
* __upd__: `diaspy.connection.Connection.login()` modifies connection object in-place **and** returns it (this allows more fluent API),
* __upd__: `diaspy.connection.Connection.login()` no longer returns status code (if login was unsuccessful it'll raise an exception),
* __upd__: `diaspy.connection.Connection._login()` no longer returns status code (if login was unsuccessful it'll raise an exception),
+* __rem__: `diaspy.connection.Connection.getUserInfo()` moved to `diaspy.people.Me.getInfo()`,
+
+
----
#### Version `0.4.1` (2013-09-12):
"""Object representing connection with the pod.
"""
_token_regex = re.compile(r'content="(.*?)"\s+name="csrf-token')
- _userinfo_regex = re.compile(r'window.current_user_attributes = ({.*})')
- _userinfo_regex_2 = re.compile(r'gon.user=({.*});gon.preloads')
def __init__(self, pod, username, password, schema='https'):
"""
self._setlogin(username, password)
self._login()
- def getUserInfo(self, fetch=False):
- """This function returns the current user's attributes.
-
- :returns: dict -- json formatted user info.
- """
- request = self.get('bookmarklet')
- userdata = self._userinfo_regex.search(request.text)
- if userdata is None: userdata = self._userinfo_regex_2.search(request.text)
- if userdata is None: raise errors.DiaspyError('cannot find user data')
- userdata = userdata.group(1)
- return json.loads(userdata)
-
def _fetchtoken(self):
"""This method tries to get token string needed for authentication on D*.
self.data = data
+class Me():
+ """Object represetnting current user.
+ """
+ _userinfo_regex = re.compile(r'window.current_user_attributes = ({.*})')
+ _userinfo_regex_2 = re.compile(r'gon.user=({.*});gon.preloads')
+
+ def __init__(self, connection):
+ self._connection = connection
+
+ def getInfo(self, fetch=False):
+ """This function returns the current user's attributes.
+
+ :returns: dict -- json formatted user info.
+ """
+ request = self._connection.get('bookmarklet')
+ userdata = self._userinfo_regex.search(request.text)
+ if userdata is None: userdata = self._userinfo_regex_2.search(request.text)
+ if userdata is None: raise errors.DiaspyError('cannot find user data')
+ userdata = userdata.group(1)
+ return json.loads(userdata)
+
+
+
class Contacts():
"""This class represents user's list of contacts.
"""