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")
示例#2
0
 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))
示例#3
0
 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))
示例#4
0
 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))
示例#5
0
 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")
示例#6
0
 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))
示例#7
0
 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))
示例#8
0
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())
示例#9
0
 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))
示例#10
0
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())
示例#11
0
 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))
示例#12
0
 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))
示例#13
0
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)
示例#14
0
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
示例#15
0
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
示例#16
0
 def test_query_parameter(self):
     self.assertEqual(req.get_query(), "")
     request = req.get_request()
     request.form["q"] = "#*!$Foo"
     self.assertEqual(req.get_query(), "Foo*")
示例#17
0
 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")
示例#18
0
 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())
示例#21
0
 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_query_parameter(self):
     self.assertEqual(req.get_query(), "")
     request = req.get_request()
     request.form["q"] = "#*!$Foo"
     self.assertEqual(req.get_query(), "Foo*")
示例#23
0
 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_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")
示例#25
0
 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_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)
示例#27
0
 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")
示例#28
0
 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)
 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_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_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_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)
示例#33
0
 def test_complete_parameter(self):
     self.assertFalse(req.get_complete())
     request = req.get_request()
     request.form["complete"] = "yes"
     self.assertTrue(req.get_complete())