2014-01-13 185 views

回答

0

request.registry.settings你在找什麼?

更多細節在這裏:

Pyramid and .ini configuration

或者你在談論的方法。你想在每個請求中訪問一個方法?

def some_method(): 
    return 'stuff you want' 

# in your main function 
config.add_request_method(some_method, 'stuff', reify=True) 

# in a view 
foo = request.stuff 
+0

其實我是想調用Configurator.absolute_asset_spec:[鏈接](http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/api/config.html#pyramid .config.Configurator.absolute_asset_spec) – Matty

0

感謝您的指針。答案是:

@view_config(route_name='home', renderer='templates/home.pt') 
def home_view(request): 
    config = Configurator(registry=request.registry) 
    path = config.absolute_asset_spec('__init__.py') 
    : 
    : 
相關問題