comparison MoinMoin/items/__init__.py @ 891:d90782ad8b24 storage-ng

instead of parent revno (int), we give parent revid (str) now
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 26 Sep 2011 17:51:13 +0200
parents 9c862a0aee26
children 79f80ce3cf78
comparison
equal deleted inserted replaced
890:9c862a0aee26 891:d90782ad8b24
147 """ if we have no stored Revision, we use this dummy """ 147 """ if we have no stored Revision, we use this dummy """
148 def __init__(self, item, contenttype): 148 def __init__(self, item, contenttype):
149 self.item = item 149 self.item = item
150 self.meta = {CONTENTTYPE: contenttype} 150 self.meta = {CONTENTTYPE: contenttype}
151 self.data = StringIO('') 151 self.data = StringIO('')
152 self.revid = '' 152 self.revid = None
153 153
154 154
155 class DummyItem(object): 155 class DummyItem(object):
156 """ if we have no stored Item, we use this dummy """ 156 """ if we have no stored Item, we use this dummy """
157 def __init__(self, name): 157 def __init__(self, name):
671 # XXX think about and add item template support 671 # XXX think about and add item template support
672 #if template_name is None and isinstance(self.rev, DummyRev): 672 #if template_name is None and isinstance(self.rev, DummyRev):
673 # return self._do_modify_show_templates() 673 # return self._do_modify_show_templates()
674 from MoinMoin.apps.frontend.views import CommentForm 674 from MoinMoin.apps.frontend.views import CommentForm
675 class ModifyForm(CommentForm): 675 class ModifyForm(CommentForm):
676 rev = Integer.using(optional=False) 676 parent = String.using(optional=True)
677 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON()) 677 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
678 data_file = FileStorage.using(optional=True, label=L_('Upload file:')) 678 data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
679 679
680 if request.method == 'GET': 680 if request.method == 'GET':
681 form = ModifyForm.from_defaults() 681 form = ModifyForm.from_defaults()
682 TextCha(form).amend_form() 682 TextCha(form).amend_form()
683 form['meta_text'] = self.meta_dict_to_text(self.meta) 683 form['meta_text'] = self.meta_dict_to_text(self.meta)
684 form['rev'] = self.rev.revid if self.rev.revid is not None else CURRENT 684 if self.rev.revid:
685 form['parent'] = self.rev.revid
685 elif request.method == 'POST': 686 elif request.method == 'POST':
686 form = ModifyForm.from_flat(request.form.items() + request.files.items()) 687 form = ModifyForm.from_flat(request.form.items() + request.files.items())
687 TextCha(form).amend_form() 688 TextCha(form).amend_form()
688 if form.validate(): 689 if form.validate():
689 try: 690 try:
1130 # XXX think about and add item template support 1131 # XXX think about and add item template support
1131 #if template_name is None and isinstance(self.rev, DummyRev): 1132 #if template_name is None and isinstance(self.rev, DummyRev):
1132 # return self._do_modify_show_templates() 1133 # return self._do_modify_show_templates()
1133 from MoinMoin.apps.frontend.views import CommentForm 1134 from MoinMoin.apps.frontend.views import CommentForm
1134 class ModifyForm(CommentForm): 1135 class ModifyForm(CommentForm):
1135 rev = String.using(optional=True) 1136 parent = String.using(optional=True)
1136 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON()) 1137 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
1137 data_text = String.using(optional=True).with_properties(placeholder=L_("Type your text here")) 1138 data_text = String.using(optional=True).with_properties(placeholder=L_("Type your text here"))
1138 data_file = FileStorage.using(optional=True, label=L_('Upload file:')) 1139 data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
1139 1140
1140 if request.method == 'GET': 1141 if request.method == 'GET':
1147 form['data_text'] = self.data_storage_to_internal(item.data) 1148 form['data_text'] = self.data_storage_to_internal(item.data)
1148 else: 1149 else:
1149 form['data_text'] = self.data_storage_to_internal(self.data) 1150 form['data_text'] = self.data_storage_to_internal(self.data)
1150 form['meta_text'] = self.meta_dict_to_text(self.meta) 1151 form['meta_text'] = self.meta_dict_to_text(self.meta)
1151 if self.rev.revid: 1152 if self.rev.revid:
1152 form['rev'] = self.rev.revid 1153 form['parent'] = self.rev.revid
1153 elif request.method == 'POST': 1154 elif request.method == 'POST':
1154 form = ModifyForm.from_flat(request.form.items() + request.files.items()) 1155 form = ModifyForm.from_flat(request.form.items() + request.files.items())
1155 TextCha(form).amend_form() 1156 TextCha(form).amend_form()
1156 if form.validate(): 1157 if form.validate():
1157 try: 1158 try:
1299 # XXX think about and add item template support 1300 # XXX think about and add item template support
1300 #if template_name is None and isinstance(self.rev, DummyRev): 1301 #if template_name is None and isinstance(self.rev, DummyRev):
1301 # return self._do_modify_show_templates() 1302 # return self._do_modify_show_templates()
1302 from MoinMoin.apps.frontend.views import CommentForm 1303 from MoinMoin.apps.frontend.views import CommentForm
1303 class ModifyForm(CommentForm): 1304 class ModifyForm(CommentForm):
1304 rev = Integer.using(optional=False) 1305 parent = String.using(optional=True)
1305 # XXX as the "saving" POSTs come from TWikiDraw (not the form), editing meta_text doesn't work 1306 # XXX as the "saving" POSTs come from TWikiDraw (not the form), editing meta_text doesn't work
1306 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON()) 1307 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
1307 data_file = FileStorage.using(optional=True, label=L_('Upload file:')) 1308 data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
1308 1309
1309 if request.method == 'GET': 1310 if request.method == 'GET':
1310 form = ModifyForm.from_defaults() 1311 form = ModifyForm.from_defaults()
1311 TextCha(form).amend_form() 1312 TextCha(form).amend_form()
1312 # XXX currently this is rather pointless, as the form does not get POSTed: 1313 # XXX currently this is rather pointless, as the form does not get POSTed:
1313 form['meta_text'] = self.meta_dict_to_text(self.meta) 1314 form['meta_text'] = self.meta_dict_to_text(self.meta)
1314 form['rev'] = self.rev.revid if self.rev.revid is not None else CURRENT 1315 if self.rev.revid:
1316 form['parent'] = self.rev.revid
1315 elif request.method == 'POST': 1317 elif request.method == 'POST':
1316 # this POST comes directly from TWikiDraw (not from Browser), thus no validation 1318 # this POST comes directly from TWikiDraw (not from Browser), thus no validation
1317 try: 1319 try:
1318 self.modify() # XXX 1320 self.modify() # XXX
1319 except AccessDeniedError: 1321 except AccessDeniedError:
1391 # XXX think about and add item template support 1393 # XXX think about and add item template support
1392 #if template_name is None and isinstance(self.rev, DummyRev): 1394 #if template_name is None and isinstance(self.rev, DummyRev):
1393 # return self._do_modify_show_templates() 1395 # return self._do_modify_show_templates()
1394 from MoinMoin.apps.frontend.views import CommentForm 1396 from MoinMoin.apps.frontend.views import CommentForm
1395 class ModifyForm(CommentForm): 1397 class ModifyForm(CommentForm):
1396 rev = Integer.using(optional=False) 1398 parent = String.using(optional=True)
1397 # XXX as the "saving" POSTs come from AnyWikiDraw (not the form), editing meta_text doesn't work 1399 # XXX as the "saving" POSTs come from AnyWikiDraw (not the form), editing meta_text doesn't work
1398 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON()) 1400 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
1399 data_file = FileStorage.using(optional=True, label=L_('Upload file:')) 1401 data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
1400 1402
1401 if request.method == 'GET': 1403 if request.method == 'GET':
1402 form = ModifyForm.from_defaults() 1404 form = ModifyForm.from_defaults()
1403 TextCha(form).amend_form() 1405 TextCha(form).amend_form()
1404 # XXX currently this is rather pointless, as the form does not get POSTed: 1406 # XXX currently this is rather pointless, as the form does not get POSTed:
1405 form['meta_text'] = self.meta_dict_to_text(self.meta) 1407 form['meta_text'] = self.meta_dict_to_text(self.meta)
1406 form['rev'] = self.rev.revid if self.rev.revid is not None else CURRENT 1408 if self.rev.revid:
1409 form['parent'] = self.rev.revid
1407 elif request.method == 'POST': 1410 elif request.method == 'POST':
1408 # this POST comes directly from AnyWikiDraw (not from Browser), thus no validation 1411 # this POST comes directly from AnyWikiDraw (not from Browser), thus no validation
1409 try: 1412 try:
1410 self.modify() # XXX 1413 self.modify() # XXX
1411 except AccessDeniedError: 1414 except AccessDeniedError:
1479 # XXX think about and add item template support 1482 # XXX think about and add item template support
1480 #if template_name is None and isinstance(self.rev, DummyRev): 1483 #if template_name is None and isinstance(self.rev, DummyRev):
1481 # return self._do_modify_show_templates() 1484 # return self._do_modify_show_templates()
1482 from MoinMoin.apps.frontend.views import CommentForm 1485 from MoinMoin.apps.frontend.views import CommentForm
1483 class ModifyForm(CommentForm): 1486 class ModifyForm(CommentForm):
1484 rev = Integer.using(optional=False) 1487 parent = String.using(optional=True)
1485 # XXX as the "saving" POSTs come from SvgDraw (not the form), editing meta_text doesn't work 1488 # XXX as the "saving" POSTs come from SvgDraw (not the form), editing meta_text doesn't work
1486 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON()) 1489 meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
1487 data_file = FileStorage.using(optional=True, label=L_('Upload file:')) 1490 data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
1488 1491
1489 if request.method == 'GET': 1492 if request.method == 'GET':
1490 form = ModifyForm.from_defaults() 1493 form = ModifyForm.from_defaults()
1491 TextCha(form).amend_form() 1494 TextCha(form).amend_form()
1492 # XXX currently this is rather pointless, as the form does not get POSTed: 1495 # XXX currently this is rather pointless, as the form does not get POSTed:
1493 form['meta_text'] = self.meta_dict_to_text(self.meta) 1496 form['meta_text'] = self.meta_dict_to_text(self.meta)
1494 form['rev'] = self.rev.revid if self.rev.revid is not None else CURRENT 1497 if self.rev.revid:
1498 form['parent'] = self.rev.revid
1495 elif request.method == 'POST': 1499 elif request.method == 'POST':
1496 # this POST comes directly from SvgDraw (not from Browser), thus no validation 1500 # this POST comes directly from SvgDraw (not from Browser), thus no validation
1497 try: 1501 try:
1498 self.modify() # XXX 1502 self.modify() # XXX
1499 except AccessDeniedError: 1503 except AccessDeniedError: