Code Monkey home page Code Monkey logo

snake-guice's People

Contributors

andreacimino avatar dependabot[bot] avatar dstanek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

snake-guice's Issues

Multi-binder doesn't support annotations or binding members of List or Dictionary to a scope.

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

Injecting third-party code

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

Create a .egg for python 2.7

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

Better massaging when using the inject decorator incorrectly

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

Singletons should be scope of the injector

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:

bind to_provider in_scope SINGLETON

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.