comparison MoinMoin/items/__init__.py @ 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.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 21 Jun 2011 14:10:42 +0200
parents 1a1dab306214
children 76a4e3cc8705
comparison
equal deleted inserted replaced
253:37c117ad8f7e 254:91330de48b9c
1 # Copyright: 2009 MoinMoin:ThomasWaldmann 1 # Copyright: 2009 MoinMoin:ThomasWaldmann
2 # Copyright: 2009 MoinMoin:ReimarBauer 2 # Copyright: 2009-2011 MoinMoin:ReimarBauer
3 # Copyright: 2009 MoinMoin:ChristopherDenter 3 # Copyright: 2009 MoinMoin:ChristopherDenter
4 # Copyright: 2008,2009 MoinMoin:BastianBlank 4 # Copyright: 2008,2009 MoinMoin:BastianBlank
5 # Copyright: 2010 MoinMoin:ValentinJaniaut 5 # Copyright: 2010 MoinMoin:ValentinJaniaut
6 # Copyright: 2010 MoinMoin:DiogenesAugusto 6 # Copyright: 2010 MoinMoin:DiogenesAugusto
7 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details. 7 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
1508 modify_help = "" 1508 modify_help = ""
1509 template = "modify_svg-edit.html" 1509 template = "modify_svg-edit.html"
1510 1510
1511 def modify(self): 1511 def modify(self):
1512 # called from modify UI/POST 1512 # called from modify UI/POST
1513 file_upload = request.values.get('data') 1513 png_upload = request.values.get('png_data')
1514 svg_upload = request.values.get('filepath')
1514 filename = request.form['filename'] 1515 filename = request.form['filename']
1515 filecontent = file_upload.decode('base_64') 1516 png_content = png_upload.decode('base_64')
1516 basepath, basename = os.path.split(filename) 1517 png_content = base64.urlsafe_b64decode(png_content.split(',')[1])
1517 basename, ext = os.path.splitext(basename) 1518 svg_content = svg_upload.decode('base_64')
1518 content_length = None 1519 content_length = None
1519 1520 self.put_member("drawing.svg", svg_content, content_length,
1520 if ext == '.png': 1521 expected_members=set(['drawing.svg', 'drawing.png']))
1521 filecontent = base64.urlsafe_b64decode(filecontent.split(',')[1]) 1522 self.put_member("drawing.png", png_content, content_length,
1522 self.put_member(filename, filecontent, content_length,
1523 expected_members=set(['drawing.svg', 'drawing.png'])) 1523 expected_members=set(['drawing.svg', 'drawing.png']))
1524 1524
1525 def do_modify(self, contenttype, template_name): 1525 def do_modify(self, contenttype, template_name):
1526 # XXX think about and add item template support 1526 # XXX think about and add item template support
1527 #if template_name is None and isinstance(self.rev, DummyRev): 1527 #if template_name is None and isinstance(self.rev, DummyRev):