Пример #1
0
    def _get_keys(self, env):
        """
        Returns the X-[Account|Container]-Meta-Temp-URL-Key[-2] header values
        for the account or container, or an empty list if none are set.

        Returns 0-4 elements depending on how many keys are set in the
        account's or container's metadata.

        Also validate that the request
        path indicates a valid container; if not, no keys will be returned.

        :param env: The WSGI environment for the request.
        :returns: list of tempurl keys
        """
        parts = env['PATH_INFO'].split('/', 4)
        if len(parts) < 4 or parts[0] or not valid_api_version(parts[1]) \
                or not parts[2] or not parts[3]:
            return []

        account_info = get_account_info(env, self.app, swift_source='FP')
        account_keys = get_tempurl_keys_from_metadata(account_info['meta'])

        container_info = get_container_info(env, self.app, swift_source='FP')
        container_keys = get_tempurl_keys_from_metadata(
            container_info.get('meta', []))

        return account_keys + container_keys
    def _get_keys(self, env):
        """
        Returns the X-[Account|Container]-Meta-Temp-URL-Key[-2] header values
        for the account or container, or an empty list if none are set.

        Returns 0-4 elements depending on how many keys are set in the
        account's or container's metadata.

        Also validate that the request
        path indicates a valid container; if not, no keys will be returned.

        :param env: The WSGI environment for the request.
        :returns: list of tempurl keys
        """
        parts = env["PATH_INFO"].split("/", 4)
        if len(parts) < 4 or parts[0] or parts[1] != "v1" or not parts[2] or not parts[3]:
            return []

        account_info = get_account_info(env, self.app, swift_source="FP")
        account_keys = get_tempurl_keys_from_metadata(account_info["meta"])

        container_info = get_container_info(env, self.app, swift_source="FP")
        container_keys = get_tempurl_keys_from_metadata(container_info.get("meta", []))

        return account_keys + container_keys
Пример #3
0
    def _get_keys(self, env):
        """
        Fetch the tempurl keys for the account. Also validate that the request
        path indicates a valid container; if not, no keys will be returned.

        :param env: The WSGI environment for the request.
        :returns: list of tempurl keys
        """
        parts = env["PATH_INFO"].split("/", 4)
        if len(parts) < 4 or parts[0] or parts[1] != "v1" or not parts[2] or not parts[3]:
            return []

        account_info = get_account_info(env, self.app, swift_source="FP")
        return get_tempurl_keys_from_metadata(account_info["meta"])
Пример #4
0
    def _get_keys(self, env):
        """
        Fetch the tempurl keys for the account. Also validate that the request
        path indicates a valid container; if not, no keys will be returned.

        :param env: The WSGI environment for the request.
        :returns: list of tempurl keys
        """
        parts = env['PATH_INFO'].split('/', 4)
        if len(parts) < 4 or parts[0] or parts[1] != 'v1' or not parts[2] or \
                not parts[3]:
            return []

        account_info = get_account_info(env, self.app, swift_source='FP')
        return get_tempurl_keys_from_metadata(account_info['meta'])
Пример #5
0
 def test_unicode_metadata_value(self):
     meta = {"temp-url-key": "test", "temp-url-key-2": u"test2"}
     results = tempurl.get_tempurl_keys_from_metadata(meta)
     for str_value in results:
         self.assertTrue(isinstance(str_value, str))