def relation(self, key): if not hasattr(self, key): return Relation(parentObject=self, key=key) try: return getattr(self, key).with_parent(parentObject=self, key=key) except: raise ParseError("Column '%s' is not a Relation." % (key, ))
def _probe_for_relation_class(self): """Retrive the schema from the server to find related class.""" schema = self.parentObject.__class__.schema() fields = schema['fields'] relatedColumn = fields[self.key] columnType = relatedColumn['type'] if columnType == 'Relation': self.relatedClassName = relatedColumn['targetClass'] else: raise ParseError('Column type is %s, expected Relation' % (columnType, ))
def save(self, batch=False): if self.url is not None: raise ParseError("Files can't be overwritten") uri = '/'.join([self.__class__.ENDPOINT_ROOT, self.name]) headers = {'Content-type': self.mimetype} response = self.__class__.POST(uri, extra_headers=headers, batch=batch, _body=self._content) self._file_url = response['url'] self._name = response['name'] self._api_url = '/'.join([API_ROOT, 'files', self._name]) if batch: return response, lambda response_dict: None
def save(self, batch=False): if self.url is not None: raise ParseError("Files can't be overwritten") headers = {'Content-type': self.mimetype} response = self.__class__.POST(name=self.name, extra_headers=headers, batch=batch, _body=self._content) self._file_url = response['url'] self._name = response['name'] if batch: return response, lambda response_dict: None
def alert(self, data=None, channels=None): # pylint: disable=unused-argument """ Implement the interface, but just raise the ParseError exception """ raise ParseError('oops')