Skip to content
Neil Williams edited this page Mar 24, 2020 · 8 revisions

v1.0

make_server_span

The context parameter of make_server_span must now inherit from RequestContext. The easiest way to get an appropriate object for this is to call make_context_object on your Baseplate instance.

Before:

class MyContext: pass

def foo():
    baseplate = Baseplate()

    ...

    context = MyContext()
    with baseplate.make_server_span(context, "bar") as span:
         ...

After:

def foo():
    baseplate = Baseplate()

    ...

    context = baseplate.make_context_object()
    with baseplate.make_server_span(context, "bar") as span:
         ...

Cassandra Execution Profiles

In older versions of the Cassandra driver, settings like timeouts and how rows are represented as objects were set globally for the whole session. As of Baseplate.py 1.0, we require at minimum a version of the Cassandra driver that uses Execution Profiles instead. This allows you to have multiple different configurations on the same session and access them by name.

Previously, CQLMapper would change the row_factory globally from its default (tuples) to dictionaries so any manual queries you ran would get a dictionary in return rather than a tuple. CQLMapper now creates its own execution profile, so the default context keeps all of its defaults from the driver. If your application runs any raw CQL queries (not through the CQLMapper ORM) and relies on the settings CQLMapper used to configure for you, you'll need to create an execution profile and configure it. For example:

from cassandra.cluster import EXEC_PROFILE_DEFAULT
from cassandra.cluster import ExecutionProfile

...

def make_processor(app_config):
    ...
    baseplate.configure_context({
        "cassandra": CQLMapperClient(
            keyspace="myservice",
            execution_profiles={
                EXEC_PROFILE_DEFAULT: ExecutionProfile(
                    consistency_level=ConsistencyLevel.LOCAL_QUORUM,
                    request_timeout=5.0,
                    row_factory=dict_factory,
                ),
            },
        ),
    )
    ...
Clone this wiki locally