On Wed, Jan 26, 2011 at 12:54 PM, Chris McDonough <chr...@plope.com> wrote: > Not sure how much speed is a concern, but the StaticViewPredicate here: > > class StaticViewPredicate(object): > def __init__(self, package, subdir): > self.package = package > self.subdir = subdir > > def __call__(self, info, request): > import logging > log = logging.getLogger(__name__) > log.setLevel(0) > subpath = info["match"]["subpath"] > log.debug("subpath is %r", subpath) > if not subpath: > log.debug("no subpath, returning false") > return False > parts = [self.subdir] > parts.extend(subpath) > resource_name = "/".join(parts) > log.debug("package=%r, resource_name=%r", self.package, > resource_name) > return pkg_resources.resource_exists(self.package, > resource_name) > > .. could be sped up. Since this predicate will be called many, many > times (at least once for each request), it might be wise to: > > - Import logging at module scope, create a logger at module scope, set > level at module scope.
Oh, that's actually development code that should be taken out. I was just making sure I was checking the right file. > Also, FWIW, I'd (reverting my prior arguments to the contrary, which I > already did here: > https://github.com/Pylons/pyramid/issues/closed#issue/44) consider > making modules a package if the config.scan() hack (as documented here: > http://docs.pylonsproject.org/projects/pyramid_cookbook/dev/sqla.html) > was injected into the paster template to cause all models to be imported > without needing a meta.py and all that stuff. I'm still concerned that this depends on the order of statements in the modules. As I understand it, config.scan() does a recursive import. But if two modules import each other, then the bottom part of one of them will not have been executed yet, and if the other module depends on something in that lower part, it'll be undefined or otherwise wrong. This can be avoided if you're careful about what you put above and below the import statements, but it can be complex to figure out when this problem will bite and what to put where. Regarding Daniel's concern, what do other people think? Should I make the user call engine_from_config or create_engine himself and pass in an engine object? -- Mike Orr <sluggos...@gmail.com> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.