class Status(Persistent, Fossilizable): """ This class represents a status for the paper reviewing. """ fossilizes(IReviewingStatusFossil) def __init__(self, newId, name, editable): """ Constructor. name: is a string which represents the name of the status editable: is a boolean which represent if the status is going to be shown in the list for editing and removing options (default statuses) """ self._id = newId self._name = name self._editable = editable def getId(self): return self._id def getName(self): return self._name def setName(self, name): self._name = name def getEditable(self): return self._editable def setEditable(self, value): self._editable = value
class CausedError(Exception, Fossilizable): """ A normal error, triggered on the server side """ fossilizes(ICausedErrorFossil) def __init__(self, code, message, inner=None, type=None): self.code = code self.message = message self.inner = inner self.type = type def getMessage(self): return self.message def getCode(self): return self.code def getInner(self): return self.inner def getType(self): return self.type def __str__(self): if not self.inner: return "%s : %s (no inner exception)" % (self.code, self.message) else: if type(self.inner) is list: inner = "\r\n".join(self.inner) else: inner = self.inner return "%s : %s\r\n\r\nInner Exception:\r\n%s" % (self.code, self.message, inner)
class EVOError(CSErrorBase): #already Fossilizable fossilizes(IEVOErrorFossil) def __init__(self, errorType, requestURL = None, userMessage = None): CSErrorBase.__init__(self) self._errorType = errorType self._requestURL = requestURL self._userMessage = None def getErrorType(self): return self._errorType def getRequestURL(self): return self._requestURL def getUserMessage(self): if self._userMessage: return self._userMessage else: if self._errorType == 'duplicated': return "This EVO meeting could not be created or changed because EVO considers the resulting meeting as duplicated." elif self._errorType == 'start_in_past': return "This EVO meeting could not be created or changed because EVO does not allow meetings starting in the past." else: return self._errorType def getLogMessage(self): return "EVO Error: " + str(self._errorType) + " for request " + str(self._requestURL)
class MaKaCError(Exception, Fossilizable): fossilizes(IErrorReportFossil) def __init__(self, msg="", area="", explanation=None): self._msg = msg self._area = area self._explanation = explanation def getMessage(self): return self._msg @ensure_str def __str__(self): if self._area != "": return "%s - %s" % (self._area, self._msg) else: return self._msg def getArea(self): return self._area def getExplanation(self): """ Some extra information, like actions that can be taken """ return self._explanation
class HTTPAPIResult(Fossilizable): fossilizes(IHTTPAPIResultFossil) def __init__(self, results, path='', query='', ts=None, complete=True, extra=None): if ts is None: ts = int(time.time()) self._results = results self._path = path self._query = query self._ts = ts self._complete = complete self._extra = extra or {} def getTS(self): return self._ts def getURL(self): prefix = Config.getInstance().getBaseSecureURL() if self._query: return prefix + self._path + '?' + self._query return prefix + self._path def getCount(self): return len(self._results) def getResults(self): return self._results def getComplete(self): return self._complete def getAdditionalInfo(self): return self._extra
class ComplexClass(Fossilizable): def __init__(self): self.simpleInstance = SimpleClass(1, 'foo', 'bar') fossilizes(IComplexFossil1Fossil, IComplexFossil2Fossil) def getSimpleInstance(self): return self.simpleInstance
class AnotherChildrenClass(Fossilizable): fossilizes(IWithConversion2Fossil) def __init__(self, a): self.a = a def getA(self): return self.a
class ParticipantPerson(Participant, Fossilizable): fossilizes(IParticipantPersonFossil) def __init__(self, booking, participantIndicoId, data): self._title = data.get("title", '') self._familyName = data.get("familyName", '') self._firstName = data.get("firstName", '') self._affiliation = data.get("affiliation", '') Participant.__init__(self, 'person', booking, participantIndicoId, data.get("ip", ''), participantName=None, participantType="by_address", participantProtocol=data.get( "participantProtocol", "h323"), createdByIndico=True) def updateData(self, newData): self._title = newData.get("title", '') self._familyName = newData.get("familyName", '') self._firstName = newData.get("firstName", '') self._affiliation = newData.get("affiliation", '') self._participantProtocol = newData.get("participantProtocol", '') self.setIp(newData.get("ip", '')) def getTitle(self): return self._title def getFamilyName(self): return self._familyName def getFirstName(self): return self._firstName def getAffiliation(self): return self._affiliation def getDisplayName(self, truncate=True): result = [] if self._title: result.append(self._title) result.append(' ') result.append(self._familyName.upper()) result.append(', ') result.append(self._firstName) if self._affiliation: result.append(' (') result.append(self._affiliation) result.append(')') result = "".join(result) if truncate: return result[:31] #31 is the max length accepted by the MCU else: return result
class ChangesFromWebExError(WebExError): fossilizes(IChangesFromWebExErrorFossil) def __init__(self, changes): WebExError.__init__(self, 'changesFromWebEx') self._changes = changes def getChanges(self): return self._changes
class ChangesFromEVOError(EVOError): #already Fossilizable fossilizes(IChangesFromEVOErrorFossil) def __init__(self, changes): EVOError.__init__(self, 'changesFromEVO') self._changes = changes def getChanges(self): return self._changes
class OverlappedError(EVOError): #already Fossilizable fossilizes(IOverlappedErrorFossil) def __init__(self, overlappedBooking): EVOError.__init__(self, 'overlapped') self._overlappedBooking = overlappedBooking def getSuperposedBooking(self): return self._overlappedBooking
class Author(Fossilizable): fossilizes(IAuthorFossil) def __init__(self, id, **data): self._id = id self.setValues(**data) def setValues(self, **data): self._title = data.get("title", "") self._firstName = data.get("first_name", "") self._familyName = data.get("family_name", "") self._affiliation = data.get("affiliation", "") self._email = data.get("email", "") self._phone = data.get("phone", "") self._speaker = data.get("isSpeaker", False) def mapAuthor(self, author): self._title = author.getTitle() self._firstName = author.getFirstName() self._familyName = author.getSurName() self._affiliation = author.getAffiliation() self._email = author.getEmail() self._phone = author.getTelephone() self._speaker = author.getAbstract().isSpeaker(author) def getTitle(self): return self._title def getId(self): return self._id def setId(self, id): self._id = id def getFirstName(self): return self._firstName def getFamilyName(self): return self._familyName def getAffiliation(self): return self._affiliation def getEmail(self): return self._email def getPhone(self): return self._phone def isSpeaker(self): return self._speaker def __str__(self): return "id:%s - nombre:%s" % (self._id, self._familyName)
class NotFoundError(MaKaCError): """ MaKaC's own NotFound version (just for legacy support) """ fossilizes(IErrorNoReportFossil) def __init__(self, message, title=""): if not title: title = message message = '' super(NotFoundError, self).__init__(title, explanation=message)
class WebExWarning(Fossilizable): fossilizes(IWebExWarningFossil) def __init__(self, msg=None, exception=None): self._msg = msg self._exception = exception def getMessage(self): return self._msg def getException(self): return self._exception
class AnotherClass(Fossilizable): fossilizes(IWithConversionFossil) def __init__(self, a, listArg): self.a = a self.list = listArg def getA(self): return self.a def getList(self): return self.list
class HTTPAPIError(Exception, Fossilizable): fossilizes(IHTTPAPIErrorFossil) def __init__(self, message, code=None): self.message = message self.code = code def getMessage(self): return self.message def getCode(self): return self.code
class ConferenceClosedError(MaKaCError): """ """ fossilizes(IErrorNoReportFossil) def __init__(self, conf): MaKaCError.__init__(self) self._conf = conf @ensure_str def __str__(self): return _("the event has been closed")
class Participant(Persistent, Fossilizable): fossilizes(IParticipantFossil) def __init__(self, booking, participantIndicoId, data): self._id = participantIndicoId self._title = data.get("title", '') self._familyName = data.get("familyName", '') self._firstName = data.get("firstName", '') self._affiliation = data.get("affiliation", '') self._email = data.get("email", '') def updateData(self, newData): self._title = newData.get("title", '') self._familyName = newData.get("familyName", '') self._firstName = newData.get("firstName", '') self._affiliation = newData.get("affiliation", '') self._email = newData.get("email", '') def getId(self): return self._id def getParticipantName(self): return "%s, %s" % (self.getFamilyName(), self.getFirstName()) def getTitle(self): return self._title def getFamilyName(self): return self._familyName def getFirstName(self): return self._firstName def getAffiliation(self): return self._affiliation def getEmail(self): return self._email def getDisplayName(self): result = [] if self._title: result.append(self._title) result.append(' ') result.append(safe_upper(self._familyName)) result.append(', ') result.append(self._firstName) if self._affiliation: result.append(' (') result.append(self._affiliation) result.append(')') return ("".join(result))
class XMPPChatroom(Chatroom): fossilizes(fossils.IXMPPChatRoomFossil) def __init__(self, name, owner, conference, modificationDate=None, description='', createdInLocalServer=True, host='', password='', showRoom=False, showPass=False): Chatroom.__init__(self, name, owner, conference, modificationDate, createdInLocalServer, showRoom) self._description = description self._host = host self._password = password self._showPass = showPass def setValues(self, values): Chatroom.setValues(self, values) self._description = values['description'] self._host = values['host'] self._password = values['password'] self._showPass = values['showPass'] def setHost(self, host): self._host = host def getHost(self): return self._host def setDescription(self, description): self._description = description def getDescription(self): return self._description def setPassword(self, password): self._password = password def getPassword(self): return self._password def setShowPass(self, showPass): self._showPass = showPass def getShowPass(self): return self._showPass
class Warning(Fossilizable): fossilizes(IWarningFossil) def __init__(self, title, content): self._title = title self._content = content def getTitle(self): return self._title def getProblems(self): return self._content
class FakeAvatarOwner(Persistent, Fossilizable): """ Used when a Vidyo admin changes the owner of a room to an account that cannot be translated to an Avatar """ fossilizes(IFakeAvatarOwnerFossil) def __init__(self, accountName): self._accountName = accountName @classmethod def getId(cls): return None def getName(self): return self._accountName
class NewsItem(Persistent, Fossilizable): fossilizes(INewsItemFossil) def __init__(self, title="", content="", type=""): self._id = None self._creationDate = nowutc() self._content = content self._title = title self._type = type self._new = True def getId(self): return self._id def setId(self, id): self._id = id def getCreationDate(self): if not isTimezoneAware(self._creationDate): self._creationDate = setAdjustedDate(self._creationDate, tz='UTC') return self._creationDate def getAdjustedCreationDate(self, tz='UTC'): return getAdjustedDate(self.getCreationDate(), tz=tz) def getContent(self): return self._content def setContent(self, content): self._content = content def getTitle(self): return self._title def setTitle(self, title): self._title = title def getType(self): return self._type def setType(self, type): self._type = type def getHumanReadableType(self): return NewsModule.getNewsTypesAsDict()[self._type] def isNew(self): newsModule = ModuleHolder().getById("news") return self.getCreationDate() + \ timedelta(days=newsModule.getRecentDays()) > nowutc()
class ParticipantRoom(Participant, Fossilizable): fossilizes(IParticipantRoomFossil) def __init__(self, booking, participantIndicoId, data, participantName=None, participantType="by_address", createdByIndico=True): self._name = data.get("name", '') self._institution = data.get("institution", '') Participant.__init__(self, 'room', booking, participantIndicoId, data.get("ip", ''), participantName, participantType, data.get("participantProtocol", "h323"), createdByIndico) def updateData(self, newData): self._name = newData.get("name", '') self._institution = newData.get("institution", '') self._participantProtocol = newData.get("participantProtocol", '') self.setIp(newData.get("ip", '')) def getName(self): return self._name def setName(self, name): self._name = name def getInstitution(self): if not hasattr(self, '_institution'): self._institution = '' return self._institution def setInstitution(self, institution): self._institution = institution def getDisplayName(self, truncate=True): result = self._name if self._institution: result = result + ' (' + self._institution + ')' if truncate: return result[:31] #31 is the max length accepted by the MCU else: return result
class AccessControlError(MaKaCError): """ """ fossilizes(IErrorNoReportFossil) def __init__(self, objectType="object"): MaKaCError.__init__(self) self.objType = objectType @ensure_str def __str__(self): return _("you are not authorised to access this %s") % self.objType def getMessage(self): return str(self)
class ResultWithWarning(Fossilizable): fossilizes(IResultWithWarningFossil) def __init__(self, result, warning): self._result = result self._warning = warning def getResult(self): return self._result def getWarning(self): return self._warning def hasWarning(self): return True
class ResultWithHighlight(Fossilizable): fossilizes(IResultWithHighlightFossil) def __init__(self, result, highlight): self._result = result self._highlight = highlight def getResult(self): return self._result def getHighlight(self): return self._highlight def hasHighlight(self): return True
class RoomWithH323(Fossilizable): fossilizes(IRoomWithH323Fossil) def __init__(self, institution, name, ip): self._institution = institution self._name = name self._ip = ip def getLocation(self): return self._institution def getName(self): return self._name def getIp(self): return self._ip
class SimpleClass(Fossilizable): fossilizes(ISimpleFossil1, ISimpleFossil2) def __init__(self, a, b, c): self.a = a self.b = b self.c = c def getA(self): return self.a def getB(self): return self.b def getC(self): return self.c
class RecordingRequestError(CSErrorBase): #already Fossilizable fossilizes(IRecordingRequestErrorFossil) def __init__(self, operation, inner): self._operation = operation self._inner = inner def getOperation(self): return self._operation def getInner(self): return str(self._inner) def getUserMessage(self): return '' def getLogMessage(self): return "Recording Request error for operation: " + str(self._operation) + ", inner exception: " + str(self._inner)
class SimpleClass(Fossilizable): fossilizes(ISimpleFossil1Fossil, ISimpleFossil2Fossil, IFossilWithProduceFossil, IAttributeFossil) def __init__(self, a, b, c): self.a = a self.b = b self.c = c def getA(self): return self.a def getB(self): return self.b def getC(self): return self.c