擅长:python、mysql、java
<p>尝试:</p>
<pre><code>class InviteManager():
ALREADY_INVITED_MESSAGE = "You are already on our invite list"
INVITE_MESSAGE = "Thank you! we will be in touch soon"
@staticmethod
@missing_input_not_allowed
def invite(email):
try:
db.session.add(Invite(email))
db.session.commit()
except IntegrityError:
return InviteManager.ALREADY_INVITED_MESSAGE
return InviteManager.INVITE_MESSAGE
</code></pre>
<p><code>InviteManager</code>在它的静态方法的范围内。</p>