diff options
author | Daniel Neuhäuser <ich@danielneuhaeuser.de> | 2010-08-11 14:23:58 +0200 |
---|---|---|
committer | Daniel Neuhäuser <ich@danielneuhaeuser.de> | 2010-08-11 14:23:58 +0200 |
commit | 1d4c7d4fe01bc768ebb0bfc9765f58a86dcc74c6 (patch) | |
tree | 8da3846b879af3aade139942bf8183f6e9a2bb6e /sphinx/websupport/storage | |
parent | 4a2a6a7eab051ae5b44c15243acc4d142b984874 (diff) | |
download | sphinx-git-1d4c7d4fe01bc768ebb0bfc9765f58a86dcc74c6.tar.gz |
Added initial versioning support
Diffstat (limited to 'sphinx/websupport/storage')
-rw-r--r-- | sphinx/websupport/storage/__init__.py | 4 | ||||
-rw-r--r-- | sphinx/websupport/storage/db.py | 8 | ||||
-rw-r--r-- | sphinx/websupport/storage/sqlalchemystorage.py | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/sphinx/websupport/storage/__init__.py b/sphinx/websupport/storage/__init__.py index 17907e992..da815d0a3 100644 --- a/sphinx/websupport/storage/__init__.py +++ b/sphinx/websupport/storage/__init__.py @@ -16,9 +16,11 @@ class StorageBackend(object): """ pass - def add_node(self, document, line, source): + def add_node(self, id, document, line, source): """Add a node to the StorageBackend. + :param id: a unique id for the comment. + :param document: the name of the document the node belongs to. :param line: the line in the source where the node begins. diff --git a/sphinx/websupport/storage/db.py b/sphinx/websupport/storage/db.py index 74a3e2b70..54b16f225 100644 --- a/sphinx/websupport/storage/db.py +++ b/sphinx/websupport/storage/db.py @@ -11,6 +11,7 @@ """ from datetime import datetime +from uuid import uuid4 from sqlalchemy import Column, Integer, Text, String, Boolean, ForeignKey,\ DateTime @@ -28,7 +29,7 @@ class Node(Base): """Data about a Node in a doctree.""" __tablename__ = db_prefix + 'nodes' - id = Column(Integer, primary_key=True) + id = Column(String(32), primary_key=True) document = Column(String(256), nullable=False) line = Column(Integer) source = Column(Text, nullable=False) @@ -93,7 +94,8 @@ class Node(Base): return comments - def __init__(self, document, line, source): + def __init__(self, id, document, line, source): + self.id = id self.document = document self.line = line self.source = source @@ -112,7 +114,7 @@ class Comment(Base): proposal_diff = Column(Text) path = Column(String(256), index=True) - node_id = Column(Integer, ForeignKey(db_prefix + 'nodes.id')) + node_id = Column(String, ForeignKey(db_prefix + 'nodes.id')) node = relation(Node, backref="comments") def __init__(self, text, displayed, username, rating, time, diff --git a/sphinx/websupport/storage/sqlalchemystorage.py b/sphinx/websupport/storage/sqlalchemystorage.py index e2cd87ac5..d1683f603 100644 --- a/sphinx/websupport/storage/sqlalchemystorage.py +++ b/sphinx/websupport/storage/sqlalchemystorage.py @@ -33,8 +33,8 @@ class SQLAlchemyStorage(StorageBackend): def pre_build(self): self.build_session = Session() - def add_node(self, document, line, source): - node = Node(document, line, source) + def add_node(self, id, document, line, source): + node = Node(id, document, line, source) self.build_session.add(node) self.build_session.flush() return node |