Thank you, so simple once you "get it" and now it is working quite
fast. For any other readers, I display inline SVG also like this:
@expose("pkg.templates.simplegraph")
def embed_svg(self):
return dict()
simplegraph.html
<div>
<embed src="/svg_graph" type="image/svg+xml">
<!-- works in Firefox >
</div>
from tg.controllers import CUSTOM_CONTENT_TYPE
#CUSTOM_CONTENT_TYPE = 'CUSTOM/LEAVE'
#http://trac.turbogears.org/ticket/2378 or 2280
@expose(content_type=CUSTOM_CONTENT_TYPE)
def svg_graph(self):
response.headers["Content-type"] = "image/svg+xml"
g = Graph.Full(12, directed=False, loops=False)
ntf = NamedTemporaryFile()
ntf.name = 'tmp.svg'
with open(ntf.name, 'w+b') as f:
g.write_svg(ntf.name, "fruchterman_reingold")
#Fruchterman-Reingold is a layout algorithm
svg_obj = f.read() #unescape(self, f.read())
f.closed
return svg_obj
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=.