# Path: crabpy/client.py
# def crab_request(client, action, *args):
#     """
#     Utility function that helps making requests to the CRAB service.
# 
#     :param client: A :class:`suds.client.Client` for the CRAB service.
#     :param string action: Which method to call, eg. `ListGewesten`
#     :returns: Result of the SOAP call.
# 
#     .. versionadded:: 0.3.0
#     """
#     log.debug("Calling %s on CRAB service.", action)
#     return getattr(client.service, action)(*args)
# 
# Path: crabpy/gateway/exception.py
# class GatewayResourceNotFoundException(GatewayException):
#     """
#     An exception that signifies that no results where found.
#     """
#     def __init__(self):
#         GatewayException.__init__(self, 'This resource was not found.')
# 
# Path: crabpy/gateway/exception.py
# class GatewayRuntimeException(GatewayException):
#     """
#     An exception that signifies a soap request went wrong.
# 
#     """
# 
#     soapfault = None
#     """
#     The soapfault that was generated by the service.
#     """
# 
#     def __init__(self, message, soapfault):
#         GatewayException.__init__(self, message)
#         self.soapfault = soapfault


import json
import logging
import math
import os
from dogpile.cache import make_region
from suds import WebFault
from crabpy.client import crab_request
from crabpy.gateway.exception import GatewayResourceNotFoundException
from crabpy.gateway.exception import GatewayRuntimeException
            )
            try:
                return [ Subadres(
                    r.SubadresId,
                    r.Subadres,
                    r.StatusSubadres
                )for r in res.SubadresWithStatusItem ]
            except AttributeError:
                return []
        if self.caches['short'].is_configured:
            key = 'ListSubadressenWithStatusByHuisnummerId#%s' % (id)
            subadressen = self.caches['short'].get_or_create(key, creator)
        else:
            subadressen = creator()
        for s in subadressen:
            s.set_gateway(self)
        return subadressen

    def get_subadres_by_id(self, id):
        """
        Retrieve a `Subadres` by the Id.

        :param integer id: the Id of the `Subadres`
        :rtype: :class:`Subadres`
        """
        def creator():
            res = crab_gateway_request(
                self.client, 'GetSubadresWithStatusBySubadresId', id
            )
            if res == None:

# Path: crabpy/client.py
# def crab_request(client, action, *args):
#     """
#     Utility function that helps making requests to the CRAB service.
# 
#     :param client: A :class:`suds.client.Client` for the CRAB service.
#     :param string action: Which method to call, eg. `ListGewesten`
#     :returns: Result of the SOAP call.
# 
#     .. versionadded:: 0.3.0
#     """
#     log.debug("Calling %s on CRAB service.", action)
#     return getattr(client.service, action)(*args)
# 
# Path: crabpy/gateway/exception.py
# class GatewayResourceNotFoundException(GatewayException):
#     """
#     An exception that signifies that no results where found.
#     """
#     def __init__(self):
#         GatewayException.__init__(self, 'This resource was not found.')
# 
# Path: crabpy/gateway/exception.py
# class GatewayRuntimeException(GatewayException):
#     """
#     An exception that signifies a soap request went wrong.
# 
#     """
# 
#     soapfault = None
#     """
#     The soapfault that was generated by the service.
#     """
# 
#     def __init__(self, message, soapfault):
#         GatewayException.__init__(self, message)
#         self.soapfault = soapfault


# Path: crabpy/gateway/crab.py
import json
import logging
import math
import os
from dogpile.cache import make_region
from suds import WebFault
from crabpy.client import crab_request
from crabpy.gateway.exception import GatewayResourceNotFoundException
from crabpy.gateway.exception import GatewayRuntimeException

            )
            try:
                return [ Subadres(
                    r.SubadresId,
                    r.Subadres,
                    r.StatusSubadres
                )for r in res.SubadresWithStatusItem ]
            except AttributeError:
                return []
        if self.caches['short'].is_configured:
            key = 'ListSubadressenWithStatusByHuisnummerId#%s' % (id)
            subadressen = self.caches['short'].get_or_create(key, creator)
        else:
            subadressen = creator()
        for s in subadressen:
            s.set_gateway(self)
        return subadressen

    def get_subadres_by_id(self, id):
        """
        Retrieve a `Subadres` by the Id.

        :param integer id: the Id of the `Subadres`
        :rtype: :class:`Subadres`
        """
        def creator():
            res = crab_gateway_request(
                self.client, 'GetSubadresWithStatusBySubadresId', id
            )
            if res == None:

                raise GatewayResourceNotFoundException()