示例#1
0
 def getObject(self):
     if self.id == 'missing':
         if self.ob.GETOBJECT_RAISES:
             raise NotFound("missing")
         else:
             return None
     if self.id == 'hop':
         raise ValueError("security problem for this object")
     return self.ob
示例#2
0
 def __call__(self):
     """ Invokes the default view.
     """
     ti = self.getTypeInfo()
     method_id = ti and ti.queryMethodID('(Default)', context=self)
     if method_id and method_id != '(Default)':
         method = getattr(self, method_id)
         if getattr(aq_base(method), 'isDocTemp', 0):
             return method(self, self.REQUEST, self.REQUEST['RESPONSE'])
         else:
             return method()
     else:
         raise NotFound('Cannot find default view for "%s"' %
                        '/'.join(self.getPhysicalPath()))
示例#3
0
def manage_addContent(self, id, type, REQUEST=None):
    """ Add the content type specified by name.
    """
    # self is a FactoryDispatcher.
    contentinit = self.contentinit
    obj = None
    for content_type in contentinit.content_types:
        if content_type.meta_type == type:
            obj = content_type(id)
            break
    if obj is None:
        raise NotFound(type)
    self._setObject(id, obj)
    if REQUEST is not None:
        return self.manage_main(self, REQUEST)
示例#4
0
def manage_addTool(self, type, REQUEST=None):
    """ Add the tool specified by name.
    """
    # self is a FactoryDispatcher.
    toolinit = self.toolinit
    obj = None
    for tool in toolinit.tools:
        if tool.meta_type == type:
            obj = tool()
            break
    if obj is None:
        raise NotFound(type)
    self._setObject(obj.getId(), obj)
    if REQUEST is not None:
        return self.manage_main(self, REQUEST)