コード例 #1
0
ファイル: implicit.py プロジェクト: oohlaf/morepath
def initialize():
    registry = ClassRegistry()
    implicit.initialize(Lookup(CachingClassLookup(registry)))
コード例 #2
0
and :mod:`morepath.pdbsupport` modules. For custom directive
implementations that interact with core directives for grouping or
subclassing purposes, or that need to use one of the Morepath
registries, you may need to import from :mod:`morepath.directive`.

The other submodules are considered private. If you find yourself
needing to import from them in application or extension code, please
report an issue about it on the Morepath issue tracker.
"""

from dectate import commit
from .app import App
from .implicit import enable_implicit, disable_implicit
from .core import (excview_tween_factory as EXCVIEW,
                   poisoned_host_header_protection_tween_factory as
                   HOST_HEADER_PROTECTION, model_predicate, name_predicate,
                   request_method_predicate, body_model_predicate)
from .core import body_model_predicate as LAST_VIEW_PREDICATE
from .generic import remember_identity, forget_identity, settings
from .view import render_json, render_html, redirect
from .request import Request, Response
from .autosetup import scan, autoscan
from .authentication import Identity, IdentityPolicy, NO_IDENTITY
from .converter import Converter
from .reify import reify
from .run import run

from reg import implicit

implicit.initialize(None)
コード例 #3
0
ファイル: __init__.py プロジェクト: pombredanne/morepath
# flake8: noqa
from .app import App, AppBase, global_app, enable_implicit, disable_implicit
from .core import setup, excview_tween_factory as EXCVIEW
from morepath import directive # register directive methods
from .generic import remember_identity, forget_identity, settings
from .view import render_json, render_html
from .request import Request, Response
from .config import Config, Directive
from .view import redirect
from morepath.autosetup import autoconfig, autosetup
from morepath.security import Identity, NO_IDENTITY
from .directive import directive
from .converter import Converter
from .reify import reify
from .run import run
from reg import ANY, implicit
from pdb import Pdb
pdb = Pdb(skip=['reg.*', 'inspect'])
implicit.initialize(None)
enable_implicit()
コード例 #4
0
class TitledReport(object):
   def __init__(self, title):
      self.title = title

class LabeledReport(object):
   def __init__(self, label):
      self.label = label

def titled_report_title(obj):
    return obj.title

def labeled_report_title(obj):
    return obj.label

registry = reg.Registry()
registry.register_function(
    title, titled_report_title, obj=TitledReport)
registry.register_function(
    title, labeled_report_title, obj=LabeledReport)

from reg import implicit
implicit.initialize(registry.lookup())


titled = TitledReport('This is a report')
labeled = LabeledReport('This is also a report')
print title(titled)
print title(labeled)