On Mon, 2010-12-13 at 15:41 -0800, Mike Orr wrote:
> Where is the config object and everything in pshell?
>
> $ paster shell development.ini MyApp
> ...
> "root" is the Pyramid app root object.
> >>> config
> NameError: name 'config' is not defined
> >>> dir()
> ['__builtins__', 'root']
> >>> dir(root)
> ['__doc__', '__init__', '__module__', '__name__', '__parent__']
> >>> sorted(root.keys())
> AttributeError: DefaultRootFactory instance has no attribute 'keys'
> >>> import pyramid.configuration
> >>> help(pyramid.configuration)
> # No 'get_config()' function or such listed.
>
> I want to see what's in config to see what I can print in a template
> and the syntax to get to it.
"config" isn't a long-lived thing. It is a wrapper for the registry
that dies once the process is "started" (or in the case of a pshell,
that dies once the interactive shell is runnning). Only the registry is
available.
But if you're in a pshell shell, you can recreate it:
from pyramid.threadlocal import get_current_registry
registry = get_current_registry()
config = Configurator(registry, package='mypackagename')
Then use it like you would in an __init__.
> Down the road I'll be wanting to debug my model and URL generation
> (request.route_url()). I can import my model directly, but how do I
> get at route_url?
When a pshell is started, a very empty request is made, so you can do:
from pyramid.threadlocal import get_current_request
request = get_current_request()
request.route_url('home')
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.