*docstrings* -> *docs/* -> *manual/*
+----
+
+Version `0.3.1` (2013-07-12):
+
+* __upd__: `diaspy.people.sephandle()` raises `InvalidHandleError` instead of `UserError`
+* __new__: `connection.Connection` has new parameter in `__init__()`: it's `schema`
+
+
+The new parameter in `connection.Connection` is useful when operating with handles.
+As handle does not contain schema (`http`, `https`, etc.) `_setlogin()` would raise an
+unhandled exception -- `requests.exceptions.MissingSchema`.
+Now, however, `Connection` will catch the exception, add missing schema and try once more.
+This parameter is provided to give programmers ability to manipulate it.
+
+Also, now you can pass just `pod.example.com` as `pod` parameter. Less typing!
+
----
Version `0.3.0` (2013-07-07):
_token_regex = re.compile(r'content="(.*?)"\s+name="csrf-token')
_userinfo_regex = re.compile(r'window.current_user_attributes = ({.*})')
- def __init__(self, pod, username='', password=''):
+ def __init__(self, pod, username='', password='', schema='https'):
"""
:param pod: The complete url of the diaspora pod to use.
:type pod: str
self.session = requests.Session()
self.login_data = {}
self.token = ''
- try:
- self._setlogin(username, password)
- except Exception as e:
- raise LoginError('cannot create login data (caused by: {0}'.format(e))
+ try: self._setlogin(username, password)
+ except request.exceptions.MissingSchema: self.pod = '{0}://{1}'.format(schema, self.pod)
+ finally: pass
+ try: self._setlogin()
+ except Exception as e: raise LoginError('cannot create login data (caused by: {0})'.format(e))
def __repr__(self):
"""Returns token string.
pass
+class InvalidHandleError(DiaspyError):
+ """Raised when invalid handle is found.
+ """
+ pass
+
+
class SearchError(DiaspyError):
"""Exception raised when something related to search goes wrong.
"""
:returns: two-tuple (pod, user)
"""
if re.match('^[a-zA-Z]+[a-zA-Z0-9_-]*@[a-z0-9.]+\.[a-z]+$', handle) is None:
- raise errors.UserError('invalid handle: {0}'.format(handle))
+ raise errors.InvalidHandleError('{0}'.format(handle))
handle = handle.split('@')
pod, user = handle[1], handle[0]
return (pod, user)