Changeset - fc3aa4d77297
[Not reviewed]
0 1 0
Lance Edgar (lance) - 17 months ago 2023-05-18 00:00:34
lance@edbob.org
Avoid lookup of continuum user for short session

at least by default..
1 file changed with 8 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rattail/app.py
Show inline comments
 
@@ -33,12 +33,13 @@ import os
 
import shutil
 
import socket
 
import tempfile
 
import warnings
 
import logging
 
from collections import OrderedDict
 
from functools import partial
 

	
 
import humanize
 
from mako.template import Template
 

	
 
from rattail.util import (load_object, load_entry_points,
 
                          progress_loop,
 
@@ -1191,13 +1192,19 @@ class AppHandler(object):
 
                session.set_continuum_user(user)
 

	
 
        return session
 

	
 
    def short_session(self, **kwargs):
 
        from rattail.db.util import short_session
 
        kwargs.setdefault('factory', self.make_session)
 

	
 
        if 'factory' not in kwargs:
 
            # nb. usually want to avoid continuum user lookup for
 
            # short session, but caller can override if needed
 
            kwargs['factory'] = partial(self.make_session,
 
                                        continuum_user=None)
 

	
 
        return short_session(**kwargs)
 

	
 
    def cache_model(self, session, model, **kwargs):
 
        """
 
        Convenience method which invokes
 
        :func:`rattail.db.cache.cache_model()` with the given model
0 comments (0 inline, 0 general)