Skip to content

Nested StorageObj #311

@polsm91

Description

@polsm91

First:

In [6]: o = Obj('some')                                                                                                                                                                       

In [7]: o.name='bla'                                                                                                                                                                          

In [8]: d = ObjO('someot')                                                                                                                                                                    

In [9]: d.internal = o      

Then:

# coding: utf-8
from storage.api import StorageObject
class Obj(StorageObject):
    '''
    @ClassField name str
    '''

class ObjO(StorageObject):
    '''
    @ClassField internal __main__.Obj
    '''

o = ObjO.get_by_alias('someot')
o.internal
o.internal.name

Results in:

In [6]: o.internal.name                                                                                                                                                                       
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~/.local/lib/python3.7/site-packages/Hecuba-0.1.3-py3.7-linux-x86_64.egg/hecuba/storageobj.py in __getattr__(self, attribute)
    246         try:
--> 247             value = result[0][0]
    248             # if exists but is set to None, the current behaviour is raising AttributeError

~/.local/lib/python3.7/site-packages/cassandra/cluster.cpython-37m-x86_64-linux-gnu.so in cassandra.cluster.ResultSet.__getitem__()

IndexError: list index out of range

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-6-0e199d745918> in <module>
----> 1 o.internal.name

~/.local/lib/python3.7/site-packages/Hecuba-0.1.3-py3.7-linux-x86_64.egg/hecuba/storageobj.py in __getattr__(self, attribute)
    251         except IndexError as ex:
    252             if not is_istorage_attr:
--> 253                 raise AttributeError('value not found')
    254             value = None
    255         except TypeError as ex:

AttributeError: value not found




In [7]: d = o.internal                                                                                                                                                                        

In [8]: d                                                                                                                                                                                     
Out[8]: <__main__.Obj at 0x7fbcea973390>

In [9]: d._get_name()                                                                                                                                                                         
Out[9]: 'my_app.someot_internal'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions