[7193] | 1 | ## $Id: interfaces.py 13394 2015-11-06 05:43:37Z henrik $ |
---|
[3521] | 2 | ## |
---|
[7193] | 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[6361] | 18 | import os |
---|
[7221] | 19 | import re |
---|
[7702] | 20 | import codecs |
---|
[9217] | 21 | import zc.async.interfaces |
---|
[7670] | 22 | import zope.i18nmessageid |
---|
[6915] | 23 | from datetime import datetime |
---|
[7063] | 24 | from hurry.file.interfaces import IFileRetrieval |
---|
[8394] | 25 | from hurry.workflow.interfaces import IWorkflowInfo |
---|
[4789] | 26 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
[6147] | 27 | from zope import schema |
---|
[7233] | 28 | from zope.pluggableauth.interfaces import IPrincipalInfo |
---|
| 29 | from zope.security.interfaces import IGroupClosureAwarePrincipal as IPrincipal |
---|
[4789] | 30 | from zope.component import getUtility |
---|
[4882] | 31 | from zope.component.interfaces import IObjectEvent |
---|
[9217] | 32 | from zope.configuration.fields import Path |
---|
| 33 | from zope.container.interfaces import INameChooser, IContainer |
---|
[8394] | 34 | from zope.interface import Interface, Attribute |
---|
[7795] | 35 | from zope.schema.interfaces import IObject |
---|
[4789] | 36 | from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm |
---|
[8176] | 37 | from waeup.kofa.schema import PhoneNumber |
---|
[11450] | 38 | from waeup.kofa.sourcefactory import SmartBasicContextualSourceFactory |
---|
[3521] | 39 | |
---|
[7811] | 40 | _ = MessageFactory = zope.i18nmessageid.MessageFactory('waeup.kofa') |
---|
[6990] | 41 | |
---|
[8214] | 42 | DELETION_MARKER = 'XXX' |
---|
| 43 | IGNORE_MARKER = '<IGNORE>' |
---|
[9217] | 44 | WAEUP_KEY = 'waeup.kofa' |
---|
| 45 | VIRT_JOBS_CONTAINER_NAME = 'jobs' |
---|
[12901] | 46 | DOCLINK = 'http://kofa-doc.waeup.org/userdocs' |
---|
[8202] | 47 | |
---|
[7673] | 48 | CREATED = 'created' |
---|
| 49 | ADMITTED = 'admitted' |
---|
| 50 | CLEARANCE = 'clearance started' |
---|
| 51 | REQUESTED = 'clearance requested' |
---|
| 52 | CLEARED = 'cleared' |
---|
| 53 | PAID = 'school fee paid' |
---|
| 54 | RETURNING = 'returning' |
---|
| 55 | REGISTERED = 'courses registered' |
---|
| 56 | VALIDATED = 'courses validated' |
---|
[10446] | 57 | GRADUATED = 'graduated' |
---|
| 58 | TRANSCRIPT = 'transcript requested' |
---|
[7670] | 59 | |
---|
[10446] | 60 | |
---|
[9217] | 61 | #: A dict giving job status as tuple (<STRING>, <TRANSLATED_STRING>), |
---|
| 62 | #: the latter for UI purposes. |
---|
| 63 | JOB_STATUS_MAP = { |
---|
| 64 | zc.async.interfaces.NEW: ('new', _('new')), |
---|
| 65 | zc.async.interfaces.COMPLETED: ('completed', _('completed')), |
---|
| 66 | zc.async.interfaces.PENDING: ('pending', _('pending')), |
---|
| 67 | zc.async.interfaces.ACTIVE: ('active', _('active')), |
---|
| 68 | zc.async.interfaces.ASSIGNED: ('assigned', _('assigned')), |
---|
| 69 | zc.async.interfaces.CALLBACKS: ('callbacks', _('callbacks')), |
---|
| 70 | } |
---|
| 71 | |
---|
[8361] | 72 | #default_rest_frontpage = u'' + codecs.open(os.path.join( |
---|
| 73 | # os.path.dirname(__file__), 'frontpage.rst'), |
---|
| 74 | # encoding='utf-8', mode='rb').read() |
---|
| 75 | |
---|
| 76 | default_html_frontpage = u'' + codecs.open(os.path.join( |
---|
| 77 | os.path.dirname(__file__), 'frontpage.html'), |
---|
[7702] | 78 | encoding='utf-8', mode='rb').read() |
---|
[6361] | 79 | |
---|
[7819] | 80 | def SimpleKofaVocabulary(*terms): |
---|
[6915] | 81 | """A well-buildt vocabulary provides terms with a value, token and |
---|
| 82 | title for each term |
---|
| 83 | """ |
---|
| 84 | return SimpleVocabulary([ |
---|
| 85 | SimpleTerm(value, value, title) for title, value in terms]) |
---|
| 86 | |
---|
| 87 | def academic_sessions(): |
---|
| 88 | curr_year = datetime.now().year |
---|
[12751] | 89 | year_range = range(1989, curr_year + 2) |
---|
[6915] | 90 | return [('%s/%s' % (year,year+1), year) for year in year_range] |
---|
| 91 | |
---|
[7819] | 92 | academic_sessions_vocab = SimpleKofaVocabulary(*academic_sessions()) |
---|
[6915] | 93 | |
---|
[7819] | 94 | registration_states_vocab = SimpleKofaVocabulary( |
---|
[7677] | 95 | (_('created'), CREATED), |
---|
| 96 | (_('admitted'), ADMITTED), |
---|
| 97 | (_('clearance started'), CLEARANCE), |
---|
| 98 | (_('clearance requested'), REQUESTED), |
---|
| 99 | (_('cleared'), CLEARED), |
---|
| 100 | (_('school fee paid'), PAID), |
---|
| 101 | (_('courses registered'), REGISTERED), |
---|
| 102 | (_('courses validated'), VALIDATED), |
---|
[9671] | 103 | (_('returning'), RETURNING), |
---|
[10451] | 104 | (_('graduated'), GRADUATED), |
---|
| 105 | (_('transcript requested'), TRANSCRIPT), |
---|
[6990] | 106 | ) |
---|
| 107 | |
---|
[11450] | 108 | class ContextualDictSourceFactoryBase(SmartBasicContextualSourceFactory): |
---|
| 109 | """A base for contextual sources based on KofaUtils dicts. |
---|
| 110 | |
---|
| 111 | To create a real source, you have to set the `DICT_NAME` attribute |
---|
| 112 | which should be the name of a dictionary in KofaUtils. |
---|
| 113 | """ |
---|
| 114 | def getValues(self, context): |
---|
| 115 | utils = getUtility(IKofaUtils) |
---|
[11664] | 116 | sorted_items = sorted(getattr(utils, self.DICT_NAME).items(), |
---|
| 117 | key=lambda item: item[1]) |
---|
| 118 | return [item[0] for item in sorted_items] |
---|
[11450] | 119 | |
---|
| 120 | def getToken(self, context, value): |
---|
| 121 | return str(value) |
---|
| 122 | |
---|
| 123 | def getTitle(self, context, value): |
---|
| 124 | utils = getUtility(IKofaUtils) |
---|
| 125 | return getattr(utils, self.DICT_NAME)[value] |
---|
| 126 | |
---|
[7795] | 127 | class SubjectSource(BasicSourceFactory): |
---|
[7918] | 128 | """A source for school subjects used in exam documentation. |
---|
| 129 | """ |
---|
[7795] | 130 | def getValues(self): |
---|
[7841] | 131 | subjects_dict = getUtility(IKofaUtils).EXAM_SUBJECTS_DICT |
---|
[7837] | 132 | return sorted(subjects_dict.keys()) |
---|
| 133 | |
---|
[7795] | 134 | def getTitle(self, value): |
---|
[7841] | 135 | subjects_dict = getUtility(IKofaUtils).EXAM_SUBJECTS_DICT |
---|
[7837] | 136 | return "%s:" % subjects_dict[value] |
---|
[7795] | 137 | |
---|
| 138 | class GradeSource(BasicSourceFactory): |
---|
[7918] | 139 | """A source for exam grades. |
---|
| 140 | """ |
---|
[7795] | 141 | def getValues(self): |
---|
[7918] | 142 | for entry in getUtility(IKofaUtils).EXAM_GRADES: |
---|
| 143 | yield entry[0] |
---|
[7837] | 144 | |
---|
[7795] | 145 | def getTitle(self, value): |
---|
[7918] | 146 | return dict(getUtility(IKofaUtils).EXAM_GRADES)[value] |
---|
[7795] | 147 | |
---|
[11451] | 148 | class DisablePaymentGroupSource(ContextualDictSourceFactoryBase): |
---|
| 149 | """A source for filtering groups of students |
---|
| 150 | """ |
---|
| 151 | #: name of dict to deliver from kofa utils. |
---|
| 152 | DICT_NAME = 'DISABLE_PAYMENT_GROUP_DICT' |
---|
| 153 | |
---|
[7850] | 154 | # Define a validation method for email addresses |
---|
[7221] | 155 | class NotAnEmailAddress(schema.ValidationError): |
---|
| 156 | __doc__ = u"Invalid email address" |
---|
| 157 | |
---|
[8638] | 158 | #: Regular expression to check email-address formats. As these can |
---|
| 159 | #: become rather complex (nearly everything is allowed by RFCs), we only |
---|
| 160 | #: forbid whitespaces, commas and dots following onto each other. |
---|
[7221] | 161 | check_email = re.compile( |
---|
[8638] | 162 | r"^[^@\s,]+@[^@\.\s,]+(\.[^@\.\s,]+)*$").match |
---|
[7221] | 163 | |
---|
| 164 | def validate_email(value): |
---|
| 165 | if not check_email(value): |
---|
| 166 | raise NotAnEmailAddress(value) |
---|
| 167 | return True |
---|
| 168 | |
---|
[12414] | 169 | # Define a validation method for ids |
---|
| 170 | class NotIdValue(schema.ValidationError): |
---|
| 171 | __doc__ = u"Invalid id" |
---|
| 172 | |
---|
| 173 | #: Regular expressions to check id formats. |
---|
[13029] | 174 | check_id = re.compile(r"^[a-zA-Z0-9_-]{2,10}$").match |
---|
[12414] | 175 | |
---|
| 176 | def validate_id(value): |
---|
| 177 | if not check_id(value): |
---|
| 178 | raise NotIdValue(value) |
---|
| 179 | return True |
---|
| 180 | |
---|
[13235] | 181 | # Define a validation method for HTML fields |
---|
| 182 | class NotHTMLValue(schema.ValidationError): |
---|
| 183 | __doc__ = u"Style or script elements not allowed" |
---|
| 184 | |
---|
| 185 | def validate_html(value): |
---|
| 186 | if '<style' in value or '<script' in value: |
---|
| 187 | raise NotHTMLValue(value) |
---|
| 188 | return True |
---|
| 189 | |
---|
[7850] | 190 | # Define a validation method for international phone numbers |
---|
| 191 | class InvalidPhoneNumber(schema.ValidationError): |
---|
| 192 | __doc__ = u"Invalid phone number" |
---|
| 193 | |
---|
| 194 | # represent format +NNN-NNNN-NNNN |
---|
| 195 | RE_INT_PHONE = re.compile(r"^\+?\d+\-\d+\-[\d\-]+$") |
---|
| 196 | |
---|
| 197 | def validate_phone(value): |
---|
[7851] | 198 | if not RE_INT_PHONE.match(value): |
---|
[7850] | 199 | raise InvalidPhoneNumber(value) |
---|
| 200 | return True |
---|
| 201 | |
---|
[4858] | 202 | class FatalCSVError(Exception): |
---|
| 203 | """Some row could not be processed. |
---|
| 204 | """ |
---|
| 205 | pass |
---|
| 206 | |
---|
[6226] | 207 | class DuplicationError(Exception): |
---|
| 208 | """An exception that can be raised when duplicates are found. |
---|
| 209 | |
---|
| 210 | When raising :exc:`DuplicationError` you can, beside the usual |
---|
| 211 | message, specify a list of objects which are duplicates. These |
---|
| 212 | values can be used by catching code to print something helpful or |
---|
| 213 | similar. |
---|
| 214 | """ |
---|
| 215 | def __init__(self, msg, entries=[]): |
---|
| 216 | self.msg = msg |
---|
| 217 | self.entries = entries |
---|
| 218 | |
---|
| 219 | def __str__(self): |
---|
| 220 | return '%r' % self.msg |
---|
| 221 | |
---|
[6143] | 222 | class RoleSource(BasicSourceFactory): |
---|
[7178] | 223 | """A source for site roles. |
---|
[6508] | 224 | """ |
---|
[6143] | 225 | def getValues(self): |
---|
[6157] | 226 | # late import: in interfaces we should not import local modules |
---|
[7811] | 227 | from waeup.kofa.permissions import get_waeup_role_names |
---|
[7186] | 228 | return get_waeup_role_names() |
---|
[6157] | 229 | |
---|
| 230 | def getTitle(self, value): |
---|
| 231 | # late import: in interfaces we should not import local modules |
---|
[7811] | 232 | from waeup.kofa.permissions import get_all_roles |
---|
[7186] | 233 | roles = dict(get_all_roles()) |
---|
[6157] | 234 | if value in roles.keys(): |
---|
| 235 | title = roles[value].title |
---|
[6569] | 236 | if '.' in title: |
---|
| 237 | title = title.split('.', 2)[1] |
---|
[6157] | 238 | return title |
---|
[6143] | 239 | |
---|
[7313] | 240 | class CaptchaSource(BasicSourceFactory): |
---|
| 241 | """A source for captchas. |
---|
| 242 | """ |
---|
| 243 | def getValues(self): |
---|
[7323] | 244 | captchas = ['No captcha', 'Testing captcha', 'ReCaptcha'] |
---|
[7313] | 245 | try: |
---|
| 246 | # we have to 'try' because IConfiguration can only handle |
---|
[7817] | 247 | # interfaces from w.k.interface. |
---|
[7811] | 248 | from waeup.kofa.browser.interfaces import ICaptchaManager |
---|
[7313] | 249 | except: |
---|
| 250 | return captchas |
---|
| 251 | return sorted(getUtility(ICaptchaManager).getAvailCaptchas().keys()) |
---|
| 252 | |
---|
| 253 | def getTitle(self, value): |
---|
| 254 | return value |
---|
| 255 | |
---|
[7795] | 256 | class IResultEntry(Interface): |
---|
| 257 | """A school grade entry. |
---|
| 258 | """ |
---|
| 259 | subject = schema.Choice( |
---|
| 260 | title = _(u'Subject'), |
---|
| 261 | source = SubjectSource(), |
---|
| 262 | ) |
---|
| 263 | grade = schema.Choice( |
---|
| 264 | title = _(u'Grade'), |
---|
| 265 | source = GradeSource(), |
---|
| 266 | ) |
---|
| 267 | |
---|
| 268 | class IResultEntryField(IObject): |
---|
| 269 | """A zope.schema-like field for usage in interfaces. |
---|
| 270 | |
---|
| 271 | Marker interface to distuingish result entries from ordinary |
---|
| 272 | object fields. Needed for registration of widgets. |
---|
| 273 | """ |
---|
| 274 | |
---|
[7819] | 275 | class IKofaUtils(Interface): |
---|
[7358] | 276 | """A collection of methods which are subject to customization. |
---|
| 277 | """ |
---|
[7568] | 278 | |
---|
[7841] | 279 | PORTAL_LANGUAGE = Attribute("Dict of global language setting") |
---|
| 280 | PREFERRED_LANGUAGES_DICT = Attribute("Dict of preferred languages") |
---|
| 281 | EXAM_SUBJECTS_DICT = Attribute("Dict of examination subjects") |
---|
[11799] | 282 | EXAM_GRADES = Attribute("Dict of examination grades") |
---|
[7841] | 283 | INST_TYPES_DICT = Attribute("Dict if institution types") |
---|
| 284 | STUDY_MODES_DICT = Attribute("Dict of study modes") |
---|
| 285 | APP_CATS_DICT = Attribute("Dict of application categories") |
---|
| 286 | SEMESTER_DICT = Attribute("Dict of semesters or trimesters") |
---|
[11799] | 287 | SYSTEM_MAX_LOAD = Attribute("Dict of maximum system loads.") |
---|
[7568] | 288 | |
---|
[7404] | 289 | def sendContactForm( |
---|
| 290 | from_name,from_addr,rcpt_name,rcpt_addr, |
---|
| 291 | from_username,usertype,portal,body,subject): |
---|
[7358] | 292 | """Send an email with data provided by forms. |
---|
| 293 | """ |
---|
| 294 | |
---|
[7475] | 295 | def fullname(firstname,lastname,middlename): |
---|
| 296 | """Full name constructor. |
---|
| 297 | """ |
---|
| 298 | |
---|
[8853] | 299 | def sendCredentials(user, password, url_info, msg): |
---|
[7475] | 300 | """Send credentials as email. |
---|
| 301 | |
---|
| 302 | Input is the applicant for which credentials are sent and the |
---|
| 303 | password. |
---|
| 304 | |
---|
| 305 | Returns True or False to indicate successful operation. |
---|
| 306 | """ |
---|
| 307 | |
---|
| 308 | def genPassword(length, chars): |
---|
| 309 | """Generate a random password. |
---|
| 310 | """ |
---|
| 311 | |
---|
[7819] | 312 | class IKofaObject(Interface): |
---|
| 313 | """A Kofa object. |
---|
[5663] | 314 | |
---|
| 315 | This is merely a marker interface. |
---|
[4789] | 316 | """ |
---|
| 317 | |
---|
[7819] | 318 | class IUniversity(IKofaObject): |
---|
[3521] | 319 | """Representation of a university. |
---|
| 320 | """ |
---|
[5955] | 321 | |
---|
[6065] | 322 | |
---|
[7819] | 323 | class IKofaContainer(IKofaObject): |
---|
| 324 | """A container for Kofa objects. |
---|
[4789] | 325 | """ |
---|
| 326 | |
---|
[7819] | 327 | class IKofaContained(IKofaObject): |
---|
| 328 | """An item contained in an IKofaContainer. |
---|
[4789] | 329 | """ |
---|
[6136] | 330 | |
---|
[7726] | 331 | class ICSVExporter(Interface): |
---|
| 332 | """A CSV file exporter for objects. |
---|
| 333 | """ |
---|
| 334 | fields = Attribute("""List of fieldnames in resulting CSV""") |
---|
[7907] | 335 | |
---|
| 336 | title = schema.TextLine( |
---|
| 337 | title = u'Title', |
---|
| 338 | description = u'Description to be displayed in selections.', |
---|
| 339 | ) |
---|
[7726] | 340 | def mangle_value(value, name, obj): |
---|
| 341 | """Mangle `value` extracted from `obj` or suobjects thereof. |
---|
| 342 | |
---|
[8394] | 343 | This is called by export before actually writing to the result |
---|
| 344 | file. |
---|
[7726] | 345 | """ |
---|
| 346 | |
---|
[9797] | 347 | def get_filtered(site, **kw): |
---|
| 348 | """Get datasets in `site` to be exported. |
---|
| 349 | |
---|
| 350 | The set of data is specified by keywords, which might be |
---|
| 351 | different for any implementaion of exporter. |
---|
| 352 | |
---|
| 353 | Returns an iterable. |
---|
| 354 | """ |
---|
| 355 | |
---|
[12516] | 356 | def get_selected(site, selected): |
---|
| 357 | """Get datasets in `site` to be exported. |
---|
| 358 | |
---|
| 359 | The set of data is specified by a list of identifiers. |
---|
| 360 | |
---|
| 361 | Returns an iterable. |
---|
| 362 | """ |
---|
| 363 | |
---|
[7730] | 364 | def export(iterable, filepath=None): |
---|
| 365 | """Export iterables as rows in a CSV file. |
---|
[7726] | 366 | |
---|
[8394] | 367 | If `filepath` is not given, a string with the data should be |
---|
| 368 | returned. |
---|
[7730] | 369 | |
---|
| 370 | What kind of iterables are acceptable depends on the specific |
---|
| 371 | exporter implementation. |
---|
[7726] | 372 | """ |
---|
| 373 | |
---|
[9766] | 374 | def export_all(site, filepath=None): |
---|
[7726] | 375 | """Export all items in `site` as CSV file. |
---|
| 376 | |
---|
[8394] | 377 | if `filepath` is not given, a string with the data should be |
---|
| 378 | returned. |
---|
[7726] | 379 | """ |
---|
| 380 | |
---|
[9797] | 381 | def export_filtered(site, filepath=None, **kw): |
---|
| 382 | """Export those items in `site` specified by `args` and `kw`. |
---|
| 383 | |
---|
| 384 | If `filepath` is not given, a string with the data should be |
---|
| 385 | returned. |
---|
| 386 | |
---|
| 387 | Which special keywords are supported is up to the respective |
---|
| 388 | exporter. |
---|
| 389 | """ |
---|
| 390 | |
---|
[12516] | 391 | def export_selected(site, filepath=None, **kw): |
---|
| 392 | """Export items in `site` specified by a list of identifiers |
---|
| 393 | called `selected`. |
---|
| 394 | |
---|
| 395 | If `filepath` is not given, a string with the data should be |
---|
| 396 | returned. |
---|
| 397 | """ |
---|
| 398 | |
---|
[7819] | 399 | class IKofaExporter(Interface): |
---|
[4789] | 400 | """An exporter for objects. |
---|
| 401 | """ |
---|
| 402 | def export(obj, filepath=None): |
---|
| 403 | """Export by pickling. |
---|
| 404 | |
---|
| 405 | Returns a file-like object containing a representation of `obj`. |
---|
| 406 | |
---|
| 407 | This is done using `pickle`. If `filepath` is ``None``, a |
---|
| 408 | `cStringIO` object is returned, that contains the saved data. |
---|
| 409 | """ |
---|
| 410 | |
---|
[7819] | 411 | class IKofaXMLExporter(Interface): |
---|
[4789] | 412 | """An XML exporter for objects. |
---|
| 413 | """ |
---|
| 414 | def export(obj, filepath=None): |
---|
| 415 | """Export as XML. |
---|
| 416 | |
---|
| 417 | Returns an XML representation of `obj`. |
---|
| 418 | |
---|
| 419 | If `filepath` is ``None``, a StringIO` object is returned, |
---|
| 420 | that contains the transformed data. |
---|
| 421 | """ |
---|
| 422 | |
---|
[7819] | 423 | class IKofaXMLImporter(Interface): |
---|
[4789] | 424 | """An XML import for objects. |
---|
| 425 | """ |
---|
| 426 | def doImport(filepath): |
---|
| 427 | """Create Python object from XML. |
---|
| 428 | |
---|
| 429 | Returns a Python object. |
---|
| 430 | """ |
---|
| 431 | |
---|
[4858] | 432 | class IBatchProcessor(Interface): |
---|
| 433 | """A batch processor that handles mass-operations. |
---|
| 434 | """ |
---|
| 435 | name = schema.TextLine( |
---|
[7933] | 436 | title = _(u'Processor name') |
---|
[4858] | 437 | ) |
---|
| 438 | |
---|
[5476] | 439 | def doImport(path, headerfields, mode='create', user='Unknown', |
---|
[8218] | 440 | logger=None, ignore_empty=True): |
---|
[4858] | 441 | """Read data from ``path`` and update connected object. |
---|
[5476] | 442 | |
---|
| 443 | `headerfields` is a list of headerfields as read from the file |
---|
| 444 | to import. |
---|
| 445 | |
---|
| 446 | `mode` gives the import mode to use (``'create'``, |
---|
| 447 | ``'update'``, or ``'remove'``. |
---|
| 448 | |
---|
| 449 | `user` is a string describing the user performing the |
---|
| 450 | import. Normally fetched from current principal. |
---|
| 451 | |
---|
| 452 | `logger` is the logger to use during import. |
---|
[8218] | 453 | |
---|
| 454 | `ignore_emtpy` in update mode ignores empty fields if true. |
---|
[4858] | 455 | """ |
---|
| 456 | |
---|
[7819] | 457 | class IContactForm(IKofaObject): |
---|
[7225] | 458 | """A contact form. |
---|
| 459 | """ |
---|
| 460 | |
---|
| 461 | email_from = schema.ASCIILine( |
---|
[7828] | 462 | title = _(u'Email Address:'), |
---|
[7225] | 463 | default = None, |
---|
| 464 | required = True, |
---|
| 465 | constraint=validate_email, |
---|
| 466 | ) |
---|
| 467 | |
---|
| 468 | email_to = schema.ASCIILine( |
---|
[7828] | 469 | title = _(u'Email to:'), |
---|
[7225] | 470 | default = None, |
---|
| 471 | required = True, |
---|
| 472 | constraint=validate_email, |
---|
| 473 | ) |
---|
| 474 | |
---|
| 475 | subject = schema.TextLine( |
---|
[7828] | 476 | title = _(u'Subject:'), |
---|
[7225] | 477 | required = True,) |
---|
| 478 | |
---|
| 479 | fullname = schema.TextLine( |
---|
[7828] | 480 | title = _(u'Full Name:'), |
---|
[7225] | 481 | required = True,) |
---|
| 482 | |
---|
| 483 | body = schema.Text( |
---|
[7828] | 484 | title = _(u'Text:'), |
---|
[7225] | 485 | required = True,) |
---|
| 486 | |
---|
[7819] | 487 | class IKofaPrincipalInfo(IPrincipalInfo): |
---|
| 488 | """Infos about principals that are users of Kofa Kofa. |
---|
[7233] | 489 | """ |
---|
| 490 | email = Attribute("The email address of a user") |
---|
| 491 | phone = Attribute("The phone number of a user") |
---|
[8757] | 492 | public_name = Attribute("The public name of a user") |
---|
[12915] | 493 | user_type = Attribute("The type of a user") |
---|
[7225] | 494 | |
---|
[7233] | 495 | |
---|
[7819] | 496 | class IKofaPrincipal(IPrincipal): |
---|
| 497 | """A principle for Kofa Kofa. |
---|
[7233] | 498 | |
---|
| 499 | This interface extends zope.security.interfaces.IPrincipal and |
---|
| 500 | requires also an `id` and other attributes defined there. |
---|
| 501 | """ |
---|
| 502 | |
---|
| 503 | email = schema.TextLine( |
---|
[7828] | 504 | title = _(u'Email Address'), |
---|
[7233] | 505 | description = u'', |
---|
| 506 | required=False,) |
---|
| 507 | |
---|
[8176] | 508 | phone = PhoneNumber( |
---|
[7828] | 509 | title = _(u'Phone'), |
---|
[7233] | 510 | description = u'', |
---|
| 511 | required=False,) |
---|
| 512 | |
---|
[8757] | 513 | public_name = schema.TextLine( |
---|
| 514 | title = _(u'Public Name'), |
---|
| 515 | required = False,) |
---|
| 516 | |
---|
[12915] | 517 | user_type = Attribute('The user type of the principal') |
---|
| 518 | |
---|
[10055] | 519 | class IFailedLoginInfo(IKofaObject): |
---|
| 520 | """Info about failed logins. |
---|
| 521 | |
---|
| 522 | Timestamps are supposed to be stored as floats using time.time() |
---|
| 523 | or similar. |
---|
| 524 | """ |
---|
| 525 | num = schema.Int( |
---|
| 526 | title = _(u'Number of failed logins'), |
---|
| 527 | description = _(u'Number of failed logins'), |
---|
| 528 | required = True, |
---|
| 529 | default = 0, |
---|
| 530 | ) |
---|
| 531 | |
---|
| 532 | last = schema.Float( |
---|
| 533 | title = _(u'Timestamp'), |
---|
| 534 | description = _(u'Timestamp of last failed login or `None`'), |
---|
| 535 | required = False, |
---|
| 536 | default = None, |
---|
| 537 | ) |
---|
| 538 | |
---|
| 539 | def as_tuple(): |
---|
| 540 | """Get login info as tuple ``<NUM>, <TIMESTAMP>``. |
---|
| 541 | """ |
---|
| 542 | |
---|
| 543 | def set_values(num=0, last=None): |
---|
| 544 | """Set number of failed logins and timestamp of last one. |
---|
| 545 | """ |
---|
| 546 | |
---|
| 547 | def increase(): |
---|
| 548 | """Increase the current number of failed logins and set timestamp. |
---|
| 549 | """ |
---|
| 550 | |
---|
| 551 | def reset(): |
---|
| 552 | """Set failed login counters back to zero. |
---|
| 553 | """ |
---|
| 554 | |
---|
| 555 | |
---|
[7819] | 556 | class IUserAccount(IKofaObject): |
---|
[4789] | 557 | """A user account. |
---|
| 558 | """ |
---|
[10055] | 559 | |
---|
[12926] | 560 | failed_logins = Attribute('FailedLoginInfo for this account') |
---|
[10055] | 561 | |
---|
[4789] | 562 | name = schema.TextLine( |
---|
[7828] | 563 | title = _(u'User Id'), |
---|
[12926] | 564 | description = _(u'Login name of user'), |
---|
[4789] | 565 | required = True,) |
---|
[7221] | 566 | |
---|
[4789] | 567 | title = schema.TextLine( |
---|
[7828] | 568 | title = _(u'Full Name'), |
---|
[8759] | 569 | required = True,) |
---|
[7221] | 570 | |
---|
[8756] | 571 | public_name = schema.TextLine( |
---|
| 572 | title = _(u'Public Name'), |
---|
[12926] | 573 | description = _(u"Substitute for officer's real name " |
---|
| 574 | "in student object histories."), |
---|
[8756] | 575 | required = False,) |
---|
| 576 | |
---|
[7197] | 577 | description = schema.Text( |
---|
[7828] | 578 | title = _(u'Description/Notice'), |
---|
[4789] | 579 | required = False,) |
---|
[7221] | 580 | |
---|
| 581 | email = schema.ASCIILine( |
---|
[7828] | 582 | title = _(u'Email Address'), |
---|
[7221] | 583 | default = None, |
---|
[7222] | 584 | required = True, |
---|
[7221] | 585 | constraint=validate_email, |
---|
| 586 | ) |
---|
| 587 | |
---|
[8176] | 588 | phone = PhoneNumber( |
---|
[7828] | 589 | title = _(u'Phone'), |
---|
[7233] | 590 | default = None, |
---|
[8062] | 591 | required = False, |
---|
[7233] | 592 | ) |
---|
| 593 | |
---|
[4789] | 594 | roles = schema.List( |
---|
[8486] | 595 | title = _(u'Portal Roles'), |
---|
[8079] | 596 | value_type = schema.Choice(source=RoleSource()), |
---|
| 597 | required = False, |
---|
| 598 | ) |
---|
[6136] | 599 | |
---|
[12926] | 600 | suspended = schema.Bool( |
---|
| 601 | title = _(u'Account suspended'), |
---|
| 602 | description = _(u'If set, the account is immediately blocked.'), |
---|
| 603 | default = False, |
---|
| 604 | required = False, |
---|
| 605 | ) |
---|
[10055] | 606 | |
---|
| 607 | |
---|
[7147] | 608 | class IPasswordValidator(Interface): |
---|
| 609 | """A password validator utility. |
---|
| 610 | """ |
---|
[6136] | 611 | |
---|
[7147] | 612 | def validate_password(password, password_repeat): |
---|
| 613 | """Validates a password by comparing it with |
---|
| 614 | control password and checking some other requirements. |
---|
| 615 | """ |
---|
| 616 | |
---|
| 617 | |
---|
[7819] | 618 | class IUsersContainer(IKofaObject): |
---|
[12915] | 619 | """A container for officers. |
---|
[4789] | 620 | """ |
---|
| 621 | |
---|
| 622 | def addUser(name, password, title=None, description=None): |
---|
| 623 | """Add a user. |
---|
| 624 | """ |
---|
| 625 | |
---|
| 626 | def delUser(name): |
---|
| 627 | """Delete a user if it exists. |
---|
| 628 | """ |
---|
| 629 | |
---|
[6141] | 630 | class ILocalRolesAssignable(Interface): |
---|
| 631 | """The local roles assignable to an object. |
---|
| 632 | """ |
---|
| 633 | def __call__(): |
---|
| 634 | """Returns a list of dicts. |
---|
| 635 | |
---|
| 636 | Each dict contains a ``name`` referring to the role assignable |
---|
| 637 | for the specified object and a `title` to describe the range |
---|
| 638 | of users to which this role can be assigned. |
---|
| 639 | """ |
---|
| 640 | |
---|
[7819] | 641 | class IConfigurationContainer(IKofaObject): |
---|
[6907] | 642 | """A container for session configuration objects. |
---|
| 643 | """ |
---|
| 644 | |
---|
| 645 | name = schema.TextLine( |
---|
[7828] | 646 | title = _(u'Name of University'), |
---|
| 647 | default = _(u'Sample University'), |
---|
[6907] | 648 | required = True, |
---|
| 649 | ) |
---|
| 650 | |
---|
[7459] | 651 | acronym = schema.TextLine( |
---|
[7828] | 652 | title = _(u'Abbreviated Title of University'), |
---|
[7819] | 653 | default = u'WAeUP.Kofa', |
---|
[7459] | 654 | required = True, |
---|
| 655 | ) |
---|
| 656 | |
---|
[6907] | 657 | frontpage = schema.Text( |
---|
[8361] | 658 | title = _(u'Content in HTML format'), |
---|
[6907] | 659 | required = False, |
---|
[8361] | 660 | default = default_html_frontpage, |
---|
[13235] | 661 | constraint=validate_html, |
---|
[6907] | 662 | ) |
---|
| 663 | |
---|
[7702] | 664 | frontpage_dict = schema.Dict( |
---|
| 665 | title = u'Content as language dictionary with values in html format', |
---|
[7485] | 666 | required = False, |
---|
[7702] | 667 | default = {}, |
---|
[7485] | 668 | ) |
---|
| 669 | |
---|
[7223] | 670 | name_admin = schema.TextLine( |
---|
[7828] | 671 | title = _(u'Name of Administrator'), |
---|
[7223] | 672 | default = u'Administrator', |
---|
[8230] | 673 | required = True, |
---|
[7223] | 674 | ) |
---|
| 675 | |
---|
[7221] | 676 | email_admin = schema.ASCIILine( |
---|
[7828] | 677 | title = _(u'Email Address of Administrator'), |
---|
[7221] | 678 | default = 'contact@waeup.org', |
---|
[8230] | 679 | required = True, |
---|
[13158] | 680 | #constraint=validate_email, |
---|
[7221] | 681 | ) |
---|
| 682 | |
---|
| 683 | email_subject = schema.TextLine( |
---|
[7828] | 684 | title = _(u'Subject of Email to Administrator'), |
---|
| 685 | default = _(u'Kofa Contact'), |
---|
[8230] | 686 | required = True, |
---|
[7221] | 687 | ) |
---|
| 688 | |
---|
[7470] | 689 | smtp_mailer = schema.Choice( |
---|
[7828] | 690 | title = _(u'SMTP mailer to use when sending mail'), |
---|
[7470] | 691 | vocabulary = 'Mail Delivery Names', |
---|
| 692 | default = 'No email service', |
---|
| 693 | required = True, |
---|
| 694 | ) |
---|
| 695 | |
---|
[7313] | 696 | captcha = schema.Choice( |
---|
[7828] | 697 | title = _(u'Captcha used for public registration pages'), |
---|
[7313] | 698 | source = CaptchaSource(), |
---|
| 699 | default = u'No captcha', |
---|
| 700 | required = True, |
---|
| 701 | ) |
---|
[7221] | 702 | |
---|
[7664] | 703 | carry_over = schema.Bool( |
---|
[7828] | 704 | title = _(u'Carry-over Course Registration'), |
---|
[7664] | 705 | default = False, |
---|
| 706 | ) |
---|
| 707 | |
---|
[10627] | 708 | current_academic_session = schema.Choice( |
---|
| 709 | title = _(u'Current Academic Session'), |
---|
[10631] | 710 | description = _(u'Session for which score editing is allowed'), |
---|
[10627] | 711 | source = academic_sessions_vocab, |
---|
| 712 | default = None, |
---|
| 713 | required = False, |
---|
| 714 | readonly = False, |
---|
| 715 | ) |
---|
| 716 | |
---|
[11589] | 717 | next_matric_integer = schema.Int( |
---|
| 718 | title = _(u'Next Matriculation Number Integer'), |
---|
| 719 | description = _(u'Integer used for constructing the next ' |
---|
| 720 | 'matriculation number'), |
---|
| 721 | default = 0, |
---|
| 722 | readonly = False, |
---|
| 723 | required = False, |
---|
| 724 | ) |
---|
| 725 | |
---|
[13354] | 726 | next_matric_integer_2 = schema.Int( |
---|
| 727 | title = _(u'Next Matriculation Number Integer 2'), |
---|
| 728 | description = _(u'2nd integer used for constructing the next ' |
---|
| 729 | 'matriculation number'), |
---|
| 730 | default = 0, |
---|
| 731 | readonly = False, |
---|
| 732 | required = False, |
---|
| 733 | ) |
---|
| 734 | |
---|
[13198] | 735 | export_disabled_message = schema.Text( |
---|
[13239] | 736 | title = _(u'Export-disabled message'), |
---|
| 737 | description = _(u'Message which will show up if an officer tries ' |
---|
| 738 | 'to export data. All exporters are automatcally ' |
---|
| 739 | 'disabled if this field is set.'), |
---|
[13198] | 740 | required = False, |
---|
| 741 | ) |
---|
| 742 | |
---|
[13394] | 743 | maintmode_enabled_by = schema.TextLine( |
---|
| 744 | title = _(u'Maintenance Mode enabled by'), |
---|
| 745 | default = None, |
---|
| 746 | required = False, |
---|
| 747 | ) |
---|
[13198] | 748 | |
---|
[13118] | 749 | def addSessionConfiguration(sessionconfiguration): |
---|
| 750 | """Add a session configuration object. |
---|
| 751 | """ |
---|
| 752 | |
---|
[7819] | 753 | class ISessionConfiguration(IKofaObject): |
---|
[6915] | 754 | """A session configuration object. |
---|
[6907] | 755 | """ |
---|
| 756 | |
---|
[6915] | 757 | academic_session = schema.Choice( |
---|
[7828] | 758 | title = _(u'Academic Session'), |
---|
[6915] | 759 | source = academic_sessions_vocab, |
---|
| 760 | default = None, |
---|
| 761 | required = True, |
---|
| 762 | readonly = True, |
---|
| 763 | ) |
---|
| 764 | |
---|
[13033] | 765 | clearance_enabled = schema.Bool( |
---|
| 766 | title = _(u'Clearance enabled'), |
---|
| 767 | default = False, |
---|
| 768 | ) |
---|
| 769 | |
---|
| 770 | payment_disabled = schema.List( |
---|
| 771 | title = _(u'Payment disabled'), |
---|
| 772 | value_type = schema.Choice( |
---|
| 773 | source = DisablePaymentGroupSource(), |
---|
| 774 | ), |
---|
| 775 | required = False, |
---|
| 776 | default = [], |
---|
| 777 | ) |
---|
| 778 | |
---|
[13034] | 779 | coursereg_deadline = schema.Datetime( |
---|
| 780 | title = _(u'Course Reg. Deadline'), |
---|
| 781 | required = False, |
---|
| 782 | description = _('Example: ') + u'2011-12-31 23:59:59+01:00', |
---|
| 783 | ) |
---|
| 784 | |
---|
| 785 | late_registration_fee = schema.Float( |
---|
| 786 | title = _(u'Late Course Reg. Fee'), |
---|
| 787 | default = 0.0, |
---|
| 788 | required = False, |
---|
| 789 | ) |
---|
| 790 | |
---|
[8260] | 791 | application_fee = schema.Float( |
---|
| 792 | title = _(u'Application Fee'), |
---|
[7927] | 793 | default = 0.0, |
---|
[7881] | 794 | required = False, |
---|
[6916] | 795 | ) |
---|
| 796 | |
---|
[8260] | 797 | clearance_fee = schema.Float( |
---|
[9243] | 798 | title = _(u'Acceptance Fee'), |
---|
[7927] | 799 | default = 0.0, |
---|
[7881] | 800 | required = False, |
---|
[6993] | 801 | ) |
---|
| 802 | |
---|
[8260] | 803 | booking_fee = schema.Float( |
---|
| 804 | title = _(u'Bed Booking Fee'), |
---|
[7927] | 805 | default = 0.0, |
---|
[7881] | 806 | required = False, |
---|
[7250] | 807 | ) |
---|
| 808 | |
---|
[9423] | 809 | maint_fee = schema.Float( |
---|
[10680] | 810 | title = _(u'Rent (fallback)'), |
---|
[9423] | 811 | default = 0.0, |
---|
| 812 | required = False, |
---|
| 813 | ) |
---|
| 814 | |
---|
[10449] | 815 | transcript_fee = schema.Float( |
---|
| 816 | title = _(u'Transcript Fee'), |
---|
| 817 | default = 0.0, |
---|
| 818 | required = False, |
---|
| 819 | ) |
---|
| 820 | |
---|
[6918] | 821 | def getSessionString(): |
---|
[13118] | 822 | """Return the session string from the vocabulary. |
---|
[6918] | 823 | """ |
---|
| 824 | |
---|
| 825 | |
---|
[6916] | 826 | class ISessionConfigurationAdd(ISessionConfiguration): |
---|
| 827 | """A session configuration object in add mode. |
---|
| 828 | """ |
---|
| 829 | |
---|
| 830 | academic_session = schema.Choice( |
---|
[7828] | 831 | title = _(u'Academic Session'), |
---|
[6916] | 832 | source = academic_sessions_vocab, |
---|
| 833 | default = None, |
---|
| 834 | required = True, |
---|
| 835 | readonly = False, |
---|
| 836 | ) |
---|
| 837 | |
---|
| 838 | ISessionConfigurationAdd['academic_session'].order = ISessionConfiguration[ |
---|
| 839 | 'academic_session'].order |
---|
| 840 | |
---|
[7819] | 841 | class IDataCenter(IKofaObject): |
---|
[4789] | 842 | """A data center. |
---|
| 843 | |
---|
[8394] | 844 | A data center manages files (uploads, downloads, etc.). |
---|
| 845 | |
---|
| 846 | Beside providing the bare paths needed to keep files, it also |
---|
| 847 | provides some helpers to put results of batch processing into |
---|
| 848 | well-defined final locations (with well-defined filenames). |
---|
| 849 | |
---|
| 850 | The main use-case is managing of site-related files, i.e. files |
---|
| 851 | for import, export etc. |
---|
| 852 | |
---|
| 853 | DataCenters are _not_ meant as storages for object-specific files |
---|
| 854 | like passport photographs and similar. |
---|
| 855 | |
---|
| 856 | It is up to the datacenter implementation how to organize data |
---|
| 857 | (paths) inside its storage path. |
---|
[4789] | 858 | """ |
---|
[8394] | 859 | storage = schema.Bytes( |
---|
| 860 | title = u'Path to directory where everything is kept.' |
---|
| 861 | ) |
---|
[4789] | 862 | |
---|
[8394] | 863 | deleted_path = schema.Bytes( |
---|
| 864 | title = u'Path were data about deleted objects should be stored.' |
---|
| 865 | ) |
---|
| 866 | |
---|
[9023] | 867 | def getPendingFiles(sort='name'): |
---|
[8394] | 868 | """Get a list of files stored in `storage` sorted by basename. |
---|
| 869 | """ |
---|
[9023] | 870 | |
---|
[9074] | 871 | def getFinishedFiles(): |
---|
| 872 | """Get a list of files stored in `finished` subfolder of `storage`. |
---|
[9023] | 873 | """ |
---|
| 874 | |
---|
[8394] | 875 | def setStoragePath(path, move=False, overwrite=False): |
---|
| 876 | """Set the path where to store files. |
---|
| 877 | |
---|
| 878 | If `move` is True, move over files from the current location |
---|
| 879 | to the new one. |
---|
| 880 | |
---|
| 881 | If `overwrite` is also True, overwrite any already existing |
---|
| 882 | files of same name in target location. |
---|
| 883 | |
---|
| 884 | Triggers a DataCenterStorageMovedEvent. |
---|
| 885 | """ |
---|
| 886 | |
---|
| 887 | def distProcessedFiles(successful, source_path, finished_file, |
---|
| 888 | pending_file, mode='create', move_orig=True): |
---|
| 889 | """Distribute processed files over final locations. |
---|
| 890 | """ |
---|
| 891 | |
---|
| 892 | |
---|
[4789] | 893 | class IDataCenterFile(Interface): |
---|
| 894 | """A data center file. |
---|
| 895 | """ |
---|
[4858] | 896 | |
---|
| 897 | name = schema.TextLine( |
---|
| 898 | title = u'Filename') |
---|
| 899 | |
---|
| 900 | size = schema.TextLine( |
---|
| 901 | title = u'Human readable file size') |
---|
| 902 | |
---|
| 903 | uploaddate = schema.TextLine( |
---|
| 904 | title = u'Human readable upload datetime') |
---|
| 905 | |
---|
| 906 | lines = schema.Int( |
---|
| 907 | title = u'Number of lines in file') |
---|
[6136] | 908 | |
---|
[4789] | 909 | def getDate(): |
---|
| 910 | """Get creation timestamp from file in human readable form. |
---|
| 911 | """ |
---|
| 912 | |
---|
| 913 | def getSize(): |
---|
| 914 | """Get human readable size of file. |
---|
| 915 | """ |
---|
[4858] | 916 | |
---|
| 917 | def getLinesNumber(): |
---|
| 918 | """Get number of lines of file. |
---|
| 919 | """ |
---|
[4882] | 920 | |
---|
| 921 | class IDataCenterStorageMovedEvent(IObjectEvent): |
---|
| 922 | """Emitted, when the storage of a datacenter changes. |
---|
| 923 | """ |
---|
[5007] | 924 | |
---|
[6136] | 925 | class IObjectUpgradeEvent(IObjectEvent): |
---|
| 926 | """Can be fired, when an object shall be upgraded. |
---|
| 927 | """ |
---|
| 928 | |
---|
[6180] | 929 | class ILocalRoleSetEvent(IObjectEvent): |
---|
| 930 | """A local role was granted/revoked for a principal on an object. |
---|
| 931 | """ |
---|
| 932 | role_id = Attribute( |
---|
| 933 | "The role id that was set.") |
---|
| 934 | principal_id = Attribute( |
---|
| 935 | "The principal id for which the role was granted/revoked.") |
---|
| 936 | granted = Attribute( |
---|
| 937 | "Boolean. If false, then the role was revoked.") |
---|
| 938 | |
---|
[5007] | 939 | class IQueryResultItem(Interface): |
---|
| 940 | """An item in a search result. |
---|
| 941 | """ |
---|
| 942 | url = schema.TextLine( |
---|
| 943 | title = u'URL that links to the found item') |
---|
| 944 | title = schema.TextLine( |
---|
| 945 | title = u'Title displayed in search results.') |
---|
| 946 | description = schema.Text( |
---|
| 947 | title = u'Longer description of the item found.') |
---|
[6136] | 948 | |
---|
[7819] | 949 | class IKofaPluggable(Interface): |
---|
| 950 | """A component that might be plugged into a Kofa Kofa app. |
---|
[5658] | 951 | |
---|
| 952 | Components implementing this interface are referred to as |
---|
| 953 | 'plugins'. They are normally called when a new |
---|
[7811] | 954 | :class:`waeup.kofa.app.University` instance is created. |
---|
[5658] | 955 | |
---|
| 956 | Plugins can setup and update parts of the central site without the |
---|
[7811] | 957 | site object (normally a :class:`waeup.kofa.app.University` object) |
---|
[5658] | 958 | needing to know about that parts. The site simply collects all |
---|
| 959 | available plugins, calls them and the plugins care for their |
---|
[5676] | 960 | respective subarea like the applicants area or the datacenter |
---|
[5658] | 961 | area. |
---|
| 962 | |
---|
| 963 | Currently we have no mechanism to define an order of plugins. A |
---|
| 964 | plugin should therefore make no assumptions about the state of the |
---|
| 965 | site or other plugins being run before and instead do appropriate |
---|
| 966 | checks if necessary. |
---|
| 967 | |
---|
| 968 | Updates can be triggered for instance by the respective form in |
---|
| 969 | the site configuration. You normally do updates when the |
---|
| 970 | underlying software changed. |
---|
[5013] | 971 | """ |
---|
[5069] | 972 | def setup(site, name, logger): |
---|
| 973 | """Create an instance of the plugin. |
---|
[5013] | 974 | |
---|
[5658] | 975 | The method is meant to be called by the central app (site) |
---|
| 976 | when it is created. |
---|
| 977 | |
---|
| 978 | `site`: |
---|
| 979 | The site that requests a setup. |
---|
| 980 | |
---|
| 981 | `name`: |
---|
| 982 | The name under which the plugin was registered (utility name). |
---|
| 983 | |
---|
| 984 | `logger`: |
---|
| 985 | A standard Python logger for the plugins use. |
---|
[5069] | 986 | """ |
---|
| 987 | |
---|
| 988 | def update(site, name, logger): |
---|
| 989 | """Method to update an already existing plugin. |
---|
| 990 | |
---|
| 991 | This might be called by a site when something serious |
---|
[5658] | 992 | changes. It is a poor-man replacement for Zope generations |
---|
| 993 | (but probably more comprehensive and better understandable). |
---|
| 994 | |
---|
| 995 | `site`: |
---|
| 996 | The site that requests an update. |
---|
| 997 | |
---|
| 998 | `name`: |
---|
| 999 | The name under which the plugin was registered (utility name). |
---|
| 1000 | |
---|
| 1001 | `logger`: |
---|
| 1002 | A standard Python logger for the plugins use. |
---|
[5069] | 1003 | """ |
---|
[5898] | 1004 | |
---|
[5899] | 1005 | class IAuthPluginUtility(Interface): |
---|
[5898] | 1006 | """A component that cares for authentication setup at site creation. |
---|
| 1007 | |
---|
| 1008 | Utilities providing this interface are looked up when a Pluggable |
---|
| 1009 | Authentication Utility (PAU) for any |
---|
[7811] | 1010 | :class:`waeup.kofa.app.University` instance is created and put |
---|
[5898] | 1011 | into ZODB. |
---|
| 1012 | |
---|
| 1013 | The setup-code then calls the `register` method of the utility and |
---|
| 1014 | expects a modified (or unmodified) version of the PAU back. |
---|
| 1015 | |
---|
| 1016 | This allows to define any authentication setup modifications by |
---|
| 1017 | submodules or third-party modules/packages. |
---|
| 1018 | """ |
---|
| 1019 | |
---|
| 1020 | def register(pau): |
---|
| 1021 | """Register any plugins wanted to be in the PAU. |
---|
| 1022 | """ |
---|
| 1023 | |
---|
| 1024 | def unregister(pau): |
---|
| 1025 | """Unregister any plugins not wanted to be in the PAU. |
---|
| 1026 | """ |
---|
[6273] | 1027 | |
---|
| 1028 | class IObjectConverter(Interface): |
---|
| 1029 | """Object converters are available as simple adapters, adapting |
---|
| 1030 | interfaces (not regular instances). |
---|
| 1031 | |
---|
| 1032 | """ |
---|
| 1033 | |
---|
[6277] | 1034 | def fromStringDict(self, data_dict, context, form_fields=None): |
---|
| 1035 | """Convert values in `data_dict`. |
---|
[6273] | 1036 | |
---|
[6277] | 1037 | Converts data in `data_dict` into real values based on |
---|
| 1038 | `context` and `form_fields`. |
---|
[6273] | 1039 | |
---|
[6277] | 1040 | `data_dict` is a mapping (dict) from field names to values |
---|
| 1041 | represented as strings. |
---|
[6273] | 1042 | |
---|
[6277] | 1043 | The fields (keys) to convert can be given in optional |
---|
| 1044 | `form_fields`. If given, form_fields should be an instance of |
---|
| 1045 | :class:`zope.formlib.form.Fields`. Suitable instances are for |
---|
| 1046 | example created by :class:`grok.AutoFields`. |
---|
[6273] | 1047 | |
---|
[6277] | 1048 | If no `form_fields` are given, a default is computed from the |
---|
| 1049 | associated interface. |
---|
[6273] | 1050 | |
---|
[6277] | 1051 | The `context` can be an existing object (implementing the |
---|
| 1052 | associated interface) or a factory name. If it is a string, we |
---|
| 1053 | try to create an object using |
---|
| 1054 | :func:`zope.component.createObject`. |
---|
| 1055 | |
---|
| 1056 | Returns a tuple ``(<FIELD_ERRORS>, <INVARIANT_ERRORS>, |
---|
| 1057 | <DATA_DICT>)`` where |
---|
| 1058 | |
---|
| 1059 | ``<FIELD_ERRORS>`` |
---|
| 1060 | is a list of tuples ``(<FIELD_NAME>, <ERROR>)`` for each |
---|
| 1061 | error that happened when validating the input data in |
---|
| 1062 | `data_dict` |
---|
| 1063 | |
---|
| 1064 | ``<INVARIANT_ERRORS>`` |
---|
| 1065 | is a list of invariant errors concerning several fields |
---|
| 1066 | |
---|
| 1067 | ``<DATA_DICT>`` |
---|
| 1068 | is a dict with the values from input dict converted. |
---|
| 1069 | |
---|
| 1070 | If errors happen, i.e. the error lists are not empty, always |
---|
| 1071 | an empty ``<DATA_DICT>`` is returned. |
---|
| 1072 | |
---|
[12836] | 1073 | If ``<DATA_DICT>`` is non-empty, there were no errors. |
---|
[6273] | 1074 | """ |
---|
[6293] | 1075 | |
---|
[7932] | 1076 | class IFieldConverter(Interface): |
---|
[8214] | 1077 | def request_data(name, value, schema_field, prefix='', mode='create'): |
---|
[7932] | 1078 | """Create a dict with key-value mapping as created by a request. |
---|
| 1079 | |
---|
| 1080 | `name` and `value` are expected to be parsed from CSV or a |
---|
| 1081 | similar input and represent an attribute to be set to a |
---|
| 1082 | representation of value. |
---|
| 1083 | |
---|
[8214] | 1084 | `mode` gives the mode of import. |
---|
| 1085 | |
---|
[7932] | 1086 | :meth:`update_request_data` is then requested to turn this |
---|
| 1087 | name and value into vars as they would be sent by a regular |
---|
| 1088 | form submit. This means we do not create the real values to be |
---|
| 1089 | set but we only define the values that would be sent in a |
---|
| 1090 | browser request to request the creation of those values. |
---|
| 1091 | |
---|
| 1092 | The returned dict should contain names and values of a faked |
---|
| 1093 | browser request for the given `schema_field`. |
---|
| 1094 | |
---|
| 1095 | Field converters are normally registered as adapters to some |
---|
| 1096 | specific zope.schema field. |
---|
| 1097 | """ |
---|
| 1098 | |
---|
[6338] | 1099 | class IObjectHistory(Interface): |
---|
| 1100 | |
---|
| 1101 | messages = schema.List( |
---|
| 1102 | title = u'List of messages stored', |
---|
| 1103 | required = True, |
---|
| 1104 | ) |
---|
| 1105 | |
---|
| 1106 | def addMessage(message): |
---|
| 1107 | """Add a message. |
---|
| 1108 | """ |
---|
[6353] | 1109 | |
---|
[7819] | 1110 | class IKofaWorkflowInfo(IWorkflowInfo): |
---|
[6353] | 1111 | """A :class:`hurry.workflow.workflow.WorkflowInfo` with additional |
---|
| 1112 | methods for convenience. |
---|
| 1113 | """ |
---|
| 1114 | def getManualTransitions(): |
---|
| 1115 | """Get allowed manual transitions. |
---|
| 1116 | |
---|
| 1117 | Get a sorted list of tuples containing the `transition_id` and |
---|
| 1118 | `title` of each allowed transition. |
---|
| 1119 | """ |
---|
[6481] | 1120 | |
---|
| 1121 | class ISiteLoggers(Interface): |
---|
| 1122 | |
---|
[7819] | 1123 | loggers = Attribute("A list or generator of registered KofaLoggers") |
---|
[6481] | 1124 | |
---|
| 1125 | def register(name, filename=None, site=None, **options): |
---|
| 1126 | """Register a logger `name` which logs to `filename`. |
---|
| 1127 | |
---|
| 1128 | If `filename` is not given, logfile will be `name` with |
---|
| 1129 | ``.log`` as filename extension. |
---|
| 1130 | """ |
---|
| 1131 | |
---|
| 1132 | def unregister(name): |
---|
| 1133 | """Unregister a once registered logger. |
---|
| 1134 | """ |
---|
| 1135 | |
---|
| 1136 | class ILogger(Interface): |
---|
| 1137 | """A logger cares for setup, update and restarting of a Python logger. |
---|
| 1138 | """ |
---|
| 1139 | |
---|
| 1140 | logger = Attribute("""A :class:`logging.Logger` instance""") |
---|
| 1141 | |
---|
| 1142 | |
---|
| 1143 | def __init__(name, filename=None, site=None, **options): |
---|
[7819] | 1144 | """Create a Kofa logger instance. |
---|
[6481] | 1145 | """ |
---|
| 1146 | |
---|
| 1147 | def setup(): |
---|
| 1148 | """Create a Python :class:`logging.Logger` instance. |
---|
| 1149 | |
---|
| 1150 | The created logger is based on the params given by constructor. |
---|
| 1151 | """ |
---|
| 1152 | |
---|
| 1153 | def update(**options): |
---|
| 1154 | """Update the logger. |
---|
| 1155 | |
---|
| 1156 | Updates the logger respecting modified `options` and changed |
---|
| 1157 | paths. |
---|
| 1158 | """ |
---|
[6754] | 1159 | |
---|
| 1160 | class ILoggerCollector(Interface): |
---|
| 1161 | |
---|
| 1162 | def getLoggers(site): |
---|
| 1163 | """Return all loggers registered for `site`. |
---|
| 1164 | """ |
---|
| 1165 | |
---|
| 1166 | def registerLogger(site, logging_component): |
---|
| 1167 | """Register a logging component residing in `site`. |
---|
| 1168 | """ |
---|
| 1169 | |
---|
| 1170 | def unregisterLogger(site, logging_component): |
---|
| 1171 | """Unregister a logger. |
---|
| 1172 | """ |
---|
[7063] | 1173 | |
---|
| 1174 | # |
---|
| 1175 | # External File Storage and relatives |
---|
| 1176 | # |
---|
| 1177 | class IFileStoreNameChooser(INameChooser): |
---|
| 1178 | """See zope.container.interfaces.INameChooser for base methods. |
---|
| 1179 | """ |
---|
[7066] | 1180 | def checkName(name, attr=None): |
---|
[7063] | 1181 | """Check whether an object name is valid. |
---|
| 1182 | |
---|
| 1183 | Raises a user error if the name is not valid. |
---|
| 1184 | """ |
---|
| 1185 | |
---|
[7066] | 1186 | def chooseName(name, attr=None): |
---|
| 1187 | """Choose a unique valid file id for the object. |
---|
[7063] | 1188 | |
---|
[7066] | 1189 | The given name may be taken into account when choosing the |
---|
| 1190 | name (file id). |
---|
[7063] | 1191 | |
---|
[7066] | 1192 | chooseName is expected to always choose a valid file id (that |
---|
| 1193 | would pass the checkName test) and never raise an error. |
---|
| 1194 | |
---|
| 1195 | If `attr` is not ``None`` it might been taken into account as |
---|
| 1196 | well when generating the file id. Usual behaviour is to |
---|
| 1197 | interpret `attr` as a hint for what type of file for a given |
---|
| 1198 | context should be stored if there are several types |
---|
| 1199 | possible. For instance for a certain student some file could |
---|
| 1200 | be the connected passport photograph or some certificate scan |
---|
| 1201 | or whatever. Each of them has to be stored in a different |
---|
| 1202 | location so setting `attr` to a sensible value should give |
---|
| 1203 | different file ids returned. |
---|
[7063] | 1204 | """ |
---|
| 1205 | |
---|
| 1206 | class IExtFileStore(IFileRetrieval): |
---|
| 1207 | """A file storage that stores files in filesystem (not as blobs). |
---|
| 1208 | """ |
---|
| 1209 | root = schema.TextLine( |
---|
| 1210 | title = u'Root path of file store.', |
---|
| 1211 | ) |
---|
| 1212 | |
---|
| 1213 | def getFile(file_id): |
---|
| 1214 | """Get raw file data stored under file with `file_id`. |
---|
| 1215 | |
---|
| 1216 | Returns a file descriptor open for reading or ``None`` if the |
---|
| 1217 | file cannot be found. |
---|
| 1218 | """ |
---|
| 1219 | |
---|
[7071] | 1220 | def getFileByContext(context, attr=None): |
---|
[7063] | 1221 | """Get raw file data stored for the given context. |
---|
| 1222 | |
---|
| 1223 | Returns a file descriptor open for reading or ``None`` if no |
---|
| 1224 | such file can be found. |
---|
| 1225 | |
---|
[7071] | 1226 | Both, `context` and `attr` might be used to find (`context`) |
---|
| 1227 | and feed (`attr`) an appropriate file name chooser. |
---|
| 1228 | |
---|
[7063] | 1229 | This is a convenience method. |
---|
| 1230 | """ |
---|
| 1231 | |
---|
[7090] | 1232 | def deleteFile(file_id): |
---|
| 1233 | """Delete file stored under `file_id`. |
---|
| 1234 | |
---|
| 1235 | Remove file from filestore so, that it is not available |
---|
| 1236 | anymore on next call to getFile for the same file_id. |
---|
| 1237 | |
---|
| 1238 | Should not complain if no such file exists. |
---|
| 1239 | """ |
---|
| 1240 | |
---|
| 1241 | def deleteFileByContext(context, attr=None): |
---|
| 1242 | """Delete file for given `context` and `attr`. |
---|
| 1243 | |
---|
| 1244 | Both, `context` and `attr` might be used to find (`context`) |
---|
| 1245 | and feed (`attr`) an appropriate file name chooser. |
---|
| 1246 | |
---|
| 1247 | This is a convenience method. |
---|
| 1248 | """ |
---|
| 1249 | |
---|
[7063] | 1250 | def createFile(filename, f): |
---|
| 1251 | """Create file given by f with filename `filename` |
---|
| 1252 | |
---|
| 1253 | Returns a hurry.file.File-based object. |
---|
| 1254 | """ |
---|
| 1255 | |
---|
| 1256 | class IFileStoreHandler(Interface): |
---|
| 1257 | """Filestore handlers handle specific files for file stores. |
---|
| 1258 | |
---|
| 1259 | If a file to store/get provides a specific filename, a file store |
---|
| 1260 | looks up special handlers for that type of file. |
---|
| 1261 | |
---|
| 1262 | """ |
---|
| 1263 | def pathFromFileID(store, root, filename): |
---|
| 1264 | """Turn file id into path to store. |
---|
| 1265 | |
---|
| 1266 | Returned path should be absolute. |
---|
| 1267 | """ |
---|
| 1268 | |
---|
| 1269 | def createFile(store, root, filename, file_id, file): |
---|
| 1270 | """Return some hurry.file based on `store` and `file_id`. |
---|
| 1271 | |
---|
| 1272 | Some kind of callback method called by file stores to create |
---|
| 1273 | file objects from file_id. |
---|
| 1274 | |
---|
| 1275 | Returns a tuple ``(raw_file, path, file_like_obj)`` where the |
---|
[7819] | 1276 | ``file_like_obj`` should be a HurryFile, a KofaImageFile or |
---|
[7063] | 1277 | similar. ``raw_file`` is the (maybe changed) input file and |
---|
| 1278 | ``path`` the relative internal path to store the file at. |
---|
| 1279 | |
---|
| 1280 | Please make sure the ``raw_file`` is opened for reading and |
---|
| 1281 | the file descriptor set at position 0 when returned. |
---|
| 1282 | |
---|
| 1283 | This method also gets the raw input file object that is about |
---|
| 1284 | to be stored and is expected to raise any exceptions if some |
---|
| 1285 | kind of validation or similar fails. |
---|
| 1286 | """ |
---|
[7389] | 1287 | |
---|
| 1288 | class IPDF(Interface): |
---|
| 1289 | """A PDF representation of some context. |
---|
| 1290 | """ |
---|
| 1291 | |
---|
[8257] | 1292 | def __call__(view=None, note=None): |
---|
[7389] | 1293 | """Create a bytestream representing a PDF from context. |
---|
| 1294 | |
---|
| 1295 | If `view` is passed in additional infos might be rendered into |
---|
| 1296 | the document. |
---|
[8257] | 1297 | |
---|
| 1298 | `note` is optional HTML rendered at bottom of the created |
---|
| 1299 | PDF. Please consider the limited reportlab support for HTML, |
---|
| 1300 | but using font-tags and friends you certainly can get the |
---|
| 1301 | desired look. |
---|
[7389] | 1302 | """ |
---|
[7473] | 1303 | |
---|
| 1304 | class IMailService(Interface): |
---|
| 1305 | """A mail service. |
---|
| 1306 | """ |
---|
| 1307 | |
---|
| 1308 | def __call__(): |
---|
| 1309 | """Get the default mail delivery. |
---|
| 1310 | """ |
---|
[7576] | 1311 | |
---|
[9217] | 1312 | |
---|
[7576] | 1313 | class IDataCenterConfig(Interface): |
---|
| 1314 | path = Path( |
---|
| 1315 | title = u'Path', |
---|
[7828] | 1316 | description = u"Directory where the datacenter should store " |
---|
| 1317 | u"files by default (adjustable in web UI).", |
---|
[7576] | 1318 | required = True, |
---|
| 1319 | ) |
---|
[8346] | 1320 | |
---|
[9217] | 1321 | # |
---|
| 1322 | # Asynchronous job handling and related |
---|
| 1323 | # |
---|
| 1324 | class IJobManager(IKofaObject): |
---|
| 1325 | """A manager for asynchronous running jobs (tasks). |
---|
| 1326 | """ |
---|
| 1327 | def put(job, site=None): |
---|
| 1328 | """Put a job into task queue. |
---|
[8346] | 1329 | |
---|
[9217] | 1330 | If no `site` is given, queue job in context of current local |
---|
| 1331 | site. |
---|
| 1332 | |
---|
| 1333 | Returns a job_id to identify the put job. This job_id is |
---|
| 1334 | needed for further references to the job. |
---|
| 1335 | """ |
---|
| 1336 | |
---|
| 1337 | def jobs(site=None): |
---|
| 1338 | """Get an iterable of jobs stored. |
---|
| 1339 | """ |
---|
| 1340 | |
---|
| 1341 | def get(job_id, site=None): |
---|
| 1342 | """Get the job with id `job_id`. |
---|
| 1343 | |
---|
| 1344 | For the `site` parameter see :meth:`put`. |
---|
| 1345 | """ |
---|
| 1346 | |
---|
| 1347 | def remove(job_id, site=None): |
---|
| 1348 | """Remove job with `job_id` from stored jobs. |
---|
| 1349 | """ |
---|
| 1350 | |
---|
| 1351 | def start_test_job(site=None): |
---|
| 1352 | """Start a test job. |
---|
| 1353 | """ |
---|
| 1354 | |
---|
| 1355 | class IProgressable(Interface): |
---|
| 1356 | """A component that can indicate its progress status. |
---|
[8346] | 1357 | """ |
---|
[9217] | 1358 | percent = schema.Float( |
---|
| 1359 | title = u'Percent of job done already.', |
---|
[8346] | 1360 | ) |
---|
| 1361 | |
---|
[9217] | 1362 | class IJobContainer(IContainer): |
---|
| 1363 | """A job container contains IJob objects. |
---|
| 1364 | """ |
---|
| 1365 | |
---|
| 1366 | class IExportJob(zc.async.interfaces.IJob): |
---|
| 1367 | def __init__(site, exporter_name): |
---|
| 1368 | pass |
---|
| 1369 | |
---|
[9816] | 1370 | finished = schema.Bool( |
---|
| 1371 | title = u'`True` if the job finished.`', |
---|
| 1372 | default = False, |
---|
| 1373 | ) |
---|
| 1374 | |
---|
| 1375 | failed = schema.Bool( |
---|
| 1376 | title = u"`True` iff the job finished and didn't provide a file.", |
---|
| 1377 | default = None, |
---|
| 1378 | ) |
---|
| 1379 | |
---|
[9764] | 1380 | class IExportJobContainer(IKofaObject): |
---|
[9217] | 1381 | """A component that contains (maybe virtually) export jobs. |
---|
| 1382 | """ |
---|
[9718] | 1383 | def start_export_job(exporter_name, user_id, *args, **kwargs): |
---|
[9217] | 1384 | """Start asynchronous export job. |
---|
| 1385 | |
---|
| 1386 | `exporter_name` is the name of an exporter utility to be used. |
---|
| 1387 | |
---|
| 1388 | `user_id` is the ID of the user that triggers the export. |
---|
| 1389 | |
---|
[9718] | 1390 | `args` positional arguments passed to the export job created. |
---|
| 1391 | |
---|
| 1392 | `kwargs` keyword arguments passed to the export job. |
---|
| 1393 | |
---|
[9217] | 1394 | The job_id is stored along with exporter name and user id in a |
---|
| 1395 | persistent list. |
---|
| 1396 | |
---|
| 1397 | Returns the job ID of the job started. |
---|
| 1398 | """ |
---|
| 1399 | |
---|
| 1400 | def get_running_export_jobs(user_id=None): |
---|
| 1401 | """Get export jobs for user with `user_id` as list of tuples. |
---|
| 1402 | |
---|
| 1403 | Each tuples holds ``<job_id>, <exporter_name>, <user_id>`` in |
---|
| 1404 | that order. The ``<exporter_name>`` is the utility name of the |
---|
| 1405 | used exporter. |
---|
| 1406 | |
---|
| 1407 | If `user_id` is ``None``, all running jobs are returned. |
---|
| 1408 | """ |
---|
| 1409 | |
---|
| 1410 | def get_export_jobs_status(user_id=None): |
---|
| 1411 | """Get running/completed export jobs for `user_id` as list of tuples. |
---|
| 1412 | |
---|
| 1413 | Each tuple holds ``<raw status>, <status translated>, |
---|
| 1414 | <exporter title>`` in that order, where ``<status |
---|
| 1415 | translated>`` and ``<exporter title>`` are translated strings |
---|
| 1416 | representing the status of the job and the human readable |
---|
| 1417 | title of the exporter used. |
---|
| 1418 | """ |
---|
| 1419 | |
---|
| 1420 | def delete_export_entry(entry): |
---|
| 1421 | """Delete the export denoted by `entry`. |
---|
| 1422 | |
---|
| 1423 | Removes `entry` from the local `running_exports` list and also |
---|
| 1424 | removes the regarding job via the local job manager. |
---|
| 1425 | |
---|
| 1426 | `entry` is a tuple ``(<job id>, <exporter name>, <user id>)`` |
---|
| 1427 | as created by :meth:`start_export_job` or returned by |
---|
| 1428 | :meth:`get_running_export_jobs`. |
---|
| 1429 | """ |
---|
| 1430 | |
---|
| 1431 | def entry_from_job_id(job_id): |
---|
| 1432 | """Get entry tuple for `job_id`. |
---|
| 1433 | |
---|
| 1434 | Returns ``None`` if no such entry can be found. |
---|
| 1435 | """ |
---|
[9726] | 1436 | |
---|
| 1437 | class IExportContainerFinder(Interface): |
---|
| 1438 | """A finder for the central export container. |
---|
| 1439 | """ |
---|
| 1440 | def __call__(): |
---|
| 1441 | """Return the currently used global or site-wide IExportContainer. |
---|
| 1442 | """ |
---|
[9766] | 1443 | |
---|
| 1444 | class IFilteredQuery(IKofaObject): |
---|
| 1445 | """A query for objects. |
---|
| 1446 | """ |
---|
| 1447 | |
---|
| 1448 | defaults = schema.Dict( |
---|
| 1449 | title = u'Default Parameters', |
---|
| 1450 | required = True, |
---|
| 1451 | ) |
---|
| 1452 | |
---|
| 1453 | def __init__(**parameters): |
---|
| 1454 | """Instantiate a filtered query by passing in parameters. |
---|
| 1455 | """ |
---|
| 1456 | |
---|
| 1457 | def query(): |
---|
| 1458 | """Get an iterable of objects denoted by the set parameters. |
---|
| 1459 | |
---|
| 1460 | The search should be applied to objects inside current |
---|
| 1461 | site. It's the caller's duty to set the correct site before. |
---|
| 1462 | |
---|
| 1463 | Result can be any iterable like a catalog result set, a list, |
---|
| 1464 | or similar. |
---|
| 1465 | """ |
---|
| 1466 | |
---|
| 1467 | class IFilteredCatalogQuery(IFilteredQuery): |
---|
| 1468 | """A catalog-based query for objects. |
---|
| 1469 | """ |
---|
| 1470 | |
---|
| 1471 | cat_name = schema.TextLine( |
---|
| 1472 | title = u'Registered name of the catalog to search.', |
---|
| 1473 | required = True, |
---|
| 1474 | ) |
---|
| 1475 | |
---|
| 1476 | def query_catalog(catalog): |
---|
| 1477 | """Query catalog with the parameters passed to constructor. |
---|
| 1478 | """ |
---|