def test_sort_order_parameter(self): self.assertEqual(req.get_sort_order(), "ascending") request = req.get_request() request.form["sort_order"] = "desc" self.assertEqual(req.get_sort_order(), "descending") request.form["sort_order"] = "DESC" self.assertEqual(req.get_sort_order(), "descending")
def make_next_url(self): if self.batch.next is not None: return None request = req.get_request() params = request.form params["b_start"] = self.batch.numpages * self.batch.size return "%s?%s" % (request.URL, urllib.urlencode(params))
def make_prev_url(self): if not self.batch.has_previous: return None request = req.get_request() params = request.form params["b_start"] = max(self.batch.pagenumber - 2, 0) * self.batch.pagesize return "%s?%s" % (request.URL, urllib.urlencode(params))
def make_next_url(self): if not self.batch.has_next: return None request = req.get_request() params = request.form params["b_start"] = self.batch.pagenumber * self.batch.pagesize return "%s?%s" % (request.URL, urllib.urlencode(params))
def make_prev_url(self): if self.batch.previous is not None: return None request = req.get_request() params = request.form params["b_start"] = max(self.batch.numpages - 2, 0) * self.batch.size return "%s?%s" % (request.URL, urllib.urlencode(params))
def get_sharing_view_for(obj): """Get the sharing view :returns: Sharing view for the given object :rtype: object """ return ploneapi.content.get_view('sharing', obj, req.get_request())
def get_view(name, context=None, request=None): """Get the view by name :param name: The name of the view :type name: str :param context: The context to query the view :type context: ATContentType/DexterityContentType/CatalogBrain :param request: The request to query the view :type request: HTTPRequest object :returns: HTTP Request :rtype: Products.Five.metaclass View object """ context = context or get_portal() request = request or req.get_request() or None return getMultiAdapter((get_object(context), request), name=name)
def get_request_query(): """ checks the request for known catalog indexes. """ query = {} # only known indexes get observed indexes = get_catalog_indexes() # check what we can use from the reqeust request = req.get_request() for idx in indexes: val = request.form.get(idx) if val: query[idx] = to_index_value(val, idx) return query
def test_query_parameter(self): self.assertEqual(req.get_query(), "") request = req.get_request() request.form["q"] = "#*!$Foo" self.assertEqual(req.get_query(), "Foo*")
def test_path_parameter(self): self.assertEqual(req.get_path(), "") request = req.get_request() request.form["path"] = "/Plone/folder" self.assertEqual(req.get_path(), "/Plone/folder")
def test_depth_parameter(self): self.assertEqual(req.get_depth(), 0) request = req.get_request() request.form["depth"] = 5 self.assertEqual(req.get_depth(), 5)
def test_recent_created_parameter(self): self.assertEqual(req.get_recent_created(), None) request = req.get_request() request.form["recent_created"] = "this-week" self.assertEqual(req.get_recent_created(), "this-week")
def test_complete_parameter(self): self.assertFalse(req.get_complete()) request = req.get_request() request.form["complete"] = "yes" self.assertTrue(req.get_complete())
def test_batch_size_parameter(self): self.assertEqual(req.get_batch_size(), 25) request = req.get_request() request.form["limit"] = 1 self.assertEqual(req.get_batch_size(), 1)
def test_sort_on_parameter(self): self.assertEqual(req.get_sort_on(), None) request = req.get_request() request.form["sort_on"] = "Title" self.assertEqual(req.get_sort_on(), "Title")
def test_sort_limit_parameter(self): self.assertEqual(req.get_sort_limit(), None) request = req.get_request() request.form["sort_limit"] = 1 self.assertEqual(req.get_sort_limit(), 1)
def test_batch_start_parameter(self): self.assertEqual(req.get_batch_start(), 0) request = req.get_request() request.form["b_start"] = 1 self.assertEqual(req.get_batch_start(), 1)