Mercurial > moin-2.0-moinboot
changeset 2128:21bd8d987eda
merged
| author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
|---|---|
| date | Sun, 07 Jul 2013 17:59:25 +0200 |
| parents | 2aaa55fc2f91 (current diff) 29b3dedf7a6b (diff) |
| children | c1f88ad9e44e 4f9b58ec2879 |
| files | |
| diffstat | 2 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py Sun Jul 07 15:33:48 2013 +0200 +++ b/MoinMoin/items/__init__.py Sun Jul 07 17:59:25 2013 +0200 @@ -394,11 +394,9 @@ # just destroy this revision self.rev.item.destroy_revision(self.rev.revid) - def modify(self, meta, data, comment=u'', contenttype_guessed=None, contenttype_qs=None): - if contenttype_qs: - # we use querystring param to FORCE content type - meta[CONTENTTYPE] = contenttype_qs - + def modify(self, meta, data, comment=u'', contenttype_guessed=None, **update_meta): + meta = dict(meta) # we may get a read-only dict-like, copy it + meta.update(update_meta) return self._save(meta, data, contenttype_guessed=contenttype_guessed, comment=comment) class _ModifyForm(BaseModifyForm): @@ -730,7 +728,7 @@ meta, data, contenttype_guessed, comment = form._dump(self) contenttype_qs = request.values.get('contenttype') try: - self.modify(meta, data, comment, contenttype_guessed, contenttype_qs) + self.modify(meta, data, comment, contenttype_guessed, **{CONTENTTYPE: contenttype_qs}) except AccessDenied: abort(403) else:
--- a/MoinMoin/items/_tests/test_Item.py Sun Jul 07 15:33:48 2013 +0200 +++ b/MoinMoin/items/_tests/test_Item.py Sun Jul 07 17:59:25 2013 +0200 @@ -352,6 +352,23 @@ item.meta['test_key'] assert item.meta['another_test_key'] == another_meta['another_test_key'] assert item.content.data == another_data + # add/update meta + another_meta = { + 'test_key': 'test_value', + 'another_test_key': 'another_test_value', + } + item.modify(another_meta, another_data) + item = Item.create(name) + update_meta = { + 'another_test_key': 'updated_test_value', + 'new_test_key': 'new_test_value', + } + item.modify(another_meta, another_data, **update_meta) + item = Item.create(name) + assert item.name == u'Test_Item' + assert item.meta['test_key'] == another_meta['test_key'] + assert item.meta['another_test_key'] == update_meta['another_test_key'] + assert item.meta['new_test_key'] == update_meta['new_test_key'] coverage_modules = ['MoinMoin.items']
