How to use the pyactiveresource.formats function in pyactiveresource

To help you get started, we’ve selected a few pyactiveresource examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JetBrains / youtrack-rest-python-library / python / pyactiveresource / activeresource.py View on Github external
self.klass.headers,
                        data=self.to_xml())
            else:
                response = self.klass.connection.post(
                        self._collection_path(self._prefix_options),
                        self.klass.headers,
                        data=self.to_xml())
                new_id = self._id_from_response(response)
                if new_id:
                    self.id = new_id
        except connection.ResourceInvalid, err:
            self.errors.from_xml(err.response.body)
            return False
        try:
            attributes = self.klass.format.decode(response.body)
        except formats.Error:
            return True
        if attributes:
            self._update(attributes)
        return True
github JetBrains / youtrack-rest-python-library / python / pyactiveresource / activeresource.py View on Github external
def get_primary_key(cls):
        return cls._primary_key

    def set_primary_key(cls, value):
        cls._primary_key = value

    primary_key = property(get_primary_key, set_primary_key, None,
                           'Name of attribute that uniquely identies the resource')


class ActiveResource(object):
    """Represents an activeresource object."""

    __metaclass__ = ResourceMeta
    _connection = None
    _format = formats.XMLFormat
    _headers = None
    _password = None
    _site = None
    _timeout = None
    _user = None
    _primary_key = "id"

    def __init__(self, attributes=None, prefix_options=None):
        """Initialize a new ActiveResource object.

        Args:
            attributes: A dictionary of attributes which represent this object.
            prefix_options: A dict of prefixes to add to the request for
                            nested URLs.
        """
        if attributes is None: