user submodule

This module is here to allow basic manipulation with users. It allows you to retreive all blogposts for fiven user, upload new concepts, register blog and so on.

class abclinuxuapi.user.User(username, password=None, lazy=False)

Bases: object

Class that is used to hold informations about given username. You can also command various operations, like get list of all blogs, or add new concept.

username

str

password

str, default None – Password for logged user.

logged_in

bool – Is the user logged in?

Parameters:
  • username (str) – Users login.
  • password (str, default None) – Optional password for given user. This will allow you to upload concepts.
  • lazy (bool, default False) – Don’t call lazy_init() right when the object is created.
has_blog

Does the user have registered blog?

lazy_init()

Parse additional informations about user. This step require one request to the site.

static from_user_id(user_id)

Transform user_id to instance of User.

Returns:User instance parsed from the user_id.
Return type:obj
login(password=None)

Logs the user in, tests, if the user is really logged.

Parameters:password (str, default None) – Password, overwrites the password set when the object was created.
Raises:UserWarning – if there was some error during login.
get_blogposts()

Lists all of users PUBLISHED blogposts. For unpublished, see get_concepts().

Returns:sorted (old->new) list of Blogpost objects.
Return type:list
get_concepts()

Return all concepts (unpublished blogs).

Returns:List of Concept objects.
Return type:list
add_concept(text, title, ts_of_pub=None)

Adds new concept into your concepts.

Parameters:
  • text (str) – Text of your concept.
  • title (str) – Title of your contept. Do not use HTML in title!
  • ts_of_pub (int/float, default None) – Timestamp of the publication.
Raises:

UserWarning – if the site is broken or user was logged out.

register_blog(blog_name)

Register blog under blog_name. Users doesn’t have blogs automatically, you have to create them manually.

Raises:
  • UserWarning – If user already have blog registered.
  • ValueError – If it is not possible to register blog for user (see exception message for details).