forked from Gig-o-Matic/GO2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
motd_db.py
45 lines (35 loc) · 788 Bytes
/
motd_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
motd class for Gig-o-Matic 2
Aaron Oppenheimer
24 August 2013
"""
from google.appengine.ext import ndb
#
# class for Motd
#
class Motd(ndb.Model):
""" Models a message of the day """
value = ndb.TextProperty()
def set_motd(value):
""" sets the MOTD """
the_motd = get_motd_object()
if the_motd:
the_motd.value=value
the_motd.put()
else:
the_motd = Motd(value=value)
the_motd.put()
def get_motd_object():
""" Return the motd if there is one """
motd_query = Motd.query()
motd = motd_query.fetch(1)
if len(motd) == 0:
return None
else:
return motd[0]
def get_motd():
m = get_motd_object()
if m:
return m.value
else:
return None