|  | @@ -0,0 +1,424 @@
 | 
	
		
			
			|  | 1 | +from paste.deploy.converters import asbool
 | 
	
		
			
			|  | 2 | +from urllib.parse import urlparse
 | 
	
		
			
			|  | 3 | +import logging
 | 
	
		
			
			|  | 4 | +
 | 
	
		
			
			|  | 5 | +from pyramid.request import Request
 | 
	
		
			
			|  | 6 | +
 | 
	
		
			
			|  | 7 | +logger = logging.getLogger(__name__)
 | 
	
		
			
			|  | 8 | +
 | 
	
		
			
			|  | 9 | +
 | 
	
		
			
			|  | 10 | +class RequestWithCFG(Request):
 | 
	
		
			
			|  | 11 | +
 | 
	
		
			
			|  | 12 | +    def config(self):
 | 
	
		
			
			|  | 13 | +        return CFG(self.registry.settings)
 | 
	
		
			
			|  | 14 | +
 | 
	
		
			
			|  | 15 | +
 | 
	
		
			
			|  | 16 | +
 | 
	
		
			
			|  | 17 | +class CFG(object):
 | 
	
		
			
			|  | 18 | +    """Object used for easy access to config file parameters."""
 | 
	
		
			
			|  | 19 | +
 | 
	
		
			
			|  | 20 | +    def __setattr__(self, key, value):
 | 
	
		
			
			|  | 21 | +        """
 | 
	
		
			
			|  | 22 | +        Log-ready setter.
 | 
	
		
			
			|  | 23 | +
 | 
	
		
			
			|  | 24 | +        Logs all configuration parameters except password.
 | 
	
		
			
			|  | 25 | +        :param key:
 | 
	
		
			
			|  | 26 | +        :param value:
 | 
	
		
			
			|  | 27 | +        :return:
 | 
	
		
			
			|  | 28 | +        """
 | 
	
		
			
			|  | 29 | +        if 'PASSWORD' not in key and \
 | 
	
		
			
			|  | 30 | +                ('URL' not in key or type(value) == str) and \
 | 
	
		
			
			|  | 31 | +                'CONTENT' not in key:
 | 
	
		
			
			|  | 32 | +            # We do not show PASSWORD for security reason
 | 
	
		
			
			|  | 33 | +            # we do not show URL because At the time of configuration setup,
 | 
	
		
			
			|  | 34 | +            # it can't be evaluated
 | 
	
		
			
			|  | 35 | +            # We do not show CONTENT in order not to pollute log files
 | 
	
		
			
			|  | 36 | +            logger.info('CONFIG: [ {} | {} ]'.format(key, value))
 | 
	
		
			
			|  | 37 | +        else:
 | 
	
		
			
			|  | 38 | +            logger.info('CONFIG: [ {} | <value not shown> ]'.format(key))
 | 
	
		
			
			|  | 39 | +
 | 
	
		
			
			|  | 40 | +        self.__dict__[key] = value
 | 
	
		
			
			|  | 41 | +
 | 
	
		
			
			|  | 42 | +    def __init__(self, settings):
 | 
	
		
			
			|  | 43 | +        """Parse configuration file."""
 | 
	
		
			
			|  | 44 | +
 | 
	
		
			
			|  | 45 | +        ### General
 | 
	
		
			
			|  | 46 | +
 | 
	
		
			
			|  | 47 | +        mandatory_msg = \
 | 
	
		
			
			|  | 48 | +            'ERROR: {} configuration is mandatory. Set it before continuing.'
 | 
	
		
			
			|  | 49 | +        self.DEPOT_STORAGE_DIR = settings.get(
 | 
	
		
			
			|  | 50 | +            'depot_storage_dir',
 | 
	
		
			
			|  | 51 | +        )
 | 
	
		
			
			|  | 52 | +        if not self.DEPOT_STORAGE_DIR:
 | 
	
		
			
			|  | 53 | +            raise Exception(
 | 
	
		
			
			|  | 54 | +                mandatory_msg.format('depot_storage_dir')
 | 
	
		
			
			|  | 55 | +            )
 | 
	
		
			
			|  | 56 | +        self.DEPOT_STORAGE_NAME = settings.get(
 | 
	
		
			
			|  | 57 | +            'depot_storage_name',
 | 
	
		
			
			|  | 58 | +        )
 | 
	
		
			
			|  | 59 | +        if not self.DEPOT_STORAGE_NAME:
 | 
	
		
			
			|  | 60 | +            raise Exception(
 | 
	
		
			
			|  | 61 | +                mandatory_msg.format('depot_storage_name')
 | 
	
		
			
			|  | 62 | +            )
 | 
	
		
			
			|  | 63 | +        self.PREVIEW_CACHE_DIR = settings.get(
 | 
	
		
			
			|  | 64 | +            'preview_cache_dir',
 | 
	
		
			
			|  | 65 | +        )
 | 
	
		
			
			|  | 66 | +        if not self.PREVIEW_CACHE_DIR:
 | 
	
		
			
			|  | 67 | +            raise Exception(
 | 
	
		
			
			|  | 68 | +                'ERROR: preview_cache_dir configuration is mandatory. '
 | 
	
		
			
			|  | 69 | +                'Set it before continuing.'
 | 
	
		
			
			|  | 70 | +            )
 | 
	
		
			
			|  | 71 | +
 | 
	
		
			
			|  | 72 | +        self.DATA_UPDATE_ALLOWED_DURATION = int(settings.get(
 | 
	
		
			
			|  | 73 | +            'content.update.allowed.duration',
 | 
	
		
			
			|  | 74 | +            0,
 | 
	
		
			
			|  | 75 | +        ))
 | 
	
		
			
			|  | 76 | +
 | 
	
		
			
			|  | 77 | +        self.WEBSITE_TITLE = settings.get(
 | 
	
		
			
			|  | 78 | +            'website.title',
 | 
	
		
			
			|  | 79 | +            'TRACIM',
 | 
	
		
			
			|  | 80 | +        )
 | 
	
		
			
			|  | 81 | +
 | 
	
		
			
			|  | 82 | +        self.WEBSITE_BASE_URL = settings.get(
 | 
	
		
			
			|  | 83 | +            'website.base_url',
 | 
	
		
			
			|  | 84 | +            '',
 | 
	
		
			
			|  | 85 | +        )
 | 
	
		
			
			|  | 86 | +
 | 
	
		
			
			|  | 87 | +        # TODO - G.M - 26-03-2018 - These params seems deprecated for tracimv2,
 | 
	
		
			
			|  | 88 | +        # Verify this
 | 
	
		
			
			|  | 89 | +        #
 | 
	
		
			
			|  | 90 | +        # self.WEBSITE_HOME_TITLE_COLOR = settings.get(
 | 
	
		
			
			|  | 91 | +        #     'website.title.color',
 | 
	
		
			
			|  | 92 | +        #     '#555',
 | 
	
		
			
			|  | 93 | +        # )
 | 
	
		
			
			|  | 94 | +        # self.WEBSITE_HOME_IMAGE_PATH = settings.get(
 | 
	
		
			
			|  | 95 | +        #     '/assets/img/home_illustration.jpg',
 | 
	
		
			
			|  | 96 | +        # )
 | 
	
		
			
			|  | 97 | +        # self.WEBSITE_HOME_BACKGROUND_IMAGE_PATH = settings.get(
 | 
	
		
			
			|  | 98 | +        #     '/assets/img/bg.jpg',
 | 
	
		
			
			|  | 99 | +        # )
 | 
	
		
			
			|  | 100 | +        #
 | 
	
		
			
			|  | 101 | +
 | 
	
		
			
			|  | 102 | +        self.WEBSITE_SERVER_NAME = settings.get(
 | 
	
		
			
			|  | 103 | +            'website.server_name',
 | 
	
		
			
			|  | 104 | +            None,
 | 
	
		
			
			|  | 105 | +        )
 | 
	
		
			
			|  | 106 | +
 | 
	
		
			
			|  | 107 | +        if not self.WEBSITE_SERVER_NAME:
 | 
	
		
			
			|  | 108 | +            self.WEBSITE_SERVER_NAME = urlparse(self.WEBSITE_BASE_URL).hostname
 | 
	
		
			
			|  | 109 | +            logger.warning(
 | 
	
		
			
			|  | 110 | +                'NOTE: Generated website.server_name parameter from '
 | 
	
		
			
			|  | 111 | +                'website.base_url parameter -> {0}'
 | 
	
		
			
			|  | 112 | +                .format(self.WEBSITE_SERVER_NAME)
 | 
	
		
			
			|  | 113 | +            )
 | 
	
		
			
			|  | 114 | +
 | 
	
		
			
			|  | 115 | +        self.WEBSITE_HOME_TAG_LINE = settings.get(
 | 
	
		
			
			|  | 116 | +            'website.home.tag_line',
 | 
	
		
			
			|  | 117 | +            '',
 | 
	
		
			
			|  | 118 | +        )
 | 
	
		
			
			|  | 119 | +        self.WEBSITE_SUBTITLE = settings.get(
 | 
	
		
			
			|  | 120 | +            'website.home.subtitle',
 | 
	
		
			
			|  | 121 | +            '',
 | 
	
		
			
			|  | 122 | +        )
 | 
	
		
			
			|  | 123 | +        self.WEBSITE_HOME_BELOW_LOGIN_FORM = settings.get(
 | 
	
		
			
			|  | 124 | +            'website.home.below_login_form',
 | 
	
		
			
			|  | 125 | +            '',
 | 
	
		
			
			|  | 126 | +        )
 | 
	
		
			
			|  | 127 | +
 | 
	
		
			
			|  | 128 | +        self.WEBSITE_TREEVIEW_CONTENT = settings.get(
 | 
	
		
			
			|  | 129 | +            'website.treeview.content',
 | 
	
		
			
			|  | 130 | +        )
 | 
	
		
			
			|  | 131 | +
 | 
	
		
			
			|  | 132 | +        self.USER_AUTH_TOKEN_VALIDITY = int(settings.get(
 | 
	
		
			
			|  | 133 | +            'user.auth_token.validity',
 | 
	
		
			
			|  | 134 | +            '604800',
 | 
	
		
			
			|  | 135 | +        ))
 | 
	
		
			
			|  | 136 | +
 | 
	
		
			
			|  | 137 | +        # TODO - G.M - 27-03-2018 - Restore email config
 | 
	
		
			
			|  | 138 | +        ###
 | 
	
		
			
			|  | 139 | +        # EMAIL related stuff (notification, reply)
 | 
	
		
			
			|  | 140 | +        ###
 | 
	
		
			
			|  | 141 | +        #
 | 
	
		
			
			|  | 142 | +        # self.EMAIL_NOTIFICATION_NOTIFIED_EVENTS = [
 | 
	
		
			
			|  | 143 | +        #     # ActionDescription.COMMENT,
 | 
	
		
			
			|  | 144 | +        #     # ActionDescription.CREATION,
 | 
	
		
			
			|  | 145 | +        #     # ActionDescription.EDITION,
 | 
	
		
			
			|  | 146 | +        #     # ActionDescription.REVISION,
 | 
	
		
			
			|  | 147 | +        #     # ActionDescription.STATUS_UPDATE
 | 
	
		
			
			|  | 148 | +        # ]
 | 
	
		
			
			|  | 149 | +        #
 | 
	
		
			
			|  | 150 | +        # self.EMAIL_NOTIFICATION_NOTIFIED_CONTENTS = [
 | 
	
		
			
			|  | 151 | +        #     # ContentType.Page,
 | 
	
		
			
			|  | 152 | +        #     # ContentType.Thread,
 | 
	
		
			
			|  | 153 | +        #     # ContentType.File,
 | 
	
		
			
			|  | 154 | +        #     # ContentType.Comment,
 | 
	
		
			
			|  | 155 | +        #     # ContentType.Folder -- Folder is skipped
 | 
	
		
			
			|  | 156 | +        # ]
 | 
	
		
			
			|  | 157 | +        # if settings.get('email.notification.from'):
 | 
	
		
			
			|  | 158 | +        #     raise Exception(
 | 
	
		
			
			|  | 159 | +        #         'email.notification.from configuration is deprecated. '
 | 
	
		
			
			|  | 160 | +        #         'Use instead email.notification.from.email and '
 | 
	
		
			
			|  | 161 | +        #         'email.notification.from.default_label.'
 | 
	
		
			
			|  | 162 | +        #     )
 | 
	
		
			
			|  | 163 | +        #
 | 
	
		
			
			|  | 164 | +        # self.EMAIL_NOTIFICATION_FROM_EMAIL = settings.get(
 | 
	
		
			
			|  | 165 | +        #     'email.notification.from.email',
 | 
	
		
			
			|  | 166 | +        # )
 | 
	
		
			
			|  | 167 | +        # self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = settings.get(
 | 
	
		
			
			|  | 168 | +        #     'email.notification.from.default_label'
 | 
	
		
			
			|  | 169 | +        # )
 | 
	
		
			
			|  | 170 | +        # self.EMAIL_NOTIFICATION_REPLY_TO_EMAIL = settings.get(
 | 
	
		
			
			|  | 171 | +        #     'email.notification.reply_to.email',
 | 
	
		
			
			|  | 172 | +        # )
 | 
	
		
			
			|  | 173 | +        # self.EMAIL_NOTIFICATION_REFERENCES_EMAIL = settings.get(
 | 
	
		
			
			|  | 174 | +        #     'email.notification.references.email'
 | 
	
		
			
			|  | 175 | +        # )
 | 
	
		
			
			|  | 176 | +        # self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = settings.get(
 | 
	
		
			
			|  | 177 | +        #     'email.notification.content_update.template.html',
 | 
	
		
			
			|  | 178 | +        # )
 | 
	
		
			
			|  | 179 | +        # self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT = settings.get(
 | 
	
		
			
			|  | 180 | +        #     'email.notification.content_update.template.text',
 | 
	
		
			
			|  | 181 | +        # )
 | 
	
		
			
			|  | 182 | +        # self.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_HTML = settings.get(
 | 
	
		
			
			|  | 183 | +        #     'email.notification.created_account.template.html',
 | 
	
		
			
			|  | 184 | +        #     './tracim/templates/mail/created_account_body_html.mak',
 | 
	
		
			
			|  | 185 | +        # )
 | 
	
		
			
			|  | 186 | +        # self.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_TEXT = settings.get(
 | 
	
		
			
			|  | 187 | +        #     'email.notification.created_account.template.text',
 | 
	
		
			
			|  | 188 | +        #     './tracim/templates/mail/created_account_body_text.mak',
 | 
	
		
			
			|  | 189 | +        # )
 | 
	
		
			
			|  | 190 | +        # self.EMAIL_NOTIFICATION_CONTENT_UPDATE_SUBJECT = settings.get(
 | 
	
		
			
			|  | 191 | +        #     'email.notification.content_update.subject',
 | 
	
		
			
			|  | 192 | +        # )
 | 
	
		
			
			|  | 193 | +        # self.EMAIL_NOTIFICATION_CREATED_ACCOUNT_SUBJECT = settings.get(
 | 
	
		
			
			|  | 194 | +        #     'email.notification.created_account.subject',
 | 
	
		
			
			|  | 195 | +        #     '[{website_title}] Created account',
 | 
	
		
			
			|  | 196 | +        # )
 | 
	
		
			
			|  | 197 | +        # self.EMAIL_NOTIFICATION_PROCESSING_MODE = settings.get(
 | 
	
		
			
			|  | 198 | +        #     'email.notification.processing_mode',
 | 
	
		
			
			|  | 199 | +        # )
 | 
	
		
			
			|  | 200 | +        #
 | 
	
		
			
			|  | 201 | +        # self.EMAIL_NOTIFICATION_ACTIVATED = asbool(settings.get(
 | 
	
		
			
			|  | 202 | +        #     'email.notification.activated',
 | 
	
		
			
			|  | 203 | +        # ))
 | 
	
		
			
			|  | 204 | +        # self.EMAIL_NOTIFICATION_SMTP_SERVER = settings.get(
 | 
	
		
			
			|  | 205 | +        #     'email.notification.smtp.server',
 | 
	
		
			
			|  | 206 | +        # )
 | 
	
		
			
			|  | 207 | +        # self.EMAIL_NOTIFICATION_SMTP_PORT = settings.get(
 | 
	
		
			
			|  | 208 | +        #     'email.notification.smtp.port',
 | 
	
		
			
			|  | 209 | +        # )
 | 
	
		
			
			|  | 210 | +        # self.EMAIL_NOTIFICATION_SMTP_USER = settings.get(
 | 
	
		
			
			|  | 211 | +        #     'email.notification.smtp.user',
 | 
	
		
			
			|  | 212 | +        # )
 | 
	
		
			
			|  | 213 | +        # self.EMAIL_NOTIFICATION_SMTP_PASSWORD = settings.get(
 | 
	
		
			
			|  | 214 | +        #     'email.notification.smtp.password',
 | 
	
		
			
			|  | 215 | +        # )
 | 
	
		
			
			|  | 216 | +        # self.EMAIL_NOTIFICATION_LOG_FILE_PATH = settings.get(
 | 
	
		
			
			|  | 217 | +        #     'email.notification.log_file_path',
 | 
	
		
			
			|  | 218 | +        #     None,
 | 
	
		
			
			|  | 219 | +        # )
 | 
	
		
			
			|  | 220 | +        #
 | 
	
		
			
			|  | 221 | +        # self.EMAIL_REPLY_ACTIVATED = asbool(settings.get(
 | 
	
		
			
			|  | 222 | +        #     'email.reply.activated',
 | 
	
		
			
			|  | 223 | +        #     False,
 | 
	
		
			
			|  | 224 | +        # ))
 | 
	
		
			
			|  | 225 | +        #
 | 
	
		
			
			|  | 226 | +        # self.EMAIL_REPLY_IMAP_SERVER = settings.get(
 | 
	
		
			
			|  | 227 | +        #     'email.reply.imap.server',
 | 
	
		
			
			|  | 228 | +        # )
 | 
	
		
			
			|  | 229 | +        # self.EMAIL_REPLY_IMAP_PORT = settings.get(
 | 
	
		
			
			|  | 230 | +        #     'email.reply.imap.port',
 | 
	
		
			
			|  | 231 | +        # )
 | 
	
		
			
			|  | 232 | +        # self.EMAIL_REPLY_IMAP_USER = settings.get(
 | 
	
		
			
			|  | 233 | +        #     'email.reply.imap.user',
 | 
	
		
			
			|  | 234 | +        # )
 | 
	
		
			
			|  | 235 | +        # self.EMAIL_REPLY_IMAP_PASSWORD = settings.get(
 | 
	
		
			
			|  | 236 | +        #     'email.reply.imap.password',
 | 
	
		
			
			|  | 237 | +        # )
 | 
	
		
			
			|  | 238 | +        # self.EMAIL_REPLY_IMAP_FOLDER = settings.get(
 | 
	
		
			
			|  | 239 | +        #     'email.reply.imap.folder',
 | 
	
		
			
			|  | 240 | +        # )
 | 
	
		
			
			|  | 241 | +        # self.EMAIL_REPLY_CHECK_HEARTBEAT = int(settings.get(
 | 
	
		
			
			|  | 242 | +        #     'email.reply.check.heartbeat',
 | 
	
		
			
			|  | 243 | +        #     60,
 | 
	
		
			
			|  | 244 | +        # ))
 | 
	
		
			
			|  | 245 | +        # self.EMAIL_REPLY_TOKEN = settings.get(
 | 
	
		
			
			|  | 246 | +        #     'email.reply.token',
 | 
	
		
			
			|  | 247 | +        # )
 | 
	
		
			
			|  | 248 | +        # self.EMAIL_REPLY_IMAP_USE_SSL = asbool(settings.get(
 | 
	
		
			
			|  | 249 | +        #     'email.reply.imap.use_ssl',
 | 
	
		
			
			|  | 250 | +        # ))
 | 
	
		
			
			|  | 251 | +        # self.EMAIL_REPLY_IMAP_USE_IDLE = asbool(settings.get(
 | 
	
		
			
			|  | 252 | +        #     'email.reply.imap.use_idle',
 | 
	
		
			
			|  | 253 | +        #     True,
 | 
	
		
			
			|  | 254 | +        # ))
 | 
	
		
			
			|  | 255 | +        # self.EMAIL_REPLY_CONNECTION_MAX_LIFETIME = int(settings.get(
 | 
	
		
			
			|  | 256 | +        #     'email.reply.connection.max_lifetime',
 | 
	
		
			
			|  | 257 | +        #     600,  # 10 minutes
 | 
	
		
			
			|  | 258 | +        # ))
 | 
	
		
			
			|  | 259 | +        # self.EMAIL_REPLY_USE_HTML_PARSING = asbool(settings.get(
 | 
	
		
			
			|  | 260 | +        #     'email.reply.use_html_parsing',
 | 
	
		
			
			|  | 261 | +        #     True,
 | 
	
		
			
			|  | 262 | +        # ))
 | 
	
		
			
			|  | 263 | +        # self.EMAIL_REPLY_USE_TXT_PARSING = asbool(settings.get(
 | 
	
		
			
			|  | 264 | +        #     'email.reply.use_txt_parsing',
 | 
	
		
			
			|  | 265 | +        #     True,
 | 
	
		
			
			|  | 266 | +        # ))
 | 
	
		
			
			|  | 267 | +        # self.EMAIL_REPLY_LOCKFILE_PATH = settings.get(
 | 
	
		
			
			|  | 268 | +        #     'email.reply.lockfile_path',
 | 
	
		
			
			|  | 269 | +        #     ''
 | 
	
		
			
			|  | 270 | +        # )
 | 
	
		
			
			|  | 271 | +        # if not self.EMAIL_REPLY_LOCKFILE_PATH and self.EMAIL_REPLY_ACTIVATED:
 | 
	
		
			
			|  | 272 | +        #     raise Exception(
 | 
	
		
			
			|  | 273 | +        #         mandatory_msg.format('email.reply.lockfile_path')
 | 
	
		
			
			|  | 274 | +        #     )
 | 
	
		
			
			|  | 275 | +        #
 | 
	
		
			
			|  | 276 | +        # self.EMAIL_PROCESSING_MODE = settings.get(
 | 
	
		
			
			|  | 277 | +        #     'email.processing_mode',
 | 
	
		
			
			|  | 278 | +        #     'sync',
 | 
	
		
			
			|  | 279 | +        # ).upper()
 | 
	
		
			
			|  | 280 | +        #
 | 
	
		
			
			|  | 281 | +        # if self.EMAIL_PROCESSING_MODE not in (
 | 
	
		
			
			|  | 282 | +        #         self.CST.ASYNC,
 | 
	
		
			
			|  | 283 | +        #         self.CST.SYNC,
 | 
	
		
			
			|  | 284 | +        # ):
 | 
	
		
			
			|  | 285 | +        #     raise Exception(
 | 
	
		
			
			|  | 286 | +        #         'email.processing_mode '
 | 
	
		
			
			|  | 287 | +        #         'can ''be "{}" or "{}", not "{}"'.format(
 | 
	
		
			
			|  | 288 | +        #             self.CST.ASYNC,
 | 
	
		
			
			|  | 289 | +        #             self.CST.SYNC,
 | 
	
		
			
			|  | 290 | +        #             self.EMAIL_PROCESSING_MODE,
 | 
	
		
			
			|  | 291 | +        #         )
 | 
	
		
			
			|  | 292 | +        #     )
 | 
	
		
			
			|  | 293 | +        #
 | 
	
		
			
			|  | 294 | +        # self.EMAIL_SENDER_REDIS_HOST = settings.get(
 | 
	
		
			
			|  | 295 | +        #     'email.async.redis.host',
 | 
	
		
			
			|  | 296 | +        #     'localhost',
 | 
	
		
			
			|  | 297 | +        # )
 | 
	
		
			
			|  | 298 | +        # self.EMAIL_SENDER_REDIS_PORT = int(settings.get(
 | 
	
		
			
			|  | 299 | +        #     'email.async.redis.port',
 | 
	
		
			
			|  | 300 | +        #     6379,
 | 
	
		
			
			|  | 301 | +        # ))
 | 
	
		
			
			|  | 302 | +        # self.EMAIL_SENDER_REDIS_DB = int(settings.get(
 | 
	
		
			
			|  | 303 | +        #     'email.async.redis.db',
 | 
	
		
			
			|  | 304 | +        #     0,
 | 
	
		
			
			|  | 305 | +        # ))
 | 
	
		
			
			|  | 306 | +
 | 
	
		
			
			|  | 307 | +        ###
 | 
	
		
			
			|  | 308 | +        # WSGIDAV (Webdav server)
 | 
	
		
			
			|  | 309 | +        ###
 | 
	
		
			
			|  | 310 | +
 | 
	
		
			
			|  | 311 | +        # TODO - G.M - 27-03-2018 - Restore wsgidav config
 | 
	
		
			
			|  | 312 | +        #self.WSGIDAV_CONFIG_PATH = settings.get(
 | 
	
		
			
			|  | 313 | +        #    'wsgidav.config_path',
 | 
	
		
			
			|  | 314 | +        #    'wsgidav.conf',
 | 
	
		
			
			|  | 315 | +        #)
 | 
	
		
			
			|  | 316 | +        # TODO: Convert to importlib
 | 
	
		
			
			|  | 317 | +        # http://stackoverflow.com/questions/41063938/use-importlib-instead-imp-for-non-py-file
 | 
	
		
			
			|  | 318 | +        #self.wsgidav_config = imp.load_source(
 | 
	
		
			
			|  | 319 | +        #    'wsgidav_config',
 | 
	
		
			
			|  | 320 | +        #    self.WSGIDAV_CONFIG_PATH,
 | 
	
		
			
			|  | 321 | +        #)
 | 
	
		
			
			|  | 322 | +        # self.WSGIDAV_PORT = self.wsgidav_config.port
 | 
	
		
			
			|  | 323 | +        # self.WSGIDAV_CLIENT_BASE_URL = settings.get(
 | 
	
		
			
			|  | 324 | +        #     'wsgidav.client.base_url',
 | 
	
		
			
			|  | 325 | +        #     None,
 | 
	
		
			
			|  | 326 | +        # )
 | 
	
		
			
			|  | 327 | +        #
 | 
	
		
			
			|  | 328 | +        # if not self.WSGIDAV_CLIENT_BASE_URL:
 | 
	
		
			
			|  | 329 | +        #     self.WSGIDAV_CLIENT_BASE_URL = \
 | 
	
		
			
			|  | 330 | +        #         '{0}:{1}'.format(
 | 
	
		
			
			|  | 331 | +        #             self.WEBSITE_SERVER_NAME,
 | 
	
		
			
			|  | 332 | +        #             self.WSGIDAV_PORT,
 | 
	
		
			
			|  | 333 | +        #         )
 | 
	
		
			
			|  | 334 | +        #     logger.warning(
 | 
	
		
			
			|  | 335 | +        #         'NOTE: Generated wsgidav.client.base_url parameter with '
 | 
	
		
			
			|  | 336 | +        #         'followings parameters: website.server_name and '
 | 
	
		
			
			|  | 337 | +        #         'wsgidav.conf port'.format(
 | 
	
		
			
			|  | 338 | +        #             self.WSGIDAV_CLIENT_BASE_URL,
 | 
	
		
			
			|  | 339 | +        #         )
 | 
	
		
			
			|  | 340 | +        #     )
 | 
	
		
			
			|  | 341 | +        #
 | 
	
		
			
			|  | 342 | +        # if not self.WSGIDAV_CLIENT_BASE_URL.endswith('/'):
 | 
	
		
			
			|  | 343 | +        #     self.WSGIDAV_CLIENT_BASE_URL += '/'
 | 
	
		
			
			|  | 344 | +
 | 
	
		
			
			|  | 345 | +        # TODO - G.M - 27-03-2018 - Restore radicale config
 | 
	
		
			
			|  | 346 | +        ###
 | 
	
		
			
			|  | 347 | +        # RADICALE (Caldav server)
 | 
	
		
			
			|  | 348 | +        ###
 | 
	
		
			
			|  | 349 | +        # self.RADICALE_SERVER_HOST = settings.get(
 | 
	
		
			
			|  | 350 | +        #     'radicale.server.host',
 | 
	
		
			
			|  | 351 | +        #     '127.0.0.1',
 | 
	
		
			
			|  | 352 | +        # )
 | 
	
		
			
			|  | 353 | +        # self.RADICALE_SERVER_PORT = int(settings.get(
 | 
	
		
			
			|  | 354 | +        #     'radicale.server.port',
 | 
	
		
			
			|  | 355 | +        #     5232,
 | 
	
		
			
			|  | 356 | +        # ))
 | 
	
		
			
			|  | 357 | +        # # Note: Other parameters needed to work in SSL (cert file, etc)
 | 
	
		
			
			|  | 358 | +        # self.RADICALE_SERVER_SSL = asbool(settings.get(
 | 
	
		
			
			|  | 359 | +        #     'radicale.server.ssl',
 | 
	
		
			
			|  | 360 | +        #     False,
 | 
	
		
			
			|  | 361 | +        # ))
 | 
	
		
			
			|  | 362 | +        # self.RADICALE_SERVER_FILE_SYSTEM_FOLDER = settings.get(
 | 
	
		
			
			|  | 363 | +        #     'radicale.server.filesystem.folder',
 | 
	
		
			
			|  | 364 | +        # )
 | 
	
		
			
			|  | 365 | +        # if not self.RADICALE_SERVER_FILE_SYSTEM_FOLDER:
 | 
	
		
			
			|  | 366 | +        #     raise Exception(
 | 
	
		
			
			|  | 367 | +        #         mandatory_msg.format('radicale.server.filesystem.folder')
 | 
	
		
			
			|  | 368 | +        #     )
 | 
	
		
			
			|  | 369 | +        # self.RADICALE_SERVER_ALLOW_ORIGIN = settings.get(
 | 
	
		
			
			|  | 370 | +        #     'radicale.server.allow_origin',
 | 
	
		
			
			|  | 371 | +        #     None,
 | 
	
		
			
			|  | 372 | +        # )
 | 
	
		
			
			|  | 373 | +        # if not self.RADICALE_SERVER_ALLOW_ORIGIN:
 | 
	
		
			
			|  | 374 | +        #     self.RADICALE_SERVER_ALLOW_ORIGIN = self.WEBSITE_BASE_URL
 | 
	
		
			
			|  | 375 | +        #     logger.warning(
 | 
	
		
			
			|  | 376 | +        #         'NOTE: Generated radicale.server.allow_origin parameter with '
 | 
	
		
			
			|  | 377 | +        #         'followings parameters: website.base_url ({0})'
 | 
	
		
			
			|  | 378 | +        #         .format(self.WEBSITE_BASE_URL)
 | 
	
		
			
			|  | 379 | +        #     )
 | 
	
		
			
			|  | 380 | +        #
 | 
	
		
			
			|  | 381 | +        # self.RADICALE_SERVER_REALM_MESSAGE = settings.get(
 | 
	
		
			
			|  | 382 | +        #     'radicale.server.realm_message',
 | 
	
		
			
			|  | 383 | +        #     'Tracim Calendar - Password Required',
 | 
	
		
			
			|  | 384 | +        # )
 | 
	
		
			
			|  | 385 | +        #
 | 
	
		
			
			|  | 386 | +        # self.RADICALE_CLIENT_BASE_URL_HOST = settings.get(
 | 
	
		
			
			|  | 387 | +        #     'radicale.client.base_url.host',
 | 
	
		
			
			|  | 388 | +        #     'http://{}:{}'.format(
 | 
	
		
			
			|  | 389 | +        #         self.RADICALE_SERVER_HOST,
 | 
	
		
			
			|  | 390 | +        #         self.RADICALE_SERVER_PORT,
 | 
	
		
			
			|  | 391 | +        #     ),
 | 
	
		
			
			|  | 392 | +        # )
 | 
	
		
			
			|  | 393 | +        #
 | 
	
		
			
			|  | 394 | +        # self.RADICALE_CLIENT_BASE_URL_PREFIX = settings.get(
 | 
	
		
			
			|  | 395 | +        #     'radicale.client.base_url.prefix',
 | 
	
		
			
			|  | 396 | +        #     '/',
 | 
	
		
			
			|  | 397 | +        # )
 | 
	
		
			
			|  | 398 | +        # # Ensure finished by '/'
 | 
	
		
			
			|  | 399 | +        # if '/' != self.RADICALE_CLIENT_BASE_URL_PREFIX[-1]:
 | 
	
		
			
			|  | 400 | +        #     self.RADICALE_CLIENT_BASE_URL_PREFIX += '/'
 | 
	
		
			
			|  | 401 | +        # if '/' != self.RADICALE_CLIENT_BASE_URL_PREFIX[0]:
 | 
	
		
			
			|  | 402 | +        #     self.RADICALE_CLIENT_BASE_URL_PREFIX \
 | 
	
		
			
			|  | 403 | +        #         = '/' + self.RADICALE_CLIENT_BASE_URL_PREFIX
 | 
	
		
			
			|  | 404 | +        #
 | 
	
		
			
			|  | 405 | +        # if not self.RADICALE_CLIENT_BASE_URL_HOST:
 | 
	
		
			
			|  | 406 | +        #     logger.warning(
 | 
	
		
			
			|  | 407 | +        #         'Generated radicale.client.base_url.host parameter with '
 | 
	
		
			
			|  | 408 | +        #         'followings parameters: website.server_name -> {}'
 | 
	
		
			
			|  | 409 | +        #         .format(self.WEBSITE_SERVER_NAME)
 | 
	
		
			
			|  | 410 | +        #     )
 | 
	
		
			
			|  | 411 | +        #     self.RADICALE_CLIENT_BASE_URL_HOST = self.WEBSITE_SERVER_NAME
 | 
	
		
			
			|  | 412 | +        #
 | 
	
		
			
			|  | 413 | +        # self.RADICALE_CLIENT_BASE_URL_TEMPLATE = '{}{}'.format(
 | 
	
		
			
			|  | 414 | +        #     self.RADICALE_CLIENT_BASE_URL_HOST,
 | 
	
		
			
			|  | 415 | +        #     self.RADICALE_CLIENT_BASE_URL_PREFIX,
 | 
	
		
			
			|  | 416 | +        # )
 | 
	
		
			
			|  | 417 | +
 | 
	
		
			
			|  | 418 | +
 | 
	
		
			
			|  | 419 | +    class CST(object):
 | 
	
		
			
			|  | 420 | +        ASYNC = 'ASYNC'
 | 
	
		
			
			|  | 421 | +        SYNC = 'SYNC'
 | 
	
		
			
			|  | 422 | +
 | 
	
		
			
			|  | 423 | +        TREEVIEW_FOLDERS = 'folders'
 | 
	
		
			
			|  | 424 | +        TREEVIEW_ALL = 'all'
 |