summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2017-03-13 19:33:42 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2017-03-13 19:33:42 +0100
commit8340f81f6d7c89edf091dbd3ca807edfc8c919ab (patch)
treed49dd5436c737a611c5a688db7b3e1f9ca431623
parenta8b53dde92c9dec0cfd74acb29b5066813827193 (diff)
Store IP address per paste.
-rw-r--r--db.py4
-rw-r--r--pastepy.py2
2 files changed, 4 insertions, 2 deletions
diff --git a/db.py b/db.py
index 003d4c4..8b2591d 100644
--- a/db.py
+++ b/db.py
@@ -19,14 +19,16 @@ class Paste(Base):
syntax = Column(String)
title = Column(String)
text = Column(Text, nullable = False)
+ ip = Column(String)
- def __init__(self, hash, nick, date, syntax, title, text):
+ def __init__(self, hash, nick, date, syntax, title, text, ip=None):
self.nick = nick
self.hash = hash
self.date = date
self.syntax = syntax
self.title = title
self.text = text
+ self.ip = ip
def __repr__(self):
return '<Paste(%d, "%s", "%s", "%s", "%s")>' % (self.id, self.hash, self.nick, self.date.ctime(), self.title)
diff --git a/pastepy.py b/pastepy.py
index 5d734fb..e868a04 100644
--- a/pastepy.py
+++ b/pastepy.py
@@ -114,7 +114,7 @@ class Paste(object):
try:
session = db.Session()
- paste = db.Paste(hash, nick, datetime.datetime.utcnow(), syntax, title, text)
+ paste = db.Paste(hash, nick, datetime.datetime.utcnow(), syntax, title, text, self.environ['REMOTE_ADDR'])
session.add(paste)
session.commit()
finally: