示例#1
0
文件: api.py 项目: andreif/djedi-cms
 def get(self, request, uri):
     try:
         uri = self.decode_uri(uri)
         uri = URI(uri)
         plugins.resolve(uri)
     except UnknownPlugin:
         raise Http404
     else:
         return self.render_plugin(request, self.get_context_data(uri=uri))
示例#2
0
    def test_resolve_plugin(self):
        with self.assertRaises(UnknownPlugin):
            plugins.get('xyz')

        plugin = plugins.resolve('i18n://sv-se@page/title.txt')
        self.assertIsInstance(plugin, TextPlugin)

        with self.assertRaises(UnknownPlugin):
            plugins.resolve('i18n://sv-se@page/title.foo')
示例#3
0
文件: api.py 项目: ZipFile/djedi-cms
 def get(self, request, uri):
     try:
         uri = self.decode_uri(uri)
         uri = URI(uri)
         plugins.resolve(uri)
     except UnknownPlugin:
         raise Http404
     else:
         return self.render_plugin(request, self.get_context_data(uri=uri))
示例#4
0
    def test_resolve_plugin(self):
        with self.assertRaises(UnknownPlugin):
            plugins.get('xyz')

        plugin = plugins.resolve('i18n://sv-se@page/title.txt')
        self.assertIsInstance(plugin, TextPlugin)

        with self.assertRaises(UnknownPlugin):
            plugins.resolve('i18n://sv-se@page/title.foo')
示例#5
0
    def get(self, request, uri):
        try:
            uri = self.decode_uri(uri)
            uri = URI(uri)
            plugin = plugins.resolve(uri)
            plugin_context = self.get_context_data(uri=uri)

            if isinstance(plugin, DjediPlugin):
                plugin_context = plugin.get_editor_context(**plugin_context)

        except UnknownPlugin:
            raise Http404
        else:
            return self.render_plugin(request, plugin_context)