예제 #1
0
 def setUp(self):
     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()
예제 #2
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)
예제 #3
0
    def test_change_schema_after_writing_and_try_to_update(self):
        self.update_page(u'Hello there?', u'Hello')

        caching.flush_all()
        schema.SCHEMA_TO_LOAD.append({
            "properties": {
                "author": {
                    "cardinality": [1, 1]
                }
            }
        })

        self.update_page(u'.schema Book\n\n    #!yaml/schema\n    author: "Alan Kang"\n\nHello there?\n', u'Hello')
예제 #4
0
    def test_change_schema_after_writing_and_try_to_read(self):
        self.update_page(u'Hello there?', u'Hello')

        caching.flush_all()
        schema.SCHEMA_TO_LOAD.append(
            {"properties": {
                "author": {
                    "cardinality": [1, 1]
                }
            }})

        page = WikiPage.get_by_title(u'Hello')
        page.rendered_body
예제 #5
0
    def test_change_schema_after_writing_and_try_to_read(self):
        self.update_page(u'Hello there?', u'Hello')

        caching.flush_all()
        schema.SCHEMA_TO_LOAD.append({
            "properties": {
                "author": {
                    "cardinality": [1, 1]
                }
            }
        })

        page = WikiPage.get_by_title(u'Hello')
        page.rendered_body
예제 #6
0
    def test_change_schema_after_writing_and_try_to_update(self):
        self.update_page(u'Hello there?', u'Hello')

        caching.flush_all()
        schema.SCHEMA_TO_LOAD.append(
            {"properties": {
                "author": {
                    "cardinality": [1, 1]
                }
            }})

        self.update_page(
            u'.schema Book\n\n    #!yaml/schema\n    author: "Alan Kang"\n\nHello there?\n',
            u'Hello')
예제 #7
0
def special(request, path):
    head = False
    if request.method == 'GET':
        if path == u'changes':
            resource = ChangeListResource(request)
            return resource.get(head)
        elif path == u'index':
            resource = TitleIndexResource(request)
            return resource.get(head)
        elif path == u'posts':
            resource = PostListResource(request)
            return resource.get(head)
        elif path == u'titles':
            resource = TitleListResource(request)
            return resource.get(head)
        elif path == u'search':
            resource = SearchResultResource(request)
            return resource.get(head)
        elif path == u'flush_cache':
            caching.flush_all()
            response = HttpResponse()
            response['Content-Type'] = 'text/plain; charset=utf-8'
            response.write('Done!')
            return response
        elif path == u'preferences':
            resource = UserPreferencesResource(request)
            return resource.get(head)
        elif path.startswith(u'schema/'):
            resource = SchemaResource(request, path)
            return resource.get(head)
        elif path == u'opensearch':
            representation = TemplateRepresentation({}, request, 'opensearch.xml')
            return representation.respond(HttpResponse(), head)
        elif path == u'randomly_update_related_pages':
            recent = request.GET.get('recent', '0')
            titles = WikiPage.randomly_update_related_links(50, recent == '1')
            response = HttpResponse()
            response['Content-Type'] = 'text/plain; charset=utf-8'
            response.write('\n'.join(titles))
            return response
    elif request.method == 'POST':
        method = request.GET.get('_method', 'POST')
        if method == 'POST' and path == 'preferences':
            resource = UserPreferencesResource(request)
            return resource.post()
예제 #8
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)
예제 #9
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)
예제 #10
0
 def tearDown(self):
     caching.flush_all()
     self.testbed.deactivate()
     self.logout()
예제 #11
0
파일: post.py 프로젝트: neuront/nijipress
def _invalidate_cache():
    memcache.delete('posts')
    caching.flush_all()