|
@@ -7,7 +7,6 @@ from datetime import datetime
|
7
|
7
|
import tg
|
8
|
8
|
from babel.dates import format_timedelta
|
9
|
9
|
from bs4 import BeautifulSoup
|
10
|
|
-from decorator import contextmanager
|
11
|
10
|
from sqlalchemy import Column, inspect
|
12
|
11
|
from sqlalchemy import ForeignKey
|
13
|
12
|
from sqlalchemy import Sequence
|
|
@@ -27,7 +26,7 @@ from sqlalchemy.types import Unicode
|
27
|
26
|
from tg.i18n import lazy_ugettext as l_, ugettext as _
|
28
|
27
|
|
29
|
28
|
from tracim.lib.exception import ContentRevisionUpdateError
|
30
|
|
-from tracim.model import DeclarativeBase, DBSession, RevisionsIntegrity
|
|
29
|
+from tracim.model import DeclarativeBase, RevisionsIntegrity
|
31
|
30
|
from tracim.model.auth import User
|
32
|
31
|
|
33
|
32
|
|
|
@@ -555,7 +554,7 @@ class ContentRevisionRO(DeclarativeBase):
|
555
|
554
|
and key in self._cloned_columns \
|
556
|
555
|
and not RevisionsIntegrity.is_updatable(self):
|
557
|
556
|
raise ContentRevisionUpdateError(
|
558
|
|
- "Can't modify revision. To work on new revision use tracim.model.data.new_revision " +
|
|
557
|
+ "Can't modify revision. To work on new revision use tracim.model.new_revision " +
|
559
|
558
|
"context manager.")
|
560
|
559
|
|
561
|
560
|
super().__setattr__(key, value)
|
|
@@ -602,7 +601,7 @@ class Content(DeclarativeBase):
|
602
|
601
|
|
603
|
602
|
# UPDATE A CONTENT
|
604
|
603
|
|
605
|
|
- To update an existing Content, you must use tracim.model.data.new_revision context manager:
|
|
604
|
+ To update an existing Content, you must use tracim.model.new_revision context manager:
|
606
|
605
|
content = my_sontent_getter_method()
|
607
|
606
|
with new_revision(content):
|
608
|
607
|
content.description = 'foo bar baz'
|
|
@@ -1120,23 +1119,6 @@ class Content(DeclarativeBase):
|
1120
|
1119
|
return url_template.format(wid=wid, fid=fid, ctype=ctype, cid=cid)
|
1121
|
1120
|
|
1122
|
1121
|
|
1123
|
|
-@contextmanager
|
1124
|
|
-def new_revision(content):
|
1125
|
|
- """
|
1126
|
|
- Prepare context to update a Content. It will add a new updatable revision to the content.
|
1127
|
|
- :param content: Content instance to update
|
1128
|
|
- :return:
|
1129
|
|
- """
|
1130
|
|
- with DBSession.no_autoflush:
|
1131
|
|
- try:
|
1132
|
|
- if inspect(content.revision).has_identity:
|
1133
|
|
- content.new_revision()
|
1134
|
|
- RevisionsIntegrity.add_to_updatable(content.revision)
|
1135
|
|
- yield content.revision
|
1136
|
|
- finally:
|
1137
|
|
- RevisionsIntegrity.remove_from_updatable(content.revision)
|
1138
|
|
-
|
1139
|
|
-
|
1140
|
1122
|
class RevisionReadStatus(DeclarativeBase):
|
1141
|
1123
|
|
1142
|
1124
|
__tablename__ = 'revision_read_status'
|