summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-01-27 16:01:00 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-01-27 16:01:00 +0100
commit7ae6693f33ee4c7f92729dd0e076491421427063 (patch)
treee99958eb9ff0cc903ecf35ba7282799ae82cd3cb
parent736f28928e0003b27707ec6e1ecbe61534751525 (diff)
Default fields to None, and don't allow paste text to be None.
This requires a recreation of the database.
-rw-r--r--db.py2
-rw-r--r--pastepy.py10
2 files changed, 6 insertions, 6 deletions
diff --git a/db.py b/db.py
index b5c5a3f..9885b4e 100644
--- a/db.py
+++ b/db.py
@@ -16,7 +16,7 @@ class Paste(Base):
date = Column(DateTime, nullable = False)
syntax = Column(String)
title = Column(String)
- text = Column(Text)
+ text = Column(Text, nullable = False)
def __init__(self, hash, nick, date, syntax, title, text):
self.nick = nick
diff --git a/pastepy.py b/pastepy.py
index c24fcf8..1aab7df 100644
--- a/pastepy.py
+++ b/pastepy.py
@@ -66,16 +66,16 @@ class Paste(object):
}))]
def add_paste(self, mp):
- nick = mp['nick'].value
- syntax = mp['syntax'].value or None
- title = mp['title'].value
- text = mp['text'].value
+ nick = mp['nick'].value.decode('utf8') or None
+ syntax = mp['syntax'].value.decode('utf8') or None
+ title = mp['title'].value.decode('utf8') or None
+ text = mp['text'].value.decode('utf8') or None
hash = ''.join(random.choice(base62_alphabet) for x in xrange(5))
try:
session = db.Session()
- paste = db.Paste(hash, nick.decode('utf8'), datetime.datetime.utcnow(), syntax.decode('utf8') if syntax else None, title.decode('utf8'), text.decode('utf8'))
+ paste = db.Paste(hash, nick, datetime.datetime.utcnow(), syntax, title, text)
session.add(paste)
session.commit()
finally: