| 951 | range_constructor = Range |
| 952 | |
| 953 | def __init__(self, parent=None, session=None, **kwargs): |
| 954 | if parent and session: |
| 955 | raise ValueError('Need a parent or a session but not both') |
| 956 | |
| 957 | self.table = parent |
| 958 | self.session = parent.session if parent else session |
| 959 | |
| 960 | cloud_data = kwargs.get(self._cloud_data_key, {}) |
| 961 | |
| 962 | self.object_id = cloud_data.get('index', None) |
| 963 | |
| 964 | # Choose the main_resource passed in kwargs over parent main_resource |
| 965 | main_resource = kwargs.pop('main_resource', None) or ( |
| 966 | getattr(parent, 'main_resource', None) if parent else None) |
| 967 | |
| 968 | # append the encoded column path |
| 969 | main_resource = '{}/rows/itemAt(index={})'.format(main_resource, self.object_id) |
| 970 | |
| 971 | super().__init__( |
| 972 | protocol=parent.protocol if parent else kwargs.get('protocol'), |
| 973 | main_resource=main_resource) |
| 974 | |
| 975 | self.index = cloud_data.get('index', 0) # zero indexed |
| 976 | self.values = cloud_data.get('values', [[]]) # json string |
| 977 | |
| 978 | def __str__(self): |
| 979 | return self.__repr__() |