annotate MoinMoin/items/__init__.py @ 1677:d74b9e4d41e5

items/__init__.py: Split helper methods from_item and from_requst in Item._ModifyForm to a separate BaseModifyForm class.
author Cheer Xiao <xiaqqaix@gmail.com>
date Tue, 14 Aug 2012 00:40:06 +0800
parents 36ae694c4122
children f77870dd132f
rev   line source
1391
339668f8ad06 refactor of apps/frontend/views.py and items/__init__.py modules
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1361
diff changeset
1 # Copyright: 2012 MoinMoin:CheerXiao
26
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
2 # Copyright: 2009 MoinMoin:ThomasWaldmann
254
91330de48b9c items: implemented 2.6 r:2031 alpha of svg-edit using a save extension for doing a single post for svg and png data.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 248
diff changeset
3 # Copyright: 2009-2011 MoinMoin:ReimarBauer
26
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
4 # Copyright: 2009 MoinMoin:ChristopherDenter
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
5 # Copyright: 2008,2009 MoinMoin:BastianBlank
26
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
6 # Copyright: 2010 MoinMoin:ValentinJaniaut
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
7 # Copyright: 2010 MoinMoin:DiogenesAugusto
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
8 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
9
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 """
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
11 MoinMoin - high-level (frontend) items
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 While MoinMoin.storage cares for backend storage of items,
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 this module cares for more high-level, frontend items,
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 e.g. showing, editing, etc. of wiki items.
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
17 Each class in this module corresponds to an itemtype.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
18 """
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
19
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
20 import re, time
486
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
21 import itertools
1623
1e67974bee6e remove simplejson fallback, json is included since python 2.6 (which we require)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1617
diff changeset
22 import json
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 from StringIO import StringIO
1613
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
24 from collections import namedtuple
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
25 from functools import partial
1675
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
26 from datetime import datetime
173
89f50aed143f move mimetype related code from wikiutil to util.mimetype
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 170
diff changeset
27
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
28 from flatland import Form
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
29 from flatland.validation import Validator
779
815c46100e2c whooshify get_templates, adapt MimeType analyzer so it yields also a full and normalized contenttype
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 525
diff changeset
30
1662
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
31 from jinja2 import Markup
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
32
1675
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
33 from whoosh.query import Term, And, Prefix, DateRange
779
815c46100e2c whooshify get_templates, adapt MimeType analyzer so it yields also a full and normalized contenttype
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 525
diff changeset
34
1653
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
35 from MoinMoin.forms import RequiredText, OptionalText, JSON, Tags, DateTime, Submit
242
e93157b8b0bd refactor modify views to use flatland, see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 241
diff changeset
36
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
37 from MoinMoin.security.textcha import TextCha, TextChaizedForm
242
e93157b8b0bd refactor modify views to use flatland, see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 241
diff changeset
38 from MoinMoin.signalling import item_modified
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
39 from MoinMoin.util.mime import Type
1005
c36f61f85e97 AccessDeniedError replaced by AccessDenied, from the new storage api.
Bruno Martin <bruno@hacklab.com.br>
parents: 1004
diff changeset
40 from MoinMoin.storage.middleware.protecting import AccessDenied
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 from MoinMoin import log
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 logging = log.getLogger(__name__)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 from flask import current_app as app
109
e4c332436733 remove flask monkeypatch, use 'from flask import g as flaskg'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 103
diff changeset
46 from flask import g as flaskg
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
48 from flask import request, Response, redirect, abort, escape
242
e93157b8b0bd refactor modify views to use flatland, see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 241
diff changeset
49
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 from werkzeug import is_resource_modified
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
52 from MoinMoin.i18n import L_
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 from MoinMoin.themes import render_template
316
4ee796d759bf use url_for_item where appropriate (in py code, no template changes yet)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 315
diff changeset
54 from MoinMoin.util.interwiki import url_for_item
1005
c36f61f85e97 AccessDeniedError replaced by AccessDenied, from the new storage api.
Bruno Martin <bruno@hacklab.com.br>
parents: 1004
diff changeset
55 from MoinMoin.storage.error import NoSuchItemError, NoSuchRevisionError, StorageError
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
56 from MoinMoin.util.registry import RegistryBase
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
57 from MoinMoin.constants.keys import (
1675
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
58 NAME, NAME_OLD, NAME_EXACT, WIKINAME, MTIME, PTIME, SYSITEM_VERSION, ITEMTYPE,
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
59 CONTENTTYPE, SIZE, TAGS, ACTION, ADDRESS, HOSTNAME, USERID, COMMENT,
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
60 HASH_ALGORITHM, ITEMID, REVID, DATAID, CURRENT, PARENTID
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
61 )
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
62 from MoinMoin.constants.contenttypes import charset, CONTENTTYPE_GROUPS
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
63
1648
1a2c53092ea1 items/content.py: Implement Content.create.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1631
diff changeset
64 from .content import Content, NonExistentContent, Draw, content_registry
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
65
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 COLS = 80
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68 ROWS_META = 10
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
71 class RegistryItem(RegistryBase):
1613
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
72 class Entry(namedtuple('Entry', 'factory itemtype priority')):
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
73 def __call__(self, itemtype, *args, **kw):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
74 if self.itemtype == itemtype:
1613
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
75 return self.factory(*args, **kw)
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
76
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
77 def __lt__(self, other):
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
78 if isinstance(other, self.__class__):
1614
5b5e7190452f Fix various registry Entry `__lt__` methods. This resolves issue #221.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1613
diff changeset
79 if self.priority != other.priority:
5b5e7190452f Fix various registry Entry `__lt__` methods. This resolves issue #221.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1613
diff changeset
80 return self.priority < other.priority
5b5e7190452f Fix various registry Entry `__lt__` methods. This resolves issue #221.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1613
diff changeset
81 return self.itemtype < other.itemtype
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
82 return NotImplemented
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
83
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
84 def register(self, factory, itemtype, priority=RegistryBase.PRIORITY_MIDDLE):
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
85 """
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
86 Register a factory
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
87
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
88 :param factory: Factory to register. Callable, must return an object.
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
89 """
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
90 return self._register(self.Entry(factory, itemtype, priority))
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
91
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
92
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
93 item_registry = RegistryItem()
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
94
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
95 def register(cls):
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
96 item_registry.register(cls._factory, cls.itemtype)
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
97 return cls
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
98
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
99
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
100 class DummyRev(dict):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
101 """ if we have no stored Revision, we use this dummy """
1672
c093039ac8a5 items/__init__.py: DummyRev.__init__: Add default values for itemtype and
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1670
diff changeset
102 def __init__(self, item, itemtype=None, contenttype=None):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
103 self.item = item
1672
c093039ac8a5 items/__init__.py: DummyRev.__init__: Add default values for itemtype and
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1670
diff changeset
104 self.meta = {
c093039ac8a5 items/__init__.py: DummyRev.__init__: Add default values for itemtype and
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1670
diff changeset
105 ITEMTYPE: itemtype or u'nonexistent',
c093039ac8a5 items/__init__.py: DummyRev.__init__: Add default values for itemtype and
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1670
diff changeset
106 CONTENTTYPE: contenttype or u'application/x-nonexistent'
c093039ac8a5 items/__init__.py: DummyRev.__init__: Add default values for itemtype and
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1670
diff changeset
107 }
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
108 self.data = StringIO('')
891
d90782ad8b24 instead of parent revno (int), we give parent revid (str) now
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 890
diff changeset
109 self.revid = None
1672
c093039ac8a5 items/__init__.py: DummyRev.__init__: Add default values for itemtype and
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1670
diff changeset
110 if self.item:
c093039ac8a5 items/__init__.py: DummyRev.__init__: Add default values for itemtype and
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1670
diff changeset
111 self.meta[NAME] = self.item.name
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
112
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
113
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
114 class DummyItem(object):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
115 """ if we have no stored Item, we use this dummy """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
116 def __init__(self, name):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
117 self.name = name
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
118 def list_revisions(self):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
119 return [] # same as an empty Item
1180
1c5a013b9ebd Fix the three failing tests.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1152
diff changeset
120 def destroy_all_revisions(self):
1c5a013b9ebd Fix the three failing tests.
Bilal Akhtar <bilalakhtar@ubuntu.com>
parents: 1152
diff changeset
121 return True
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
122
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
123
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
124 class BaseChangeForm(TextChaizedForm):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
125 comment = OptionalText.using(label=L_('Comment')).with_properties(placeholder=L_("Comment about your change"))
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
126 submit = Submit
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
127
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
128
1624
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
129 class BaseMetaForm(Form):
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
130 itemtype = RequiredText.using(label=L_("Item type")).with_properties(placeholder=L_("Item type"))
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
131 contenttype = RequiredText.using(label=L_("Content type")).with_properties(placeholder=L_("Content type"))
1627
b0b73fe90f3d Remove wikiname, disable ACL in metadata editor
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1626
diff changeset
132 # Disabled - Flatland doesn't distinguish emtpy value and nonexistent
b0b73fe90f3d Remove wikiname, disable ACL in metadata editor
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1626
diff changeset
133 # value, while an emtpy acl and no acl have different semantics
b0b73fe90f3d Remove wikiname, disable ACL in metadata editor
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1626
diff changeset
134 #acl = OptionalText.using(label=L_('ACL')).with_properties(placeholder=L_("Access Control List"))
1624
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
135 summary = OptionalText.using(label=L_("Summary")).with_properties(placeholder=L_("One-line summary of the item"))
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
136 tags = Tags
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
137
1626
346c52c9c1e5 Fixes to forms.py and items/__init__.py
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1625
diff changeset
138
1677
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
139 class BaseModifyForm(BaseChangeForm):
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
140 @classmethod
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
141 def from_item(cls, item):
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
142 form = cls.from_defaults()
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
143 TextCha(form).amend_form()
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
144 form._load(item)
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
145 return form
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
146
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
147 @classmethod
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
148 def from_request(cls, request):
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
149 form = cls.from_flat(request.form.items() + request.files.items())
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
150 TextCha(form).amend_form()
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
151 return form
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
152
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
153
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
154 class Item(object):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
155 """ Highlevel (not storage) Item, wraps around a storage Revision"""
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
156 @classmethod
1613
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
157 def _factory(cls, *args, **kw):
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
158 return cls(*args, **kw)
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
159
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
160 @classmethod
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
161 def create(cls, name=u'', itemtype=None, contenttype=None, rev_id=CURRENT, item=None):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
162 """
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
163 Create a highlevel Item by looking up :name or directly wrapping
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
164 :item and extract the Revision designated by :rev_id revision.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
165
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
166 The highlevel Item is created by creating an instance of Content
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
167 subclass according to the item's contenttype metadata entry; The
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
168 :contenttype argument can be used to override contenttype. It is used
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
169 only when handling +convert (when deciding the contenttype of target
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
170 item), +modify (when creating a new item whose contenttype is not yet
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
171 decided), +diff and +diffraw (to coerce the Content to a common
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
172 super-contenttype of both revisions).
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
173
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
174 After that the Content instance, an instance of Item subclass is
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
175 created according to the item's itemtype metadata entry, and the
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
176 previously created Content instance is assigned to its content
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
177 property.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
178 """
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
179 if 1: # try:
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
180 if item is None:
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
181 item = flaskg.storage[name]
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
182 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
183 name = item.name
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
184 if not item: # except NoSuchItemError:
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
185 logging.debug("No such item: {0!r}".format(name))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
186 item = DummyItem(name)
1650
07b2146ba96f Store `itemtype` metadata entry in DummyRev so that newly created items have
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1649
diff changeset
187 rev = DummyRev(item, itemtype, contenttype)
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
188 logging.debug("Item {0!r}, created dummy revision with contenttype {1!r}".format(name, contenttype))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
189 else:
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
190 logging.debug("Got item: {0!r}".format(name))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
191 try:
905
51475954290f rename all revno usages to revid (no numbers any more), remove update_item param
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 904
diff changeset
192 rev = item.get_revision(rev_id)
415
d755f798fe66 fix some tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 402
diff changeset
193 contenttype = u'application/octet-stream' # it exists
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
194 itemtype = u'default' # default itemtype to u'default' for compatibility
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
195 except KeyError: # NoSuchRevisionError:
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
196 try:
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
197 rev = item.get_revision(CURRENT) # fall back to current revision
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
198 # XXX add some message about invalid revision
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
199 except KeyError: # NoSuchRevisionError:
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
200 logging.debug("Item {0!r} has no revisions.".format(name))
1650
07b2146ba96f Store `itemtype` metadata entry in DummyRev so that newly created items have
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1649
diff changeset
201 rev = DummyRev(item, itemtype, contenttype)
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
202 logging.debug("Item {0!r}, created dummy revision with contenttype {1!r}".format(name, contenttype))
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
203 logging.debug("Got item {0!r}, revision: {1!r}".format(name, rev_id))
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
204 contenttype = rev.meta.get(CONTENTTYPE) or contenttype # use contenttype in case our metadata does not provide CONTENTTYPE
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
205 logging.debug("Item {0!r}, got contenttype {1!r} from revision meta".format(name, contenttype))
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
206 #logging.debug("Item %r, rev meta dict: %r" % (name, dict(rev.meta)))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
207
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
208 # XXX Cannot pass item=item to Content.__init__ via
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
209 # content_registry.get yet, have to patch it later.
1648
1a2c53092ea1 items/content.py: Implement Content.create.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1631
diff changeset
210 content = Content.create(contenttype)
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
211
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
212 itemtype = rev.meta.get(ITEMTYPE) or itemtype
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
213 logging.debug("Item {0!r}, got itemtype {1!r} from revision meta".format(name, itemtype))
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
214
1613
bc8a2546468b Clean up registry code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1460
diff changeset
215 item = item_registry.get(itemtype, name, rev=rev, content=content)
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
216 logging.debug("Item class {0!r} handles {1!r}".format(item.__class__, itemtype))
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
217
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
218 content.item = item
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
219
225
bac248bcf98c use a Item/contenttype registry to get the right Item subclass
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 221
diff changeset
220 return item
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
221
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
222 def __init__(self, name, rev=None, content=None):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
223 self.name = name
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
224 self.rev = rev
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
225 self.content = content
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
226
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
227 def get_meta(self):
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
228 return self.rev.meta
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
229 meta = property(fget=get_meta)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
230
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
231 # XXX Backward compatibility, remove soon
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
232 @property
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
233 def contenttype(self):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
234 return self.content.contenttype if self.content else None
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
235
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
236 def _render_meta(self):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
237 return "<pre>{0}</pre>".format(escape(self.meta_dict_to_text(self.meta, use_filter=False)))
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
238
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
239 def meta_filter(self, meta):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
240 """ kill metadata entries that we set automatically when saving """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
241 kill_keys = [# shall not get copied from old rev to new rev
1019
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
242 SYSITEM_VERSION,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
243 NAME_OLD,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
244 # are automatically implanted when saving
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
245 NAME,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
246 ITEMID, REVID, DATAID,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
247 HASH_ALGORITHM,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
248 SIZE,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
249 COMMENT,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
250 MTIME,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
251 ACTION,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
252 ADDRESS, HOSTNAME, USERID,
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
253 ]
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
254 for key in kill_keys:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
255 meta.pop(key, None)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
256 return meta
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
257
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
258 def meta_text_to_dict(self, text):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
259 """ convert meta data from a text fragment to a dict """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
260 meta = json.loads(text)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
261 return self.meta_filter(meta)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
262
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
263 def meta_dict_to_text(self, meta, use_filter=True):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
264 """ convert meta data from a dict to a text fragment """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
265 meta = dict(meta)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
266 if use_filter:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
267 meta = self.meta_filter(meta)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
268 return json.dumps(meta, sort_keys=True, indent=2, ensure_ascii=False)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
269
892
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
270 def prepare_meta_for_modify(self, meta):
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
271 """
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
272 transform the meta dict of the current revision into a meta dict
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
273 that can be used for savind next revision (after "modify").
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
274 """
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
275 meta = dict(meta)
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
276 revid = meta.pop(REVID, None)
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
277 if revid is not None:
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
278 meta[PARENTID] = revid
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
279 return meta
79f80ce3cf78 implement parents (key PARENTID), add it to index schema
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 891
diff changeset
280
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
281 def _rename(self, name, comment, action):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
282 self._save(self.meta, self.content.data, name=name, action=action, comment=comment)
1019
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
283 for child in self.get_index():
afe0afe4e1a6 recursive rename
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 993
diff changeset
284 item = Item.create(child[0])
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
285 item._save(item.meta, item.content.data, name='/'.join((name, child[1])), action=action, comment=comment)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
286
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
287 def rename(self, name, comment=u''):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
288 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
289 rename this item to item <name>
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
290 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
291 return self._rename(name, comment, action=u'RENAME')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
292
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
293 def delete(self, comment=u''):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
294 """
904
46263060782e remove references to "trash" (is an implementation detail and might change)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 903
diff changeset
295 delete this item
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
296 """
903
50aa61c9b952 fixed rename issue: do not use the new name to load the item, but the old one
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 902
diff changeset
297 trash_prefix = u'Trash/' # XXX move to config
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
298 now = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime())
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
299 # make trash name unique by including timestamp:
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
300 trashname = u'{0}{1} ({2} UTC)'.format(trash_prefix, self.name, now)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
301 return self._rename(trashname, comment, action=u'TRASH')
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
302
1407
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
303 def revert(self, comment=u''):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
304 return self._save(self.meta, self.content.data, action=u'REVERT', comment=comment)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
305
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
306 def destroy(self, comment=u'', destroy_item=False):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
307 # called from destroy UI/POST
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
308 if destroy_item:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
309 # destroy complete item with all revisions, metadata, etc.
910
5b7e522d97af fix destroy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 908
diff changeset
310 self.rev.item.destroy_all_revisions()
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
311 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
312 # just destroy this revision
910
5b7e522d97af fix destroy
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 908
diff changeset
313 self.rev.item.destroy_revision(self.rev.revid)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
314
1407
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
315 def modify(self, meta, data, comment=u'', contenttype_guessed=None, contenttype_qs=None):
236
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
316 if contenttype_qs:
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
317 # we use querystring param to FORCE content type
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
318 meta[CONTENTTYPE] = contenttype_qs
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
319
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
320 return self._save(meta, data, contenttype_guessed=contenttype_guessed, comment=comment)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
321
1677
d74b9e4d41e5 items/__init__.py: Split helper methods from_item and from_requst in
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1676
diff changeset
322 class _ModifyForm(BaseModifyForm):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
323 """Base class for ModifyForm of Item subclasses."""
1624
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
324 meta_form = BaseMetaForm
1625
6748d609a242 forms.py: Create JSON widget
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1624
diff changeset
325 extra_meta_text = JSON.using(label=L_("Extra MetaData (JSON)")).with_properties(rows=ROWS_META, cols=COLS)
1624
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
326 meta_template = 'modify_meta.html'
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
327
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
328 def _load(self, item):
1624
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
329 meta = item.prepare_meta_for_modify(item.meta)
1630
24c1a4b29c86 items/__init__.py: comment policy='duck' argument passed to Flatland.Dict.set
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1629
diff changeset
330 # Default value of `policy` argument of Flatland.Dict.set's is
24c1a4b29c86 items/__init__.py: comment policy='duck' argument passed to Flatland.Dict.set
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1629
diff changeset
331 # 'strict', which causes KeyError to be thrown when meta contains
24c1a4b29c86 items/__init__.py: comment policy='duck' argument passed to Flatland.Dict.set
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1629
diff changeset
332 # meta keys that are not present in self['meta_form']. Setting
24c1a4b29c86 items/__init__.py: comment policy='duck' argument passed to Flatland.Dict.set
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1629
diff changeset
333 # policy to 'duck' suppresses this behavior.
24c1a4b29c86 items/__init__.py: comment policy='duck' argument passed to Flatland.Dict.set
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1629
diff changeset
334 self['meta_form'].set(meta, policy='duck')
1624
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
335 for k in self['meta_form'].field_schema_mapping.keys():
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
336 meta.pop(k, None)
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
337 self['extra_meta_text'].set(item.meta_dict_to_text(meta))
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
338 self['content_form']._load(item.content)
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
339
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
340 def _dump(self, item):
1624
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
341 meta = self['meta_form'].value.copy()
c6974ba2e2b2 Widget-based metadata editor.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1614
diff changeset
342 meta.update(item.meta_text_to_dict(self['extra_meta_text'].value))
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
343 data, contenttype_guessed = self['content_form']._dump(item.content)
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
344 comment = self['comment'].value
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
345 return meta, data, contenttype_guessed, comment
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
346
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
347 def do_modify(self):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
348 """
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
349 Handle +modify requests, both GET and POST.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
350
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
351 This method should be overridden in subclasses, providing polymorphic
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
352 behavior for the +modify view.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
353 """
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
354 raise NotImplementedError
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
355
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
356 def _save(self, meta, data=None, name=None, action=u'SAVE', contenttype_guessed=None, comment=u'', overwrite=False):
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
357 backend = flaskg.storage
903
50aa61c9b952 fixed rename issue: do not use the new name to load the item, but the old one
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 902
diff changeset
358 storage_item = backend[self.name]
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
359 try:
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
360 currentrev = storage_item.get_revision(CURRENT)
905
51475954290f rename all revno usages to revid (no numbers any more), remove update_item param
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 904
diff changeset
361 rev_id = currentrev.revid
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
362 contenttype_current = currentrev.meta.get(CONTENTTYPE)
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
363 except KeyError: # XXX was: NoSuchRevisionError:
241
f464adcc3a51 fix saving no data if no previous revision exists
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 236
diff changeset
364 currentrev = None
905
51475954290f rename all revno usages to revid (no numbers any more), remove update_item param
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 904
diff changeset
365 rev_id = None
236
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
366 contenttype_current = None
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
367
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
368 meta = dict(meta) # we may get a read-only dict-like, copy it
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
369
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
370 # we store the previous (if different) and current item name into revision metadata
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
371 # this is useful for rename history and backends that use item uids internally
903
50aa61c9b952 fixed rename issue: do not use the new name to load the item, but the old one
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 902
diff changeset
372 if name is None:
50aa61c9b952 fixed rename issue: do not use the new name to load the item, but the old one
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 902
diff changeset
373 name = self.name
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
374 oldname = meta.get(NAME)
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
375 if oldname and oldname != name:
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
376 meta[NAME_OLD] = oldname
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
377 meta[NAME] = name
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
378
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
379 if comment:
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
380 meta[COMMENT] = unicode(comment)
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
381
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
382 if not overwrite and REVID in meta:
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
383 # we usually want to create a new revision, thus we must remove the existing REVID
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
384 del meta[REVID]
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
385
236
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
386 if data is None:
241
f464adcc3a51 fix saving no data if no previous revision exists
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 236
diff changeset
387 if currentrev is not None:
f464adcc3a51 fix saving no data if no previous revision exists
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 236
diff changeset
388 # we don't have (new) data, just copy the old one.
f464adcc3a51 fix saving no data if no previous revision exists
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 236
diff changeset
389 # a valid usecase of this is to just edit metadata.
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
390 data = currentrev.data
241
f464adcc3a51 fix saving no data if no previous revision exists
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 236
diff changeset
391 else:
f464adcc3a51 fix saving no data if no previous revision exists
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 236
diff changeset
392 data = ''
236
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
393
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
394 if isinstance(data, unicode):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
395 data = data.encode(charset) # XXX wrong! if contenttype gives a coding, we MUST use THAT.
236
7a77ae08161e items: cleanup contenttype handling in modify/_save, see below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 225
diff changeset
396
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
397 if isinstance(data, str):
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
398 data = StringIO(data)
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
399
1266
1c66f39aa44f implement validation for revision metadata storage using flatland
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1236
diff changeset
400 newrev = storage_item.store_revision(meta, data, overwrite=overwrite,
1c66f39aa44f implement validation for revision metadata storage using flatland
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1236
diff changeset
401 action=unicode(action),
1c66f39aa44f implement validation for revision metadata storage using flatland
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1236
diff changeset
402 contenttype_current=contenttype_current,
1c66f39aa44f implement validation for revision metadata storage using flatland
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1236
diff changeset
403 contenttype_guessed=contenttype_guessed,
1c66f39aa44f implement validation for revision metadata storage using flatland
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1236
diff changeset
404 )
242
e93157b8b0bd refactor modify views to use flatland, see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 241
diff changeset
405 item_modified.send(app._get_current_object(), item_name=name)
905
51475954290f rename all revno usages to revid (no numbers any more), remove update_item param
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 904
diff changeset
406 return newrev.revid, newrev.meta[SIZE]
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
407
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
408 def get_index(self):
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
409 """ create an index of sub items of this item """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
410 if self.name:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
411 prefix = self.name + u'/'
827
94e388cd4e28 use 'constants' for metadata keys / whoosh field names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 794
diff changeset
412 query = And([Term(WIKINAME, app.cfg.interwikiname), Prefix(NAME_EXACT, prefix)])
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
413 else:
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
414 # trick: an item of empty name can be considered as "virtual root item",
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
415 # that has all wiki items as sub items
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
416 prefix = u''
827
94e388cd4e28 use 'constants' for metadata keys / whoosh field names
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 794
diff changeset
417 query = Term(WIKINAME, app.cfg.interwikiname)
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
418 # We only want the sub-item part of the item names, not the whole item objects.
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
419 prefix_len = len(prefix)
953
326f7a365007 search/indexing: remove all_revs=False params (it is the default)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 910
diff changeset
420 revs = flaskg.storage.search(query, sortedby=NAME_EXACT, limit=None)
852
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
421 items = [(rev.meta[NAME], rev.meta[NAME][prefix_len:], rev.meta[CONTENTTYPE])
5ad4ae0b1e09 lots of fixes / adaptions for storage-ng code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 827
diff changeset
422 for rev in revs]
780
f5e0f85e66ce whooshify get_index()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 779
diff changeset
423 return items
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
424
993
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
425 def _connect_levels(self, index):
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
426 new_index = []
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
427 last = self.name
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
428 for item in index:
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
429 name = item[0]
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
430
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
431 while not name.startswith(last):
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
432 last = last.rpartition('/')[0]
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
433
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
434 missing_layers = name.split('/')[last.count('/')+1:-1]
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
435
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
436 for layer in missing_layers:
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
437 last = '/'.join([last, layer])
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
438 new_index.append((last, last[len(self.name)+1:], u'application/x-nonexistent'))
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
439
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
440 last = item[0]
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
441 new_index.append(item)
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
442
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
443 return new_index
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
444
486
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
445 def flat_index(self, startswith=None, selected_groups=None):
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
446 """
993
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
447 creates a top level index of sub items of this item
486
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
448 if startswith is set, filtering is done on the basis of starting letter of item name
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
449 if selected_groups is set, items whose contentype belonging to the selected contenttype_groups, are filtered.
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
450 """
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
451 index = self.get_index()
993
6dd0b0755b6a disconnected levels now shown in index, fixes #75
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 969
diff changeset
452 index = self._connect_levels(index)
486
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
453
496
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
454 all_ctypes = [[ctype for ctype, clabel in contenttypes]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
455 for gname, contenttypes in CONTENTTYPE_GROUPS]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
456 all_ctypes_chain = itertools.chain(*all_ctypes)
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
457 all_contenttypes = list(all_ctypes_chain)
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
458 contenttypes_without_encoding = [contenttype[:contenttype.index(u';')]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
459 for contenttype in all_contenttypes
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
460 if u';' in contenttype]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
461 all_contenttypes.extend(contenttypes_without_encoding) # adding more mime-types without the encoding term
486
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
462
496
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
463 if selected_groups:
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
464 ctypes = [[ctype for ctype, clabel in contenttypes]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
465 for gname, contenttypes in CONTENTTYPE_GROUPS
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
466 if gname in selected_groups]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
467 ctypes_chain = itertools.chain(*ctypes)
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
468 selected_contenttypes = list(ctypes_chain)
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
469 contenttypes_without_encoding = [contenttype[:contenttype.index(u';')]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
470 for contenttype in selected_contenttypes
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
471 if u';' in contenttype]
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
472 selected_contenttypes.extend(contenttypes_without_encoding)
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
473 else:
a286df67f294 contenttype filter code updated, due to lack of encoding information for uploaded files, some extra checks have been added.
Akash Sinha <akash2607@gmail.com>
parents: 492
diff changeset
474 selected_contenttypes = all_contenttypes
486
b6149c732926 contenttype filtering added to global index page
Akash Sinha <akash2607@gmail.com>
parents: 484
diff changeset
475
518
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
476 unknown_item_group = "unknown items"
477
72899d48db41 alphabetic listing of global index, with link to item index
Akash Sinha <akash2607@gmail.com>
parents: 257
diff changeset
477 if startswith:
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
478 startswith = (u'{0}'.format(startswith), u'{0}'.format(startswith.swapcase()))
520
6332dda59cb6 some pep8 fixes
Akash Sinha <akash2607@gmail.com>
parents: 518
diff changeset
479 if not selected_groups or unknown_item_group in selected_groups:
518
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
480 index = [(fullname, relname, contenttype)
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
481 for fullname, relname, contenttype in index
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
482 if u'/' not in relname
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
483 and relname.startswith(startswith)
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
484 and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
485 # If an item's contenttype not present in the default contenttype list,
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
486 # then it will be shown without going through any filter.
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
487 else:
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
488 index = [(fullname, relname, contenttype)
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
489 for fullname, relname, contenttype in index
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
490 if u'/' not in relname
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
491 and relname.startswith(startswith)
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
492 and (contenttype in selected_contenttypes)]
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
493
477
72899d48db41 alphabetic listing of global index, with link to item index
Akash Sinha <akash2607@gmail.com>
parents: 257
diff changeset
494 else:
518
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
495 if not selected_groups or unknown_item_group in selected_groups:
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
496 index = [(fullname, relname, contenttype)
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
497 for fullname, relname, contenttype in index
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
498 if u'/' not in relname
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
499 and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
500 else:
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
501 index = [(fullname, relname, contenttype)
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
502 for fullname, relname, contenttype in index
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
503 if u'/' not in relname
0398d1eb14c1 small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
Akash Sinha <akash2607@gmail.com>
parents: 510
diff changeset
504 and contenttype in selected_contenttypes]
477
72899d48db41 alphabetic listing of global index, with link to item index
Akash Sinha <akash2607@gmail.com>
parents: 257
diff changeset
505
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
506 return index
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
507
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
508 index_template = 'index.html'
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
509
484
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
510 def get_detailed_index(self, index):
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
511 """ appends a flag in the index of items indicating that the parent has sub items """
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
512 detailed_index = []
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
513 all_item_index = self.get_index()
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
514 all_item_text = "\n".join(item_info[1] for item_info in all_item_index)
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
515 for fullname, relname, contenttype in index:
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
516 hassubitem = False
969
5bf6d7a2ffcf Convert all %r, %s, %x, %d, %i, %o to new Format String Syntax
Vedran Mileti? <rivanvx@gmail.com>
parents: 957
diff changeset
517 subitem_name_re = u"^{0}/[^/]+$".format(re.escape(relname))
524
77a9bd2d3dc8 regex search function updated, to get the subitem flag correctly
Akash Sinha <akash2607@gmail.com>
parents: 520
diff changeset
518 regex = re.compile(subitem_name_re, re.UNICODE|re.M)
484
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
519 if regex.search(all_item_text):
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
520 hassubitem = True
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
521 detailed_index.append((fullname, relname, contenttype, hassubitem))
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
522 return detailed_index
19b257c0e102 code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
Akash Sinha <akash2607@gmail.com>
parents: 477
diff changeset
523
477
72899d48db41 alphabetic listing of global index, with link to item index
Akash Sinha <akash2607@gmail.com>
parents: 257
diff changeset
524 def name_initial(self, names=None):
72899d48db41 alphabetic listing of global index, with link to item index
Akash Sinha <akash2607@gmail.com>
parents: 257
diff changeset
525 initials = [(name[1][0])
72899d48db41 alphabetic listing of global index, with link to item index
Akash Sinha <akash2607@gmail.com>
parents: 257
diff changeset
526 for name in names]
72899d48db41 alphabetic listing of global index, with link to item index
Akash Sinha <akash2607@gmail.com>
parents: 257
diff changeset
527 return initials
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
528
1003
8621c3e273a1 fixes #72. Implements the page to handle 404 error, and calls abort(404) in some view, when apropriate.
Bruno Martin <bruno@hacklab.com.br>
parents: 969
diff changeset
529 delete_template = 'delete.html'
8621c3e273a1 fixes #72. Implements the page to handle 404 error, and calls abort(404) in some view, when apropriate.
Bruno Martin <bruno@hacklab.com.br>
parents: 969
diff changeset
530 destroy_template = 'destroy.html'
8621c3e273a1 fixes #72. Implements the page to handle 404 error, and calls abort(404) in some view, when apropriate.
Bruno Martin <bruno@hacklab.com.br>
parents: 969
diff changeset
531 diff_template = 'diff.html'
8621c3e273a1 fixes #72. Implements the page to handle 404 error, and calls abort(404) in some view, when apropriate.
Bruno Martin <bruno@hacklab.com.br>
parents: 969
diff changeset
532 rename_template = 'rename.html'
8621c3e273a1 fixes #72. Implements the page to handle 404 error, and calls abort(404) in some view, when apropriate.
Bruno Martin <bruno@hacklab.com.br>
parents: 969
diff changeset
533 revert_template = 'revert.html'
8621c3e273a1 fixes #72. Implements the page to handle 404 error, and calls abort(404) in some view, when apropriate.
Bruno Martin <bruno@hacklab.com.br>
parents: 969
diff changeset
534
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
535
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
536 class Contentful(Item):
245
52ca5dc1ab15 add a JSON validator, use it to validate meta_text
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 244
diff changeset
537 """
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
538 Base class for Item subclasses that have content.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
539 """
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
540 @property
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
541 def ModifyForm(self):
1653
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
542 class C(self._ModifyForm):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
543 content_form = self.content.ModifyForm
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
544 C.__name__ = 'ModifyForm'
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
545 return C
1420
100197cb69ab Convert Flatland forms to contain rendering hints.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1408
diff changeset
546
100197cb69ab Convert Flatland forms to contain rendering hints.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1408
diff changeset
547
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
548 @register
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
549 class Default(Contentful):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
550 """
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
551 A "conventional" wiki item.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
552 """
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
553 itemtype = u'default'
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
554
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
555 def _do_modify_show_templates(self):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
556 # call this if the item is still empty
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
557 rev_ids = []
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
558 item_templates = self.content.get_templates(self.contenttype)
1460
157d41b326b1 Rename modify_show_*_selection.html templates to modify_select_*.html
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1456
diff changeset
559 return render_template('modify_select_template.html',
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
560 item_name=self.name,
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
561 itemtype=self.itemtype,
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
562 rev=self.rev,
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
563 contenttype=self.contenttype,
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
564 templates=item_templates,
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
565 first_rev_id=rev_ids and rev_ids[0],
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
566 last_rev_id=rev_ids and rev_ids[-1],
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
567 meta_rendered='',
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
568 data_rendered='',
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
569 )
242
e93157b8b0bd refactor modify views to use flatland, see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 241
diff changeset
570
1662
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
571 def do_show(self, revid):
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
572 show_revision = revid != CURRENT
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
573 show_navigation = False # TODO
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
574 first_rev = last_rev = None # TODO
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
575 return render_template(self.show_template,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
576 item=self, item_name=self.name,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
577 rev=self.rev,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
578 contenttype=self.contenttype,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
579 first_rev_id=first_rev,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
580 last_rev_id=last_rev,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
581 data_rendered=Markup(self.content._render_data()),
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
582 show_revision=show_revision,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
583 show_navigation=show_navigation,
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
584 )
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
585
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
586 def do_modify(self):
1407
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
587 method = request.method
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
588 if method == 'GET':
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
589 if isinstance(self.content, NonExistentContent):
1460
157d41b326b1 Rename modify_show_*_selection.html templates to modify_select_*.html
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1456
diff changeset
590 return render_template('modify_select_contenttype.html',
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
591 item_name=self.name,
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
592 itemtype=self.itemtype,
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
593 contenttype_groups=CONTENTTYPE_GROUPS,
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
594 )
1407
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
595 item = self
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
596 if isinstance(self.rev, DummyRev):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
597 template_name = request.values.get('template')
1407
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
598 if template_name is None:
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
599 return self._do_modify_show_templates()
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
600 elif template_name:
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
601 item = Item.create(template_name)
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
602 form = self.ModifyForm.from_item(item)
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
603 elif method == 'POST':
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
604 # XXX workaround for *Draw items
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
605 if isinstance(self.content, Draw):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
606 try:
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
607 self.content.handle_post()
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
608 except AccessDenied:
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
609 abort(403)
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
610 else:
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
611 # *Draw Applets POSTs more than once, redirecting would
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
612 # break them
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
613 return "OK"
1407
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
614 form = self.ModifyForm.from_request(request)
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
615 if form.validate():
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
616 meta, data, contenttype_guessed, comment = form._dump(self)
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
617 contenttype_qs = request.values.get('contenttype')
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
618 try:
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
619 self.modify(meta, data, comment, contenttype_guessed, contenttype_qs)
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
620 except AccessDenied:
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
621 abort(403)
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
622 else:
8bbdf554e812 Cleanups and fixes for the items module.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1397
diff changeset
623 return redirect(url_for_item(self.name))
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
624 return render_template(self.modify_template,
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
625 item_name=self.name,
242
e93157b8b0bd refactor modify views to use flatland, see details below
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 241
diff changeset
626 rows_meta=str(ROWS_META), cols=str(COLS),
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
627 form=form,
1229
29301b8a2718 Hide search box in modify views.
Sam Toyer <samATqxcvDOTnet>
parents: 1214
diff changeset
628 search_form=None,
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
629 )
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
630
1662
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
631 show_template = 'show.html'
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
632 modify_template = 'modify.html'
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
633
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
634
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
635 @register
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
636 class Userprofile(Item):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
637 """
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
638 Currently userprofile is implemented as a contenttype. This is a stub of an
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
639 itemtype implementation of userprofile.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
640 """
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
641 itemtype = u'userprofile'
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
642
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
643
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
644 @register
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
645 class NonExistent(Item):
1649
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
646 """
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
647 A dummy Item for nonexistent items (when modifying, a nonexistent item with
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
648 undetermined itemtype)
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
649 """
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
650 itemtype = u'nonexistent'
5dc142ab43d2 Keep itemtype and contenttype in Item and Content subclasses.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1648
diff changeset
651
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
652 def _convert(self, doc):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
653 abort(404)
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
654
1662
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
655 def do_show(self, revid):
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
656 # First, check if the current user has the required privileges
1670
d3a1a3e7075f items.NonExistent.do_show should always return 404 status code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1667
diff changeset
657 if flaskg.user.may.create(self.name):
d3a1a3e7075f items.NonExistent.do_show should always return 404 status code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1667
diff changeset
658 content = self._select_itemtype()
d3a1a3e7075f items.NonExistent.do_show should always return 404 status code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1667
diff changeset
659 else:
d3a1a3e7075f items.NonExistent.do_show should always return 404 status code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1667
diff changeset
660 content = render_template('show_nonexistent.html',
d3a1a3e7075f items.NonExistent.do_show should always return 404 status code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1667
diff changeset
661 item_name=self.name,
d3a1a3e7075f items.NonExistent.do_show should always return 404 status code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1667
diff changeset
662 )
d3a1a3e7075f items.NonExistent.do_show should always return 404 status code.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1667
diff changeset
663 return Response(content, 404)
1662
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
664
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
665 def do_modify(self):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
666 # First, check if the current user has the required privileges
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
667 if not flaskg.user.may.create(self.name):
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
668 abort(403)
1662
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
669 return self._select_itemtype()
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
670
1662
465b22852fae Let Item subclasses handle +show.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1650
diff changeset
671 def _select_itemtype(self):
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
672 # TODO Construct this list from the item_registry. Two more fields (ie.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
673 # display name and description) are needed in the registry then to
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
674 # support the automatic construction.
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
675 ITEMTYPES = [
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
676 (u'default', u'Default', 'Wiki item'),
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
677 (u'ticket', u'Ticket', 'Ticket item'),
1653
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
678 (u'blog', u'Blog', 'Blog item'),
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
679 (u'blogentry', u'Blog entry', 'Blog entry item'),
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
680 ]
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
681
1460
157d41b326b1 Rename modify_show_*_selection.html templates to modify_select_*.html
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1456
diff changeset
682 return render_template('modify_select_itemtype.html',
1451
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
683 item_name=self.name,
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
684 itemtypes=ITEMTYPES,
c32ff2e07e7a Introduce itemtype.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1421
diff changeset
685 )
1653
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
686
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
687
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
688 # TODO: move into a separate items/blog.py module
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
689 class BlogMetaForm(BaseMetaForm):
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
690 supertags = (Tags.using(label=L_('Supertags (Categories)'))
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
691 .with_properties(placeholder=L_("Ordered comma separated list of tags")))
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
692
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
693 class BlogEntryMetaForm(BaseMetaForm):
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
694 summary = (OptionalText.using(label=L_("Title"))
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
695 .with_properties(placeholder=L_("One-line title of the blog entry")))
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
696 ptime = DateTime.using(label=L_('Publication time (UTC)'), optional=True)
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
697
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
698 @register
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
699 class Blog(Default):
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
700 itemtype = u'blog'
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
701
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
702 class _ModifyForm(Default._ModifyForm):
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
703 meta_form = BlogMetaForm
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
704 meta_template = 'modify_blog_meta.html'
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
705
1675
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
706 def do_show(self, revid):
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
707 """
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
708 Show a blog item and a list of its blog entries below it.
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
709
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
710 If tag GET-parameter is defined, the list of blog entries consists only
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
711 of those entries that contain the tag value in their lists of tags.
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
712 """
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
713 # for now it is just one tag=value, later it could be tag=value1&tag=value2&...
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
714 tag = request.values.get('tag')
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
715 prefix = self.name + u'/'
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
716 current_timestamp = int(time.time())
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
717 terms = [Term(WIKINAME, app.cfg.interwikiname),
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
718 # Only sub items of this item
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
719 Prefix(NAME_EXACT, prefix),
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
720 # Filter out those items that do not have a PTIME meta or PTIME is in the future.
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
721 DateRange(PTIME, start=None, end=datetime.utcfromtimestamp(current_timestamp)),
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
722 ]
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
723 if tag:
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
724 terms.append(Term(TAGS, tag))
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
725 query = And(terms)
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
726 revs = flaskg.storage.search(query, sortedby=[PTIME], reverse=True, limit=None)
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
727 blog_entry_items = [Item.create(rev.meta[NAME], rev_id=rev.revid) for rev in revs]
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
728 return render_template('blog.html',
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
729 item_name=self.name,
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
730 blog_item=self,
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
731 blog_entry_items=blog_entry_items,
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
732 tag=tag,
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
733 )
1653
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
734
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
735 @register
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
736 class BlogEntry(Default):
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
737 itemtype = u'blogentry'
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
738
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
739 class _ModifyForm(Default._ModifyForm):
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
740 meta_form = BlogEntryMetaForm
57e864bb8852 Add the ability to create new Blog and Blog entry items.
Pavel Sviderski <pavel@psviderski.name>
parents: 1650
diff changeset
741 meta_template = 'modify_blog_entry_meta.html'
1667
0104f76e30d0 items/__init__.py: Remove Ticket stub and call load_package_modules there.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1665
diff changeset
742
1675
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
743 def do_show(self, revid):
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
744 blog_item_name = self.name.rsplit('/', 1)[0]
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
745 try:
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
746 blog_item = Item.create(blog_item_name)
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
747 except AccessDenied:
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
748 abort(403)
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
749 if not isinstance(blog_item, Blog):
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
750 # The parent item of this blog entry item is not a Blog item.
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
751 abort(403)
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
752 return render_template('blog_entry.html',
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
753 item_name=self.name,
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
754 blog_item=blog_item,
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
755 blog_entry_item=self,
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
756 )
b0ba46ffe914 Let Blog and BlogEntry classes handle +show view.
Pavel Sviderski <pavel@psviderski.name>
parents: 1670
diff changeset
757
1667
0104f76e30d0 items/__init__.py: Remove Ticket stub and call load_package_modules there.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1665
diff changeset
758
0104f76e30d0 items/__init__.py: Remove Ticket stub and call load_package_modules there.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1665
diff changeset
759 from ..util.pysupport import load_package_modules
0104f76e30d0 items/__init__.py: Remove Ticket stub and call load_package_modules there.
Cheer Xiao <xiaqqaix@gmail.com>
parents: 1665
diff changeset
760 load_package_modules(__name__, __path__)