コード例 #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
コード例 #2
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 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
ファイル: formpost.py プロジェクト: GitFloki/Shake
    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))