launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25745
[Merge] ~twom/launchpad:questions-about-reopening-storms into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:questions-about-reopening-storms into launchpad:master.
Commit message:
Port questionreopening to Storm
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/394547
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:questions-about-reopening-storms into launchpad:master.
diff --git a/lib/lp/answers/model/question.py b/lib/lp/answers/model/question.py
index a46cb06..8015c6f 100644
--- a/lib/lp/answers/model/question.py
+++ b/lib/lp/answers/model/question.py
@@ -234,8 +234,8 @@ class Question(SQLBase, BugLinkTargetMixin):
# ReferenceSets, so use a list() property instead.
_messages = ReferenceSet(
'id', 'QuestionMessage.question_id', order_by='QuestionMessage.id')
- reopenings = SQLMultipleJoin('QuestionReopening', orderBy='datecreated',
- joinColumn='question')
+ reopenings = ReferenceSet(
+ 'id', 'QuestionReopening.question_id', order_by='datecreated')
@property
def messages(self):
diff --git a/lib/lp/answers/model/questionreopening.py b/lib/lp/answers/model/questionreopening.py
index 9cd78b4..9d0910d 100644
--- a/lib/lp/answers/model/questionreopening.py
+++ b/lib/lp/answers/model/questionreopening.py
@@ -8,8 +8,14 @@ __metaclass__ = type
__all__ = ['QuestionReopening',
'create_questionreopening']
+import re
from lazr.lifecycle.event import ObjectCreatedEvent
-from sqlobject import ForeignKey
+from storm.locals import (
+ DateTime,
+ Int,
+ Reference,
+ Unicode,
+ )
from zope.event import notify
from zope.interface import implementer
from zope.security.proxy import ProxyFactory
@@ -19,27 +25,40 @@ from lp.answers.interfaces.questionreopening import IQuestionReopening
from lp.registry.interfaces.person import validate_public_person
from lp.services.database.constants import DEFAULT
from lp.services.database.datetimecol import UtcDateTimeCol
-from lp.services.database.enumcol import EnumCol
-from lp.services.database.sqlbase import SQLBase
+from lp.services.database.enumcol import DBEnum
+from lp.services.database.stormbase import StormBase
@implementer(IQuestionReopening)
-class QuestionReopening(SQLBase):
+class QuestionReopening(StormBase):
"""A table recording each time a question is re-opened."""
- _table = 'QuestionReopening'
+ __storm_table__ = 'QuestionReopening'
- question = ForeignKey(
- dbName='question', foreignKey='Question', notNull=True)
- datecreated = UtcDateTimeCol(notNull=True, default=DEFAULT)
- reopener = ForeignKey(
- dbName='reopener', foreignKey='Person',
- storm_validator=validate_public_person, notNull=True)
- answerer = ForeignKey(
- dbName='answerer', foreignKey='Person',
- storm_validator=validate_public_person, notNull=False, default=None)
- date_solved = UtcDateTimeCol(notNull=False, default=None)
- priorstate = EnumCol(schema=QuestionStatus, notNull=True)
+ id = Int(primary=True)
+
+ question_id = Int(name='question', allow_none=False)
+ question = Reference(question_id, 'Question.id')
+ datecreated = DateTime(
+ name='datecreated', allow_none=False, default=DEFAULT)
+ reopener_id = Int(
+ name='reopener', allow_none=False, validator=validate_public_person)
+ reopener = Reference(reopener_id, 'Person.id')
+ answerer_id = Int(name='answerer', allow_none=True, default=None,
+ validator=validate_public_person)
+ answerer = Reference(answerer_id, 'Person.id')
+ date_solved = DateTime(allow_none=True, default=None)
+ priorstate = DBEnum(
+ name="priorstate", enum=QuestionStatus, allow_none=False)
+
+ def __init__(self, question, reopener, datecreated,
+ answerer, date_solved, priorstate):
+ self.question = question
+ self.reopener = reopener
+ self.datecreated = datecreated
+ self.answerer = answerer
+ self.date_solved = date_solved
+ self.priorstate = priorstate
def create_questionreopening(