コード例 #1
0
    def has_next(self):
        try:
            self.page.rewind()
        except Exception as detail:
            Log.warning(detail)

        return True if (self.page.count(True) == self.limit) else False
コード例 #2
0
ファイル: paginator.py プロジェクト: mrcrabby/whirlwind
 def has_next(self):
     try:
         self.page.rewind()
     except Exception as detail:
         Log.warning(detail)
         
     return True if (self.page.count(True) == self.limit) else False
コード例 #3
0
 def delete_selected(handler,pymongo_collection,feild_name='ids',return_stats=False):
     ids = handler.get_argument(feild_name,[])
     
     if len(ids) == 0: return False
     
     if not return_stats:
         pymongo_collection.remove(
             {'_id':{'$in':ids}
         })
         return True
     else:
         stats = {
             'requested':len(ids),
             'success':0,
             'failed':0
         }
         
         for id in ids:
             try:
                 pymongo_collection.remove({'_id':id},True)
                 stats['success'] += 1
             except Exception, ex:
                 stats['failed'] += 1
                 Log.error(ex.message)
     
         return stats
コード例 #4
0
ファイル: paginator.py プロジェクト: mrcrabby/whirlwind
 def page(self):
     start = self.page_number * self.limit
     end = start + self.limit
     try:
         return self.collection[start:end]
     except Exception as detail:
         Log.warning(detail)
         return []
コード例 #5
0
 def page(self):
     start = self.page_number * self.limit
     end = start + self.limit
     try:
         return self.collection[start:end]
     except Exception as detail:
         Log.warning(detail)
         return []
コード例 #6
0
    def main(self, path):
        #import tornado stuff
        import tornado.web, tornado.httpserver, tornado.ioloop, tornado.options
        from tornado.options import options
        from config import options_setup
        from whirlwind.db.mongo import Mongo

        #parse the app config
        tornado.options.parse_config_file(
            os.path.join(path, 'config/settings.py'))
        #parse the command line args
        tornado.options.parse_command_line()

        #connect to our db using our options set in settings.py
        Mongo.create(host=options.db_host, port=options.db_port)

        #init our url routes
        url_routes = self.init_routes()

        #init a logger
        self.init_logging(options.log)

        #add in any app settings
        settings = {
            "static_path": options.static_path,
            "cookie_secret": options.cookie_secret,
            "login_url": options.login_url,
        }

        #setup the controller action routes
        self.application = tornado.web.Application(url_routes, **settings)

        #instantiate a server instance
        http_server = tornado.httpserver.HTTPServer(self.application)

        #bind server to port
        http_server.listen(options.port)

        #log our start message
        Log.info("Ready and listening")

        #start the server
        tornado.ioloop.IOLoop.instance().start()
コード例 #7
0
ファイル: bootstrap.py プロジェクト: jerryjj/whirlwind
 def main(self):
     #import tornado stuff
     import tornado.web, tornado.httpserver, tornado.ioloop, tornado.options
     from tornado.options import options
     from config import options_setup
     from whirlwind.db.mongo import Mongo
     
     #parse the app config
     tornado.options.parse_config_file(os.path.join(os.path.dirname(__file__),'config/settings.py'))
     #parse the command line args
     tornado.options.parse_command_line()
     
     #connect to our db using our options set in settings.py
     Mongo.create(host=options.db_host, port=options.db_port)
     
     #init our url routes
     url_routes = self.init_routes()
     
     #init a logger
     self.init_logging(options.log)
     
     #add in any app settings 
     settings = {
         "static_path": options.static_path,
         "cookie_secret": options.cookie_secret,
         "login_url": options.login_url,
     }
     
     #setup the controller action routes
     self.application = tornado.web.Application(url_routes,**settings)
     
     #instantiate a server instance
     http_server = tornado.httpserver.HTTPServer(self.application)
     
     #bind server to port
     http_server.listen(options.port)
     
     #log our start message
     Log.info("Ready and listening")
     
     #start the server
     tornado.ioloop.IOLoop.instance().start()
コード例 #8
0
ファイル: bootstrap.py プロジェクト: jerryjj/whirlwind
 def init_logging(self,log):
     if log == 'db':
         Log.create()
     else:
         Log.create('FILE',log)
コード例 #9
0
 def init_logging(self, log):
     if log == 'db':
         Log.create()
     else:
         Log.create('FILE', log)