Exemple #1
0
def menuFilter(context, request):
    '''This is a function that filters the "Add" menu item'''
    adding = queryMultiAdapter((context, request), name="+")
    if adding is None:
        adding = Adding(context, request)
    adding.__parent__ = context
    adding.__name__ = '+'
    info = adding.addingInfo()
    return bool(info)
Exemple #2
0
def menuFilter(context, request):
    """This is a function that filters the "Add" menu item"""
    adding = queryMultiAdapter((context, request), name="+")
    if adding is None:
        adding = Adding(context, request)
    adding.__parent__ = context
    adding.__name__ = "+"
    info = adding.addingInfo()
    return bool(info)
Exemple #3
0
 def test_action(self):
     container = Container()
     container = contained(container, Root(), "container")
     request = TestRequest()
     adding = Adding(container, request)
     adding.__name__ = "+"
     ztapi.browserView(IAdding, "Thing", CreationView)
     ztapi.browserView(Interface, "absolute_url", AbsoluteURL)
     ztapi.browserView(None, "", AbsoluteURL, providing=IAbsoluteURL)
     self.assertRaises(UserError, adding.action, "", "foo")
     adding.action("Thing", "foo")
     self.assertEqual(adding.request.response.getHeader("location"), "/container/+/Thing=foo")
     adding.action("Thing/screen1", "foo")
     self.assertEqual(adding.request.response.getHeader("location"), "/container/+/Thing/screen1=foo")
Exemple #4
0
 def test_action(self):
     container = Container()
     container = contained(container, Root(), "container")
     request = TestRequest()
     adding = Adding(container, request)
     adding.__name__ = '+'
     ztapi.browserView(IAdding, "Thing", CreationView)
     ztapi.browserView(Interface, "absolute_url", AbsoluteURL)
     ztapi.browserView(None, '', AbsoluteURL, providing=IAbsoluteURL)
     self.assertRaises(UserError, adding.action, '', 'foo')
     adding.action('Thing', 'foo')
     self.assertEqual(adding.request.response.getHeader('location'),
                      '/container/+/Thing=foo')
     adding.action('Thing/screen1', 'foo')
     self.assertEqual(adding.request.response.getHeader('location'),
                      '/container/+/Thing/screen1=foo')
Exemple #5
0
    def addObject(self):
        request = self.request
        if IContainerNamesContainer.providedBy(self.context):
            new = ""
        else:
            new = request["new_value"]

        adding = zapi.queryMultiAdapter((self.context, self.request), name="+")
        if adding is None:
            adding = Adding(self.context, request)
        else:
            # Set up context so that the adding can build a url
            # if the type name names a view.
            # Note that we can't so this for the "adding is None" case
            # above, because there is no "+" view.
            adding.__parent__ = self.context
            adding.__name__ = '+'

        adding.action(request['type_name'], new)
Exemple #6
0
    def addObject(self):
        request = self.request
        if IContainerNamesContainer.providedBy(self.context):
            new = ""
        else:
            new = request["new_value"]

        adding = queryMultiAdapter((self.context, self.request), name="+")
        if adding is None:
            adding = Adding(self.context, request)
        else:
            # Set up context so that the adding can build a url
            # if the type name names a view.
            # Note that we can't so this for the "adding is None" case
            # above, because there is no "+" view.
            adding.__parent__ = self.context
            adding.__name__ = '+'

        adding.action(request['type_name'], new)