Private Methods & Classes¶
Knowledge of the following methods & classes
(which are not part of the public rosteron module API)
is only of benefit if further developing the rosteron module.
Private Session Methods¶
_browse() Method¶
-
Session._browse(url_fragment: Optional[str], purpose: str) → rosteron._Response¶ Note the current client time, browse to the next page, log the response in case
save_logs()is called later, and attempt to build a corresponding_Responseobject.Parameters: - url_fragment – if specified,
the URL (minus the base
SessionURL) that will be navigated to; if not specified, the current page’s selected form will be submitted. - purpose – the type of output expected by this navigation/submission
(
login,home,roster, orlogout). Used inBadResponseErrormessages and response logging.
Return type: Raises: BadResponseError – if the response doesn’t have the expected RosterOn page traits.
- url_fragment – if specified,
the URL (minus the base
__exit__() Method¶
-
Session.__exit__(exc_type, exc_val, exc_tb) → bool¶ Ensure that the RosterOn user is logged out. Called at the end of any
withblock that uses thisSessionobject.The parameters describe the exception raised inside the
withblock, if any, and are not used.Returns: False, to indicate that any exception that occurred should propagate to the caller rather than be suppressed.
Private _Response Class¶
-
class
rosteron._Response(time: datetime.datetime, id: str, content: bs4.Tag)¶ A semi-evaluated RosterOn response, returned by the
Session._browse()method.Every interesting response from RosterOn Mobile conveniently holds its interesting content in a structure like this:
... <div data-role="page" id="account-login"> ... <div data-role="content"> <!-- content of interest within --> </div> </div> ...The
idattribute can be used to very confidently (and cheaply) determine the intent of the page. The content itself should only be further processed if that ID is as expected.Parameters: - time – ideally the time as returned by the server in the response header; failing that, the client time when the request was started.
- id – the page ID as specified by the
idattribute in the<div data-role="page">element. - content – the
<div data-role="content">element as abs4.Tagobject.
Private _LogEntry Class¶
-
class
rosteron._LogEntry(time: datetime.datetime, response: requests.Response, purpose: str)¶ A saved, timestamped RosterOn request/response pair for potential later logging to file.
These are constructed in
Session._browse(), appended to theSession._loglist, and emitted on request bySession.save_logs()as files.Parameters: - time – the client time when the request was started.
- response – the final returned
requests.Responseobject, which holds its corresponding request in itsrequestattribute and intermediate responses (if any) in itshistoryattribute. - purpose – the type of output that was expected by this operation
(
login,home,roster, orlogout). Used in the filename.