dstanek / snake-guice Goto Github PK
View Code? Open in Web Editor NEWA lightweight dependency injection framework for Python
License: MIT License
A lightweight dependency injection framework for Python
License: MIT License
Graph visualizer ala http://code.google.com/p/google-guice/wiki/Grapher
Original issue reported on code.google.com by [email protected]
on 29 Mar 2009 at 12:29
There is no .egg distribution for python 2.4. Is this intended?
Original issue reported on code.google.com by [email protected]
on 4 Nov 2010 at 2:40
What steps will reproduce the problem?
These tests inside of test_using_ListBinder will currently fail:
def test_that_items_are_created_in_scope(self):
class MyListChipsModule(object):
def configure(self, binder):
listbinder = ListBinder(binder, ISnack)
listbinder.add_binding(to=Lays, in_scope=scopes.SINGLETON)
provider = providers.create_simple_provider(Tostitos)
listbinder.add_binding(to_provider=provider, in_scope=scopes.SINGLETON)
listbinder.add_binding(to_instance=Ruffles(), in_scope=scopes.SINGLETON)
injector = create_injector([ListCandyModule(), MyListChipsModule()])
snacks1 = injector.get_instance(ListSnackMachine)
snacks2 = injector.get_instance(ListSnackMachine)
for n, snack in enumerate(snacks1.snacks):
if isinstance(snack, Lays) or \
isinstance(snack, Tostitos) or \
isinstance(snack, Ruffles):
assert snack is snacks2.snacks[n]
def test_using_annotation_on_ListBinder(self):
class MyListChipsModule(object):
def configure(self, binder):
listbinder = ListBinder(binder, ISnack, annotated_with='FritoLaySnackMachine')
provider = providers.create_simple_provider(Tostitos)
listbinder.add_binding(to_provider=provider, in_scope=scopes.SINGLETON)
listbinder.add_binding(to_instance=Ruffles(), in_scope=scopes.SINGLETON)
class MySnackMachine(object):
@inject(snacks=List(ISnack))
@annotate(snacks='FritoLaySnackMachine')
def __init__(self, snacks):
self.snacks = snacks
injector = create_injector([ListChipsModule(), MyListChipsModule()])
snacks1 = injector.get_instance(ListSnackMachine)
snacks2 = injector.get_instance(MySnackMachine, annotation='FritoLaySnackMachine')
assert len(snacks2.snacks) == 2
Ditto for dictbinder.
Original issue reported on code.google.com by [email protected]
on 30 Jul 2012 at 3:30
How can this be done? There are probably a number of ways. Is there code
required to make this happen?
Possible use cases:
* Local interfaces bound to a 3rd party implementation
* Injecting into 3rd party instances
Original issue reported on code.google.com by [email protected]
on 29 Mar 2009 at 12:32
Maybe something like an @implemented_by decorator.
Original issue reported on code.google.com by [email protected]
on 28 Mar 2009 at 8:25
If possible, it'd be great to get a .egg uploaded for python 2.7, so we can
easy_install/pip this easily.
This does work with 2.7 if I download and install it manually, but it'd be nice
to have the egg available for all our other machines.
Original issue reported on code.google.com by [email protected]
on 19 Jul 2011 at 6:59
This would be useful for @provides(Config) in a Config related Module.
Original issue reported on code.google.com by [email protected]
on 3 Aug 2012 at 4:17
Missed a usage of it in interceptors
Original issue reported on code.google.com by pjenvey%[email protected]
on 7 Sep 2009 at 8:19
Attachments:
[deleted issue]
Should it? How would it work?
Original issue reported on code.google.com by [email protected]
on 28 Mar 2009 at 7:59
We are getting this traceback:
{{{
File "/home/mgriffith/src/sandbox/src/applib/app/pw/controller/test.py",
line 35, in TestController
@inject(customer_facade=cf.CustomerFacade)
File "build\bdist.win32\egg\peak\util\decorators.py", line 576, in tracer
File "build/bdist.linux-i686/egg/snakeguice/decorators.py", line 66, in
callback
_validate_property_args(func, args, kwargs)
File "build/bdist.linux-i686/egg/snakeguice/decorators.py", line 46, in
_validate_property_args
raise DecorationError('only 1 decorator argument allowed')
DecorationError: only 1 decorator argument allowed
}}}
when using inject incorrectly. We were specifying property injection and
including a keyword arg that was unexpected. Can we make this more obvious?
Original issue reported on code.google.com by [email protected]
on 30 Apr 2009 at 4:10
What steps will reproduce the problem?
1. Create an injector to build my instances (somewhere there's a Singleton)
2. Teardown what I'm doing, create a new injector, create new instances
What is the expected output? What do you see instead?
Singleton instances are the same instances across injectors. I would expect
all singletons created from the same injector to be equal, but singletons
created from different injectors to be different instances.
What version of the product are you using? On what operating system?
0.2.1dev rev d28d5e34beb6 on Ubuntu 8.10, Python 2.5.2
Please provide any additional information below.
Though a running system should never be strung together by multiple
injectors, this is a common pattern in tests. In the setup method, create
an injector with a TestModule, pull out the instances you'd like to test,
then test them.
This is extraordinarily convenient when dealing with Singletons because
they hold some state almost by definition. IMHO, one of the big wins of
using DI is isolated tests without complicated tearDown procedures to reset
the system's state.
I'm not intimately familiar with the source, but I believe a reasonable way
to fix this is to attach GuiceData instances to the Injector instead of the
class. If this sounds reasonable to the author (and he/she agrees this is
the expected behavior), I'd be more than happy to implement the patch.
I have attached a failing test.
Original issue reported on code.google.com by [email protected]
on 20 Nov 2009 at 4:03
Attachments:
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 8 Sep 2011 at 1:03
Rather the annotation is just disregarded. Either regard it nevertheless or
raise an exception please.
Original issue reported on code.google.com by [email protected]
on 6 Oct 2011 at 6:37
Instead of adding three public attributes to my class I really wish that
you can just add one 'special' one. Something like __guice__ that stores a
new object containing the injection type mappings.
Original issue reported on code.google.com by [email protected]
on 28 Mar 2009 at 7:45
I want a way to declare a provider that gets it's value out of a
configuration file.
Original issue reported on code.google.com by [email protected]
on 28 Mar 2009 at 7:56
It seems that adding a really simple module that allows me to add routes in
a guicey way would be cool.
Original issue reported on code.google.com by [email protected]
on 28 Mar 2009 at 7:50
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.