Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        super(BaseStorageSessionManager, self).__init__(*args, **kwargs)
        make_dir(self.settings['folder_path'])

        if issubclass(self.session, BaseStorageWithImageSession):
            self.image_cls = _import_module('PIL.Image')
            self.resize_quality = self.image_cls.ANTIALIAS

            self.resizes = {}
            for key, value in self.settings.items():
                if key.startswith('resize.'):
                    blocks = key.split('.', 3)
                    if len(blocks) == 4:
                        resize_type, application_code, name = blocks[1:]
                        if resize_type in ('width', 'height'):
                            self.resizes.setdefault(application_code, {}).setdefault(name, {})[resize_type] = int(value)

            self.tinypng_api = self.settings.get('tinypng_api')
            self.tinypng_locked_months = []
Esempio n. 2
0
    def __init__(
            self,
            path,
            timeout=30,
            delete_lock_on_timeout=False,
            retry_errno=None,
            retries=3):

        self.path = make_dir(path)
        self.timeout = int(timeout)
        self.delete_lock_on_timeout = delete_lock_on_timeout
        self.retries = maybe_integer(retries) or 3
        self.retry_errno = maybe_set(retry_errno)
        self.retry_errno.update(DEFAULT_RETRY_ERRNO)

        # Clean locks!
        self.clean_junk_locks_as_daemon()
Esempio n. 3
0
    def __init__(self, *args, **kwargs):
        super(BaseMailerSessionManager, self).__init__(*args, **kwargs)

        pyramid_mailer = lazy_import_module('pyramid_mailer')
        self.mailer = pyramid_mailer.mailer_factory_from_settings(self.settings, prefix='')
        pyramid_mailer_message = lazy_import_module('pyramid_mailer.message')
        self.message_cls = pyramid_mailer_message.Message
        self.attachment_cls = pyramid_mailer_message.Attachment

        if self.settings.get('queue_path'):
            make_dir(self.settings['queue_path'])
            make_dir(join_paths(self.settings['queue_path'], 'cur'))
            make_dir(join_paths(self.settings['queue_path'], 'tmp'))
            make_dir(join_paths(self.settings['queue_path'], 'new'))

            sendmail_queue = lazy_import_module('repoze.sendmail.queue')
            self.queue_processor = sendmail_queue.QueueProcessor

            self.transaction = lazy_import_module('transaction')
            self.__dict__.setdefault('__middlewares__', []).append(RepozeTMMiddleware)
Esempio n. 4
0
    def __init__(
            self,
            path,
            expire=None,
            retry_errno=None,
            retries=3,
            **lock_settings):

        self.expire = maybe_integer(expire)
        self.path = make_dir(path)
        self.retries = maybe_integer(retries) or 3
        self.retry_errno = maybe_set(retry_errno)
        self.retry_errno.update(DEFAULT_RETRY_ERRNO)

        # Lock settings
        settings = {}
        for key, value in list(lock_settings.items()):
            if key.startswith('lock_'):
                settings[key.split('lock_', 1)[1]] = value

        lock_path = settings.pop('path', None) or join_paths(self.path, 'locks')
        self.lockme = LockMe(lock_path, **settings)
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     super(SaveMeWithReference, self).__init__(*args, **kwargs)
     self.reference_path = make_dir(join_paths(self.path, 'references'))