def url(self, request): """ return the url to fetch the given file """ root_directory = get_root_directory(request) relpath = self.path.replace(root_directory, "", 1) return request.route_path("treasury_files", id=request.context.id, _query=dict(name=encode_path(relpath)))
def url(self, request, company_id=None): """ return the url to fetch the given file :param obj request: The current request object :param int company_id: The id of the company owning the document (default: the current request context) """ if company_id is None: company_id = request.context.id root_directory = get_root_directory(request) relpath = self.path.replace(root_directory, "", 1) return request.route_path("treasury_files", id=company_id, _query=dict(name=encode_path(relpath)))
def url(self, request, company_id=None): """ return the url to fetch the given file :param obj request: The current request object :param int company_id: The id of the company owning the document (default: the current request context) """ if company_id is None: company_id = request.context.id root_directory = get_root_directory(request) relpath = self.path.replace(root_directory, "", 1) return request.route_path( "treasury_files", id=company_id, _query=dict(name=encode_path(relpath)) )
def test_encode_decode(): st = u"$deù % ù$ùdeù % - /// // \ \dekodok %spkoij idje ' kopk \"" encoded = encode_path(st) assert decode_path(encoded) == st
def test_encode_decode(self): st = u"$deù % ù$ùdeù % - /// // \ \dekodok %spkoij idje ' kopk \"" encoded = encode_path(st) self.assertEqual(decode_path(encoded), st)