| @@ 132-170 (lines=39) @@ | ||
| 129 | }) |
|
| 130 | ||
| 131 | ||
| 132 | @zope.interface.implementer(INISerializable) |
|
| 133 | @zope.interface.implementer(DefaultProvider) |
|
| 134 | class Statistics(Model): |
|
| 135 | enabled = BooleanType( |
|
| 136 | default=True, |
|
| 137 | required=True, |
|
| 138 | ) |
|
| 139 | users = ModelType( |
|
| 140 | model_spec=Users, |
|
| 141 | required=True, |
|
| 142 | ) |
|
| 143 | belligerents = ModelType( |
|
| 144 | model_spec=Belligerents, |
|
| 145 | required=True, |
|
| 146 | ) |
|
| 147 | ||
| 148 | @classmethod |
|
| 149 | def from_ini(cls, ini): |
|
| 150 | return cls({ |
|
| 151 | 'enabled': not field_from_ini( |
|
| 152 | cls.enabled, ini, |
|
| 153 | 'NET', 'disableNetStatStatistics', |
|
| 154 | False, |
|
| 155 | ), |
|
| 156 | 'users': Users.from_ini(ini), |
|
| 157 | 'belligerents': Belligerents.from_ini(ini), |
|
| 158 | }) |
|
| 159 | ||
| 160 | def to_ini(self, ini): |
|
| 161 | field_to_ini(not self.enabled, ini, 'NET', 'disableNetStatStatistics') |
|
| 162 | self.users.to_ini(ini) |
|
| 163 | self.belligerents.to_ini(ini) |
|
| 164 | ||
| 165 | @classmethod |
|
| 166 | def default(cls): |
|
| 167 | return cls({ |
|
| 168 | 'enabled': cls.enabled.default, |
|
| 169 | 'users': Users.default(), |
|
| 170 | 'belligerents': Belligerents.default(), |
|
| 171 | }) |
|
| 172 | ||
| @@ 60-92 (lines=33) @@ | ||
| 57 | }) |
|
| 58 | ||
| 59 | ||
| 60 | @zope.interface.implementer(INISerializable) |
|
| 61 | @zope.interface.implementer(DefaultProvider) |
|
| 62 | class Events(Model): |
|
| 63 | chat_level = IntType( |
|
| 64 | min_value=0, |
|
| 65 | max_value=3, |
|
| 66 | default=3, |
|
| 67 | required=True, |
|
| 68 | ) |
|
| 69 | logging = ModelType( |
|
| 70 | model_spec=Logging, |
|
| 71 | required=True, |
|
| 72 | ) |
|
| 73 | ||
| 74 | @classmethod |
|
| 75 | def from_ini(cls, ini): |
|
| 76 | return cls({ |
|
| 77 | 'chat_level': field_from_ini( |
|
| 78 | cls.chat_level, ini, |
|
| 79 | 'chat', 'autoLogDetail', |
|
| 80 | ), |
|
| 81 | 'logging': Logging.from_ini(ini), |
|
| 82 | }) |
|
| 83 | ||
| 84 | def to_ini(self, ini): |
|
| 85 | field_to_ini(self.chat_level, ini, 'chat', 'autoLogDetail') |
|
| 86 | self.logging.to_ini(ini) |
|
| 87 | ||
| 88 | @classmethod |
|
| 89 | def default(cls): |
|
| 90 | return cls({ |
|
| 91 | 'chat_level': cls.chat_level.default, |
|
| 92 | 'logging': Logging.default(), |
|
| 93 | }) |
|
| 94 | ||