> Style concerns aside, I think using or disusing the ZCA is not relevant
> here; Vlad wants to be able to access deployment settings without
> passing any contextual values around. He could use a global ZCA
> registry to obtain global settings, but it's still a global, and has all
> the downsides of using any other global.
>
I guess I was unclear, that wasn't what I meant at all. I was referring to
his comment about pluggable modules and wondering how much refactoring
would be necessary.
We're using the zca as the way our components interact, by instantiating
them inside adapters of request, context, and sometimes view. This is still
being done using the registry attached to request, so it's not the global
zca registry or global zca api. ie we get them by doing:
# get the right kind of Foobar for current context & view
adapter_of_foobar = request.registry.queryAdapter(request, context, view)
I realize that may have been misleading as in the past I asked you about
using the global zca registry, but we arent' doing that anymore. This was
more meant as a comment that if you are looking for ways to plug components
together, and wanting to avoid huge refactorings of these components that
were designed outside of the context of pyramid, and you want them to
easily get access to deployment settings in one clear point, you can wrap
your components in zca adapters of request/context/view and this gives you
a very clean way of having them get config values *without* resorting to
globals or threadlocals.
class AdapterOfFooBar:
def __init__(self, request, context, view):
self.foobar = Foobar()
# inject config value without having to refactor Foobar
self.foobar.setWithFoobarOldApi(
request.registry.get('myconfig_value') )
etc
I also realize that I am in a minority in my liking working with pyramid in
a very ZCA centric fashion, but for me, it's a great way to connect
packages we use for all jobs, and packages/modules specific to our
individual client apps. Opinions certainly differ, but I think ZCA adapters
are freaking awesome and more people in Pyramid land would love them if
they learned how to use them. YMMV!
HTH
Iain
--
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.