source: TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/utils/classfactory.py @ 6572

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/utils/classfactory.py@6572
Revision 6572, 1.3 KB checked in by pjkersha, 11 years ago (diff)

Working refactored Attribute Authority Client unit tests.

Line 
1"""
2Class Factory
3
4NERC DataGrid project
5"""
6__author__ = "C Byrom - Tessella"
7__date__ = "28/08/08"
8__copyright__ = "(C) 2009 Science and Technology Facilities Council"
9__license__ = "BSD - see LICENSE file in top-level directory"
10__contact__ = "Philip.Kershaw@stfc.ac.uk"
11__revision__ = '$Id: $'
12from ndg.security.common.utils.factory import (importModuleObject,
13                                               callModuleObject)
14 
15def importClass(*arg, **kw):
16    """Backwards compatibility - use importModuleObject instead"""
17    nArgs = len(arg)
18    if nArgs > 1:
19        kw['objectName'] = arg.pop(1)
20    else:
21        kw['objectName'] = kw.pop('className', None)
22       
23    return importModuleObject(*arg, **kw)
24
25           
26def instantiateClass(*arg, **kw):
27    """Wrapper to callModuleObject"""
28    nArgs = len(arg)
29    arg = list(arg)
30    if nArgs > 1:
31        kw['objectName'] = arg.pop(1)
32    else:
33        kw['objectName'] = kw.pop('className', None)
34       
35    if nArgs > 2:
36        kw['objectArgs'] = arg.pop(2)
37    else:
38        kw['objectArgs'] = kw.pop('classArgs', None)
39       
40    if nArgs > 3:
41        kw['objectProperties'] = arg.pop(3)
42    else:
43        kw['objectProperties'] = kw.pop('classProperties', None)
44
45    arg = tuple(arg)
46    return callModuleObject(*arg, **kw)
Note: See TracBrowser for help on using the repository browser.