def configure(args=None): """do one-time global setup things""" config = web.Config('gifserver') config.option('images') # directories full of images config.option('thumbs') # directory to store thumbnails in config.option('database') # SQLObject database URI config.option('app_secret') # Cookie secret config.option('password') # used for authing config.retrieve(args) if config.images[-1] is not '/': config.images += '/' # set up connections sqlhub.processConnection = connectionForURI(config.database) # socket = squidwork.quick.pub(*config.uris) FileMeta.createTable(ifNotExists=True) # configure thumbnails Image.thumb_dir = config.thumbs return config
def get(self, path, include_body=True): self.path = self.parse_url_path(path) absolute_path = self.get_absolute_path(self.root, self.path) self.absolute_path = self.validate_absolute_path( self.root, absolute_path) if self.absolute_path is None: return should_count = self.get_argument('count', 'true') if should_count != 'false': # count access times with hit() meta = FileMeta.for_path(self.absolute_path) meta.hit() if is_image(self.absolute_path): img = WebImage(self.absolute_path, self.root) img.generate_thumb_in_background() return super(HitCountImageServer, self).get(path, include_body)
def get(self, path, include_body=True): self.path = self.parse_url_path(path) absolute_path = self.get_absolute_path(self.root, self.path) self.absolute_path = self.validate_absolute_path(self.root, absolute_path) if self.absolute_path is None: return should_count = self.get_argument('count', 'true') if should_count != 'false': # count access times with hit() meta = FileMeta.for_path(self.absolute_path) meta.hit() if is_image(self.absolute_path): img = WebImage(self.absolute_path, self.root) img.generate_thumb_in_background() return super(HitCountImageServer, self).get(path, include_body)