Have you considered zope.component and zope.interface?

<ducks>
On Feb 8, 2014 4:33 PM, "Arialdo Martini" <[email protected]> wrote:

> Hi Nikolaos.
> I'm very interested in achieving the same results you are trying to
> achieve.
>
> After having read the amazing post Rails is not your 
> application<http://blog.firsthand.ca/2011/10/rails-is-not-your-application.html>
>  I
> started taking into consideration a very different approach.
> I asked myself: is it that important that the view callable is subjected
> to dependency injection? What if I move the application one layer down, and
> use Pyramid only to drive my application and expose it to to web, rather
> than to build it?
>
> In other words, I could have a very thin view-callable layer, with no
> dependency injection at all but the minimum offered by Pyramid: an injected
> (an a bit augmented) request object. The view callable contains no business
> logic, since it delegates the real job to an underlying layer, that is,
> your application. Pyramid could pass your callable-view the request *and* a
> IoC container.
>
> def you_callable_view(request):
>   ioc = request.ioc
>   service = ioc.get_service('foo')
>   result = service.do_your_job()
>   return result
>
> In "service" I could have costructor dependency injection and the like.
>
>
>
>
> Il giorno mercoledì 1 febbraio 2012 00:09:48 UTC+1, Nikolaos Papagrigoriou
> ha scritto:
>>
>> Hello everyone,
>>
>> From the object-oriented point of view, a Pyramid View (instance of a
>> callable class) depends on the context and the request. Pyramid,
>> correctly injects those dependencies into the view, during a view's
>> class instantiation (while processing a Request).
>>
>> Assuming that a view depends on other objects to do its job, is there
>> a preferred or suggested way of injecting other services
>> (dependencies) in a Pyramid view? By "injecting", I do not mean to use
>> the Service Locator design pattern, i.e. let the view find its
>> dependencies using a registry.
>>
>> For the record, I recently configured and used yaak.inject (http://
>> pypi.python.org/pypi/yaak.inject) to a Pyramid project. However, I am
>> still investigating if there is a better way.
>>
>> Cheers,
>>
>> Nikolaos Papagrigoriou
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pylons-discuss.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to