API documentation¶
Backends¶
The role of a backend is to handle the communication with a backend tool that will store the timesheets and provide projects and activities.
-
class
taxi.backends.
BaseBackend
(username, password, hostname, port, path, options, context)¶ All Taxi backends should inherit from the
BaseBackend
class. Backends are usually constructed from a URL in the form <backend_name>://<username>:<password>@<hostname>:<port><path>?<options>. ThePluginsRegistry
takes care of the parsing and the instanciation of the backend objects. The options parameter is a dictionary constructed from the backend URL querystring.Construct the backend.
-
get_projects
()¶ Return a list of projects and activities. These will be then stored for further use. The list should contain
Project
objects.
-
post_push_entries
()¶ Called after the entries have been pushed. Useful if you need to do post-processing like closing connection, or sending entries buffered in
push_entry()
.If an exception is raised in this method, the status of all the entries of the backend will be considered failed. You can also raise
PushEntriesFailed
with a custom user message to mark their status as failed. If you want to mark individual entries as failed, raisePushEntriesFailed
withentries
being a dictionary containing entries as keys, and error messages as values.
-
push_entry
(date, entry)¶ Called when an entry should be pushed to the backend. date is a
datetime.date
object. entry is aTimesheetEntry
object.If the push fails, this method should raise a
PushEntryFailed
exception.
-
-
exception
taxi.backends.
PushEntriesFailed
(message=None, entries=None)¶ Exception indicating that a set of entries couldn’t be pushed. Typically raised by
BaseBackend.post_push_entries()
.If
entries
is set, it should be a dictionary mappingtaxi.timesheet.entry.TimesheetEntry
with errors as strings.
-
exception
taxi.backends.
PushEntryFailed
¶ Exception indicating that an entry couldn’t be pushed.