示例#1
0
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
示例#2
0
文件: web.py 项目: justjake/squidwork
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
示例#3
0
    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)
示例#4
0
    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)