how can i get the ini data in pyramid? -


there development.ini or production.ini in pyramid project. add own config data in ini files like:

[thrift] host = 0.0.0.0 port = 8080 

and want use config data in 1 of py files in project. how can data without request object? (i've seen solution uses request.)

you can access settings @ request.registry.settings or pyramid.threadlocal.get_current_registry().settings. behaves dictionary.

if want use second one, getting settings without having request, have warn you. according the doc :

this function should used extremely sparingly, in unit testing code. it’s mistake use get_current_registry outside testing context because usage makes possible write code can neither tested nor scripted.

any part of code needs access settings part of web application, , should access request, not magically accessible global. might think have reason, there's better way. if want discuss (maybe in question if it's complex, code help), i'll glad find clean way it.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -