Exemplo n.º 1
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"mifan.tv",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=True,
        )

        handlers = [
            (r"/", handler.index.IndexHandler),
            (r"/community", handler.community.CommunityHandler),
            (r"/p/(\d+)", handler.post.PostHandler),
            (r"/create", handler.post.CreatePostHandler),

            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.post_model = self.loader.use("post.model")
        self.head1_model = self.loader.use("head1.model")
        self.head2_model = self.loader.use("head2.model")
        self.std_model = self.loader.use("std.model")
        self.hot_model = self.loader.use("hot.model")
        self.comment_model = self.loader.use("comment.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 2
0
class Application(tornado.web.Application):
	def __init__(self):
		settings = dict(
			blog_title = u"Dota2Ark Community",
			template_path = os.path.join(os.path.dirname(__file__), "templates"),
			static_path = os.path.join(os.path.dirname(__file__), "static"),
			avatar_path = os.path.join(os.path.dirname(__file__), 'static/avatar'),
			xsrf_cookies = True,
			cookie_secret = "cookie_secret_code",
			login_url = "/login",
			autoescape = None,
			jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
			reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
			# debug = True,
		)

		tornado.web.Application.__init__(self, routes, **settings)

		# Have one global connection to the blog DB across all handlers
		self.db = torndb.Connection(
			host = options.mysql_host, database = options.mysql_database,
			user = options.mysql_user, password = options.mysql_password
		)

		# Have one global loader for loading models and handles
		self.loader = Loader(self.db)

		# Have one global model for db query
		self.user_model = self.loader.use("user.model")
		self.topic_model = self.loader.use("topic.model")
		self.reply_model = self.loader.use("reply.model")
		self.plane_model = self.loader.use("plane.model")
		self.node_model = self.loader.use("node.model")
		self.notification_model = self.loader.use("notification.model")
		self.vote_model = self.loader.use("vote.model")
		self.favorite_model = self.loader.use("favorite.model")

		self.panel_model = self.loader.use('panel.model')
		self.item_model = self.loader.use('item.model')
		self.inventory_model = self.loader.use('inventory.model')
		# Have one global session controller
		self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

		# Have one global memcache controller
		self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 3
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__),
                                     "templates/spa/static"),
            #xsrf_cookies = True,
            xsrf_cookies=False,
            cookie_secret="cookie_secret_code",
            login_url="/login",
            autoescape=None,
            jinja2=Environment(loader=FileSystemLoader(
                os.path.join(os.path.dirname(__file__), "templates")),
                               trim_blocks=True),
        )

        handlers = [
            (r"/", handler.index.IndexHandler),
            (r"/signup/", handler.signup.SignupHandler),
            (r"/home/", handler.home.HomeHandler),
            (r"/history/(.*)/", handler.history.HistoryHandler),
            (r"/spa/(.*)/", handler.note.NoteHandler),
            # signup
            (r"/api/signup/", handler.usi.UsiSignupHandler),
            # login
            (r"/api/login/", handler.usi.UsiLoginHandler),
            # logout
            (r"/api/logout/", handler.usi.UsiLogoutHandler),
            # get_note_list
            (r"/api/note-list/", handler.usi.UsiGetNoteListHandler),

            # new api
            (r"/api/new-note/", handler.api.ApiNewNoteHandler),
            # get note api
            (r"/api/get-note/", handler.api.ApiGetNoteHandler),
            # delete api
            (r"/api/delete-note/", handler.api.ApiDeleteNoteHandler),
            #save api
            (r"/api/heartbeat/", handler.api.ApiHeartbeatHandler),
            # websocket api
            (r"/api/ws/echo/(.*)", handler.api.EchoWebSocket),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        self.db = sqlite3.connect('db/youdao.db')

        self.redis = redis.Redis(host='127.0.0.1', port=6379)

        self.loader = Loader(self.db)
        self.user_model = self.loader.use("user.model")
        self.note_model = self.loader.use("note.model")
Exemplo n.º 4
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"Git Eye",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies = True,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
        )

        handlers.append(
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
        )

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.socialauth_model = self.loader.use("socialauth.model")

        # Have one global redis controller
        pool = redis.ConnectionPool(host=options.redis_host, port=options.redis_port, db=options.redis_db)
        self.rc = redis.StrictRedis(connection_pool=pool)

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], self.rc, 86400 * 15)
Exemplo n.º 5
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"Home of 360",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
        )

        handlers = [
            (r"/", handler.home.IndexHandler),
            (r"/register", handler.user.RegisterHandler),
            (r"/u/(\w+)", handler.user.UserDetailHandler),
            (r"/edit", handler.user.UserModifyHandler),
            (r"/b", handler.blog.BlogHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        conn = MongoClient("localhost", 27017)
        self.db = conn.example

        self.loader = Loader(self.db)

        self.user_model = self.loader.use("user.model")

        self.blog_model = self.loader.use("blog.model")

        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 6
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"ttx",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            root_path = os.path.join(os.path.dirname(__file__), "/"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=True,
        )

        handlers = [
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),

            (r"/", handler.index.IndexHandler),
            (r"/p/(\d+)", handler.index.PostHandler),
            (r"/baicai", handler.index.ListHandler),
            (r"/baicai/items", handler.index.GetListItemsHandler),
            (r"/item", handler.index.TaobaoHandler),
            (r"/coupon", handler.index.CouponHandler),
            (r"/prompt", handler.index.TaobaoPromptHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.post_model = self.loader.use("post.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])

        DEBUG_FLAG = False
        if DEBUG_FLAG:
            self.debug_flag = True
            self.static_path = "/static"
            self.template_path = ""
        else:
            self.debug_flag = False
            self.static_path = "/static/dist"
            self.template_path = "dist/"
Exemplo n.º 7
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"1024nj",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            root_path = os.path.join(os.path.dirname(__file__), "/"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=True,
        )

        handlers = [
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(baidu_verify_cNFzOIiNxf\.html)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(google4a4f69878d81fc8a\.html)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),

            (r"/", handler.index.BbsHandler),
            (r"/p/(\d+)", handler.index.PostHandler),
            (r"/new", handler.index.NewHandler),
            (r"/t/(.*)", handler.index.TagHandler),   
            (r"/tags", handler.index.TagsHandler),
            (r"/reply/(\d+)", handler.index.ReplyHandler),
            (r"/follow", handler.index.FollowHandler),
            (r"/vote/reply/(\d+)", handler.index.VoteReplyHandler),
            (r"/vote/post/(\d+)", handler.index.VotePostHandler),
            (r"/thank/(\d+)", handler.index.ThankHandler),
            (r"/report/(\d+)", handler.index.ReportHandler),
            (r"/delete/reply/(\d+)", handler.index.DeleteReplyHandler),
            (r"/edit/reply/(\d+)", handler.index.EditReplyHandler),
            (r"/delete/post/(\d+)", handler.index.DeletePostHandler),
            (r"/edit/(\d+)", handler.index.EditHandler),

            (r"/u/(.*)", handler.user.UserHandler),
            (r"/signin", handler.user.SigninHandler),
            (r"/signout", handler.user.SignoutHandler),
            (r"/signup", handler.user.SignupHandler),
            (r"/setting", handler.user.SettingHandler),
            (r"/setting/avatar", handler.user.SettingAvatarHandler),
            (r"/setting/cover", handler.user.SettingCoverHandler),
            (r"/setting/password", handler.user.SettingPasswordHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/social", handler.user.SocialHandler),
            (r"/notifications", handler.index.NoticeHandler),
            (r"/follows/(.*)", handler.index.FollowsHandler),
            (r"/get/users/(\d+)", handler.index.GetInviteUsersHandler),
            (r"/invite/to/answer/(\d+)", handler.index.InviteToAnswerHandler),
            (r"/invitations", handler.index.InvitationsHandler),
            (r"/invite/to/email/(\d+)", handler.index.InviteToEmailHandler),
            (r"/invite/to/join", handler.index.InviteToJoinHandler),
            (r"/invite/(.*)", handler.index.InviteHandler),

            (r"/edit/tag/(\d+)", handler.index.EditTagHandler),
            (r"/upload", handler.index.UploadHandler),
            (r"/list", handler.index.ListHandler),
            (r"/balance", handler.index.BalanceHandler),
            (r"/update/user/view/follow", handler.index.UpdateUserViewFollowHandler),  
            (r"/get/youku/(.*)", handler.index.GetYoukuHandler),
            (r"/get/user/(.*)", handler.index.GetUserHandler),
            (r"/get/tag/(.*)", handler.index.GetTagHandler),
            (r"/get/tags", handler.index.GetTagsHandler),

            (r"/additem", handler.index.AddItemHandler),
            (r"/item/(\d+)", handler.index.ItemHandler),
            (r"/like/(\d+)", handler.index.LikeItemHandler),
            #(r".*", handler.index.PageNotFoundHandler)

            (r"/get/nav/(\d+)", handler.index.NavListNewsHandler),

            (r"/nba", handler.index.NbaHandler),
            (r"/football", handler.index.FootballHandler),
            (r"/bbs", handler.index.BbsHandler),
            (r"/hot", handler.index.HotHandler),
            (r"/live", handler.index.LiveHandler),
            (r"/get/nodes", handler.index.GetNodesHandler),
            (r"/go/(.*)", handler.index.NodeHandler),

            (r"/pages/(.*)", handler.index.PageHandler),
            (r"/admin", handler.admin.IndexAdminHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.feed_model = self.loader.use("feed.model")
        self.post_model = self.loader.use("post.model")
        self.reply_model = self.loader.use("reply.model")
        self.feed_type_model = self.loader.use("feed_type.model")
        self.like_item_model = self.loader.use("like_item.model")
        self.vote_model = self.loader.use("vote.model")
        self.post_tag_model = self.loader.use("post_tag.model")
        self.tag_model = self.loader.use("tag.model")
        self.category_model = self.loader.use("category.model")
        self.follow_model = self.loader.use("follow.model")
        self.thank_model = self.loader.use("thank.model")
        self.report_model = self.loader.use("report.model")
        self.notice_model = self.loader.use("notice.model")
        self.invite_model = self.loader.use("invite.model")
        self.tag_type_model = self.loader.use("tag_type.model")
        self.tag_parent_model = self.loader.use("tag_parent.model")
        self.icode_model = self.loader.use("icode.model")
        self.avatar_model = self.loader.use("avatar.model")
        self.balance_model = self.loader.use("balance.model")
        self.balance_type_model = self.loader.use("balance_type.model")
        self.ads_model = self.loader.use("ads.model")
        self.item_model = self.loader.use("item.model")
        self.live_model = self.loader.use("live.model")
        self.video_model = self.loader.use("video.model")
        self.section_model = self.loader.use("section.model")
        self.object_video_model = self.loader.use("object_video.model")
        self.section_video_model = self.loader.use("section_video.model")
        self.nav_model = self.loader.use("nav.model")
        self.post_node_model = self.loader.use("post_node.model")
        self.node_model = self.loader.use("node.model")


        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 8
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"wanzhu",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            root_path = os.path.join(os.path.dirname(__file__), "/"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=True,
        )

        handlers = [
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),

            (r"/", handler.index.IndexHandler),
            (r"/bbs", handler.index.BbsHandler),
            (r"/new", handler.index.NewHandler),
            (r"/t/(.*)", handler.index.TagHandler), 
            (r"/p/(\d+)", handler.index.PostHandler),
            (r"/d/(.*)", handler.index.PostHandler),
            (r"/reply/(\d+)", handler.index.ReplyHandler),
            (r"/upload/image", handler.index.UploadImageHandler),
            (r"/signin", handler.user.SigninHandler),
            (r"/signout", handler.user.SignoutHandler),
            (r"/signup", handler.user.SignupHandler),
            (r"/admin", handler.admin.IndexAdminHandler),
            (r"/admin/signin", handler.admin.SigninAdminHandler),
            (r"/admin/signout", handler.admin.SignoutAdminHandler),
            (r"/admin/signup", handler.admin.SignupAdminHandler),
            (r"/admin/users", handler.admin.UsersAdminHandler),
            (r"/admin/user/new", handler.admin.UserNewAdminHandler),
            (r"/admin/user/edit/(\d+)", handler.admin.UserEditAdminHandler),
            (r"/admin/user/delete/(\d+)", handler.admin.UserDeleteAdminHandler),
            (r"/admin/tags", handler.admin.TagsAdminHandler),
            (r"/admin/tag/new", handler.admin.TagNewAdminHandler),
            (r"/admin/tag/edit/(\d+)", handler.admin.TagEditAdminHandler),
            (r"/admin/tag/delete/(\d+)", handler.admin.TagDeleteAdminHandler),
            (r"/api/signin", handler.api.SigninApiHandler),
            (r"/api/signout", handler.api.SignoutApiHandler),
            (r"/api/setting/password", handler.api.SettingPasswordApiHandler),
            (r"/api/get/user/base", handler.api.GetUserBaseInfoApiHandler),
            (r"/api/update/user/base", handler.api.UpdateUserBaseInfoApiHandler),
            (r"/get/tags", handler.index.GetTagsHandler),
            (r"/tags", handler.index.TagsHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.post_model = self.loader.use("post.model")
        self.reply_model = self.loader.use("reply.model")
        self.tag_model = self.loader.use("tag.model")
        self.post_tag_model = self.loader.use("post_tag.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])

        DEBUG_FLAG = True
        if DEBUG_FLAG:
            self.debug_flag = True
            self.static_path = "/static"
            self.template_path = ""
        else:
            self.debug_flag = False
            self.static_path = "/static/dist"
            self.template_path = "dist/"
Exemplo n.º 9
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"youxia",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            root_path = os.path.join(os.path.dirname(__file__), "/"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=True,
        )

        handlers = [
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),

            (r"/", handler.index.IndexHandler),
            (r"/reviews", handler.index.ReviewsHandler),
            (r"/bbs", handler.index.BbsHandler),
            (r"/new", handler.index.NewHandler),
            (r"/tag/(.*)", handler.index.TagHandler), 
            (r"/user/(.*)", handler.user.UserHandler), 
            (r"/p/(\d+)", handler.index.PostHandler),
            (r"/post/(\d+)", handler.index.PostHandler),
            (r"/d/(.*)", handler.index.PostHandler),
            (r"/reply/(\d+)", handler.index.ReplyHandler),
            (r"/like/(\d+)", handler.index.LikeHandler),
            (r"/upload/image", handler.index.UploadImageHandler),
            (r"/signin", handler.user.SigninHandler),
            (r"/signout", handler.user.SignoutHandler),
            (r"/signup", handler.user.SignupHandler),
            (r"/settings", handler.user.SettingsHandler),
            (r"/admin", handler.admin.IndexAdminHandler),
            (r"/admin/signin", handler.admin.SigninAdminHandler),
            (r"/admin/signout", handler.admin.SignoutAdminHandler),
            (r"/admin/signup", handler.admin.SignupAdminHandler),
            (r"/admin/users", handler.admin.UsersAdminHandler),
            (r"/admin/user/new", handler.admin.UserNewAdminHandler),
            (r"/admin/user/edit/(\d+)", handler.admin.UserEditAdminHandler),
            (r"/admin/user/delete/(\d+)", handler.admin.UserDeleteAdminHandler),
            (r"/admin/newsfeeds", handler.admin.NewsfeedsAdminHandler),
            (r"/admin/newsfeed/new", handler.admin.NewsfeedNewAdminHandler),
            (r"/admin/newsfeed/edit/(\d+)", handler.admin.NewsfeedEditAdminHandler),
            (r"/admin/nowfeeds", handler.admin.NowfeedsAdminHandler),
            (r"/admin/nowfeed/new", handler.admin.NowfeedNewAdminHandler),
            (r"/admin/nowfeed/edit/(\d+)", handler.admin.NowfeedEditAdminHandler),
            (r"/admin/nowfeed/delete/(\d+)", handler.admin.NowfeedDeleteAdminHandler),
            (r"/admin/tags", handler.admin.TagsAdminHandler),
            (r"/admin/tag/new", handler.admin.TagNewAdminHandler),
            (r"/admin/tag/edit/(\d+)", handler.admin.TagEditAdminHandler),
            (r"/admin/tag/delete/(\d+)", handler.admin.TagDeleteAdminHandler),
            (r"/admin/carbrands", handler.admin.CarBrandsAdminHandler),
            (r"/admin/carvenders", handler.admin.CarVendersAdminHandler),
            (r"/admin/carmodels", handler.admin.CarModelsAdminHandler),
            (r"/admin/cardata/new", handler.admin.CarDataNewAdminHandler),
            (r"/admin/cardata/edit/(\d+)", handler.admin.CarDataEditAdminHandler),
            (r"/api/signin", handler.api.SigninApiHandler),
            (r"/api/signout", handler.api.SignoutApiHandler),
            (r"/api/setting/password", handler.api.SettingPasswordApiHandler),
            (r"/api/get/user/base", handler.api.GetUserBaseInfoApiHandler),
            (r"/api/update/user/base", handler.api.UpdateUserBaseInfoApiHandler),
            (r"/tags", handler.index.TagsHandler),
            (r"/api/get/posts", handler.api.GetPostsApiHandler),
            (r"/api/get/tags", handler.api.GetTagsApiHandler),
            (r"/api/get/cars", handler.api.GetCarsApiHandler),
            (r"/api/get/user/posts/(.*)", handler.api.GetUserPostsApiHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.post_model = self.loader.use("post.model")
        self.nowfeed_model = self.loader.use("nowfeed.model")
        self.newsfeed_model = self.loader.use("newsfeed.model")
        self.reply_model = self.loader.use("reply.model")
        self.tag_model = self.loader.use("tag.model")
        self.post_tag_model = self.loader.use("post_tag.model")
        self.car_data_model = self.loader.use("car_data.model")
        self.ylike_model = self.loader.use("ylike.model")
        self.item_model = self.loader.use("item.model")
        self.color_model = self.loader.use("color.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])

        DEBUG_FLAG = True
        if DEBUG_FLAG:
            self.debug_flag = True
            self.static_path = "/static"
            self.template_path = ""
        else:
            self.debug_flag = False
            self.static_path = "/static/dist"
            self.template_path = "dist/"
Exemplo n.º 10
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title=u"分知网",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies=True,
            cookie_secret="F66eavGATJy49AopMxnMBJ5PTVabo0ZujPWT4ZJVJnU=",
            login_url="/login",
            autoescape=None,
            jinja2=Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved=["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=False,
        )

        handlers = [
            (r"/", handler.topic.IndexHandler),
            (r"/t/(\d+)", handler.topic.ViewHandler),
            (r"/t/create/(.*)", handler.topic.CreateHandler),
            (r"/t/edit/(.*)", handler.topic.EditHandler),
            (r"/reply/edit/(.*)", handler.topic.ReplyEditHandler),
            (r"/node/(.*)", handler.topic.NodeTopicsHandler),
            (r"/college/(.*)", handler.topic.CollegeTopicsHandler),
            (r"/u/(.*)/topics", handler.topic.UserTopicsHandler),
            (r"/u/(.*)/replies", handler.topic.UserRepliesHandler),
            (r"/u/(.*)/favorites", handler.topic.UserFavoritesHandler),
            (r"/u/(.*)", handler.topic.ProfileHandler),
            (r"/vote", handler.topic.VoteHandler),
            (r"/favorite", handler.topic.FavoriteHandler),
            (r"/notifications", handler.notification.ListHandler),
            (r"/members", handler.topic.MembersHandler),
            (r"/nodes", handler.topic.NodesHandler),
            (r"/colleges", handler.topic.CollegesHandler),
            (r"/setting", handler.user.SettingHandler),
            (r"/setting/avatar", handler.user.SettingAvatarHandler),
            (r"/setting/avatar/gravatar", handler.user.SettingAvatarFromGravatarHandler),
            (r"/setting/password", handler.user.SettingPasswordHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/login", handler.user.LoginHandler),
            (r"/logout", handler.user.LogoutHandler),
            (r"/register", handler.user.RegisterHandler),
            (r"/register/college", handler.user.RegisterCollegeHandler),
            (r"/register/college/(.*)", handler.user.SetCollegeHandler),
            (r"/s/college/(.*)", handler.topic.CollegesHandler),
            (r"/s/node/(.*)", handler.topic.NodesHandler),
            (r"/f/node/(.*)", handler.topic.FollowNodeHandler),
            (r"/f/user/(.*)", handler.topic.FollowUserHandler),
            (r"/m/(.*)", handler.message.CreateMessageHandler),
            (r"/messages", handler.message.MessagesHandler),
            (r"/about", handler.page.AboutHandler),
            (r"/license", handler.page.AboutHandler),
            (r"/feedback", handler.page.AboutHandler),
            (r"/guide", handler.page.AboutHandler),

            (r"/square", handler.image.ImageHandler),

            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            # (r"/(.*)", handler.topic.ProfileHandler),
            (r"/upload", handler.upload.UploadHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = tornado.database.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.topic_model = self.loader.use("topic.model")
        self.reply_model = self.loader.use("reply.model")
        self.plane_model = self.loader.use("plane.model")
        self.node_model = self.loader.use("node.model")
        self.college_model = self.loader.use("college.model")
        self.province_model = self.loader.use("province.model")
        self.notification_model = self.loader.use("notification.model")
        self.vote_model = self.loader.use("vote.model")
        self.favorite_model = self.loader.use("favorite.model")
        self.interest_model = self.loader.use("interest.model")
        self.follow_model = self.loader.use("follow.model")
        self.message_model = self.loader.use("message.model")
        self.image_model = self.loader.use("image.model")
        self.roll_model = self.loader.use("roll.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 11
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"mifan.tv",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=True,
        )

        handlers = [
            (r"/", handler.topic.IndexHandler),
            (r"/video", handler.channel.VideoHandler),
            (r"/favorite", handler.topic.FavoriteHandler),
            (r"/later", handler.topic.LaterHandler),
            (r"/later/clear", handler.topic.LaterClearHandler),
            (r"/watch", handler.topic.WatchHandler),
            (r"/watch/clear", handler.topic.WatchClearHandler),
            (r"/follow", handler.channel.FollowsHandler),
            (r"/notification", handler.topic.NotificationsHandler),
            (r"/n/(\d+)", handler.topic.NotificationHandler),
            (r"/c/(\d+)", handler.channel.ChannelHandler),
            (r"/u/(.*)", handler.topic.UserHandler),
            (r"/channels/u/(.*)", handler.channel.UserOtherChannelsHandler),
            (r"/login", handler.user.LoginHandler),
            (r"/logout", handler.user.LogoutHandler),
            (r"/signup", handler.user.RegisterHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/f/(\d+)", handler.channel.FollowHandler),
            (r"/p/(\d+)", handler.topic.PostHandler),
            (r"/s/(\d+)", handler.topic.SpamPostHandle),
            (r"/d/(\d+)", handler.topic.DeletePostHandle),
            (r"/comment/(\d+)", handler.topic.CommentHandler),
            (r"/rate/(\d+)", handler.topic.RateHandler),
            (r"/setting", handler.user.SettingHandler),
            (r"/setting/avatar", handler.user.SettingAvatarHandler),
            (r"/setting/cover", handler.user.SettingCoverHandler),
            (r"/setting/password", handler.user.SettingPasswordHandler),
            (r"/c/(\d+)/setting", handler.channel.ChannelSettingHandler),
            (r"/c/(\d+)/setting/avatar", handler.channel.ChannelSettingAvatarHandler),
            (r"/c/(\d+)/setting/cover", handler.channel.ChannelSettingCoverHandler),
            (r"/micro", handler.channel.MicroHandler),
            (r"/movie", handler.channel.MovieHandler),
            (r"/tv", handler.channel.TVHandler),
            (r"/star", handler.channel.StarHandler),
            (r"/favorite/(\d+)", handler.topic.FavoriteManagerHandler),
            (r"/later/(\d+)", handler.topic.LaterManagerHandler),
            (r"/watch/(\d+)", handler.topic.WatchManagerHandler),
            (r"/suggestions", handler.channel.SuggestionsHandler),
            (r"/hot", handler.channel.HotChannelsHandler),
            (r"/searchchannel", handler.channel.SearchChannelHandler),

            (r"/forum", handler.topic.ForumHandler),
            (r"/t/create", handler.topic.CreateTopicHandler),
            (r"/t/(\d+)", handler.topic.ViewHandler),
            (r"/t/edit/(.*)", handler.topic.EditHandler),
            (r"/reply/edit/(.*)", handler.topic.ReplyEditHandler),

            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.follow_model = self.loader.use("follow.model")
        self.post_model = self.loader.use("post.model")
        self.channel_model = self.loader.use("channel.model")
        self.plus_model = self.loader.use("plus.model")
        self.comment_model = self.loader.use("comment.model")
        self.nav_model = self.loader.use("nav.model")
        self.subnav_model = self.loader.use("subnav.model")
        self.video_model = self.loader.use("video.model")
        self.favorite_model = self.loader.use("favorite.model")
        self.later_model = self.loader.use("later.model")
        self.watch_model = self.loader.use("watch.model")
        self.rate_model = self.loader.use("rate.model")
        self.notification_model = self.loader.use("notification.model")

        self.topic_model = self.loader.use("topic.model")
        self.reply_model = self.loader.use("reply.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 12
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"webeta",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            root_path = os.path.join(os.path.dirname(__file__), "/"),
            xsrf_cookies = False,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
            debug=True,
        )

        handlers = [
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),

            (r"/", handler.index.IndexHandler),
            (r"/weixin", handler.index.WeixinHandler),
            (r"/shareit", handler.index.ShareItHandler),
            (r"/t/(.*)", handler.index.TopicHandler),
            (r"/addad", handler.index.AddAdHandler),
            (r"/myshares", handler.index.MySharesHandler),
            (r"/myads", handler.index.MyAdsHandler),
            (r"/tb/(.*)", handler.index.TaobaoHandler),
            (r"/prompt/(.*)", handler.index.TaobaoPromptHandler),
            (r"/addtb", handler.index.AddTbHandler),
            (r"/get/shop", handler.index.GetShopUUIDHandler),
            (r"/shop/(.*)", handler.index.ShopHandler),
            (r"/api/shop/(.*)", handler.index.GetShopItemsHandler),
            (r"/mytbs", handler.index.MyTabaosHandler),
            (r"/edit/tb/(.*)", handler.index.TaobaoEditHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.topic_model = self.loader.use("topic.model")
        self.ad_model = self.loader.use("ad.model")
        self.taobao_model = self.loader.use("taobao.model")
        self.shop_model = self.loader.use("shop.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 13
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title=u"mifan.tv",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies=False,
            cookie_secret="cookie_secret_code",
            login_url="/login",
            autoescape=None,
            jinja2=Environment(loader=FileSystemLoader(
                os.path.join(os.path.dirname(__file__), "templates")),
                               trim_blocks=True),
            reserved=[
                "user", "topic", "home", "setting", "forgot", "login",
                "logout", "register", "admin"
            ],
            debug=True,
        )

        handlers = [
            (r"/", handler.topic.IndexHandler),
            (r"/video", handler.topic.VideoHandler),
            (r"/c/(\d+)", handler.topic.ChannelHandler),
            (r"/u/(.*)", handler.topic.UserHandler),
            (r"/login", handler.user.LoginHandler),
            (r"/register", handler.user.RegisterHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/f/(\d+)", handler.topic.FollowHandler),
            (r"/p/(\d+)", handler.topic.PlusChannelHandler),
            (r"/comment", handler.topic.CommentHandler),
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(host=options.mysql_host,
                                    database=options.mysql_database,
                                    user=options.mysql_user,
                                    password=options.mysql_password)

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.follow_model = self.loader.use("follow.model")
        self.post_model = self.loader.use("post.model")
        self.channel_model = self.loader.use("channel.model")
        self.plus_model = self.loader.use("plus.model")
        self.comment_model = self.loader.use("comment.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"],
                                              ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 14
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title=u"F2E Community",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies=True,
            cookie_secret="cookie_secret_code",
            login_url="/login",
            autoescape=None,
            jinja2=Environment(loader=FileSystemLoader(
                os.path.join(os.path.dirname(__file__), "templates")),
                               trim_blocks=True),
            reserved=[
                "user", "topic", "home", "setting", "forgot", "login",
                "logout", "register", "admin"
            ],
        )

        handlers = [
            (r"/", handler.topic.IndexHandler),
            (r"/t/(\d+)", handler.topic.ViewHandler),
            (r"/t/create/(.*)", handler.topic.CreateHandler),
            (r"/t/edit/(.*)", handler.topic.EditHandler),
            (r"/reply/edit/(.*)", handler.topic.ReplyEditHandler),
            (r"/node/(.*)", handler.topic.NodeTopicsHandler),
            (r"/u/(.*)/topics", handler.topic.UserTopicsHandler),
            (r"/u/(.*)/replies", handler.topic.UserRepliesHandler),
            (r"/u/(.*)/favorites", handler.topic.UserFavoritesHandler),
            (r"/u/(.*)", handler.topic.ProfileHandler),
            (r"/vote", handler.topic.VoteHandler),
            (r"/favorite", handler.topic.FavoriteHandler),
            (r"/unfavorite", handler.topic.CancelFavoriteHandler),
            (r"/notifications", handler.notification.ListHandler),
            (r"/members", handler.topic.MembersHandler),
            (r"/setting", handler.user.SettingHandler),
            (r"/setting/avatar", handler.user.SettingAvatarHandler),
            (r"/setting/avatar/gravatar",
             handler.user.SettingAvatarFromGravatarHandler),
            (r"/setting/password", handler.user.SettingPasswordHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/login", handler.user.LoginHandler),
            (r"/logout", handler.user.LogoutHandler),
            (r"/register", handler.user.RegisterHandler),
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(.*)", handler.topic.ProfileHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(host=options.mysql_host,
                                    database=options.mysql_database,
                                    user=options.mysql_user,
                                    password=options.mysql_password)

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.topic_model = self.loader.use("topic.model")
        self.reply_model = self.loader.use("reply.model")
        self.plane_model = self.loader.use("plane.model")
        self.node_model = self.loader.use("node.model")
        self.notification_model = self.loader.use("notification.model")
        self.vote_model = self.loader.use("vote.model")
        self.favorite_model = self.loader.use("favorite.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"],
                                              ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 15
0
class Application(tornado.web.Application):
    def __init__(self):
        app_settings = dict(
            blog_title=settings.site['title'],
            login_url="/login",
            jinja2=Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")),
                               trim_blocks=True),
            reserved=["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
        )
        app_settings.update(settings.app_settings)

        handlers = [
            (r"/", handler.topic.IndexHandler),
            (r"/t/(\d+)", handler.topic.ViewHandler),
            (r"/t/create/(.*)", handler.topic.CreateHandler),
            (r"/t/edit/(.*)", handler.topic.EditHandler),
            (r"/reply/edit/(.*)", handler.topic.ReplyEditHandler),
            (r"/node/(.*)", handler.topic.NodeTopicsHandler),
            (r"/u/(.*)/topics", handler.topic.UserTopicsHandler),
            (r"/u/(.*)/replies", handler.topic.UserRepliesHandler),
            (r"/u/(.*)/favorites", handler.topic.UserFavoritesHandler),
            (r"/u/(.*)", handler.topic.ProfileHandler),
            (r"/vote", handler.topic.VoteHandler),
            (r"/favorite", handler.topic.FavoriteHandler),
            (r"/unfavorite", handler.topic.CancelFavoriteHandler),
            (r"/notifications", handler.notification.ListHandler),
            (r"/members", handler.topic.MembersHandler),
            (r"/setting", handler.user.SettingHandler),
            (r"/setting/avatar", handler.user.SettingAvatarHandler),
            (r"/setting/avatar/gravatar", handler.user.SettingAvatarFromGravatarHandler),
            (r"/setting/password", handler.user.SettingPasswordHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/login", handler.user.LoginHandler),
            (r"/logout", handler.user.LogoutHandler),
            (r"/register", handler.user.RegisterHandler),

            (r'/admin/user$', handler.user.UserAdminHandler),
            (r'/admin/node$', handler.topic.NodeAdminHandler),
            (r'/admin/node/new$', handler.topic.NodeEditHandler),
            (r'/admin/node/(\d+)$', handler.topic.NodeEditHandler),
            (r'/admin/plane$', handler.topic.PlaneAdminHandler),
            (r'/admin/plane/new$', handler.topic.PlaneEditHandler),
            (r'/admin/plane/(\d+)$', handler.topic.PlaneEditHandler),

            (r'/resource/picture/upload_async', handler.page.PictureIframeUploadHandler),

            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path=app_settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path=app_settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path=app_settings["static_path"])),
            (r"/(.*)", handler.topic.ProfileHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **app_settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host=db_default['host'], database=db_default['db_name'],
            user=db_default['user'], password=db_default['password']
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.topic_model = self.loader.use("topic.model")
        self.reply_model = self.loader.use("reply.model")
        self.plane_model = self.loader.use("plane.model")
        self.node_model = self.loader.use("node.model")
        self.notification_model = self.loader.use("notification.model")
        self.vote_model = self.loader.use("vote.model")
        self.favorite_model = self.loader.use("favorite.model")
        self.picture_model = self.loader.use('picture.model')

        # Have one global session controller
        self.session_manager = SessionManager(app_settings["cookie_secret"], settings.memcached, 0)

        # Have one global memcache controller
        self.mc = memcache.Client(settings.memcached)
Exemplo n.º 16
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title = u"snowy",
            template_path = os.path.join(os.path.dirname(__file__), "templates"),
            static_path = os.path.join(os.path.dirname(__file__), "static"),
            xsrf_cookies = True,
            cookie_secret = "cookie_secret_code",
            login_url = "/login",
            autoescape = None,
            jinja2 = Environment(loader = FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates")), trim_blocks = True),
            reserved = ["user", "topic", "home", "setting", "forgot", "login", "logout", "register", "admin"],
        )

        handlers = [
            (r"/", handler.topic.IndexHandler),
            (r"/t/(\d+)", handler.topic.ViewHandler),
            (r"/t/create/(.*)", handler.topic.CreateHandler),
            (r"/t/edit/(.*)", handler.topic.EditHandler),
            (r"/t/(.*)/delete", handler.topic.DeleteTopicHandler),
            (r"/reply/edit/(.*)", handler.topic.ReplyEditHandler),
            (r"/reply/(.*)/delete", handler.topic.DeleteReplyHandler),
            (r"/node/(.*)", handler.topic.NodeTopicsHandler),
            (r"/u/(.*)/topics", handler.topic.UserTopicsHandler),
            (r"/u/(.*)/delete", handler.user.DeleteUserHandler),
            (r"/u/(.*)/replies", handler.topic.UserRepliesHandler),
            (r"/u/(.*)/favorites", handler.topic.UserFavoritesHandler),
            (r"/u/(.*)", handler.topic.ProfileHandler),
            (r"/vote", handler.topic.VoteHandler),
            (r"/favorite", handler.topic.FavoriteHandler),
            (r"/unfavorite", handler.topic.CancelFavoriteHandler),
            (r"/notifications", handler.notification.ListHandler),
            (r"/members", handler.topic.MembersHandler),
            (r"/setting", handler.user.SettingHandler),
            (r"/setting/avatar", handler.user.SettingAvatarHandler),
            (r"/setting/avatar/gravatar", handler.user.SettingAvatarFromGravatarHandler),
            (r"/setting/password", handler.user.SettingPasswordHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/login", handler.user.LoginHandler),
            (r"/logout", handler.user.LogoutHandler),
            (r"/register", handler.user.RegisterHandler),
            (r"/admin", handler.admin.AdminHandler),
            (r"/admin/members", handler.admin.MembersHandler),

            (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler, dict(path = settings["static_path"])),
            (r"/(.*)", handler.topic.ProfileHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(
            host = options.mysql_host, database = options.mysql_database,
            user = options.mysql_user, password = options.mysql_password
        )

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.topic_model = self.loader.use("topic.model")
        self.reply_model = self.loader.use("reply.model")
        self.plane_model = self.loader.use("plane.model")
        self.node_model = self.loader.use("node.model")
        self.notification_model = self.loader.use("notification.model")
        self.vote_model = self.loader.use("vote.model")
        self.favorite_model = self.loader.use("favorite.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"], ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])
Exemplo n.º 17
0
class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            blog_title=u"1024nj",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            root_path=os.path.join(os.path.dirname(__file__), "/"),
            xsrf_cookies=False,
            cookie_secret="cookie_secret_code",
            login_url="/login",
            autoescape=None,
            jinja2=Environment(loader=FileSystemLoader(
                os.path.join(os.path.dirname(__file__), "templates")),
                               trim_blocks=True),
            reserved=[
                "user", "topic", "home", "setting", "forgot", "login",
                "logout", "register", "admin"
            ],
            debug=True,
        )

        handlers = [
            (r"/(favicon\.ico)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(sitemap.*$)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(bdsitemap\.txt)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(orca\.txt)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(baidu_verify_cNFzOIiNxf\.html)",
             tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/(google4a4f69878d81fc8a\.html)", tornado.web.StaticFileHandler,
             dict(path=settings["static_path"])),
            (r"/", handler.index.BbsHandler),
            (r"/p/(\d+)", handler.index.PostHandler),
            (r"/new", handler.index.NewHandler),
            (r"/t/(.*)", handler.index.TagHandler),
            (r"/tags", handler.index.TagsHandler),
            (r"/reply/(\d+)", handler.index.ReplyHandler),
            (r"/follow", handler.index.FollowHandler),
            (r"/vote/reply/(\d+)", handler.index.VoteReplyHandler),
            (r"/vote/post/(\d+)", handler.index.VotePostHandler),
            (r"/thank/(\d+)", handler.index.ThankHandler),
            (r"/report/(\d+)", handler.index.ReportHandler),
            (r"/delete/reply/(\d+)", handler.index.DeleteReplyHandler),
            (r"/edit/reply/(\d+)", handler.index.EditReplyHandler),
            (r"/delete/post/(\d+)", handler.index.DeletePostHandler),
            (r"/edit/(\d+)", handler.index.EditHandler),
            (r"/u/(.*)", handler.user.UserHandler),
            (r"/signin", handler.user.SigninHandler),
            (r"/signout", handler.user.SignoutHandler),
            (r"/signup", handler.user.SignupHandler),
            (r"/setting", handler.user.SettingHandler),
            (r"/setting/avatar", handler.user.SettingAvatarHandler),
            (r"/setting/cover", handler.user.SettingCoverHandler),
            (r"/setting/password", handler.user.SettingPasswordHandler),
            (r"/forgot", handler.user.ForgotPasswordHandler),
            (r"/social", handler.user.SocialHandler),
            (r"/notifications", handler.index.NoticeHandler),
            (r"/follows/(.*)", handler.index.FollowsHandler),
            (r"/get/users/(\d+)", handler.index.GetInviteUsersHandler),
            (r"/invite/to/answer/(\d+)", handler.index.InviteToAnswerHandler),
            (r"/invitations", handler.index.InvitationsHandler),
            (r"/invite/to/email/(\d+)", handler.index.InviteToEmailHandler),
            (r"/invite/to/join", handler.index.InviteToJoinHandler),
            (r"/invite/(.*)", handler.index.InviteHandler),
            (r"/edit/tag/(\d+)", handler.index.EditTagHandler),
            (r"/upload", handler.index.UploadHandler),
            (r"/list", handler.index.ListHandler),
            (r"/balance", handler.index.BalanceHandler),
            (r"/update/user/view/follow",
             handler.index.UpdateUserViewFollowHandler),
            (r"/get/youku/(.*)", handler.index.GetYoukuHandler),
            (r"/get/user/(.*)", handler.index.GetUserHandler),
            (r"/get/tag/(.*)", handler.index.GetTagHandler),
            (r"/get/tags", handler.index.GetTagsHandler),
            (r"/additem", handler.index.AddItemHandler),
            (r"/item/(\d+)", handler.index.ItemHandler),
            (r"/like/(\d+)", handler.index.LikeItemHandler),
            #(r".*", handler.index.PageNotFoundHandler)
            (r"/get/nav/(\d+)", handler.index.NavListNewsHandler),
            (r"/nba", handler.index.NbaHandler),
            (r"/football", handler.index.FootballHandler),
            (r"/bbs", handler.index.BbsHandler),
            (r"/hot", handler.index.HotHandler),
            (r"/live", handler.index.LiveHandler),
            (r"/get/nodes", handler.index.GetNodesHandler),
            (r"/go/(.*)", handler.index.NodeHandler),
            (r"/pages/(.*)", handler.index.PageHandler),
            (r"/admin", handler.admin.IndexAdminHandler),
        ]

        tornado.web.Application.__init__(self, handlers, **settings)

        # Have one global connection to the blog DB across all handlers
        self.db = torndb.Connection(host=options.mysql_host,
                                    database=options.mysql_database,
                                    user=options.mysql_user,
                                    password=options.mysql_password)

        # Have one global loader for loading models and handles
        self.loader = Loader(self.db)

        # Have one global model for db query
        self.user_model = self.loader.use("user.model")
        self.feed_model = self.loader.use("feed.model")
        self.post_model = self.loader.use("post.model")
        self.reply_model = self.loader.use("reply.model")
        self.feed_type_model = self.loader.use("feed_type.model")
        self.like_item_model = self.loader.use("like_item.model")
        self.vote_model = self.loader.use("vote.model")
        self.post_tag_model = self.loader.use("post_tag.model")
        self.tag_model = self.loader.use("tag.model")
        self.category_model = self.loader.use("category.model")
        self.follow_model = self.loader.use("follow.model")
        self.thank_model = self.loader.use("thank.model")
        self.report_model = self.loader.use("report.model")
        self.notice_model = self.loader.use("notice.model")
        self.invite_model = self.loader.use("invite.model")
        self.tag_type_model = self.loader.use("tag_type.model")
        self.tag_parent_model = self.loader.use("tag_parent.model")
        self.icode_model = self.loader.use("icode.model")
        self.avatar_model = self.loader.use("avatar.model")
        self.balance_model = self.loader.use("balance.model")
        self.balance_type_model = self.loader.use("balance_type.model")
        self.ads_model = self.loader.use("ads.model")
        self.item_model = self.loader.use("item.model")
        self.live_model = self.loader.use("live.model")
        self.video_model = self.loader.use("video.model")
        self.section_model = self.loader.use("section.model")
        self.object_video_model = self.loader.use("object_video.model")
        self.section_video_model = self.loader.use("section_video.model")
        self.nav_model = self.loader.use("nav.model")
        self.post_node_model = self.loader.use("post_node.model")
        self.node_model = self.loader.use("node.model")

        # Have one global session controller
        self.session_manager = SessionManager(settings["cookie_secret"],
                                              ["127.0.0.1:11211"], 0)

        # Have one global memcache controller
        self.mc = memcache.Client(["127.0.0.1:11211"])