Bug 810571 - Params cannot be instantiated before api is imported.
Summary: Params cannot be instantiated before api is imported.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: oVirt
Classification: Retired
Component: ovirt-engine-sdk
Version: unspecified
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
: ---
Assignee: Michael Pasternak
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-04-06 19:00 UTC by Jaroslav Henner
Modified: 2014-01-13 00:37 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-04-06 19:56:10 UTC
oVirt Team: ---
Embargoed:


Attachments (Terms of Use)

Description Jaroslav Henner 2012-04-06 19:00:31 UTC
Description of problem:
Params cannot be instantiated before api is imported.

Version-Release number of selected component (if applicable):
sdk: release 1.6.4-1

How reproducible:


Steps to Reproduce:
In [1]: import ovirtsdk.xml.params as p

In [2]: p.Cluster()
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2302, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (7340, 0))
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/home/jhenner/work/rest-api-tests/<ipython-input-2-1ebbf7d062e4> in <module>()
----> 1 p.Cluster()

/usr/lib/python2.7/site-packages/ovirtsdk/xml/params.pyc in __init__(self, href, id, name, description, actions, creation_status, link, cpu, data_center, memory_policy, scheduling_policy, version, supported_versions, error_handling)
   5223     superclass = BaseResource
   5224     def __init__(self, href=None, id=None, name=None, description=None, actions=None, creation_status=None, link=None, cpu=None, data_center=None, memory_policy=None, scheduling_policy=None, version=None, supported_versions=None, error_handling=None):
-> 5225         super(Cluster, self).__init__(href, id, name, description, actions, creation_status, link, )
   5226         self.cpu = cpu
   5227         self.data_center = data_center

/usr/lib/python2.7/site-packages/ovirtsdk/xml/params.pyc in __init__(self, href, id, name, description, actions, creation_status, link, extensiontype_)
   4144     superclass = None
   4145     def __init__(self, href=None, id=None, name=None, description=None, actions=None, creation_status=None, link=None, extensiontype_=None):
-> 4146         self.href = _cast(None, href)
   4147         self.id = _cast(None, id)
   4148         self.name = name

/usr/lib/python2.7/site-packages/ovirtsdk/xml/params.pyc in __setattr__(self, item, value)
    185                     object.__setattr__(self, item, value.superclass)
    186             elif not isinstance(value, list) and  \
--> 187                  ReflectionHelper.isModuleMember(sys.modules['ovirtsdk.infrastructure.brokers'], type(self)) and \
    188                  self.__dict__.has_key('superclass') and self.superclass is not None and \
    189                  not ReflectionHelper.isModuleMember(sys.modules['ovirtsdk.infrastructure.brokers'], type(value)) and\

KeyError: 'ovirtsdk.infrastructure.brokers'

In [3]: from ovirtsdk import api

In [4]: p.Cluster()
Out[4]: <ovirtsdk.xml.params.Cluster at 0x241f190>



  
Actual results:


Expected results:
p.Cluster() is instantiable no matter whether API is imported.

Additional info:

Comment 1 Michael Pasternak 2012-04-06 19:56:10 UTC
by-design, 

also there is no reason to call this bug, importing several modules
for certain module is a common not just in python, but also in others
programming languages,

and having import of ovirtsdk.api in params module not possible
as it will create circular dependency,

p.s note that /import/ paradigm is well documented.

Comment 2 Jaroslav Henner 2012-04-06 20:53:34 UTC
(In reply to comment #1)
> by-design, 
> 
> also there is no reason to call this bug, importing several modules
> for certain module is a common not just in python, but also in others
> programming languages,
> 
> and having import of ovirtsdk.api in params module not possible
> as it will create circular dependency
What about pulling the common dependency to separate module?

> 
> p.s note that /import/ paradigm is well documented.
Where?

Comment 3 Michael Pasternak 2012-04-07 11:32:10 UTC
> What about pulling the common dependency to separate module?

what 'common dependency'?, it's doesn't work because 'brokers' module has
to be loaded in priori, and moving this dep. to any other module won't help
as it will have to be loaded anyway according to dependencies chain,

but i truly don't understand the problem, if documentation says that in
order to use certain class, you have to import module a and module b, but 
you importing only b -  you cannot expect the app. to work, also calling
this bug doesn't make sense.

>> p.s note that /import/ paradigm is well documented.
> Where?

wiki (this is only documentation for the upstream projects)


Note You need to log in before you can comment on or make changes to this bug.