l.s.w.adapter : module documentation

Part of lp.services.webapp

No module docstring
Class LaunchpadTimeoutError A variant of TimeoutError that reports the original PostgreSQL error.
Class RequestExpired Request has timed out.
Class CommitLogger Undocumented
Class FilteredTimeline A timeline that filters its actions.
Function set_request_started Set the start time for the request being served by the current
Function clear_request_started Clear the request timer. This function should be called when
Function summarize_requests Produce human-readable summary of requests issued so far.
Function get_timeline_actions Return an iterable of timeline actions.
Function store_sql_statements_and_request_duration Undocumented
Function get_request_statements Get the list of executed statements in the request.
Function get_request_start_time Get the time at which the request started.
Function get_request_duration Get the duration of the current request in seconds.
Function set_permit_timeout_from_features Control request timeouts being obtained from the 'hard_timeout' flag.
Function get_request_remaining_seconds Return how many seconds are remaining in the current request budget.
Function set_launchpad_default_timeout Set the LAZR default timeout function on IProcessStartingEvent.
Function soft_timeout_expired Returns True if the soft request timeout been reached.
Function start_sql_logging Turn the sql data logging on.
Function stop_sql_logging Turn off the sql data logging and return the result.
Function print_queries Undocumented
Class StormAccessFromMainThread The main thread must not access the database via Storm.
Function break_main_thread_db_access Ensure that Storm connections are not made in the main thread.
Class LaunchpadDatabase No class docstring; 1/3 methods documented
Class LaunchpadSessionDatabase Undocumented
Class LaunchpadTimeoutTracer Storm tracer class to keep statement execution time bounded.
Class LaunchpadStatementTracer Storm tracer class to log executed statements.
Class StoreSelector See lp.services.database.interfaces.IStoreSelector.
Function get_store Return a flavored Store for the given database class.
Function get_master_store Return the master Store for the given database class.
Function get_slave_store Return the master Store for the given database class.
Function get_object_from_master_store Return a copy of the given object retrieved from its master Store.
Function get_store_name Helper to retrieve the store name for a ZStorm Store.
Class WhichDbView A page that reports which database is being used by default.
Function _get_dirty_commit_flags Return the current dirty commit status
Function _reset_dirty_commit_flags Set the dirty commit status to False unless previous is True
Function _get_request_timeout Get the timeout value in ms for the current request.
def _get_dirty_commit_flags():
Return the current dirty commit status
def _reset_dirty_commit_flags(previous_committed, previous_dirty):
Set the dirty commit status to False unless previous is True
def set_request_started(starttime=None, request_statements=None, txn=None, enable_timeout=True, detail_filter=None):
Set the start time for the request being served by the current
thread.

:param start_time: The start time of the request. If given, it is used as
    the start time for the request, as returned by time().  If it is not
    given, the current time is used.
:param request_statements; The sequence used to store the logged SQL
    statements.
:type request_statements: mutable sequence.
:param txn: The current transaction manager. If given, txn.commit() and
    txn.abort() calls are logged too.
:param enable_timeout: If True, a timeout error is raised if the request
    runs for a longer time than the configured timeout.
:param detail_filter: An optional (category, detail) -> detail callable
    that filters action details.  This may be used when some details are
    expected to be very large.
def clear_request_started():
Clear the request timer. This function should be called when the request completes.
def summarize_requests():
Produce human-readable summary of requests issued so far.
def get_timeline_actions():
Return an iterable of timeline actions.
def store_sql_statements_and_request_duration(event):
Undocumented
def get_request_statements():
Get the list of executed statements in the request.

The list is composed of (starttime, endtime, db_id, statement) tuples. Times are given in milliseconds since the start of the request.

def get_request_start_time():
Get the time at which the request started.
def get_request_duration(now=None):
Get the duration of the current request in seconds.
def set_permit_timeout_from_features(enabled):
Control request timeouts being obtained from the 'hard_timeout' flag.

Until we've fully setup a page to render - routed the request to the right object, setup a participation etc, feature flags cannot be completely used; and because doing feature flag lookups will trigger DB access, attempting to do a DB lookup will cause a nested DB lookup (the one being done, and the flags lookup). To resolve all of this, timeouts start as a config file only setting, and are then overridden once the request is ready to execute.

ParametersenabledIf True permit looking up request timeouts in feature flags.
def _get_request_timeout(timeout=None):
Get the timeout value in ms for the current request.

:param timeout: A custom timeout in ms.
:return None or a time in ms representing the budget to grant the request.
def get_request_remaining_seconds(no_exception=False, now=None, timeout=None):
Return how many seconds are remaining in the current request budget.

If timeouts are disabled, None is returned.

Parametersno_exceptionIf True, do not raise an error if the request is out of time. Instead return a float e.g. -2.0 for 2 seconds over budget.
nowOverride the result of time.time()
timeoutA custom timeout in ms.
ReturnsNone or a float representing the remaining time budget.
def set_launchpad_default_timeout(event):
Set the LAZR default timeout function on IProcessStartingEvent.
def soft_timeout_expired():
Returns True if the soft request timeout been reached.
def start_sql_logging(tracebacks_if=False):
Turn the sql data logging on.
def stop_sql_logging():
Turn off the sql data logging and return the result.
def print_queries(queries, file=None):
Undocumented
def break_main_thread_db_access(*ignored):
Ensure that Storm connections are not made in the main thread.

When the app server is running, we want ensure we don't use the connection cache from the main thread as this would only be done on process startup and would leave an open connection dangling, wasting resources.

This method is invoked by an IProcessStartingEvent - it would be easier to do on module load, but the test suite has legitimate uses for using connections from the main thread.

def get_store(storm_class, flavor=DEFAULT_FLAVOR):
Return a flavored Store for the given database class.
def get_master_store(storm_class):
Return the master Store for the given database class.
def get_slave_store(storm_class):
Return the master Store for the given database class.
def get_object_from_master_store(obj):
Return a copy of the given object retrieved from its master Store.

Returns the object if it already comes from the relevant master Store.

Registered as a trusted adapter, so if the input is security wrapped, so is the result. Otherwise an unwrapped object is returned.

def get_store_name(store):
Helper to retrieve the store name for a ZStorm Store.
API Documentation for Launchpad, generated by pydoctor at 2018-11-15 00:00:05.