~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/answers/model/questionmessage.py

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    QuestionStatus,
24
24
    )
25
25
from lp.answers.interfaces.questionmessage import IQuestionMessage
 
26
from lp.registry.interfaces.person import validate_public_person
26
27
from lp.services.propertycache import cachedproperty
27
28
 
28
29
 
45
46
    new_status = EnumCol(
46
47
        schema=QuestionStatus, notNull=True, default=QuestionStatus.OPEN)
47
48
 
 
49
    owner = ForeignKey(dbName='owner', foreignKey='Person',
 
50
        storm_validator=validate_public_person, notNull=True)
 
51
 
 
52
    def __init__(self, **kwargs):
 
53
        if 'owner' not in kwargs:
 
54
            # Although a trigger will set the owner after the SQL
 
55
            # INSERT has been executed, we must specify the parameter
 
56
            # explicitly to fulfill the DB constraint OWNER NOT NULL,
 
57
            # otherweise we'll get an error from the DB server.
 
58
            kwargs['owner'] = kwargs['message'].owner
 
59
        super(QuestionMessage, self).__init__(**kwargs)
 
60
 
48
61
    def __iter__(self):
49
62
        """See IMessage."""
50
63
        # Delegates do not proxy __ methods, because of the name mangling.