| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## |
|---|
| 4 | ## This file is part of CDS Indico. |
|---|
| 5 | ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. |
|---|
| 6 | ## |
|---|
| 7 | ## CDS Indico is free software; you can redistribute it and/or |
|---|
| 8 | ## modify it under the terms of the GNU General Public License as |
|---|
| 9 | ## published by the Free Software Foundation; either version 2 of the |
|---|
| 10 | ## License, or (at your option) any later version. |
|---|
| 11 | ## |
|---|
| 12 | ## CDS Indico is distributed in the hope that it will be useful, but |
|---|
| 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | ## General Public License for more details. |
|---|
| 16 | ## |
|---|
| 17 | ## You should have received a copy of the GNU General Public License |
|---|
| 18 | ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | |
|---|
| 21 | """ |
|---|
| 22 | Module containing the MaKaC exception class hierarchy |
|---|
| 23 | """ |
|---|
| 24 | |
|---|
| 25 | class MaKaCError(Exception): |
|---|
| 26 | |
|---|
| 27 | def __init__( self, msg="",area="", explanation = None): |
|---|
| 28 | self._msg = msg |
|---|
| 29 | self._area = area |
|---|
| 30 | self._explanation = explanation |
|---|
| 31 | |
|---|
| 32 | def getMsg( self ): |
|---|
| 33 | return self._msg |
|---|
| 34 | |
|---|
| 35 | def __str__(self): |
|---|
| 36 | if self._area != "": |
|---|
| 37 | return "%s - %s"%(self._area,self._msg) |
|---|
| 38 | else: |
|---|
| 39 | return self._msg |
|---|
| 40 | |
|---|
| 41 | def getArea(self): |
|---|
| 42 | return self._area |
|---|
| 43 | |
|---|
| 44 | def getExplanation(self): |
|---|
| 45 | """ |
|---|
| 46 | Some extra information, like actions that can be taken |
|---|
| 47 | """ |
|---|
| 48 | |
|---|
| 49 | return self._explanation |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | class AccessControlError(MaKaCError): |
|---|
| 53 | """ |
|---|
| 54 | """ |
|---|
| 55 | def __init__(self, objectType="object"): |
|---|
| 56 | self.objType = objectType |
|---|
| 57 | |
|---|
| 58 | def __str__( self ): |
|---|
| 59 | return _("you are not authorised to access this %s")%self.objType |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | class ConferenceClosedError(MaKaCError): |
|---|
| 63 | """ |
|---|
| 64 | """ |
|---|
| 65 | def __init__(self, conf): |
|---|
| 66 | self._conf = conf |
|---|
| 67 | |
|---|
| 68 | def __str__( self ): |
|---|
| 69 | return _("the event has been closed") |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | class DomainNotAllowedError(AccessControlError): |
|---|
| 73 | |
|---|
| 74 | def __str__( self ): |
|---|
| 75 | return _("your domain is not allowed to acces this %s")%self.objType |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | class AccessError(AccessControlError): |
|---|
| 79 | """ |
|---|
| 80 | """ |
|---|
| 81 | pass |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | class KeyAccessError(AccessControlError): |
|---|
| 85 | """ |
|---|
| 86 | """ |
|---|
| 87 | pass |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | class HostnameResolveError(MaKaCError): |
|---|
| 91 | """ |
|---|
| 92 | Hostname resolution failed |
|---|
| 93 | """ |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | class ModificationError(AccessControlError): |
|---|
| 97 | """ |
|---|
| 98 | """ |
|---|
| 99 | def __str__( self ): |
|---|
| 100 | return _("you are not authorised to modify this %s")%self.objType |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | class AdminError(AccessControlError): |
|---|
| 104 | """ |
|---|
| 105 | """ |
|---|
| 106 | def __str__(self): |
|---|
| 107 | return _("only administrators can access this %s")%self.objType |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | class WebcastAdminError(AccessControlError): |
|---|
| 111 | """ |
|---|
| 112 | """ |
|---|
| 113 | def __str__(self): |
|---|
| 114 | return _("only webcast administrators can access this %s")%self.objType |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | class TimingError(MaKaCError): |
|---|
| 118 | """ |
|---|
| 119 | Timetable problems |
|---|
| 120 | """ |
|---|
| 121 | |
|---|
| 122 | def __init__(self, msg = "", area = "", explanation = None): |
|---|
| 123 | MaKaCError.__init__(self, msg, area, explanation) |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | class ParentTimingError(TimingError): |
|---|
| 127 | """ |
|---|
| 128 | """ |
|---|
| 129 | pass |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | class EntryTimingError(TimingError): |
|---|
| 133 | """ |
|---|
| 134 | """ |
|---|
| 135 | pass |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | class UserError(MaKaCError): |
|---|
| 139 | """ |
|---|
| 140 | """ |
|---|
| 141 | def init(self, msg = ""): |
|---|
| 142 | self._msg = msg |
|---|
| 143 | |
|---|
| 144 | def __str__(self): |
|---|
| 145 | if self._msg: |
|---|
| 146 | return self._msg |
|---|
| 147 | else: |
|---|
| 148 | return _("Error creating user") |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | class FormValuesError(MaKaCError): |
|---|
| 152 | """ |
|---|
| 153 | """ |
|---|
| 154 | def __init__( self, msg="",area=""): |
|---|
| 155 | self._msg = msg |
|---|
| 156 | self._area = area |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | class NoReportError(MaKaCError): |
|---|
| 160 | """ |
|---|
| 161 | """ |
|---|
| 162 | def __init__( self, msg="", area=""): |
|---|
| 163 | self._msg = msg |
|---|
| 164 | self._area = area |
|---|
| 165 | |
|---|
| 166 | class NotFoundError(MaKaCError): |
|---|
| 167 | """ |
|---|
| 168 | """ |
|---|
| 169 | def __init__( self, msg="", area=""): |
|---|
| 170 | self._msg = msg |
|---|
| 171 | self._area = area |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | class PluginError(MaKaCError): |
|---|
| 175 | pass |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | class HtmlScriptError(MaKaCError): |
|---|
| 179 | """ |
|---|
| 180 | """ |
|---|
| 181 | pass |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | class HtmlForbiddenTag(MaKaCError): |
|---|
| 185 | """ |
|---|
| 186 | """ |
|---|
| 187 | pass |
|---|