| | |
| | | 'pyramid.scaffolds.PyramidTemplate in Pyramid 1.1'), |
| | | ) |
| | | |
| | | def get_app(config_file, name=None, loadapp=loadapp): |
| | | def get_app(config_uri, name=None, loadapp=loadapp): |
| | | """ Return the WSGI application named ``name`` in the PasteDeploy |
| | | config file ``config_file``. |
| | | config file specified by ``config_uri``. |
| | | |
| | | If the ``name`` is None, this will attempt to parse the name from |
| | | the ``config_file`` string expecting the format ``ini_file#name``. |
| | | the ``config_uri`` string expecting the format ``inifile#name``. |
| | | If no name is found, the name will default to "main".""" |
| | | if '#' in config_file: |
| | | path, section = config_file.split('#', 1) |
| | | if '#' in config_uri: |
| | | path, section = config_uri.split('#', 1) |
| | | else: |
| | | path, section = config_file, 'main' |
| | | path, section = config_uri, 'main' |
| | | if name: |
| | | section = name |
| | | config_name = 'config:%s' % path |
| | |
| | | |
| | | This command accepts one positional argument: |
| | | |
| | | ``config_file#section_name`` -- specifies the PasteDeploy config file |
| | | to use for the interactive shell. If the section_name is left off, |
| | | ``config_uri`` -- specifies the PasteDeploy config file to use for the |
| | | interactive shell. The format is ``inifile#name``. If the name is left off, |
| | | ``main`` will be assumed. |
| | | |
| | | Example:: |
| | | |
| | | $ paster pshell myapp.ini#main |
| | | |
| | | .. note:: You should use a ``section_name`` that refers to the |
| | | actual ``app`` section in the config file that points at |
| | | your Pyramid app without any middleware wrapping, or this |
| | | command will almost certainly fail. |
| | | .. note:: If you do not point the loader directly at the section of the |
| | | ini file containing your :app:`Pyramid` application, the |
| | | command will attempt to find the app for you. If you are |
| | | loading a pipeline that contains more than one :app:`Pyramid` |
| | | application within it, the loader will use the last one. |
| | | |
| | | """ |
| | | summary = "Open an interactive shell with a Pyramid application loaded" |
| | |
| | | IPShell = None |
| | | cprt = 'Type "help" for more information.' |
| | | banner = "Python %s on %s\n%s" % (sys.version, sys.platform, cprt) |
| | | app_spec = self.args[0] |
| | | config_file = app_spec.split('#', 1)[0] |
| | | config_uri = self.args[0] |
| | | config_file = config_uri.split('#', 1)[0] |
| | | self.logging_file_config(config_file) |
| | | app = self.get_app(app_spec, loadapp=self.loadapp[0]) |
| | | app = self.get_app(config_uri, loadapp=self.loadapp[0]) |
| | | |
| | | # load default globals |
| | | shell_globals = { |
| | |
| | | |
| | | This command accepts one positional argument: |
| | | |
| | | ``config_file#section_name`` -- specifies the PasteDeploy config file |
| | | to use for the interactive shell. If the section_name is left off, |
| | | ``config_uri`` -- specifies the PasteDeploy config file to use for the |
| | | interactive shell. The format is ``inifile#name``. If the name is left off, |
| | | ``main`` will be assumed. |
| | | |
| | | Example:: |
| | |
| | | from pyramid.interfaces import IViewClassifier |
| | | from pyramid.interfaces import IView |
| | | from zope.interface import Interface |
| | | app_spec = self.args[0] |
| | | app = self.get_app(app_spec, loadapp=self.loadapp[0]) |
| | | config_uri = self.args[0] |
| | | app = self.get_app(config_uri, loadapp=self.loadapp[0]) |
| | | registry = app.registry |
| | | mapper = self._get_mapper(app) |
| | | if mapper is not None: |
| | |
| | | |
| | | This command accepts two positional arguments: |
| | | |
| | | ``config_file#section_name`` -- specifies the PasteDeploy config file |
| | | to use for the interactive shell. If the section_name is left off, |
| | | ``config_uri`` -- specifies the PasteDeploy config file to use for the |
| | | interactive shell. The format is ``inifile#name``. If the name is left off, |
| | | ``main`` will be assumed. |
| | | |
| | | ``url`` -- specifies the URL that will be used to find matching views. |
| | |
| | | self.out("%sview predicates (%s)" % (indent, predicate_text)) |
| | | |
| | | def command(self): |
| | | app_spec, url = self.args |
| | | config_uri, url = self.args |
| | | if not url.startswith('/'): |
| | | url = '/%s' % url |
| | | app = self.get_app(app_spec, loadapp=self.loadapp[0]) |
| | | app = self.get_app(config_uri, loadapp=self.loadapp[0]) |
| | | registry = app.registry |
| | | view = self._find_view(url, registry) |
| | | self.out('') |