

def _context_descriptor(attr=None):
    getter = operator.attrgetter(getter)

    def _property_for_context(context):
        try:
            transaction_context = context.transaction_ctx
        except exception.NoEngineContextEstablished:
            raise exception.NoEngineContextEstablished(('No TransactionContext is established for this %s object within the current thread; the %r attribute is unavailable.' % (context, attr)))
        else:
            result = getter(transaction_context)
            if (result is None):
                raise exception.ContextNotRequestedError(("The '%s' context attribute was requested but it has not been established for this context." % attr))
            return result
    return property(_property_for_context)

dataset/ETHPy150Open openstack/oslo.db/oslo_db/sqlalchemy/enginefacade.py _context_descriptor/VarMisuse@18/22 `attr`->`getter`