def __init__(self, address, apikey=None, user_agent=None, get_only=False, session=None, base_url='api/action/'): self.address = address self.apikey = apikey self.get_only = get_only self.session = session self.base_url = base_url if not user_agent: user_agent = "ckanapi/{version} (+{url})".format( version=__version__, url='https://github.com/ckan/ckanapi') self.user_agent = user_agent self.action = ActionShortcut(self) net_loc = urlparse(address) if ']' in net_loc: net_loc = net_loc[:net_loc.index(']') + 1] elif ':' in net_loc: net_loc = net_loc[:net_loc.index(':')] if net_loc not in MY_SITES: # add your sites to MY_SITES above instead of removing this self.parallel_limit = PARALLEL_LIMIT
def __init__(self, username=None, context=None): from ckan.logic import get_action self._get_action = get_action if username is None: username = self.get_site_username() self.username = username self.context = dict(context or [], user=self.username) self.action = ActionShortcut(self)
def __init__(self, test_app, apikey=None): self.test_app = test_app self.apikey = apikey self.action = ActionShortcut(self)