Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested StorageObj #311

Open
polsm91 opened this issue Jan 30, 2020 · 0 comments
Open

Nested StorageObj #311

polsm91 opened this issue Jan 30, 2020 · 0 comments
Labels

Comments

@polsm91
Copy link
Collaborator

polsm91 commented Jan 30, 2020

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'
@yolandab yolandab added the bug label Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants