Add FactoryDelegate provider + tests

This commit is contained in:
Roman Mogilatov 2017-07-09 23:13:10 +03:00
parent fcb7cf8e3b
commit 89c1c975e6
5 changed files with 1434 additions and 918 deletions

View File

@ -641,6 +641,7 @@ struct __pyx_obj_19dependency_injector_9providers_Configuration;
struct __pyx_obj_19dependency_injector_9providers_Factory;
struct __pyx_obj_19dependency_injector_9providers_DelegatedFactory;
struct __pyx_obj_19dependency_injector_9providers_AbstractFactory;
struct __pyx_obj_19dependency_injector_9providers_FactoryDelegate;
struct __pyx_obj_19dependency_injector_9providers_BaseSingleton;
struct __pyx_obj_19dependency_injector_9providers_Singleton;
struct __pyx_obj_19dependency_injector_9providers_DelegatedSingleton;
@ -659,7 +660,7 @@ struct __pyx_obj_19dependency_injector_10containers___pyx_scope_struct_3_overrid
struct __pyx_obj_19dependency_injector_10containers___pyx_scope_struct_4_copy;
struct __pyx_opt_args_19dependency_injector_9providers_deepcopy;
/* "providers.pxd":166
/* "providers.pxd":170
*
*
* cpdef object deepcopy(object instance, dict memo=*) # <<<<<<<<<<<<<<
@ -834,7 +835,19 @@ struct __pyx_obj_19dependency_injector_9providers_AbstractFactory {
};
/* "providers.pxd":89
/* "providers.pxd":88
*
*
* cdef class FactoryDelegate(Delegate): # <<<<<<<<<<<<<<
* pass
*
*/
struct __pyx_obj_19dependency_injector_9providers_FactoryDelegate {
struct __pyx_obj_19dependency_injector_9providers_Delegate __pyx_base;
};
/* "providers.pxd":93
*
* # Singleton providers
* cdef class BaseSingleton(Provider): # <<<<<<<<<<<<<<
@ -847,7 +860,7 @@ struct __pyx_obj_19dependency_injector_9providers_BaseSingleton {
};
/* "providers.pxd":93
/* "providers.pxd":97
*
*
* cdef class Singleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -860,7 +873,7 @@ struct __pyx_obj_19dependency_injector_9providers_Singleton {
};
/* "providers.pxd":99
/* "providers.pxd":103
*
*
* cdef class DelegatedSingleton(Singleton): # <<<<<<<<<<<<<<
@ -872,7 +885,7 @@ struct __pyx_obj_19dependency_injector_9providers_DelegatedSingleton {
};
/* "providers.pxd":103
/* "providers.pxd":107
*
*
* cdef class ThreadSafeSingleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -886,7 +899,7 @@ struct __pyx_obj_19dependency_injector_9providers_ThreadSafeSingleton {
};
/* "providers.pxd":110
/* "providers.pxd":114
*
*
* cdef class DelegatedThreadSafeSingleton(ThreadSafeSingleton): # <<<<<<<<<<<<<<
@ -898,7 +911,7 @@ struct __pyx_obj_19dependency_injector_9providers_DelegatedThreadSafeSingleton {
};
/* "providers.pxd":114
/* "providers.pxd":118
*
*
* cdef class ThreadLocalSingleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -911,7 +924,7 @@ struct __pyx_obj_19dependency_injector_9providers_ThreadLocalSingleton {
};
/* "providers.pxd":120
/* "providers.pxd":124
*
*
* cdef class DelegatedThreadLocalSingleton(ThreadLocalSingleton): # <<<<<<<<<<<<<<
@ -923,7 +936,7 @@ struct __pyx_obj_19dependency_injector_9providers_DelegatedThreadLocalSingleton
};
/* "providers.pxd":124
/* "providers.pxd":128
*
*
* cdef class AbstractSingleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -935,7 +948,7 @@ struct __pyx_obj_19dependency_injector_9providers_AbstractSingleton {
};
/* "providers.pxd":129
/* "providers.pxd":133
*
* # Injections
* cdef class Injection(object): # <<<<<<<<<<<<<<
@ -951,7 +964,7 @@ struct __pyx_obj_19dependency_injector_9providers_Injection {
};
/* "providers.pxd":136
/* "providers.pxd":140
*
*
* cdef class PositionalInjection(Injection): # <<<<<<<<<<<<<<
@ -963,7 +976,7 @@ struct __pyx_obj_19dependency_injector_9providers_PositionalInjection {
};
/* "providers.pxd":140
/* "providers.pxd":144
*
*
* cdef class NamedInjection(Injection): # <<<<<<<<<<<<<<
@ -1213,7 +1226,21 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_AbstractFactory {
static struct __pyx_vtabstruct_19dependency_injector_9providers_AbstractFactory *__pyx_vtabptr_19dependency_injector_9providers_AbstractFactory;
/* "providers.pxd":89
/* "providers.pxd":88
*
*
* cdef class FactoryDelegate(Delegate): # <<<<<<<<<<<<<<
* pass
*
*/
struct __pyx_vtabstruct_19dependency_injector_9providers_FactoryDelegate {
struct __pyx_vtabstruct_19dependency_injector_9providers_Delegate __pyx_base;
};
static struct __pyx_vtabstruct_19dependency_injector_9providers_FactoryDelegate *__pyx_vtabptr_19dependency_injector_9providers_FactoryDelegate;
/* "providers.pxd":93
*
* # Singleton providers
* cdef class BaseSingleton(Provider): # <<<<<<<<<<<<<<
@ -1227,7 +1254,7 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_BaseSingleton {
static struct __pyx_vtabstruct_19dependency_injector_9providers_BaseSingleton *__pyx_vtabptr_19dependency_injector_9providers_BaseSingleton;
/* "providers.pxd":93
/* "providers.pxd":97
*
*
* cdef class Singleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -1241,7 +1268,7 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_Singleton {
static struct __pyx_vtabstruct_19dependency_injector_9providers_Singleton *__pyx_vtabptr_19dependency_injector_9providers_Singleton;
/* "providers.pxd":99
/* "providers.pxd":103
*
*
* cdef class DelegatedSingleton(Singleton): # <<<<<<<<<<<<<<
@ -1255,7 +1282,7 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedSingleton {
static struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedSingleton *__pyx_vtabptr_19dependency_injector_9providers_DelegatedSingleton;
/* "providers.pxd":103
/* "providers.pxd":107
*
*
* cdef class ThreadSafeSingleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -1269,7 +1296,7 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadSafeSingleton {
static struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadSafeSingleton *__pyx_vtabptr_19dependency_injector_9providers_ThreadSafeSingleton;
/* "providers.pxd":110
/* "providers.pxd":114
*
*
* cdef class DelegatedThreadSafeSingleton(ThreadSafeSingleton): # <<<<<<<<<<<<<<
@ -1283,7 +1310,7 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadSafeSing
static struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadSafeSingleton *__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadSafeSingleton;
/* "providers.pxd":114
/* "providers.pxd":118
*
*
* cdef class ThreadLocalSingleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -1297,7 +1324,7 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadLocalSingleton {
static struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadLocalSingleton *__pyx_vtabptr_19dependency_injector_9providers_ThreadLocalSingleton;
/* "providers.pxd":120
/* "providers.pxd":124
*
*
* cdef class DelegatedThreadLocalSingleton(ThreadLocalSingleton): # <<<<<<<<<<<<<<
@ -1311,7 +1338,7 @@ struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadLocalSin
static struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadLocalSingleton *__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadLocalSingleton;
/* "providers.pxd":124
/* "providers.pxd":128
*
*
* cdef class AbstractSingleton(BaseSingleton): # <<<<<<<<<<<<<<
@ -1817,6 +1844,7 @@ static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_Configuration
static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_Factory = 0;
static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_DelegatedFactory = 0;
static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_AbstractFactory = 0;
static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_FactoryDelegate = 0;
static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_BaseSingleton = 0;
static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_Singleton = 0;
static PyTypeObject *__pyx_ptype_19dependency_injector_9providers_DelegatedSingleton = 0;
@ -8163,7 +8191,7 @@ static PyObject *__pyx_pf_19dependency_injector_10containers_6_check_provider_ty
return __pyx_r;
}
/* "providers.pxd":170
/* "providers.pxd":174
*
* # Inline helper functions
* cdef inline object __get_name(NamedInjection self): # <<<<<<<<<<<<<<
@ -8176,7 +8204,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_na
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__get_name", 0);
/* "providers.pxd":171
/* "providers.pxd":175
* # Inline helper functions
* cdef inline object __get_name(NamedInjection self):
* return self.__name # <<<<<<<<<<<<<<
@ -8188,7 +8216,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_na
__pyx_r = __pyx_v_self->__pyx___name;
goto __pyx_L0;
/* "providers.pxd":170
/* "providers.pxd":174
*
* # Inline helper functions
* cdef inline object __get_name(NamedInjection self): # <<<<<<<<<<<<<<
@ -8203,7 +8231,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_na
return __pyx_r;
}
/* "providers.pxd":174
/* "providers.pxd":178
*
*
* cdef inline object __get_value(Injection self): # <<<<<<<<<<<<<<
@ -8220,7 +8248,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va
PyObject *__pyx_t_4 = NULL;
__Pyx_RefNannySetupContext("__get_value", 0);
/* "providers.pxd":175
/* "providers.pxd":179
*
* cdef inline object __get_value(Injection self):
* if self.__call == 0: # <<<<<<<<<<<<<<
@ -8230,7 +8258,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va
__pyx_t_1 = ((__pyx_v_self->__pyx___call == 0) != 0);
if (__pyx_t_1) {
/* "providers.pxd":176
/* "providers.pxd":180
* cdef inline object __get_value(Injection self):
* if self.__call == 0:
* return self.__value # <<<<<<<<<<<<<<
@ -8242,7 +8270,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va
__pyx_r = __pyx_v_self->__pyx___value;
goto __pyx_L0;
/* "providers.pxd":175
/* "providers.pxd":179
*
* cdef inline object __get_value(Injection self):
* if self.__call == 0: # <<<<<<<<<<<<<<
@ -8251,7 +8279,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va
*/
}
/* "providers.pxd":177
/* "providers.pxd":181
* if self.__call == 0:
* return self.__value
* return self.__value() # <<<<<<<<<<<<<<
@ -8271,10 +8299,10 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va
}
}
if (__pyx_t_4) {
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 177, __pyx_L1_error)
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 181, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
} else {
__pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 177, __pyx_L1_error)
__pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 181, __pyx_L1_error)
}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@ -8282,7 +8310,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va
__pyx_t_2 = 0;
goto __pyx_L0;
/* "providers.pxd":174
/* "providers.pxd":178
*
*
* cdef inline object __get_value(Injection self): # <<<<<<<<<<<<<<
@ -8303,7 +8331,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___get_va
return __pyx_r;
}
/* "providers.pxd":182
/* "providers.pxd":186
* @cython.boundscheck(False)
* @cython.wraparound(False)
* cdef inline tuple __provide_positional_args(tuple args, # <<<<<<<<<<<<<<
@ -8324,7 +8352,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
int __pyx_t_5;
__Pyx_RefNannySetupContext("__provide_positional_args", 0);
/* "providers.pxd":189
/* "providers.pxd":193
* cdef PositionalInjection injection
*
* if inj_args_len == 0: # <<<<<<<<<<<<<<
@ -8334,7 +8362,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
__pyx_t_1 = ((__pyx_v_inj_args_len == 0) != 0);
if (__pyx_t_1) {
/* "providers.pxd":190
/* "providers.pxd":194
*
* if inj_args_len == 0:
* return args # <<<<<<<<<<<<<<
@ -8346,7 +8374,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
__pyx_r = __pyx_v_args;
goto __pyx_L0;
/* "providers.pxd":189
/* "providers.pxd":193
* cdef PositionalInjection injection
*
* if inj_args_len == 0: # <<<<<<<<<<<<<<
@ -8355,19 +8383,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
*/
}
/* "providers.pxd":192
/* "providers.pxd":196
* return args
*
* positional_args = list() # <<<<<<<<<<<<<<
* for index in range(inj_args_len):
* injection = <PositionalInjection>inj_args[index]
*/
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 192, __pyx_L1_error)
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 196, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_v_positional_args = ((PyObject*)__pyx_t_2);
__pyx_t_2 = 0;
/* "providers.pxd":193
/* "providers.pxd":197
*
* positional_args = list()
* for index in range(inj_args_len): # <<<<<<<<<<<<<<
@ -8378,7 +8406,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_index = __pyx_t_4;
/* "providers.pxd":194
/* "providers.pxd":198
* positional_args = list()
* for index in range(inj_args_len):
* injection = <PositionalInjection>inj_args[index] # <<<<<<<<<<<<<<
@ -8387,36 +8415,36 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
*/
if (unlikely(__pyx_v_inj_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 194, __pyx_L1_error)
__PYX_ERR(1, 198, __pyx_L1_error)
}
__pyx_t_2 = PyTuple_GET_ITEM(__pyx_v_inj_args, __pyx_v_index);
__Pyx_INCREF(__pyx_t_2);
__Pyx_XDECREF_SET(__pyx_v_injection, ((struct __pyx_obj_19dependency_injector_9providers_PositionalInjection *)__pyx_t_2));
__pyx_t_2 = 0;
/* "providers.pxd":195
/* "providers.pxd":199
* for index in range(inj_args_len):
* injection = <PositionalInjection>inj_args[index]
* positional_args.append(__get_value(injection)) # <<<<<<<<<<<<<<
* positional_args.extend(args)
*
*/
__pyx_t_2 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_injection)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 195, __pyx_L1_error)
__pyx_t_2 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_injection)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 199, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_5 = __Pyx_PyList_Append(__pyx_v_positional_args, __pyx_t_2); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 195, __pyx_L1_error)
__pyx_t_5 = __Pyx_PyList_Append(__pyx_v_positional_args, __pyx_t_2); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 199, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
/* "providers.pxd":196
/* "providers.pxd":200
* injection = <PositionalInjection>inj_args[index]
* positional_args.append(__get_value(injection))
* positional_args.extend(args) # <<<<<<<<<<<<<<
*
* return tuple(positional_args)
*/
__pyx_t_5 = __Pyx_PyList_Extend(__pyx_v_positional_args, __pyx_v_args); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 196, __pyx_L1_error)
__pyx_t_5 = __Pyx_PyList_Extend(__pyx_v_positional_args, __pyx_v_args); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 200, __pyx_L1_error)
/* "providers.pxd":198
/* "providers.pxd":202
* positional_args.extend(args)
*
* return tuple(positional_args) # <<<<<<<<<<<<<<
@ -8424,13 +8452,13 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = PyList_AsTuple(__pyx_v_positional_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 198, __pyx_L1_error)
__pyx_t_2 = PyList_AsTuple(__pyx_v_positional_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 202, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_r = ((PyObject*)__pyx_t_2);
__pyx_t_2 = 0;
goto __pyx_L0;
/* "providers.pxd":182
/* "providers.pxd":186
* @cython.boundscheck(False)
* @cython.wraparound(False)
* cdef inline tuple __provide_positional_args(tuple args, # <<<<<<<<<<<<<<
@ -8451,7 +8479,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
return __pyx_r;
}
/* "providers.pxd":203
/* "providers.pxd":207
* @cython.boundscheck(False)
* @cython.wraparound(False)
* cdef inline dict __provide_keyword_args(dict kwargs, # <<<<<<<<<<<<<<
@ -8473,7 +8501,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
int __pyx_t_6;
__Pyx_RefNannySetupContext("__provide_keyword_args", 0);
/* "providers.pxd":210
/* "providers.pxd":214
* cdef NamedInjection kw_injection
*
* if len(kwargs) == 0: # <<<<<<<<<<<<<<
@ -8482,13 +8510,13 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
*/
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
__PYX_ERR(1, 210, __pyx_L1_error)
__PYX_ERR(1, 214, __pyx_L1_error)
}
__pyx_t_1 = PyDict_Size(__pyx_v_kwargs); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 210, __pyx_L1_error)
__pyx_t_1 = PyDict_Size(__pyx_v_kwargs); if (unlikely(__pyx_t_1 == -1)) __PYX_ERR(1, 214, __pyx_L1_error)
__pyx_t_2 = ((__pyx_t_1 == 0) != 0);
if (__pyx_t_2) {
/* "providers.pxd":211
/* "providers.pxd":215
*
* if len(kwargs) == 0:
* for index in range(inj_kwargs_len): # <<<<<<<<<<<<<<
@ -8499,7 +8527,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_index = __pyx_t_4;
/* "providers.pxd":212
/* "providers.pxd":216
* if len(kwargs) == 0:
* for index in range(inj_kwargs_len):
* kw_injection = <NamedInjection>inj_kwargs[index] # <<<<<<<<<<<<<<
@ -8508,43 +8536,43 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
*/
if (unlikely(__pyx_v_inj_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 212, __pyx_L1_error)
__PYX_ERR(1, 216, __pyx_L1_error)
}
__pyx_t_5 = PyTuple_GET_ITEM(__pyx_v_inj_kwargs, __pyx_v_index);
__Pyx_INCREF(__pyx_t_5);
__Pyx_XDECREF_SET(__pyx_v_kw_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_5));
__pyx_t_5 = 0;
/* "providers.pxd":213
/* "providers.pxd":217
* for index in range(inj_kwargs_len):
* kw_injection = <NamedInjection>inj_kwargs[index]
* name = __get_name(kw_injection) # <<<<<<<<<<<<<<
* kwargs[name] = __get_value(kw_injection)
* else:
*/
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 213, __pyx_L1_error)
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_5);
__pyx_t_5 = 0;
/* "providers.pxd":214
/* "providers.pxd":218
* kw_injection = <NamedInjection>inj_kwargs[index]
* name = __get_name(kw_injection)
* kwargs[name] = __get_value(kw_injection) # <<<<<<<<<<<<<<
* else:
* for index in range(inj_kwargs_len):
*/
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 214, __pyx_L1_error)
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 218, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 214, __pyx_L1_error)
__PYX_ERR(1, 218, __pyx_L1_error)
}
if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_5) < 0)) __PYX_ERR(1, 214, __pyx_L1_error)
if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_5) < 0)) __PYX_ERR(1, 218, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
}
/* "providers.pxd":210
/* "providers.pxd":214
* cdef NamedInjection kw_injection
*
* if len(kwargs) == 0: # <<<<<<<<<<<<<<
@ -8554,7 +8582,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
goto __pyx_L3;
}
/* "providers.pxd":216
/* "providers.pxd":220
* kwargs[name] = __get_value(kw_injection)
* else:
* for index in range(inj_kwargs_len): # <<<<<<<<<<<<<<
@ -8566,7 +8594,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_index = __pyx_t_4;
/* "providers.pxd":217
/* "providers.pxd":221
* else:
* for index in range(inj_kwargs_len):
* kw_injection = <NamedInjection>inj_kwargs[index] # <<<<<<<<<<<<<<
@ -8575,26 +8603,26 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
*/
if (unlikely(__pyx_v_inj_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 217, __pyx_L1_error)
__PYX_ERR(1, 221, __pyx_L1_error)
}
__pyx_t_5 = PyTuple_GET_ITEM(__pyx_v_inj_kwargs, __pyx_v_index);
__Pyx_INCREF(__pyx_t_5);
__Pyx_XDECREF_SET(__pyx_v_kw_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_5));
__pyx_t_5 = 0;
/* "providers.pxd":218
/* "providers.pxd":222
* for index in range(inj_kwargs_len):
* kw_injection = <NamedInjection>inj_kwargs[index]
* name = __get_name(kw_injection) # <<<<<<<<<<<<<<
* if name not in kwargs:
* kwargs[name] = __get_value(kw_injection)
*/
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 218, __pyx_L1_error)
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_kw_injection); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 222, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_5);
__pyx_t_5 = 0;
/* "providers.pxd":219
/* "providers.pxd":223
* kw_injection = <NamedInjection>inj_kwargs[index]
* name = __get_name(kw_injection)
* if name not in kwargs: # <<<<<<<<<<<<<<
@ -8603,29 +8631,29 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
*/
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
__PYX_ERR(1, 219, __pyx_L1_error)
__PYX_ERR(1, 223, __pyx_L1_error)
}
__pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_kwargs, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 219, __pyx_L1_error)
__pyx_t_2 = (__Pyx_PyDict_ContainsTF(__pyx_v_name, __pyx_v_kwargs, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 223, __pyx_L1_error)
__pyx_t_6 = (__pyx_t_2 != 0);
if (__pyx_t_6) {
/* "providers.pxd":220
/* "providers.pxd":224
* name = __get_name(kw_injection)
* if name not in kwargs:
* kwargs[name] = __get_value(kw_injection) # <<<<<<<<<<<<<<
*
* return kwargs
*/
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 220, __pyx_L1_error)
__pyx_t_5 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_kw_injection)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 224, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (unlikely(__pyx_v_kwargs == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 220, __pyx_L1_error)
__PYX_ERR(1, 224, __pyx_L1_error)
}
if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_5) < 0)) __PYX_ERR(1, 220, __pyx_L1_error)
if (unlikely(PyDict_SetItem(__pyx_v_kwargs, __pyx_v_name, __pyx_t_5) < 0)) __PYX_ERR(1, 224, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
/* "providers.pxd":219
/* "providers.pxd":223
* kw_injection = <NamedInjection>inj_kwargs[index]
* name = __get_name(kw_injection)
* if name not in kwargs: # <<<<<<<<<<<<<<
@ -8637,7 +8665,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
}
__pyx_L3:;
/* "providers.pxd":222
/* "providers.pxd":226
* kwargs[name] = __get_value(kw_injection)
*
* return kwargs # <<<<<<<<<<<<<<
@ -8649,7 +8677,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
__pyx_r = __pyx_v_kwargs;
goto __pyx_L0;
/* "providers.pxd":203
/* "providers.pxd":207
* @cython.boundscheck(False)
* @cython.wraparound(False)
* cdef inline dict __provide_keyword_args(dict kwargs, # <<<<<<<<<<<<<<
@ -8670,7 +8698,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___provid
return __pyx_r;
}
/* "providers.pxd":227
/* "providers.pxd":231
* @cython.boundscheck(False)
* @cython.wraparound(False)
* cdef inline object __inject_attributes(object instance, # <<<<<<<<<<<<<<
@ -8690,7 +8718,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject
int __pyx_t_5;
__Pyx_RefNannySetupContext("__inject_attributes", 0);
/* "providers.pxd":231
/* "providers.pxd":235
* int attributes_len):
* cdef NamedInjection attr_injection
* for index in range(attributes_len): # <<<<<<<<<<<<<<
@ -8701,7 +8729,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_index = __pyx_t_2;
/* "providers.pxd":232
/* "providers.pxd":236
* cdef NamedInjection attr_injection
* for index in range(attributes_len):
* attr_injection = <NamedInjection>attributes[index] # <<<<<<<<<<<<<<
@ -8710,46 +8738,46 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject
*/
if (unlikely(__pyx_v_attributes == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(1, 232, __pyx_L1_error)
__PYX_ERR(1, 236, __pyx_L1_error)
}
__pyx_t_3 = PyTuple_GET_ITEM(__pyx_v_attributes, __pyx_v_index);
__Pyx_INCREF(__pyx_t_3);
__Pyx_XDECREF_SET(__pyx_v_attr_injection, ((struct __pyx_obj_19dependency_injector_9providers_NamedInjection *)__pyx_t_3));
__pyx_t_3 = 0;
/* "providers.pxd":234
/* "providers.pxd":238
* attr_injection = <NamedInjection>attributes[index]
* setattr(instance,
* __get_name(attr_injection), # <<<<<<<<<<<<<<
* __get_value(attr_injection))
*
*/
__pyx_t_3 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_attr_injection); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 234, __pyx_L1_error)
__pyx_t_3 = __pyx_f_19dependency_injector_9providers___get_name(__pyx_v_attr_injection); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 238, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
/* "providers.pxd":235
/* "providers.pxd":239
* setattr(instance,
* __get_name(attr_injection),
* __get_value(attr_injection)) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_4 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_attr_injection)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 235, __pyx_L1_error)
__pyx_t_4 = __pyx_f_19dependency_injector_9providers___get_value(((struct __pyx_obj_19dependency_injector_9providers_Injection *)__pyx_v_attr_injection)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
/* "providers.pxd":233
/* "providers.pxd":237
* for index in range(attributes_len):
* attr_injection = <NamedInjection>attributes[index]
* setattr(instance, # <<<<<<<<<<<<<<
* __get_name(attr_injection),
* __get_value(attr_injection))
*/
__pyx_t_5 = PyObject_SetAttr(__pyx_v_instance, __pyx_t_3, __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 233, __pyx_L1_error)
__pyx_t_5 = PyObject_SetAttr(__pyx_v_instance, __pyx_t_3, __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(1, 237, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
}
/* "providers.pxd":227
/* "providers.pxd":231
* @cython.boundscheck(False)
* @cython.wraparound(False)
* cdef inline object __inject_attributes(object instance, # <<<<<<<<<<<<<<
@ -8772,7 +8800,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___inject
return __pyx_r;
}
/* "providers.pxd":238
/* "providers.pxd":242
*
*
* cdef inline object __callable_call(Callable self, tuple args, dict kwargs): # <<<<<<<<<<<<<<
@ -8789,7 +8817,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab
PyObject *__pyx_t_2 = NULL;
__Pyx_RefNannySetupContext("__callable_call", 0);
/* "providers.pxd":243
/* "providers.pxd":247
*
* positional_args = __provide_positional_args(args,
* self.__args, # <<<<<<<<<<<<<<
@ -8799,20 +8827,20 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab
__pyx_t_1 = __pyx_v_self->__pyx___args;
__Pyx_INCREF(__pyx_t_1);
/* "providers.pxd":242
/* "providers.pxd":246
* cdef dict keyword_args
*
* positional_args = __provide_positional_args(args, # <<<<<<<<<<<<<<
* self.__args,
* self.__args_len)
*/
__pyx_t_2 = __pyx_f_19dependency_injector_9providers___provide_positional_args(__pyx_v_args, ((PyObject*)__pyx_t_1), __pyx_v_self->__pyx___args_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 242, __pyx_L1_error)
__pyx_t_2 = __pyx_f_19dependency_injector_9providers___provide_positional_args(__pyx_v_args, ((PyObject*)__pyx_t_1), __pyx_v_self->__pyx___args_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 246, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_positional_args = ((PyObject*)__pyx_t_2);
__pyx_t_2 = 0;
/* "providers.pxd":246
/* "providers.pxd":250
* self.__args_len)
* keyword_args = __provide_keyword_args(kwargs,
* self.__kwargs, # <<<<<<<<<<<<<<
@ -8822,20 +8850,20 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab
__pyx_t_2 = __pyx_v_self->__pyx___kwargs;
__Pyx_INCREF(__pyx_t_2);
/* "providers.pxd":245
/* "providers.pxd":249
* self.__args,
* self.__args_len)
* keyword_args = __provide_keyword_args(kwargs, # <<<<<<<<<<<<<<
* self.__kwargs,
* self.__kwargs_len)
*/
__pyx_t_1 = __pyx_f_19dependency_injector_9providers___provide_keyword_args(__pyx_v_kwargs, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error)
__pyx_t_1 = __pyx_f_19dependency_injector_9providers___provide_keyword_args(__pyx_v_kwargs, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___kwargs_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 249, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_keyword_args = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
/* "providers.pxd":249
/* "providers.pxd":253
* self.__kwargs_len)
*
* return self.__provides(*positional_args, **keyword_args) # <<<<<<<<<<<<<<
@ -8845,19 +8873,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab
__Pyx_XDECREF(__pyx_r);
if (unlikely(__pyx_v_positional_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
__PYX_ERR(1, 249, __pyx_L1_error)
__PYX_ERR(1, 253, __pyx_L1_error)
}
if (unlikely(__pyx_v_keyword_args == Py_None)) {
PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
__PYX_ERR(1, 249, __pyx_L1_error)
__PYX_ERR(1, 253, __pyx_L1_error)
}
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___provides, __pyx_v_positional_args, __pyx_v_keyword_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 249, __pyx_L1_error)
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->__pyx___provides, __pyx_v_positional_args, __pyx_v_keyword_args); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 253, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* "providers.pxd":238
/* "providers.pxd":242
*
*
* cdef inline object __callable_call(Callable self, tuple args, dict kwargs): # <<<<<<<<<<<<<<
@ -8879,7 +8907,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___callab
return __pyx_r;
}
/* "providers.pxd":252
/* "providers.pxd":256
*
*
* cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<<
@ -8896,7 +8924,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor
int __pyx_t_3;
__Pyx_RefNannySetupContext("__factory_call", 0);
/* "providers.pxd":255
/* "providers.pxd":259
* cdef object instance
*
* instance = __callable_call(self.__instantiator, args, kwargs) # <<<<<<<<<<<<<<
@ -8905,13 +8933,13 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor
*/
__pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx___instantiator);
__Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = __pyx_f_19dependency_injector_9providers___callable_call(((struct __pyx_obj_19dependency_injector_9providers_Callable *)__pyx_t_1), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 255, __pyx_L1_error)
__pyx_t_2 = __pyx_f_19dependency_injector_9providers___callable_call(((struct __pyx_obj_19dependency_injector_9providers_Callable *)__pyx_t_1), __pyx_v_args, __pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 259, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_instance = __pyx_t_2;
__pyx_t_2 = 0;
/* "providers.pxd":257
/* "providers.pxd":261
* instance = __callable_call(self.__instantiator, args, kwargs)
*
* if self.__attributes_len > 0: # <<<<<<<<<<<<<<
@ -8921,7 +8949,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor
__pyx_t_3 = ((__pyx_v_self->__pyx___attributes_len > 0) != 0);
if (__pyx_t_3) {
/* "providers.pxd":259
/* "providers.pxd":263
* if self.__attributes_len > 0:
* __inject_attributes(instance,
* self.__attributes, # <<<<<<<<<<<<<<
@ -8931,19 +8959,19 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor
__pyx_t_2 = __pyx_v_self->__pyx___attributes;
__Pyx_INCREF(__pyx_t_2);
/* "providers.pxd":258
/* "providers.pxd":262
*
* if self.__attributes_len > 0:
* __inject_attributes(instance, # <<<<<<<<<<<<<<
* self.__attributes,
* self.__attributes_len)
*/
__pyx_t_1 = __pyx_f_19dependency_injector_9providers___inject_attributes(__pyx_v_instance, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___attributes_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 258, __pyx_L1_error)
__pyx_t_1 = __pyx_f_19dependency_injector_9providers___inject_attributes(__pyx_v_instance, ((PyObject*)__pyx_t_2), __pyx_v_self->__pyx___attributes_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 262, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "providers.pxd":257
/* "providers.pxd":261
* instance = __callable_call(self.__instantiator, args, kwargs)
*
* if self.__attributes_len > 0: # <<<<<<<<<<<<<<
@ -8952,7 +8980,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor
*/
}
/* "providers.pxd":262
/* "providers.pxd":266
* self.__attributes_len)
*
* return instance # <<<<<<<<<<<<<<
@ -8962,7 +8990,7 @@ static CYTHON_INLINE PyObject *__pyx_f_19dependency_injector_9providers___factor
__pyx_r = __pyx_v_instance;
goto __pyx_L0;
/* "providers.pxd":252
/* "providers.pxd":256
*
*
* cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<<
@ -9685,7 +9713,7 @@ static int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 55, __pyx_L1_error)
__pyx_builtin_AttributeError = __Pyx_GetBuiltinName(__pyx_n_s_AttributeError); if (!__pyx_builtin_AttributeError) __PYX_ERR(0, 111, __pyx_L1_error)
__pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 358, __pyx_L1_error)
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 193, __pyx_L1_error)
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 197, __pyx_L1_error)
return 0;
__pyx_L1_error:;
return -1;
@ -10070,25 +10098,27 @@ PyMODINIT_FUNC PyInit_containers(void)
__pyx_vtabptr_19dependency_injector_9providers_DelegatedFactory = (struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedFactory*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_DelegatedFactory->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_DelegatedFactory)) __PYX_ERR(1, 80, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_AbstractFactory = __Pyx_ImportType("dependency_injector.providers", "AbstractFactory", sizeof(struct __pyx_obj_19dependency_injector_9providers_AbstractFactory), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_AbstractFactory)) __PYX_ERR(1, 84, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_AbstractFactory = (struct __pyx_vtabstruct_19dependency_injector_9providers_AbstractFactory*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_AbstractFactory->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_AbstractFactory)) __PYX_ERR(1, 84, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_BaseSingleton = __Pyx_ImportType("dependency_injector.providers", "BaseSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_BaseSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_BaseSingleton)) __PYX_ERR(1, 89, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_BaseSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_BaseSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_BaseSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_BaseSingleton)) __PYX_ERR(1, 89, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_Singleton = __Pyx_ImportType("dependency_injector.providers", "Singleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_Singleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_Singleton)) __PYX_ERR(1, 93, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_Singleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_Singleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_Singleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_Singleton)) __PYX_ERR(1, 93, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_DelegatedSingleton = __Pyx_ImportType("dependency_injector.providers", "DelegatedSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_DelegatedSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_DelegatedSingleton)) __PYX_ERR(1, 99, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_DelegatedSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_DelegatedSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_DelegatedSingleton)) __PYX_ERR(1, 99, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_ThreadSafeSingleton = __Pyx_ImportType("dependency_injector.providers", "ThreadSafeSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_ThreadSafeSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_ThreadSafeSingleton)) __PYX_ERR(1, 103, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_ThreadSafeSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadSafeSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_ThreadSafeSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_ThreadSafeSingleton)) __PYX_ERR(1, 103, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_DelegatedThreadSafeSingleton = __Pyx_ImportType("dependency_injector.providers", "DelegatedThreadSafeSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_DelegatedThreadSafeSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_DelegatedThreadSafeSingleton)) __PYX_ERR(1, 110, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadSafeSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadSafeSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_DelegatedThreadSafeSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadSafeSingleton)) __PYX_ERR(1, 110, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_ThreadLocalSingleton = __Pyx_ImportType("dependency_injector.providers", "ThreadLocalSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_ThreadLocalSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_ThreadLocalSingleton)) __PYX_ERR(1, 114, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_ThreadLocalSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadLocalSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_ThreadLocalSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_ThreadLocalSingleton)) __PYX_ERR(1, 114, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_DelegatedThreadLocalSingleton = __Pyx_ImportType("dependency_injector.providers", "DelegatedThreadLocalSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_DelegatedThreadLocalSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_DelegatedThreadLocalSingleton)) __PYX_ERR(1, 120, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadLocalSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadLocalSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_DelegatedThreadLocalSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadLocalSingleton)) __PYX_ERR(1, 120, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_AbstractSingleton = __Pyx_ImportType("dependency_injector.providers", "AbstractSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_AbstractSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_AbstractSingleton)) __PYX_ERR(1, 124, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_AbstractSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_AbstractSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_AbstractSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_AbstractSingleton)) __PYX_ERR(1, 124, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_Injection = __Pyx_ImportType("dependency_injector.providers", "Injection", sizeof(struct __pyx_obj_19dependency_injector_9providers_Injection), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_Injection)) __PYX_ERR(1, 129, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_PositionalInjection = __Pyx_ImportType("dependency_injector.providers", "PositionalInjection", sizeof(struct __pyx_obj_19dependency_injector_9providers_PositionalInjection), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_PositionalInjection)) __PYX_ERR(1, 136, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_NamedInjection = __Pyx_ImportType("dependency_injector.providers", "NamedInjection", sizeof(struct __pyx_obj_19dependency_injector_9providers_NamedInjection), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_NamedInjection)) __PYX_ERR(1, 140, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_FactoryDelegate = __Pyx_ImportType("dependency_injector.providers", "FactoryDelegate", sizeof(struct __pyx_obj_19dependency_injector_9providers_FactoryDelegate), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_FactoryDelegate)) __PYX_ERR(1, 88, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_FactoryDelegate = (struct __pyx_vtabstruct_19dependency_injector_9providers_FactoryDelegate*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_FactoryDelegate->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_FactoryDelegate)) __PYX_ERR(1, 88, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_BaseSingleton = __Pyx_ImportType("dependency_injector.providers", "BaseSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_BaseSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_BaseSingleton)) __PYX_ERR(1, 93, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_BaseSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_BaseSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_BaseSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_BaseSingleton)) __PYX_ERR(1, 93, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_Singleton = __Pyx_ImportType("dependency_injector.providers", "Singleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_Singleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_Singleton)) __PYX_ERR(1, 97, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_Singleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_Singleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_Singleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_Singleton)) __PYX_ERR(1, 97, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_DelegatedSingleton = __Pyx_ImportType("dependency_injector.providers", "DelegatedSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_DelegatedSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_DelegatedSingleton)) __PYX_ERR(1, 103, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_DelegatedSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_DelegatedSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_DelegatedSingleton)) __PYX_ERR(1, 103, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_ThreadSafeSingleton = __Pyx_ImportType("dependency_injector.providers", "ThreadSafeSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_ThreadSafeSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_ThreadSafeSingleton)) __PYX_ERR(1, 107, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_ThreadSafeSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadSafeSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_ThreadSafeSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_ThreadSafeSingleton)) __PYX_ERR(1, 107, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_DelegatedThreadSafeSingleton = __Pyx_ImportType("dependency_injector.providers", "DelegatedThreadSafeSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_DelegatedThreadSafeSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_DelegatedThreadSafeSingleton)) __PYX_ERR(1, 114, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadSafeSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadSafeSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_DelegatedThreadSafeSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadSafeSingleton)) __PYX_ERR(1, 114, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_ThreadLocalSingleton = __Pyx_ImportType("dependency_injector.providers", "ThreadLocalSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_ThreadLocalSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_ThreadLocalSingleton)) __PYX_ERR(1, 118, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_ThreadLocalSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_ThreadLocalSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_ThreadLocalSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_ThreadLocalSingleton)) __PYX_ERR(1, 118, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_DelegatedThreadLocalSingleton = __Pyx_ImportType("dependency_injector.providers", "DelegatedThreadLocalSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_DelegatedThreadLocalSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_DelegatedThreadLocalSingleton)) __PYX_ERR(1, 124, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadLocalSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_DelegatedThreadLocalSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_DelegatedThreadLocalSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_DelegatedThreadLocalSingleton)) __PYX_ERR(1, 124, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_AbstractSingleton = __Pyx_ImportType("dependency_injector.providers", "AbstractSingleton", sizeof(struct __pyx_obj_19dependency_injector_9providers_AbstractSingleton), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_AbstractSingleton)) __PYX_ERR(1, 128, __pyx_L1_error)
__pyx_vtabptr_19dependency_injector_9providers_AbstractSingleton = (struct __pyx_vtabstruct_19dependency_injector_9providers_AbstractSingleton*)__Pyx_GetVtable(__pyx_ptype_19dependency_injector_9providers_AbstractSingleton->tp_dict); if (unlikely(!__pyx_vtabptr_19dependency_injector_9providers_AbstractSingleton)) __PYX_ERR(1, 128, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_Injection = __Pyx_ImportType("dependency_injector.providers", "Injection", sizeof(struct __pyx_obj_19dependency_injector_9providers_Injection), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_Injection)) __PYX_ERR(1, 133, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_PositionalInjection = __Pyx_ImportType("dependency_injector.providers", "PositionalInjection", sizeof(struct __pyx_obj_19dependency_injector_9providers_PositionalInjection), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_PositionalInjection)) __PYX_ERR(1, 140, __pyx_L1_error)
__pyx_ptype_19dependency_injector_9providers_NamedInjection = __Pyx_ImportType("dependency_injector.providers", "NamedInjection", sizeof(struct __pyx_obj_19dependency_injector_9providers_NamedInjection), 1); if (unlikely(!__pyx_ptype_19dependency_injector_9providers_NamedInjection)) __PYX_ERR(1, 144, __pyx_L1_error)
/*--- Variable import code ---*/
__pyx_t_1 = __Pyx_ImportModule("dependency_injector.providers"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
if (__Pyx_ImportVoidPtr(__pyx_t_1, "CLASS_TYPES", (void **)&__pyx_vp_19dependency_injector_9providers_CLASS_TYPES, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
@ -10648,7 +10678,7 @@ PyMODINIT_FUNC PyInit_containers(void)
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
/* "providers.pxd":252
/* "providers.pxd":256
*
*
* cdef inline object __factory_call(Factory self, tuple args, dict kwargs): # <<<<<<<<<<<<<<

File diff suppressed because it is too large Load Diff

View File

@ -85,6 +85,10 @@ cdef class AbstractFactory(Factory):
cpdef object _provide(self, tuple args, dict kwargs)
cdef class FactoryDelegate(Delegate):
pass
# Singleton providers
cdef class BaseSingleton(Provider):
cdef Factory __instantiator

View File

@ -1066,6 +1066,29 @@ cdef class AbstractFactory(Factory):
raise NotImplementedError('Abstract provider forward providing logic '
'to overriding provider')
cdef class FactoryDelegate(Delegate):
"""Factory delegate injects delegating factory "as is".
.. py:attribute:: provides
Value that have to be provided.
:type: object
"""
def __init__(self, factory):
"""Initializer.
:param provides: Value that have to be provided.
:type provides: object
"""
if isinstance(factory, Factory) is False:
raise Error('{0} can wrap only {1} providers'.format(
self.__class__, Factory))
super(Delegate, self).__init__(factory)
cdef class BaseSingleton(Provider):
"""Base class of singleton providers."""

View File

@ -399,3 +399,18 @@ class AbstractFactoryTests(unittest.TestCase):
'AbstractFactory({0}) at {1}>'.format(
repr(Example),
hex(id(provider))))
class FactoryDelegateTests(unittest.TestCase):
def setUp(self):
self.delegated = providers.Factory(object)
self.delegate = providers.FactoryDelegate(self.delegated)
def test_is_delegate(self):
self.assertIsInstance(self.delegate, providers.Delegate)
def test_init_with_not_factory(self):
self.assertRaises(errors.Error,
providers.FactoryDelegate,
providers.Object(object()))