Last active
May 17, 2016 13:13
-
-
Save sergiors/4fe9a259fb5d3904a4156b01bdddd9b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# from sig import Provider | |
class Container(dict): | |
def __delitem__(self, name): | |
if self.has(name): | |
dict.__delitem__(self, name) | |
def has(self, name): | |
return name in self | |
# def register(self, provider: Container): | |
def register(self, provider): | |
provider.register(self) | |
# does not work | |
if __name__ == '__main__': | |
container = Container() | |
container.register(TestProvider()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from abc import ABCMeta, abstractmethod | |
from sig import Container | |
class Provider(metaclass=ABCMeta): | |
@abstractmethod | |
def register(self, container: Container): | |
pass |
A ideia é fazer algo semelhante ao código abaixo:
container = Container()
container.register(TestProvider())
dai o container
passa ela para o provider
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sergiors como está chamando o método
register
?Provider.register()
ouProvider().register()