Beispiel #1
0
    def setUp(self):
        self.database_name = 'test_motorblog'
        sync_client = pymongo.mongo_client.MongoClient()
        self.sync_db = sync_client[self.database_name]
        for collection_name in [
                'events', 'fs.chunks', 'fs.files', 'posts', 'categories'
        ]:
            self.sync_db.drop_collection(collection_name)

        self.patchers = []
        self.set_option('host', 'localhost')
        self.set_option('blog_name', 'My Test Blog')
        self.set_option('base_url', 'test-blog')
        self.set_option('author_display_name', 'Test J. Author')
        self.set_option('author_email', '*****@*****.**')
        self.set_option('twitter_handle', 'test_twitter_handle')
        self.set_option('description', 'test description')
        self.set_option('google_analytics_id', 'TEST GA ID')
        self.set_option('user', 'admin')
        self.set_option('password', 'password')
        self.set_option('cookie_secret', 'test-cookie-secret')
        self.set_option('debug', True)

        # Sets self.__port, and sets self.app = self.get_app().
        super(MotorBlogTest, self).setUp()
        cache.startup(self.get_db())

        # Clear categories cache.
        cache._on_event({'name': 'categories_changed'})
Beispiel #2
0
    def setUp(self):
        self.database_name = 'test_motorblog'
        sync_client = pymongo.mongo_client.MongoClient()
        self.sync_db = sync_client[self.database_name]
        for collection_name in [
                'events',
                'fs.chunks',
                'fs.files',
                'posts',
                'categories']:
            self.sync_db.drop_collection(collection_name)

        self.patchers = []
        self.set_option('host', 'localhost')
        self.set_option('blog_name', 'My Test Blog')
        self.set_option('base_url', 'test-blog')
        self.set_option('author_display_name', 'Test J. Author')
        self.set_option('author_email', '*****@*****.**')
        self.set_option('twitter_handle', 'test_twitter_handle')
        self.set_option('description', 'test description')
        self.set_option('google_analytics_id', 'TEST GA ID')
        self.set_option('user', 'admin')
        self.set_option('password', 'password')
        self.set_option('cookie_secret', 'test-cookie-secret')
        self.set_option('debug', True)

        # Sets self.__port, and sets self.app = self.get_app().
        super(MotorBlogTest, self).setUp()
        cache.startup(self.get_db())

        # Clear categories cache.
        cache._on_event({'name': 'categories_changed'})
Beispiel #3
0
from motor_blog.api.handlers import APIHandler, RSDHandler
from motor_blog.web.lytics import TrackingPixelHandler
from motor_blog.web.handlers import *
from motor_blog.web.admin import *

# TODO: RPC over HTTPS
# TODO: a static-url function to set long cache TTL on media URLs
# TODO: Nginx cache media
# TODO: sitemap.xml

if __name__ == "__main__":
    opts = options.options()

    # TODO: Mongo connection options
    db = motor.MotorClient().open_sync().motorblog
    cache.startup(db)

    if opts.rebuild_indexes or opts.ensure_indexes:
        indexes.ensure_indexes(
            db.connection.sync_client().motorblog,
            opts.rebuild_indexes)

    base_url = opts.base_url

    class U(tornado.web.URLSpec):
        def __init__(self, pattern, *args, **kwargs):
            """Include base_url in pattern"""
            super(U, self).__init__(
                '/' + base_url.strip('/') + '/' + pattern.lstrip('/'),
                *args, **kwargs
            )
Beispiel #4
0
    print >> sys.stderr, ("Can't import motor.\n\n"
                          " Motor is an experimental async driver for"
                          " MongoDB, get it by cloning\n"
                          " git://github.com/ajdavis/mongo-python-driver.git"
                          " and switching to branch 'motor',\n"
                          " then put the mongo-python-driver directory"
                          " on your PYTHONPATH\n\n")

    raise

if __name__ == "__main__":
    opts = options.options()

    # TODO: Mongo connection options
    db = motor.MotorConnection().open_sync().motorblog
    cache.startup(db)

    if opts.ensure_indexes:
        logging.info('Ensuring indexes...')
        indexes.ensure_indexes(db)
        logging.info('    done.')

    base_url = opts.base_url

    class U(tornado.web.URLSpec):
        def __init__(self, pattern, *args, **kwargs):
            """Include base_url in pattern"""
            super(U, self).__init__(
                '/' + base_url.strip('/') + '/' + pattern.lstrip('/'), *args,
                **kwargs)