How to use the pyactiveresource.activeresource.ActiveResource 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 Shopify / shopify_python_api / shopify / base.py View on Github external
version = property(get_version, set_version, None,
                      'Shopify Api Version')

    def get_url(cls):
        return getattr(cls._threadlocal, 'url', ShopifyResource._url)

    def set_url(cls, value):
        ShopifyResource._url = cls._threadlocal.url = value

    url = property(get_url, set_url, None,
                      'Base URL including protocol and shopify domain')


@six.add_metaclass(ShopifyResourceMeta)
class ShopifyResource(ActiveResource, mixins.Countable):
    _format = formats.JSONFormat
    _threadlocal = threading.local()
    _headers = {'User-Agent': 'ShopifyPythonAPI/%s Python/%s' % (shopify.VERSION, sys.version.split(' ', 1)[0])}
    _version = None
    _url = None

    def __init__(self, attributes=None, prefix_options=None):
        if attributes is not None and prefix_options is None:
            prefix_options, attributes = self.__class__._split_options(attributes)
        return super(ShopifyResource, self).__init__(attributes, prefix_options)

    def is_new(self):
        return not self.id

    def _load_attributes_from_response(self, response):
        if response.body.strip():
github JetBrains / youtrack-python-scripts / youtrackutils / redmine / client.py View on Github external
import pprint

from pyactiveresource.activeresource import ActiveResource
from pyactiveresource.connection import ResourceNotFound, MethodNotAllowed, ServerError


class RedmineResource(ActiveResource):
    root_element = None

    def __init__(self, attributes=None, prefix_options=None):
        if isinstance(attributes, basestring):
            self.name = attributes
        super(RedmineResource, self).__init__(attributes, prefix_options)

    def __repr__(self):
        return pprint.pformat(self.attributes, indent=2, width=140)

    @classmethod
    def _build_list(cls, elements, prefix_options=None):
        if cls.root_element is not None and \
                isinstance(elements, dict) and cls.root_element in elements:
            elements = elements[cls.root_element]
        return super(RedmineResource, cls)._build_list(elements, prefix_options)
github zen4ever / route53manager / route53 / views / slicehost.py View on Github external
def get_record_class():
    class Record(ActiveResource):
        _site = API_URL % session[API_KEY]
    return Record
github JetBrains / youtrack-rest-python-library / python / redmine / client.py View on Github external
import sys
import os
from pyactiveresource.activeresource import ActiveResource
from pyactiveresource.connection import ResourceNotFound, MethodNotAllowed
import urlparse
import pprint


class RedmineResource(ActiveResource):
    def __init__(self, attributes=None, prefix_options=None):
        if isinstance(attributes, basestring):
            self.name = attributes
        super(RedmineResource, self).__init__(attributes, prefix_options)

    def __repr__(self):
        return pprint.pformat(self.attributes, indent=2, width=140)


class Project(RedmineResource): pass

class Issue(RedmineResource): pass

class Group(RedmineResource): pass

class User(RedmineResource): pass
github zen4ever / route53manager / route53 / views / slicehost.py View on Github external
def get_zone_class():
    class Zone(ActiveResource):
        _site = API_URL % session[API_KEY]
    return Zone