content,
<span xmlns:kid="http://purl.org/kid/ns#" kid:omit="">
<?python
from rdflib.util import date_time
from urlparse import urljoin
from urllib import quote
from time import gmtime, time
from kid import XML
TEMPLATE = redfoot.namespace("http://redfoot.net/3.0/template#")
DC = redfoot.namespace("http://purl.org/dc/elements/1.1/")
DCTERMS = redfoot.namespace("http://purl.org/dc/terms/")
SESSION = redfoot.namespace("http://redfoot.net/3.0/session#")
KID = redfoot.namespace("http://redfoot.net/3.0/kid#")
SERVER = redfoot.namespace("http://redfoot.net/3.0/server#")
CODE = redfoot.namespace("http://redfoot.net/3.0/code#")
XSD = redfoot.namespace("http://www.w3.org/2001/XMLSchema#")
uri = request.parameters.get("uri")
title = request.parameters.get("title")
content_value = request.parameters.get("content") or ""
content_type = URIRef(request.parameters.get("format") or "")
content_value = Literal(content_value, datatype=XSD.string)
if uri:
uri = URIRef(uri)
# We do the following get context to create the default context if one's not already created.
redfoot.get_context(redfoot.context_id(uri.abstract(), context_id="#context"))
context = redfoot.get_context(redfoot.context_id(uri.abstract(), context_id="#edit_content"))
if title:
label = Literal(title)
redfoot.remove((uri, RDFS.label, None))
context.add((uri, RDFS.label, label))
content = redfoot.value(uri, TEMPLATE.content)
if not content or isinstance(content, BNode):
content = redfoot.context_id(uri.abstract(), context_id="content_handler")
for c in redfoot.objects(uri, TEMPLATE.content):
context.remove((uri, TEMPLATE.content, c))
context.remove((c, None, None))
context.add((uri, TEMPLATE.content, content))
redfoot.remove((content, None, None))
if content_type==KID.PagePartHandler:
context.add((content, RDF.type, KID.PagePartHandler))
context.add((content, KID.template, content_value))
elif content_type==SERVER.PagePartHandler:
context.add((content, RDF.type, SERVER.PagePartHandler))
context.add((content, CODE.python, content_value))
else:
raise Exception("Unexpected content type: %s" % content_type)
redfoot.remove((uri, SERVER.last_modified, None))
context.add((uri, SERVER.last_modified, Literal("%s" % time())))
message = ""
if content_type==KID.PagePartHandler:
try:
for item in XML(content_value, fragment=False):
pass
except Exception, e:
message = str(e)
content = None
from urllib import quote
?>
<h2 kid:if="message">${message} <a href="/edit/content/?uri=${quote(uri)}">Edit again</a></h2>
<h2 kid:if="not message">Thank you for your content:
<a href="${quote(uri.concrete(), ':/')}">${redfoot.label(uri, uri)}</a>
</h2>
</span>
Comments regarding http://redfoot.net/3.0/aspects/edit_content/put_content_content
Login to submit a comment.