コード例 #1
0
ファイル: resources.py プロジェクト: gcmcom/ecogwiki
 def __init__(self, req, res, default_restype="html", default_view="default"):
     caching.create_prc()
     self.user = get_cur_user()
     self.req = req
     self.res = res
     self.default_restype = default_restype
     self.default_view = default_view
コード例 #2
0
ファイル: __init__.py プロジェクト: 0hoo/ecogwiki
    def setUp(self):
        caching.create_prc()

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_user_stub()
        caching.flush_all()
コード例 #3
0
 def __init__(self,
              req,
              res,
              default_restype='html',
              default_view='default'):
     caching.create_prc()
     self.user = get_cur_user()
     self.req = req
     self.res = res
     self.default_restype = default_restype
     self.default_view = default_view
コード例 #4
0
ファイル: views.py プロジェクト: EdgarSun/ecogwiki
 def get(self, path, head=False):
     if path == u'titles':
         resource = TitleListResource(self.request, self.response)
         resource.get(head)
     elif path == u'changes':
         resource = ChangeListResource(self.request, self.response)
         resource.get(head)
     elif path == u'index':
         resource = TitleIndexResource(self.request, self.response)
         resource.get(head)
     elif path == u'posts':
         resource = PostListResource(self.request, self.response)
         resource.get(head)
     elif path == u'search':
         resource = SearchResultResource(self.request, self.response)
         resource.get(head)
     elif path == u'preferences':
         resource = UserPreferencesResource(self.request, self.response)
         resource.get(head)
     elif path.startswith(u'schema/'):
         resource = SchemaResource(self.request, self.response, path)
         resource.get(head)
     elif path == u'opensearch':
         representation = TemplateRepresentation({}, self.request, 'opensearch.xml')
         representation.respond(self.response, head)
     elif path == u'flush_cache':
         caching.flush_all()
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('Done!')
     elif path == u'randomly_update_related_pages':
         caching.create_prc()
         recent = self.request.GET.get('recent', '0')
         titles = WikiPage.randomly_update_related_links(50, recent == '1')
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('\n'.join(titles))
     elif path == u'rebuild_data_index':
         deferred.defer(WikiPage.rebuild_all_data_index, 0)
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('Done! (queued)')
     # elif path == u'gcstest':
     #     import cloudstorage as gcs
     #     f = gcs.open(
     #         '/ecogwiki/test.txt', 'w',
     #         content_type='text/plain',
     #         retry_params=gcs.RetryParams(backoff_factor=1.1),
     #         options={'x-goog-acl': 'public-read'},
     #     )
     #     f.write('Hello')
     #     f.close()
     #     self.response.write('Done')
     else:
         self.abort(404)
コード例 #5
0
ファイル: views.py プロジェクト: yong27/incodom
 def get(self, path, head=False):
     if path == u'titles':
         resource = TitleListResource(self.request, self.response)
         resource.get(head)
     elif path == u'changes':
         resource = ChangeListResource(self.request, self.response)
         resource.get(head)
     elif path == u'index':
         resource = TitleIndexResource(self.request, self.response)
         resource.get(head)
     elif path == u'home':
         resource = NewHomeResource(self.request, self.response)
         resource.get(head)
     elif path == u'posts':
         resource = PostListResource(self.request, self.response)
         resource.get(head)
     elif path == u'search':
         resource = SearchResultResource(self.request, self.response)
         resource.get(head)
     elif path == u'preferences':
         resource = UserPreferencesResource(self.request, self.response)
         resource.get(head)
     elif path.startswith(u'schema/'):
         resource = SchemaResource(self.request, self.response, path)
         resource.get(head)
     elif path == u'opensearch':
         representation = TemplateRepresentation({}, self.request, 'opensearch.xml')
         representation.respond(self.response, head)
     elif path == u'flush_cache':
         caching.flush_all()
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('Done!')
     elif path == u'randomly_update_related_pages':
         caching.create_prc()
         recent = self.request.GET.get('recent', '0')
         titles = WikiPage.randomly_update_related_links(50, recent == '1')
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('\n'.join(titles))
     elif path == u'rebuild_data_index':
         deferred.defer(WikiPage.rebuild_all_data_index, 0)
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('Done! (queued)')
     else:
         self.abort(404)
コード例 #6
0
 def get(self, path, head=False):
     if path == u'titles':
         resource = TitleListResource(self.request, self.response)
         resource.get(head)
     elif path == u'changes':
         resource = ChangeListResource(self.request, self.response)
         resource.get(head)
     elif path == u'index':
         resource = TitleIndexResource(self.request, self.response)
         resource.get(head)
     elif path == u'home':
         resource = NewHomeResource(self.request, self.response)
         resource.get(head)
     elif path == u'posts':
         resource = PostListResource(self.request, self.response)
         resource.get(head)
     elif path == u'search':
         resource = SearchResultResource(self.request, self.response)
         resource.get(head)
     elif path == u'preferences':
         resource = UserPreferencesResource(self.request, self.response)
         resource.get(head)
     elif path.startswith(u'schema/'):
         resource = SchemaResource(self.request, self.response, path)
         resource.get(head)
     elif path == u'opensearch':
         representation = TemplateRepresentation({}, self.request, 'opensearch.xml')
         representation.respond(self.response, head)
     elif path == u'flush_cache':
         caching.flush_all()
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('Done!')
     elif path == u'randomly_update_related_pages':
         caching.create_prc()
         recent = self.request.GET.get('recent', '0')
         titles = WikiPage.randomly_update_related_links(50, recent == '1')
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('\n'.join(titles))
     elif path == u'rebuild_data_index':
         deferred.defer(WikiPage.rebuild_all_data_index, 0)
         self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
         self.response.write('Done! (queued)')
     else:
         self.abort(404)