| 1022 | range_constructor = Range |
| 1023 | |
| 1024 | def __init__(self, parent=None, session=None, **kwargs): |
| 1025 | if parent and session: |
| 1026 | raise ValueError('Need a parent or a session but not both') |
| 1027 | |
| 1028 | self.table = parent |
| 1029 | self.session = parent.session if parent else session |
| 1030 | |
| 1031 | cloud_data = kwargs.get(self._cloud_data_key, {}) |
| 1032 | |
| 1033 | self.object_id = cloud_data.get('id', None) |
| 1034 | |
| 1035 | # Choose the main_resource passed in kwargs over parent main_resource |
| 1036 | main_resource = kwargs.pop('main_resource', None) or ( |
| 1037 | getattr(parent, 'main_resource', None) if parent else None) |
| 1038 | |
| 1039 | # append the encoded column path |
| 1040 | main_resource = "{}/columns('{}')".format(main_resource, quote(self.object_id)) |
| 1041 | |
| 1042 | super().__init__( |
| 1043 | protocol=parent.protocol if parent else kwargs.get('protocol'), |
| 1044 | main_resource=main_resource) |
| 1045 | |
| 1046 | self.name = cloud_data.get('name', '') |
| 1047 | self.index = cloud_data.get('index', 0) # zero indexed |
| 1048 | self.values = cloud_data.get('values', [[]]) # json string |
| 1049 | |
| 1050 | def __str__(self): |
| 1051 | return self.__repr__() |