Esempio n. 1
0
class TestJulyApplication(object):
    def setUp(self):
        self.application = JulyApplication()

    def test_register_context(self):
        self.application.register_context('key', 'value')
        assert self.application.settings['__july_global__']['key'] == 'value'

    def test_register_filter(self):
        self.application.register_filter('min', min)

    @raises(ImportError)
    def test_register_app1(self):
        app = JulyApp('app1', __name__)
        app.add_handler(('', 'joking'))
        self.application.register_app(app, '/app')

    def test_register_app2(self):
        #: app without handlers
        app = JulyApp('app2', 'app2')
        assert '__july_apps__' not in self.application.settings
        self.application.register_app(app, '/app')
Esempio n. 2
0
File: app.py Progetto: npk/june
def create_application():
    settings = dict(
        debug=options.debug,
        autoescape=options.autoescape,
        cookie_secret=options.cookie_secret,
        xsrf_cookies=True,
        login_url=options.login_url,
        template_path=options.template_path,
        static_path=options.static_path,
        static_url_prefix=options.static_url_prefix,
    )
    #: init application
    application = JulyApplication(**settings)

    #: register account app
    application.register_app("june.account.handlers.app", url_prefix="/account")
    application.register_app("june.account.service.app", url_prefix="/social")
    application.add_handler(("/members", "june.account.handlers.MembersHandler"))
    application.add_handler(("/city/(.*)", "june.account.handlers.CityMembersHandler"))

    #: register node app
    application.register_app("june.node.handlers.app", url_prefix="/node")

    from june.node.handlers import NodeListHandler

    application.add_handler(("/nodes", NodeListHandler))

    #: register topic app
    application.register_app("june.topic.handlers.app", url_prefix="/topic")

    from june.topic.handlers import CreateNodeTopicHandler
    from june.topic.handlers import ReplyHandler

    application.add_handler(("/node/(\w+)/create", CreateNodeTopicHandler))
    application.add_handler(("/reply/(\d+)", ReplyHandler))

    #: register dashboard app
    application.register_app("june.dashboard.handlers.app", url_prefix="/dashboard")

    #: register mail service
    application.register_app("july.ext.mail.handlers.app", url_prefix="/mail")

    #: register front app
    application.register_app("june.front.handlers.app", url_prefix="")

    #: register feedback app
    # application.register_app('june.feedback.handlers.app')

    for key in ["sitename", "siteurl", "sitefeed", "version", "ga", "gcse"]:
        application.register_context(key, options[key].value())

    import datetime

    application.register_context("now", datetime.datetime.utcnow)
    application.register_context("debug", options.debug)

    from june.filters import markdown, xmldatetime, localtime, timesince
    from june.filters import topiclink, normal_markdown

    application.register_filter("markdown", markdown)
    application.register_filter("normal_markdown", normal_markdown)
    application.register_filter("xmldatetime", xmldatetime)
    application.register_filter("localtime", localtime)
    application.register_filter("timesince", timesince)
    application.register_filter("topiclink", topiclink)

    return application
Esempio n. 3
0
 def setUp(self):
     self.application = JulyApplication()
Esempio n. 4
0
File: app.py Progetto: zofuthan/july

class HomeHandler(JulyHandler):
    def get(self):
        self.render('home.html')

    def post(self):
        user = self.get_argument('user')
        subject = self.get_argument('subject')
        body = self.get_argument('body')
        dct = dict(user=user, subject=subject, body=body, subtype='html')
        self.redirect('/')
        webservice.post('mail/outbox', dct)


handlers = [
    ('/', HomeHandler),
]


settings = dict(
    template_path=os.path.join(ROOT, 'templates'),
)

application = JulyApplication(handlers=handlers, debug=True, **settings)

application.register_app('july.ext.mail.handlers.app', url_prefix='/mail')

if __name__ == '__main__':
    run_server(application)
Esempio n. 5
0
File: app.py Progetto: zofuthan/july
import os.path
ROOT = os.path.abspath(os.path.dirname(__file__))
from post.models import Post
from post.handlers import post_app


class HomeHandler(JulyHandler):
    def get(self):
        posts = Post.query.all()
        self.render('home.html', posts=posts)


handlers = [
    ('/', HomeHandler),
]


settings = dict(
    template_path=os.path.join(ROOT, 'templates'),
    static_path=os.path.join(ROOT, 'static'),
    static_url_prefix='/static/',
)

application = JulyApplication(handlers=handlers, debug=True, **settings)

application.register_app(post_app, url_prefix='/post')

if __name__ == '__main__':
    run_server(application)
Esempio n. 6
0
File: app.py Progetto: askender/june
def create_application():
    settings = dict(
        debug=options.debug,
        autoescape=options.autoescape,
        cookie_secret=options.cookie_secret,
        xsrf_cookies=True,
        login_url=options.login_url,

        template_path=options.template_path,
        static_path=options.static_path,
        static_url_prefix=options.static_url_prefix,
    )
    #: init application
    application = JulyApplication(**settings)

    #: register account app
    application.register_app(
        'june.account.handlers.app',
        url_prefix='/account'
    )
    application.register_app('june.account.service.app', url_prefix='/social')
    application.add_handler(
        ('/members', 'june.account.handlers.MembersHandler')
    )
    application.add_handler(
        ('/city/(.*)', 'june.account.handlers.CityMembersHandler')
    )

    #: register node app
    application.register_app('june.node.handlers.app', url_prefix='/node')

    from june.node.handlers import NodeListHandler
    application.add_handler(('/nodes', NodeListHandler))

    #: register topic app
    application.register_app('june.topic.handlers.app', url_prefix='/topic')

    from june.topic.handlers import CreateNodeTopicHandler
    from june.topic.handlers import ReplyHandler
    application.add_handler(('/node/(\w+)/create', CreateNodeTopicHandler))
    application.add_handler(('/reply/(\d+)', ReplyHandler))

    #: register dashboard app
    application.register_app(
        'june.dashboard.handlers.app',
        url_prefix='/dashboard'
    )

    #: register mail service
    application.register_app('july.ext.mail.handlers.app', url_prefix='/mail')

    #: register front app
    application.register_app('june.front.handlers.app', url_prefix='')

    #: register feedback app
    # application.register_app('june.feedback.handlers.app')

    for key in ['sitename', 'siteurl', 'sitefeed', 'version', 'ga', 'gcse']:
        application.register_context(key, options[key].value())

    import datetime
    application.register_context('now', datetime.datetime.utcnow)

    from june.filters import markdown, xmldatetime, localtime, timesince
    from june.filters import topiclink, normal_markdown
    application.register_filter('markdown', markdown)
    application.register_filter('normal_markdown', normal_markdown)
    application.register_filter('xmldatetime', xmldatetime)
    application.register_filter('localtime', localtime)
    application.register_filter('timesince', timesince)
    application.register_filter('topiclink', topiclink)

    return application