Merge lp:~richies/hypernucleus-server/UberHax_Broken_MadScientist into lp:~hypernucleus/hypernucleus-server/trunk
- UberHax_Broken_MadScientist
- Merge into trunk
Proposed by
Richie Ward
Status: | Merged |
---|---|
Merged at revision: | 75 |
Proposed branch: | lp:~richies/hypernucleus-server/UberHax_Broken_MadScientist |
Merge into: | lp:~hypernucleus/hypernucleus-server/trunk |
Diff against target: |
1072 lines (+295/-481) 16 files modified
hypernucleusserver/hypernucleusserver/model/board.py (+1/-1) hypernucleusserver/hypernucleusserver/model/content.py (+2/-1) hypernucleusserver/hypernucleusserver/model/dependencies.py (+0/-162) hypernucleusserver/hypernucleusserver/model/gamedep.py (+173/-1) hypernucleusserver/hypernucleusserver/model/games.py (+0/-159) hypernucleusserver/hypernucleusserver/model/tags.py (+3/-17) hypernucleusserver/hypernucleusserver/model/tokens.py (+1/-1) hypernucleusserver/hypernucleusserver/models.py (+20/-52) hypernucleusserver/hypernucleusserver/security.py (+2/-1) hypernucleusserver/hypernucleusserver/viewlib/boardlib.py (+3/-2) hypernucleusserver/hypernucleusserver/viewlib/contentlib.py (+3/-2) hypernucleusserver/hypernucleusserver/viewlib/gamedeplib.py (+51/-59) hypernucleusserver/hypernucleusserver/viewlib/outputlib.py (+24/-13) hypernucleusserver/hypernucleusserver/viewlib/userlib.py (+3/-1) hypernucleusserver/hypernucleusserver/views/errwarninfo.py (+5/-2) hypernucleusserver/hypernucleusserver/views/gamedep.py (+4/-7) |
To merge this branch: | bzr merge lp:~richies/hypernucleus-server/UberHax_Broken_MadScientist |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Richie Ward | Pending | ||
Review via email: mp+65409@code.launchpad.net |
Commit message
Description of the change
Huge sweeping changes to the model
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hypernucleusserver/hypernucleusserver/model/board.py' |
2 | --- hypernucleusserver/hypernucleusserver/model/board.py 2011-06-18 20:38:51 +0000 |
3 | +++ hypernucleusserver/hypernucleusserver/model/board.py 2011-06-21 20:38:13 +0000 |
4 | @@ -2,7 +2,7 @@ |
5 | from sqlalchemy import Column, Integer, ForeignKey, Unicode, UniqueConstraint |
6 | from sqlalchemy import DateTime |
7 | from sqlalchemy.orm import relationship |
8 | -from hypernucleusserver.models import Tags, BBThreadTags |
9 | +from hypernucleusserver.model.tags import Tags, BBThreadTags |
10 | from hypernucleusserver.models import Base as DeclarativeBase |
11 | from hypernucleusserver.model.file import Files |
12 | from hypernucleusserver.model.auth import User |
13 | |
14 | === modified file 'hypernucleusserver/hypernucleusserver/model/content.py' |
15 | --- hypernucleusserver/hypernucleusserver/model/content.py 2011-06-20 14:35:59 +0000 |
16 | +++ hypernucleusserver/hypernucleusserver/model/content.py 2011-06-21 20:38:13 +0000 |
17 | @@ -1,7 +1,8 @@ |
18 | from datetime import datetime |
19 | from sqlalchemy import ForeignKey, Column, UniqueConstraint, desc |
20 | from sqlalchemy.types import Integer, Unicode, DateTime, Boolean |
21 | -from hypernucleusserver.models import Tags, ContentTags, User |
22 | +from hypernucleusserver.model.tags import Tags, ContentTags |
23 | +from hypernucleusserver.model.auth import User |
24 | from hypernucleusserver.models import Base as DeclarativeBase |
25 | from sqlalchemy.orm import relationship |
26 | |
27 | |
28 | === removed file 'hypernucleusserver/hypernucleusserver/model/dependencies.py' |
29 | --- hypernucleusserver/hypernucleusserver/model/dependencies.py 2011-06-20 14:43:33 +0000 |
30 | +++ hypernucleusserver/hypernucleusserver/model/dependencies.py 1970-01-01 00:00:00 +0000 |
31 | @@ -1,162 +0,0 @@ |
32 | -from datetime import datetime |
33 | -from sqlalchemy import Column, Integer, desc |
34 | -from sqlalchemy import ForeignKey, UniqueConstraint, Float, DateTime, Boolean |
35 | -from sqlalchemy import Unicode |
36 | -from sqlalchemy.orm import relationship |
37 | -from hypernucleusserver.models import Base as DeclarativeBase |
38 | -from hypernucleusserver.models import Tags, DependenciesTags |
39 | -from hypernucleusserver.models import OperatingSystems |
40 | -from hypernucleusserver.models import Architectures, GameDepModuleType |
41 | -from hypernucleusserver.model.file import Files |
42 | -from hypernucleusserver.model.auth import User |
43 | - |
44 | -class DependenciesPicture(DeclarativeBase): |
45 | - __tablename__ = 'dependenciespicture' |
46 | - __table_args__ = (UniqueConstraint('game_id', 'file_id'), |
47 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
48 | - |
49 | - id = Column(Integer, primary_key=True) |
50 | - game_id = Column(Integer, ForeignKey('dependenciespage.id'), nullable=False) |
51 | - file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
52 | - |
53 | -class DependenciesBinaryFiles(DeclarativeBase): |
54 | - __tablename__ = 'dependenciesbinaryfiles' |
55 | - __table_args__ = (UniqueConstraint('binary_id', 'file_id'), |
56 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
57 | - |
58 | - id = Column(Integer, primary_key=True) |
59 | - binary_id = Column(Integer, ForeignKey('dependenciesbinary.id'), |
60 | - nullable=False) |
61 | - file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
62 | - |
63 | -class DependenciesBinaryOperatingSystem(DeclarativeBase): |
64 | - __tablename__ = 'dependenciesbinaryoperatingsystem' |
65 | - __table_args__ = (UniqueConstraint('binary_id', 'operatingsystem_id'), |
66 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
67 | - |
68 | - id = Column(Integer, primary_key=True) |
69 | - binary_id = Column(Integer, ForeignKey('dependenciesbinary.id'), |
70 | - nullable=False) |
71 | - operatingsystem_id = Column(Integer, ForeignKey('operatingsystems.id'), |
72 | - nullable=False) |
73 | - |
74 | -class DependenciesBinaryArchitecture(DeclarativeBase): |
75 | - __tablename__ = 'dependenciesbinaryarchitecture' |
76 | - __table_args__ = (UniqueConstraint('binary_id', 'architecture_id'), |
77 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
78 | - |
79 | - id = Column(Integer, primary_key=True) |
80 | - binary_id = Column(Integer, ForeignKey('dependenciesbinary.id'), |
81 | - nullable=False) |
82 | - architecture_id = Column(Integer, ForeignKey('architectures.id'), |
83 | - nullable=False) |
84 | - |
85 | -class DependenciesBinary(DeclarativeBase): |
86 | - __tablename__ = 'dependenciesbinary' |
87 | - __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
88 | - |
89 | - id = Column(Integer, primary_key=True) |
90 | - revision_id = Column(Integer, ForeignKey('dependenciesrevision.id'), |
91 | - nullable=False) |
92 | - file_obj = relationship(Files, |
93 | - secondary=DependenciesBinaryFiles.__table__, |
94 | - uselist=False, single_parent=True, |
95 | - cascade="all, delete, delete-orphan") |
96 | - operatingsystem_obj = relationship(OperatingSystems, |
97 | - secondary=DependenciesBinaryOperatingSystem.__table__, |
98 | - uselist=False) |
99 | - architecture_obj = relationship(Architectures, |
100 | - secondary=DependenciesBinaryArchitecture.__table__, |
101 | - uselist=False) |
102 | - |
103 | - def __init__(self, file_obj, operatingsystem_obj, architecture_obj): |
104 | - self.file_obj = file_obj |
105 | - self.operatingsystem_obj = operatingsystem_obj |
106 | - self.architecture_obj = architecture_obj |
107 | - |
108 | -class DependenciesDependency(DeclarativeBase): |
109 | - __tablename__ = 'dependenciesdependency' |
110 | - __table_args__ = (UniqueConstraint('game_id', 'dependency_id'), |
111 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
112 | - |
113 | - id = Column(Integer, primary_key=True) |
114 | - game_id = Column(Integer, ForeignKey('dependenciespage.id'), |
115 | - nullable=False) |
116 | - dependency_id = Column(Integer, ForeignKey('dependenciespage.id'), |
117 | - nullable=False) |
118 | - |
119 | -class DependenciesRevisionFiles(DeclarativeBase): |
120 | - __tablename__ = 'dependenciesrevisionfiles' |
121 | - __table_args__ = (UniqueConstraint('revision_id', 'file_id'), |
122 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
123 | - |
124 | - id = Column(Integer, primary_key=True) |
125 | - revision_id = Column(Integer, ForeignKey('dependenciesrevision.id'), |
126 | - nullable=False) |
127 | - file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
128 | - |
129 | -class DependenciesModuleTypeRevision(DeclarativeBase): |
130 | - __tablename__ = 'dependenciesmoduletyperevision' |
131 | - __table_args__ = (UniqueConstraint('revision_id', 'moduletype_id'), |
132 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
133 | - |
134 | - id = Column(Integer, primary_key=True) |
135 | - revision_id = Column(Integer, ForeignKey('dependenciesrevision.id'), |
136 | - nullable=False) |
137 | - moduletype_id = Column(Integer, ForeignKey('gamedepmoduletype.id'), |
138 | - nullable=False) |
139 | - |
140 | -class DependenciesRevision(DeclarativeBase): |
141 | - __tablename__ = 'dependenciesrevision' |
142 | - __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
143 | - |
144 | - id = Column(Integer, primary_key=True) |
145 | - page_id = Column(Integer, ForeignKey('dependenciespage.id'), |
146 | - nullable=False) |
147 | - version = Column(Float(), default=0.1, index=True, nullable=False) |
148 | - created = Column(DateTime, default=datetime.now) |
149 | - published = Column(Boolean, default=False, index=True) |
150 | - page = relationship("DependenciesPage") |
151 | - moduletype = relationship(GameDepModuleType, |
152 | - secondary=DependenciesModuleTypeRevision.__table__, |
153 | - uselist=False) |
154 | - file_obj = relationship(Files, |
155 | - secondary=DependenciesRevisionFiles.__table__, |
156 | - uselist=False) |
157 | - binary = relationship(DependenciesBinary, |
158 | - cascade="all, delete") |
159 | - |
160 | - def __init__(self, version, moduletype): |
161 | - self.version = version |
162 | - self.moduletype = moduletype |
163 | - |
164 | -class DependenciesPage(DeclarativeBase): |
165 | - __tablename__ = 'dependenciespage' |
166 | - __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
167 | - |
168 | - id = Column(Integer, primary_key=True) |
169 | - name = Column(Unicode(128), index=True, unique=True, nullable=False) |
170 | - display_name = Column(Unicode(128), index=True, nullable=False) |
171 | - description = Column(Unicode(16384), default=u"") |
172 | - created = Column(DateTime, default=datetime.now) |
173 | - deleted = Column(Boolean, default=False, index=True) |
174 | - revisions = relationship(DependenciesRevision, |
175 | - cascade="all, delete, delete-orphan", |
176 | - lazy="dynamic", |
177 | - order_by=desc(DependenciesRevision.id), |
178 | - single_parent=True) |
179 | - tags = relationship(Tags, secondary=DependenciesTags.__table__, |
180 | - cascade="all, delete") |
181 | - dependencies = relationship('DependenciesPage', |
182 | - secondary=DependenciesDependency.__table__, |
183 | - |
184 | - primaryjoin=id == DependenciesDependency.game_id, |
185 | - secondaryjoin=DependenciesDependency.dependency_id == id, |
186 | - cascade="all, delete") |
187 | - picture = relationship(Files, secondary=DependenciesPicture.__table__, |
188 | - cascade="all, delete") |
189 | - |
190 | - def __init__(self, name, display_name): |
191 | - self.name = name |
192 | - self.display_name = display_name |
193 | - |
194 | |
195 | === modified file 'hypernucleusserver/hypernucleusserver/model/gamedep.py' |
196 | --- hypernucleusserver/hypernucleusserver/model/gamedep.py 2010-12-16 05:24:55 +0000 |
197 | +++ hypernucleusserver/hypernucleusserver/model/gamedep.py 2011-06-21 20:38:13 +0000 |
198 | @@ -1,5 +1,18 @@ |
199 | -from sqlalchemy import Column, Integer, Unicode |
200 | +from sqlalchemy import Column, Integer, desc, Unicode |
201 | +from sqlalchemy import ForeignKey, UniqueConstraint, Float, DateTime, Boolean |
202 | +from sqlalchemy.orm import relationship |
203 | from hypernucleusserver.models import Base as DeclarativeBase |
204 | +from hypernucleusserver.model.file import Files |
205 | +from hypernucleusserver.model.tags import Tags, GameDepTags |
206 | +from datetime import datetime |
207 | +class GameDepType(DeclarativeBase): |
208 | + __tablename__ = 'gamedeptype' |
209 | + __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
210 | + id = Column(Integer, primary_key=True) |
211 | + name = Column(Unicode(128), index=True, unique=True, nullable=False) |
212 | + |
213 | + def __init__(self, name): |
214 | + self.name = name |
215 | |
216 | class GameDepModuleType(DeclarativeBase): |
217 | __tablename__ = 'gamedepmoduletype' |
218 | @@ -37,3 +50,162 @@ |
219 | def __init__(self, name, display_name): |
220 | self.name = name |
221 | self.display_name = display_name |
222 | + |
223 | + |
224 | + |
225 | +class GameDepPicture(DeclarativeBase): |
226 | + __tablename__ = 'gamedeppicture' |
227 | + __table_args__ = (UniqueConstraint('game_id', 'file_id'), |
228 | + {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
229 | + |
230 | + id = Column(Integer, primary_key=True) |
231 | + game_id = Column(Integer, ForeignKey('gamedeppage.id'), nullable=False) |
232 | + file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
233 | + |
234 | +class GameDepBinaryFiles(DeclarativeBase): |
235 | + __tablename__ = 'gamedepbinaryfiles' |
236 | + __table_args__ = (UniqueConstraint('binary_id', 'file_id'), |
237 | + {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
238 | + |
239 | + id = Column(Integer, primary_key=True) |
240 | + binary_id = Column(Integer, ForeignKey('gamedepbinary.id'), |
241 | + nullable=False) |
242 | + file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
243 | + |
244 | +class GameDepBinaryOperatingSystem(DeclarativeBase): |
245 | + __tablename__ = 'gamedepbinaryoperatingsystem' |
246 | + __table_args__ = (UniqueConstraint('binary_id', 'operatingsystem_id'), |
247 | + {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
248 | + |
249 | + id = Column(Integer, primary_key=True) |
250 | + binary_id = Column(Integer, ForeignKey('gamedepbinary.id'), |
251 | + nullable=False) |
252 | + operatingsystem_id = Column(Integer, ForeignKey('operatingsystems.id'), |
253 | + nullable=False) |
254 | + |
255 | +class GameDepBinaryArchitecture(DeclarativeBase): |
256 | + __tablename__ = 'gamedepbinaryarchitecture' |
257 | + __table_args__ = (UniqueConstraint('binary_id', 'architecture_id'), |
258 | + {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
259 | + |
260 | + id = Column(Integer, primary_key=True) |
261 | + binary_id = Column(Integer, ForeignKey('gamedepbinary.id'), |
262 | + nullable=False) |
263 | + architecture_id = Column(Integer, ForeignKey('architectures.id'), |
264 | + nullable=False) |
265 | + |
266 | +class GameDepBinary(DeclarativeBase): |
267 | + __tablename__ = 'gamedepbinary' |
268 | + __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
269 | + |
270 | + id = Column(Integer, primary_key=True) |
271 | + revision_id = Column(Integer, ForeignKey('gamedeprevision.id'), |
272 | + nullable=False) |
273 | + file_obj = relationship(Files, |
274 | + secondary=GameDepBinaryFiles.__table__, |
275 | + uselist=False, single_parent=True, |
276 | + cascade="all, delete, delete-orphan") |
277 | + operatingsystem_obj = relationship(OperatingSystems, |
278 | + secondary=GameDepBinaryOperatingSystem.__table__, |
279 | + uselist=False) |
280 | + architecture_obj = relationship(Architectures, |
281 | + secondary=GameDepBinaryArchitecture.__table__, |
282 | + uselist=False) |
283 | + |
284 | + def __init__(self, file_obj, operatingsystem_obj, architecture_obj): |
285 | + self.file_obj = file_obj |
286 | + self.operatingsystem_obj = operatingsystem_obj |
287 | + self.architecture_obj = architecture_obj |
288 | + |
289 | +class GameDepDependency(DeclarativeBase): |
290 | + __tablename__ = 'gamedepdependency' |
291 | + __table_args__ = (UniqueConstraint('game_id', 'dependency_id'), |
292 | + {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
293 | + |
294 | + id = Column(Integer, primary_key=True) |
295 | + game_id = Column(Integer, ForeignKey('gamedeppage.id'), |
296 | + nullable=False) |
297 | + dependency_id = Column(Integer, ForeignKey('gamedeppage.id'), |
298 | + nullable=False) |
299 | + |
300 | +class GameDepRevisionFiles(DeclarativeBase): |
301 | + __tablename__ = 'gamedeprevisionfiles' |
302 | + __table_args__ = (UniqueConstraint('revision_id', 'file_id'), |
303 | + {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
304 | + |
305 | + id = Column(Integer, primary_key=True) |
306 | + revision_id = Column(Integer, ForeignKey('gamedeprevision.id'), |
307 | + nullable=False) |
308 | + file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
309 | + |
310 | +class GameDepModuleTypeRevision(DeclarativeBase): |
311 | + __tablename__ = 'gamedepmoduletyperevision' |
312 | + __table_args__ = (UniqueConstraint('revision_id', 'moduletype_id'), |
313 | + {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
314 | + |
315 | + id = Column(Integer, primary_key=True) |
316 | + revision_id = Column(Integer, ForeignKey('gamedeprevision.id'), |
317 | + nullable=False) |
318 | + moduletype_id = Column(Integer, ForeignKey('gamedepmoduletype.id'), |
319 | + nullable=False) |
320 | + |
321 | + |
322 | + |
323 | + |
324 | +class GameDepRevision(DeclarativeBase): |
325 | + __tablename__ = 'gamedeprevision' |
326 | + __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
327 | + |
328 | + id = Column(Integer, primary_key=True) |
329 | + page_id = Column(Integer, ForeignKey('gamedeppage.id'), |
330 | + nullable=False) |
331 | + page = relationship("GameDepPage") |
332 | + version = Column(Float(), default=0.1, index=True, nullable=False) |
333 | + created = Column(DateTime, default=datetime.now) |
334 | + published = Column(Boolean, default=False, index=True) |
335 | + moduletype = relationship(GameDepModuleType, |
336 | + secondary=GameDepModuleTypeRevision.__table__, |
337 | + uselist=False) |
338 | + file_obj = relationship(Files, |
339 | + secondary=GameDepRevisionFiles.__table__, |
340 | + uselist=False) |
341 | + binary = relationship(GameDepBinary, |
342 | + cascade="all, delete") |
343 | + |
344 | + def __init__(self, version, moduletype): |
345 | + self.version = version |
346 | + self.moduletype = moduletype |
347 | + |
348 | +class GameDepPage(DeclarativeBase): |
349 | + __tablename__ = 'gamedeppage' |
350 | + __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
351 | + |
352 | + id = Column(Integer, primary_key=True) |
353 | + gamedeptype_id = Column(Integer, ForeignKey('gamedeptype.id'), |
354 | + nullable=False) |
355 | + gamedeptype = relationship(GameDepType, uselist=False) |
356 | + name = Column(Unicode(128), index=True, unique=True, nullable=False) |
357 | + display_name = Column(Unicode(128), index=True, nullable=False) |
358 | + description = Column(Unicode(16384), default=u"") |
359 | + created = Column(DateTime, default=datetime.now) |
360 | + deleted = Column(Boolean, default=False, index=True) |
361 | + revisions = relationship(GameDepRevision, |
362 | + cascade="all, delete, delete-orphan", |
363 | + lazy="dynamic", |
364 | + order_by=desc(GameDepRevision.id), |
365 | + single_parent=True) |
366 | + tags = relationship(Tags, secondary=GameDepTags.__table__, |
367 | + cascade="all, delete") |
368 | + dependencies = relationship('GameDepPage', |
369 | + secondary=GameDepDependency.__table__, |
370 | + |
371 | + primaryjoin=id == GameDepDependency.game_id, |
372 | + secondaryjoin=GameDepDependency.dependency_id == id, |
373 | + cascade="all, delete") |
374 | + picture = relationship(Files, secondary=GameDepPicture.__table__, |
375 | + cascade="all, delete") |
376 | + |
377 | + def __init__(self, gamedeptype, name, display_name): |
378 | + self.name = name |
379 | + self.display_name = display_name |
380 | + self.gamedeptype = gamedeptype |
381 | \ No newline at end of file |
382 | |
383 | === removed file 'hypernucleusserver/hypernucleusserver/model/games.py' |
384 | --- hypernucleusserver/hypernucleusserver/model/games.py 2011-06-20 14:43:33 +0000 |
385 | +++ hypernucleusserver/hypernucleusserver/model/games.py 1970-01-01 00:00:00 +0000 |
386 | @@ -1,159 +0,0 @@ |
387 | -from datetime import datetime |
388 | -from sqlalchemy import Column, Integer, desc |
389 | -from sqlalchemy import ForeignKey, UniqueConstraint, Float, DateTime, Boolean |
390 | -from sqlalchemy import Unicode |
391 | -from sqlalchemy.orm import relationship |
392 | -from hypernucleusserver.models import Base as DeclarativeBase |
393 | -from hypernucleusserver.models import Tags, GamesTags |
394 | -from hypernucleusserver.models import OperatingSystems |
395 | -from hypernucleusserver.models import Architectures, GameDepModuleType |
396 | -from hypernucleusserver.model.file import Files |
397 | -from hypernucleusserver.model.auth import User |
398 | - |
399 | -class GamesPicture(DeclarativeBase): |
400 | - __tablename__ = 'gamespicture' |
401 | - __table_args__ = (UniqueConstraint('game_id', 'file_id'), |
402 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
403 | - |
404 | - id = Column(Integer, primary_key=True) |
405 | - game_id = Column(Integer, ForeignKey('gamespage.id'), nullable=False) |
406 | - file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
407 | - |
408 | -class GamesBinaryFiles(DeclarativeBase): |
409 | - __tablename__ = 'gamesbinaryfiles' |
410 | - __table_args__ = (UniqueConstraint('binary_id', 'file_id'), |
411 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
412 | - |
413 | - id = Column(Integer, primary_key=True) |
414 | - binary_id = Column(Integer, ForeignKey('gamesbinary.id'), |
415 | - nullable=False) |
416 | - file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
417 | - |
418 | -class GamesBinaryOperatingSystem(DeclarativeBase): |
419 | - __tablename__ = 'gamesbinaryoperatingsystem' |
420 | - __table_args__ = (UniqueConstraint('binary_id', 'operatingsystem_id'), |
421 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
422 | - |
423 | - id = Column(Integer, primary_key=True) |
424 | - binary_id = Column(Integer, ForeignKey('gamesbinary.id'), |
425 | - nullable=False) |
426 | - operatingsystem_id = Column(Integer, ForeignKey('operatingsystems.id'), |
427 | - nullable=False) |
428 | - |
429 | -class GamesBinaryArchitecture(DeclarativeBase): |
430 | - __tablename__ = 'gamesbinaryarchitecture' |
431 | - __table_args__ = (UniqueConstraint('binary_id', 'architecture_id'), |
432 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
433 | - |
434 | - id = Column(Integer, primary_key=True) |
435 | - binary_id = Column(Integer, ForeignKey('gamesbinary.id'), |
436 | - nullable=False) |
437 | - architecture_id = Column(Integer, ForeignKey('architectures.id'), |
438 | - nullable=False) |
439 | - |
440 | -class GamesBinary(DeclarativeBase): |
441 | - __tablename__ = 'gamesbinary' |
442 | - __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
443 | - |
444 | - id = Column(Integer, primary_key=True) |
445 | - revision_id = Column(Integer, ForeignKey('gamesrevision.id'), |
446 | - nullable=False) |
447 | - file_obj = relationship(Files, |
448 | - secondary=GamesBinaryFiles.__table__, |
449 | - uselist=False, single_parent=True, |
450 | - cascade="all, delete, delete-orphan") |
451 | - operatingsystem_obj = relationship(OperatingSystems, |
452 | - secondary=GamesBinaryOperatingSystem.__table__, |
453 | - uselist=False) |
454 | - architecture_obj = relationship(Architectures, |
455 | - secondary=GamesBinaryArchitecture.__table__, |
456 | - uselist=False) |
457 | - |
458 | - def __init__(self, file_obj, operatingsystem_obj, architecture_obj): |
459 | - self.file_obj = file_obj |
460 | - self.operatingsystem_obj = operatingsystem_obj |
461 | - self.architecture_obj = architecture_obj |
462 | - |
463 | -class GamesDependency(DeclarativeBase): |
464 | - __tablename__ = 'gamesdependency' |
465 | - __table_args__ = (UniqueConstraint('game_id', 'dependency_id'), |
466 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
467 | - |
468 | - id = Column(Integer, primary_key=True) |
469 | - game_id = Column(Integer, ForeignKey('gamespage.id'), |
470 | - nullable=False) |
471 | - dependency_id = Column(Integer, ForeignKey('dependenciespage.id'), |
472 | - nullable=False) |
473 | - |
474 | -class GamesRevisionFiles(DeclarativeBase): |
475 | - __tablename__ = 'gamesrevisionfiles' |
476 | - __table_args__ = (UniqueConstraint('revision_id', 'file_id'), |
477 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
478 | - |
479 | - id = Column(Integer, primary_key=True) |
480 | - revision_id = Column(Integer, ForeignKey('gamesrevision.id'), |
481 | - nullable=False) |
482 | - file_id = Column(Integer, ForeignKey('files.id'), nullable=False) |
483 | - |
484 | -class GamesModuleTypeRevision(DeclarativeBase): |
485 | - __tablename__ = 'gamesmoduletyperevision' |
486 | - __table_args__ = (UniqueConstraint('revision_id', 'moduletype_id'), |
487 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
488 | - |
489 | - id = Column(Integer, primary_key=True) |
490 | - revision_id = Column(Integer, ForeignKey('gamesrevision.id'), |
491 | - nullable=False) |
492 | - moduletype_id = Column(Integer, ForeignKey('gamedepmoduletype.id'), |
493 | - nullable=False) |
494 | - |
495 | -class GamesRevision(DeclarativeBase): |
496 | - __tablename__ = 'gamesrevision' |
497 | - __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
498 | - |
499 | - id = Column(Integer, primary_key=True) |
500 | - page_id = Column(Integer, ForeignKey('gamespage.id'), |
501 | - nullable=False) |
502 | - version = Column(Float(), default=0.1, index=True, nullable=False) |
503 | - created = Column(DateTime, default=datetime.now) |
504 | - published = Column(Boolean, default=False, index=True) |
505 | - page = relationship("GamesPage") |
506 | - moduletype = relationship(GameDepModuleType, |
507 | - secondary=GamesModuleTypeRevision.__table__, |
508 | - uselist=False) |
509 | - file_obj = relationship(Files, |
510 | - secondary=GamesRevisionFiles.__table__, |
511 | - uselist=False) |
512 | - binary = relationship(GamesBinary, |
513 | - cascade="all, delete") |
514 | - |
515 | - def __init__(self, version, moduletype): |
516 | - self.version = version |
517 | - self.moduletype = moduletype |
518 | - |
519 | -class GamesPage(DeclarativeBase): |
520 | - __tablename__ = 'gamespage' |
521 | - __table_args__ = {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'} |
522 | - |
523 | - id = Column(Integer, primary_key=True) |
524 | - name = Column(Unicode(128), index=True, unique=True, nullable=False) |
525 | - display_name = Column(Unicode(128), index=True, nullable=False) |
526 | - description = Column(Unicode(16384), default=u"") |
527 | - created = Column(DateTime, default=datetime.now) |
528 | - deleted = Column(Boolean, default=False, index=True) |
529 | - revisions = relationship(GamesRevision, |
530 | - cascade="all, delete, delete-orphan", |
531 | - lazy="dynamic", |
532 | - order_by=desc(GamesRevision.id), |
533 | - single_parent=True) |
534 | - tags = relationship(Tags, secondary=GamesTags.__table__, |
535 | - cascade="all, delete") |
536 | - dependencies = relationship('DependenciesPage', |
537 | - secondary=GamesDependency.__table__, |
538 | - cascade="all, delete") |
539 | - picture = relationship(Files, secondary=GamesPicture.__table__, |
540 | - cascade="all, delete") |
541 | - |
542 | - def __init__(self, name, display_name): |
543 | - self.name = name |
544 | - self.display_name = display_name |
545 | - |
546 | |
547 | === modified file 'hypernucleusserver/hypernucleusserver/model/tags.py' |
548 | --- hypernucleusserver/hypernucleusserver/model/tags.py 2011-06-18 10:18:12 +0000 |
549 | +++ hypernucleusserver/hypernucleusserver/model/tags.py 2011-06-21 20:38:13 +0000 |
550 | @@ -11,28 +11,14 @@ |
551 | def __init__(self, name): |
552 | self.name = name |
553 | |
554 | -class DependenciesTags(DeclarativeBase): |
555 | - __tablename__ = 'dependenciestags' |
556 | - __table_args__ = (UniqueConstraint('tag_id', 'dependency_id'), |
557 | - {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
558 | - |
559 | - id = Column(Integer, primary_key=True) |
560 | - tag_id = Column(Integer, ForeignKey('tags.id'), nullable=False) |
561 | - dependency_id = Column(Integer, ForeignKey('dependenciespage.id'), |
562 | - nullable=False) |
563 | - |
564 | - def __init__(self, tag_id, dependency_id): |
565 | - self.tag_id = tag_id |
566 | - self.dependency_id = dependency_id |
567 | - |
568 | -class GamesTags(DeclarativeBase): |
569 | - __tablename__ = 'gamestags' |
570 | +class GameDepTags(DeclarativeBase): |
571 | + __tablename__ = 'gamedeptags' |
572 | __table_args__ = (UniqueConstraint('tag_id', 'game_id'), |
573 | {'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'}) |
574 | |
575 | id = Column(Integer, primary_key=True) |
576 | tag_id = Column(Integer, ForeignKey('tags.id'), nullable=False) |
577 | - game_id = Column(Integer, ForeignKey('gamespage.id'), nullable=False) |
578 | + game_id = Column(Integer, ForeignKey('gamedeppage.id'), nullable=False) |
579 | |
580 | def __init__(self, game_id, tag_id): |
581 | self.game_id = game_id |
582 | |
583 | === modified file 'hypernucleusserver/hypernucleusserver/model/tokens.py' |
584 | --- hypernucleusserver/hypernucleusserver/model/tokens.py 2011-06-20 14:35:59 +0000 |
585 | +++ hypernucleusserver/hypernucleusserver/model/tokens.py 2011-06-21 20:38:13 +0000 |
586 | @@ -3,7 +3,7 @@ |
587 | from sqlalchemy.orm import relationship |
588 | from datetime import datetime, timedelta |
589 | from hypernucleusserver.models import Base as DeclarativeBase |
590 | -from hypernucleusserver.models import User |
591 | +from hypernucleusserver.model.auth import User |
592 | import uuid |
593 | |
594 | def gen_token(): |
595 | |
596 | === modified file 'hypernucleusserver/hypernucleusserver/models.py' |
597 | --- hypernucleusserver/hypernucleusserver/models.py 2011-06-21 17:37:46 +0000 |
598 | +++ hypernucleusserver/hypernucleusserver/models.py 2011-06-21 20:38:13 +0000 |
599 | @@ -9,61 +9,25 @@ |
600 | from sqlalchemy.orm import sessionmaker |
601 | from sqlalchemy.ext.declarative import declarative_base |
602 | from sqlalchemy.exc import IntegrityError |
603 | -from sqlalchemy.orm.exc import NoResultFound |
604 | from sqlalchemy import create_engine |
605 | - |
606 | from zope.sqlalchemy import ZopeTransactionExtension |
607 | |
608 | DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) |
609 | Base = declarative_base() |
610 | |
611 | -from hypernucleusserver.model.gamedep import GameDepModuleType |
612 | -from hypernucleusserver.model.gamedep import OperatingSystems, Architectures |
613 | -from hypernucleusserver.model.tags import Tags, DependenciesTags, GamesTags |
614 | -from hypernucleusserver.model.tags import ContentTags, BBThreadTags |
615 | -from hypernucleusserver.model.auth import Sexes, User, Group, ACLParent |
616 | -from hypernucleusserver.model.auth import ACLChild, UserGroup |
617 | -from hypernucleusserver.model.auth import UserSexes |
618 | +from hypernucleusserver.model.auth import ACLParent, ACLChild, User, Group |
619 | +from hypernucleusserver.model.auth import Sexes |
620 | +from hypernucleusserver.model.gamedep import Architectures, OperatingSystems |
621 | +from hypernucleusserver.model.gamedep import GameDepModuleType, GameDepPage |
622 | +from hypernucleusserver.model.gamedep import GameDepType |
623 | +from hypernucleusserver.model.errwarninfo import ErrWarnInfoInfo |
624 | +from hypernucleusserver.model.errwarninfo import ErrWarnInfoError |
625 | +from hypernucleusserver.model.errwarninfo import ErrWarnInfoWarn |
626 | from hypernucleusserver.model.content import ContentPage, ContentRevision |
627 | from hypernucleusserver.model.board import BBCategory, BBPost |
628 | from hypernucleusserver.model.board import BBThread, BBForum |
629 | -from hypernucleusserver.model.file import Files, FilesData |
630 | -from hypernucleusserver.model.tokens import Token |
631 | -from hypernucleusserver.model.errwarninfo import ErrWarnInfoInfo |
632 | -from hypernucleusserver.model.errwarninfo import ErrWarnInfoError |
633 | -from hypernucleusserver.model.errwarninfo import ErrWarnInfoWarn |
634 | - |
635 | -from hypernucleusserver.model.dependencies import DependenciesBinary |
636 | -from hypernucleusserver.model.dependencies import \ |
637 | - DependenciesBinaryArchitecture |
638 | -from hypernucleusserver.model.dependencies import \ |
639 | - DependenciesBinaryFiles |
640 | -from hypernucleusserver.model.dependencies import \ |
641 | - DependenciesBinaryOperatingSystem |
642 | -from hypernucleusserver.model.dependencies import DependenciesPage |
643 | -from hypernucleusserver.model.dependencies import DependenciesPicture |
644 | -from hypernucleusserver.model.dependencies import DependenciesRevision |
645 | -from hypernucleusserver.model.dependencies import \ |
646 | - DependenciesRevisionFiles |
647 | -from hypernucleusserver.model.dependencies import \ |
648 | - DependenciesModuleTypeRevision |
649 | - |
650 | -from hypernucleusserver.model.games import GamesBinary |
651 | -from hypernucleusserver.model.games import \ |
652 | - GamesBinaryArchitecture |
653 | -from hypernucleusserver.model.games import \ |
654 | - GamesBinaryFiles |
655 | -from hypernucleusserver.model.games import \ |
656 | - GamesBinaryOperatingSystem |
657 | -from hypernucleusserver.model.games import GamesPage |
658 | -from hypernucleusserver.model.games import GamesPicture |
659 | -from hypernucleusserver.model.games import GamesRevision |
660 | -from hypernucleusserver.model.games import \ |
661 | - GamesRevisionFiles |
662 | -from hypernucleusserver.model.games import \ |
663 | - GamesModuleTypeRevision |
664 | - |
665 | - |
666 | +from hypernucleusserver.model.tags import Tags |
667 | + |
668 | class RootFactory(object): |
669 | __acl__ = set() |
670 | |
671 | @@ -341,25 +305,29 @@ |
672 | session.add(pygame) |
673 | session.add(pcgame) |
674 | |
675 | + # Add the GameDepTypes |
676 | + gametype = GameDepType(u"game") |
677 | + deptype = GameDepType(u"dep") |
678 | + |
679 | # Add some primitive games and dependencies |
680 | - depzero = DependenciesPage(u"testzero", u"Test Zero") |
681 | + depzero = GameDepPage(deptype, u"testzero", u"Test Zero") |
682 | session.add(depzero) |
683 | - depone = DependenciesPage(u"testdep", u"Test Dependency") |
684 | + depone = GameDepPage(deptype, u"testdep", u"Test Dependency") |
685 | depone.dependencies.append(depzero) |
686 | depone.tags.append(first_tag) |
687 | session.add(depone) |
688 | - deptwo = DependenciesPage(u"testdeptwo", u"Test Dependency Two") |
689 | + deptwo = GameDepPage(deptype, u"testdeptwo", u"Test Dependency Two") |
690 | deptwo.dependencies.append(depzero) |
691 | session.add(deptwo) |
692 | - depthree = DependenciesPage(u"testdepthree", u"Test Dependency Three") |
693 | + depthree = GameDepPage(deptype, u"testdepthree", u"Test Dependency Three") |
694 | depthree.dependencies.append(deptwo) |
695 | depthree.dependencies.append(depzero) |
696 | session.add(depthree) |
697 | |
698 | - gameone = GamesPage(u"testgame", u"Test Game") |
699 | + gameone = GameDepPage(gametype, u"testgame", u"Test Game") |
700 | gameone.tags.append(first_tag) |
701 | session.add(gameone) |
702 | - gametwo = GamesPage(u"testgametwo", u"Test Game Two") |
703 | + gametwo = GameDepPage(gametype, u"testgametwo", u"Test Game Two") |
704 | gametwo.dependencies.append(depone) |
705 | session.add(gametwo) |
706 | |
707 | |
708 | === modified file 'hypernucleusserver/hypernucleusserver/security.py' |
709 | --- hypernucleusserver/hypernucleusserver/security.py 2010-12-16 05:24:55 +0000 |
710 | +++ hypernucleusserver/hypernucleusserver/security.py 2011-06-21 20:38:13 +0000 |
711 | @@ -1,4 +1,5 @@ |
712 | -from hypernucleusserver.models import User, DBSession |
713 | +from hypernucleusserver.model.auth import User |
714 | +from hypernucleusserver.models import DBSession |
715 | def groupfinder(userid, request): |
716 | dbsession = DBSession() |
717 | auth = dbsession.query(User).filter(User.name==unicode(userid)).first() |
718 | |
719 | === modified file 'hypernucleusserver/hypernucleusserver/viewlib/boardlib.py' |
720 | --- hypernucleusserver/hypernucleusserver/viewlib/boardlib.py 2011-06-18 17:05:05 +0000 |
721 | +++ hypernucleusserver/hypernucleusserver/viewlib/boardlib.py 2011-06-21 20:38:13 +0000 |
722 | @@ -1,5 +1,6 @@ |
723 | -from hypernucleusserver.models import DBSession, BBCategory, BBForum, BBThread |
724 | -from hypernucleusserver.models import NoResultFound |
725 | +from hypernucleusserver.models import DBSession |
726 | +from sqlalchemy.orm.exc import NoResultFound |
727 | +from hypernucleusserver.model.board import BBCategory, BBForum, BBThread |
728 | |
729 | class CategoryNotFound(Exception): |
730 | pass |
731 | |
732 | === modified file 'hypernucleusserver/hypernucleusserver/viewlib/contentlib.py' |
733 | --- hypernucleusserver/hypernucleusserver/viewlib/contentlib.py 2011-06-16 16:31:38 +0000 |
734 | +++ hypernucleusserver/hypernucleusserver/viewlib/contentlib.py 2011-06-21 20:38:13 +0000 |
735 | @@ -1,5 +1,6 @@ |
736 | -from hypernucleusserver.models import DBSession, ContentPage |
737 | -from hypernucleusserver.models import ContentRevision, NoResultFound |
738 | +from hypernucleusserver.models import DBSession |
739 | +from sqlalchemy.orm.exc import NoResultFound |
740 | +from hypernucleusserver.model.content import ContentRevision, ContentPage |
741 | from hypernucleusserver.viewlib.helpers import bbcode |
742 | import transaction |
743 | |
744 | |
745 | === modified file 'hypernucleusserver/hypernucleusserver/viewlib/gamedeplib.py' |
746 | --- hypernucleusserver/hypernucleusserver/viewlib/gamedeplib.py 2011-06-18 20:55:24 +0000 |
747 | +++ hypernucleusserver/hypernucleusserver/viewlib/gamedeplib.py 2011-06-21 20:38:13 +0000 |
748 | @@ -1,12 +1,9 @@ |
749 | -from hypernucleusserver.models import DBSession, NoResultFound |
750 | -from hypernucleusserver.models import GameDepModuleType, \ |
751 | - OperatingSystems, Architectures |
752 | -from hypernucleusserver.model.dependencies import DependenciesBinary |
753 | -from hypernucleusserver.model.dependencies import DependenciesPage |
754 | -from hypernucleusserver.model.dependencies import DependenciesRevision |
755 | -from hypernucleusserver.model.games import GamesBinary |
756 | -from hypernucleusserver.model.games import GamesPage |
757 | -from hypernucleusserver.model.games import GamesRevision |
758 | +from hypernucleusserver.models import DBSession |
759 | +from sqlalchemy.orm.exc import NoResultFound |
760 | +from hypernucleusserver.model.gamedep import GameDepModuleType |
761 | +from hypernucleusserver.model.gamedep import OperatingSystems, Architectures |
762 | +from hypernucleusserver.model.gamedep import GameDepBinary, GameDepPage |
763 | +from hypernucleusserver.model.gamedep import GameDepRevision, GameDepType |
764 | #from hypernucleusserver.viewlib.helpers import bbcode |
765 | from hypernucleusserver.viewlib.filelib import AlchemyIO |
766 | import transaction |
767 | @@ -63,18 +60,24 @@ |
768 | if not gamedep_type in [GAME, DEP]: |
769 | raise InvalidGameDepType |
770 | self.gamedep_type = gamedep_type |
771 | - |
772 | + |
773 | + def get_gamedeptype(self): |
774 | + if self.gamedep_type == GAME: |
775 | + gamedeptype = DBSession.query(GameDepType).filter_by( |
776 | + name=u"game").one() |
777 | + else: |
778 | + gamedeptype = DBSession.query(GameDepType).filter_by( |
779 | + name=u"dep").one() |
780 | + return gamedeptype |
781 | + |
782 | def list(self): |
783 | """ |
784 | List all the pages |
785 | """ |
786 | result = set() |
787 | - if self.gamedep_type == GAME: |
788 | - gamedeps = DBSession.query(GamesPage).filter_by( |
789 | - deleted=False) |
790 | - else: |
791 | - gamedeps = DBSession.query(DependenciesPage).filter_by( |
792 | - deleted=False) |
793 | + gamedeptype = self.get_gamedeptype() |
794 | + gamedeps = DBSession.query(GameDepPage).filter_by( |
795 | + gamedeptype_id=gamedeptype.id, deleted=False) |
796 | if not gamedeps: |
797 | raise GameDepNotFound |
798 | for gamedep in gamedeps: |
799 | @@ -90,7 +93,8 @@ |
800 | display_name = unicode(display_name) |
801 | description = unicode(description) |
802 | if not self.exists(name, raise_if_found=True): |
803 | - page = self.show(name)[0] |
804 | + gamedeptype = self.get_gamedeptype() |
805 | + page = GameDepPage(gamedeptype, name, display_name) |
806 | page.description = description |
807 | DBSession.add(page) |
808 | transaction.commit() |
809 | @@ -119,10 +123,7 @@ |
810 | moduletype = self.get_moduletype(moduletype) |
811 | if not self.exists(name, version, raise_if_found=True): |
812 | page, rev = self.show(name) |
813 | - if self.gamedep_type == GAME: |
814 | - rev = GamesRevision(version, moduletype) |
815 | - else: |
816 | - rev = DependenciesRevision(version, moduletype) |
817 | + rev = GameDepRevision(version, moduletype) |
818 | page.revisions.append(rev) |
819 | transaction.commit() |
820 | |
821 | @@ -172,12 +173,8 @@ |
822 | |
823 | def show_binary(self, binaryid): |
824 | try: |
825 | - if self.gamedep_type == GAME: |
826 | - bin_obj = DBSession.query(GamesBinary).filter_by( |
827 | - id=binaryid).one() |
828 | - else: |
829 | - bin_obj = DBSession.query(DependenciesBinary).filter_by( |
830 | - id=binaryid).one() |
831 | + bin_obj = DBSession.query(GameDepBinary).filter_by( |
832 | + id=binaryid).one() |
833 | except NoResultFound: |
834 | raise GameDepNotFound |
835 | return bin_obj |
836 | @@ -201,14 +198,8 @@ |
837 | aio = AlchemyIO(fle=binary, sess=DBSession, |
838 | mime=mimetype, filename=filename) |
839 | aio_obj = aio.write() |
840 | - |
841 | - if self.gamedep_type == GAME: |
842 | - bin_obj = GamesBinary(aio_obj, os_obj, arch_obj) |
843 | - else: |
844 | - bin_obj = DependenciesBinary(aio_obj, os_obj, arch_obj) |
845 | - |
846 | + bin_obj = GameDepBinary(aio_obj, os_obj, arch_obj) |
847 | rev.binary.append(bin_obj) |
848 | - |
849 | transaction.commit() |
850 | |
851 | def update_binary(self, name, revision, binaryid, operatingsystem, |
852 | @@ -272,10 +263,12 @@ |
853 | """ |
854 | name = unicode(name) |
855 | dep_id = int(dep_id) |
856 | - |
857 | + gamedeptype = DBSession.query(GameDepType).filter_by( |
858 | + name=u"dep").one() |
859 | try: |
860 | - dep = DBSession.query(DependenciesPage).filter_by( |
861 | - id=dep_id).one() |
862 | + dep = DBSession.query(GameDepPage).filter_by( |
863 | + gamedeptype_id=gamedeptype.id, |
864 | + deleted=False, id=dep_id).one() |
865 | except NoResultFound: |
866 | raise GameDepNotFound |
867 | |
868 | @@ -334,11 +327,11 @@ |
869 | """ |
870 | name = unicode(name) |
871 | try: |
872 | - if self.gamedep_type == GAME: |
873 | - page = DBSession.query(GamesPage).filter_by(name=name).one() |
874 | - else: |
875 | - page = DBSession.query(DependenciesPage).filter_by( |
876 | - name=name).one() |
877 | + gamedeptype = self.get_gamedeptype() |
878 | + page = DBSession.query(GameDepPage).filter_by( |
879 | + name=name, |
880 | + gamedeptype_id=gamedeptype.id, |
881 | + deleted=False).one() |
882 | except NoResultFound: |
883 | return False |
884 | |
885 | @@ -413,7 +406,10 @@ |
886 | return archlist |
887 | |
888 | def dependency_dropdown(self): |
889 | - page = DBSession.query(DependenciesPage.id, DependenciesPage.name) |
890 | + gamedeptype = DBSession.query(GameDepType).filter_by( |
891 | + name=u"dep").one() |
892 | + page = DBSession.query(GameDepPage.id, GameDepPage.name).filter_by( |
893 | + deleted=False, gamedeptype_id=gamedeptype.id) |
894 | return page.all() |
895 | |
896 | def show(self, name, revision=None): |
897 | @@ -429,27 +425,23 @@ |
898 | |
899 | if not revision: |
900 | try: |
901 | - if self.gamedep_type == GAME: |
902 | - page = DBSession.query(GamesPage).filter_by( |
903 | - name=name).one() |
904 | - else: |
905 | - page = DBSession.query(DependenciesPage).filter_by( |
906 | - name=name).one() |
907 | + gamedeptype = self.get_gamedeptype() |
908 | + page = DBSession.query(GameDepPage).filter_by( |
909 | + name=name, |
910 | + gamedeptype_id=gamedeptype.id, |
911 | + deleted=False).one() |
912 | return (page, None) |
913 | except NoResultFound: |
914 | raise GameDepNotFound |
915 | else: |
916 | try: |
917 | - if self.gamedep_type == GAME: |
918 | - page = DBSession.query(GamesPage).filter_by( |
919 | - name=name).one() |
920 | - rev = DBSession.query(GamesRevision).filter_by( |
921 | - id=revision).one() |
922 | - else: |
923 | - page = DBSession.query(DependenciesPage).filter_by( |
924 | - name=name).one() |
925 | - rev = DBSession.query(DependenciesRevision).filter_by( |
926 | - id=revision).one() |
927 | + gamedeptype = self.get_gamedeptype() |
928 | + page = DBSession.query(GameDepPage).filter_by( |
929 | + name=name, |
930 | + gamedeptype_id=gamedeptype.id, |
931 | + deleted=False).one() |
932 | + rev = DBSession.query(GameDepRevision).filter_by( |
933 | + id=revision).one() |
934 | if not rev in page.revisions: |
935 | raise GameDepNotFound |
936 | |
937 | |
938 | === modified file 'hypernucleusserver/hypernucleusserver/viewlib/outputlib.py' |
939 | --- hypernucleusserver/hypernucleusserver/viewlib/outputlib.py 2011-06-19 17:05:44 +0000 |
940 | +++ hypernucleusserver/hypernucleusserver/viewlib/outputlib.py 2011-06-21 20:38:13 +0000 |
941 | @@ -1,7 +1,8 @@ |
942 | -from hypernucleusserver.models import DBSession, GamesPage, DependenciesPage |
943 | -from hypernucleusserver.models import NoResultFound, GamesPicture, Files |
944 | -from hypernucleusserver.models import GamesBinary, DependenciesBinary |
945 | -from xml.etree.ElementTree import Element, SubElement, ElementTree, tostring |
946 | +from hypernucleusserver.models import DBSession |
947 | +from sqlalchemy.orm.exc import NoResultFound |
948 | +from hypernucleusserver.model.gamedep import GameDepPage, GameDepType |
949 | +from hypernucleusserver.model.file import Files |
950 | +from xml.etree.ElementTree import Element, SubElement, tostring |
951 | import json |
952 | |
953 | class FileNotFound(Exception): |
954 | @@ -62,8 +63,12 @@ |
955 | uploadurl = self.uploadurl |
956 | sess = DBSession |
957 | root = Element("hypernucleus") |
958 | - dbgame = sess.query(GamesPage).all() |
959 | - dbdependency = sess.query(DependenciesPage).all() |
960 | + gametype = sess.query(GameDepType).filter_by(name="game").one() |
961 | + deptype = sess.query(GameDepType).filter_by(name="dep").one() |
962 | + dbgame = sess.query(GameDepPage).filter_by( |
963 | + gamedeptype_id=gametype.id, deleted=False).all() |
964 | + dbdep = sess.query(GameDepPage).filter_by( |
965 | + gamedeptype_id=deptype.id, deleted=False).all() |
966 | for dbitem in dbgame: |
967 | game = SubElement(root, "game") |
968 | SubElement(game, "name").text = dbitem.display_name |
969 | @@ -82,7 +87,7 @@ |
970 | dependency = SubElement(game, "dependency") |
971 | SubElement(dependency, "modulename").text = dbdepitem.name |
972 | SubElement(dependency, "version").text = "1" #str(dbdepitem.version) |
973 | - for dbitem in dbdependency: |
974 | + for dbitem in dbdep: |
975 | if countobj(dbitem.revisions) > 0: |
976 | for binary in dbitem.revisions[0].binary: |
977 | dependency = SubElement(root, "dependency") |
978 | @@ -102,9 +107,12 @@ |
979 | |
980 | def show_new_xml(self): |
981 | root = Element("hypernucleus") |
982 | - game = DBSession.query(GamesPage).filter_by(deleted=False).all() |
983 | - dep = DBSession.query(DependenciesPage).filter_by( |
984 | - deleted=False).all() |
985 | + gametype = DBSession.query(GameDepType).filter_by(name="game").one() |
986 | + deptype = DBSession.query(GameDepType).filter_by(name="dep").one() |
987 | + game = DBSession.query(GameDepPage).filter_by( |
988 | + gamedeptype_id=gametype.id, deleted=False).all() |
989 | + dep = DBSession.query(GameDepPage).filter_by( |
990 | + gamedeptype_id=deptype.id, deleted=False).all() |
991 | for gamedep in [game, dep]: |
992 | for item in gamedep: |
993 | if gamedep == game: |
994 | @@ -150,9 +158,12 @@ |
995 | """ |
996 | root = [] |
997 | key = None |
998 | - game = DBSession.query(GamesPage).filter_by(deleted=False).all() |
999 | - dep = DBSession.query(DependenciesPage).filter_by( |
1000 | - deleted=False).all() |
1001 | + gametype = DBSession.query(GameDepType).filter_by(name="game").one() |
1002 | + deptype = DBSession.query(GameDepType).filter_by(name="dep").one() |
1003 | + game = DBSession.query(GameDepPage).filter_by( |
1004 | + gamedeptype_id=gametype.id, deleted=False).all() |
1005 | + dep = DBSession.query(GameDepPage).filter_by( |
1006 | + gamedeptype_id=deptype.id, deleted=False).all() |
1007 | for gamedep in [game, dep]: |
1008 | if gamedep == game: |
1009 | key = "game" |
1010 | |
1011 | === modified file 'hypernucleusserver/hypernucleusserver/viewlib/userlib.py' |
1012 | --- hypernucleusserver/hypernucleusserver/viewlib/userlib.py 2010-12-11 20:46:28 +0000 |
1013 | +++ hypernucleusserver/hypernucleusserver/viewlib/userlib.py 2011-06-21 20:38:13 +0000 |
1014 | @@ -1,4 +1,6 @@ |
1015 | -from hypernucleusserver.models import DBSession, User, NoResultFound |
1016 | +from hypernucleusserver.models import DBSession |
1017 | +from sqlalchemy.orm.exc import NoResultFound |
1018 | +from hypernucleusserver.model.auth import User |
1019 | |
1020 | class UserNotFound(Exception): |
1021 | pass |
1022 | |
1023 | === modified file 'hypernucleusserver/hypernucleusserver/views/errwarninfo.py' |
1024 | --- hypernucleusserver/hypernucleusserver/views/errwarninfo.py 2010-12-07 23:25:07 +0000 |
1025 | +++ hypernucleusserver/hypernucleusserver/views/errwarninfo.py 2011-06-21 20:38:13 +0000 |
1026 | @@ -1,9 +1,12 @@ |
1027 | import json |
1028 | from pyramid.url import route_url |
1029 | from string import Template |
1030 | -from hypernucleusserver.models import DBSession, ErrWarnInfoInfo, NoResultFound |
1031 | -from hypernucleusserver.models import ErrWarnInfoError, ErrWarnInfoWarn |
1032 | +from hypernucleusserver.models import DBSession |
1033 | +from hypernucleusserver.model.errwarninfo import ErrWarnInfoInfo |
1034 | +from hypernucleusserver.model.errwarninfo import ErrWarnInfoError |
1035 | +from hypernucleusserver.model.errwarninfo import ErrWarnInfoWarn |
1036 | from pyramid.httpexceptions import HTTPFound |
1037 | +from sqlalchemy.orm.exc import NoResultFound |
1038 | |
1039 | notexisterr = u"errwarninfo_notexist" |
1040 | jsonerr = u"errwarninfo_json" |
1041 | |
1042 | === modified file 'hypernucleusserver/hypernucleusserver/views/gamedep.py' |
1043 | --- hypernucleusserver/hypernucleusserver/views/gamedep.py 2011-06-17 19:53:18 +0000 |
1044 | +++ hypernucleusserver/hypernucleusserver/views/gamedep.py 2011-06-21 20:38:13 +0000 |
1045 | @@ -1,10 +1,7 @@ |
1046 | from hypernucleusserver.viewlib.userlib import UserLib |
1047 | from hypernucleusserver.viewlib.gamedeplib import GameDepLib, GameDepNotFound |
1048 | -from hypernucleusserver.viewlib.helpers import error_redirect, get_username |
1049 | -from pyramid.httpexceptions import HTTPFound, HTTPNotFound |
1050 | -from pyramid.exceptions import Forbidden, NotFound |
1051 | -from pyramid.url import route_url |
1052 | -from pyramid.security import has_permission |
1053 | +from hypernucleusserver.viewlib.helpers import error_redirect |
1054 | +from pyramid.exceptions import NotFound |
1055 | from colander import MappingSchema, SchemaNode, String, Decimal, OneOf |
1056 | from deform import ValidationFailure, Form, FileData |
1057 | from deform.widget import TextAreaWidget, TextInputWidget, RadioChoiceWidget, \ |
1058 | @@ -47,12 +44,12 @@ |
1059 | pageid = request.matchdict.get('pageid') |
1060 | |
1061 | try: |
1062 | - dbpage, dbrevision = g.show(pageid) |
1063 | + dbpage = g.show(pageid)[0] |
1064 | dbdescription = dbpage.description |
1065 | dbname = dbpage.name |
1066 | dbdisplay_name = dbpage.display_name |
1067 | except GameDepNotFound: |
1068 | - dbpage, dbrevision = (None, None) |
1069 | + dbpage = None |
1070 | dbdescription = u"" |
1071 | dbname = u"" |
1072 | dbdisplay_name = u"" |