content,
<span xmlns:kid="http://purl.org/kid/ns#" kid:omit="">
<?python
import logging
_logger = logging.getLogger(__uri__)
comment_module = redfoot.module(URIRef("#module", base=__uri__))
from rdflib.util import date_time
from urlparse import urljoin
from time import gmtime, time
SESSION = redfoot.namespace("http://redfoot.net/3.0/session#")
COMMENT = redfoot.namespace("http://redfoot.net/3.0/comment#")
DC = redfoot.namespace("http://purl.org/dc/elements/1.1/")
DCTERMS = redfoot.namespace("http://purl.org/dc/terms/")
SERVER = redfoot.namespace("http://redfoot.net/3.0/server#")
uri = request.parameters.get("uri")
if not uri is None:
uri = URIRef(uri)
comment = Literal(request.parameters.get("comment"))
if uri is not None and comment:
year, month, date, h, m, s, _, _, _ = gmtime()
name = "%04d-%02d-%02dT%02d:%02d:%02d" % (year, month, date, h, m, s)
uid = redfoot.value(request.session_id, SESSION.uid)
c_uri = URIRef("%s/%s#comment" % (request.host, name))
assert (c_uri, None, None) not in redfoot, "context created for comment already in use"
context_uri = redfoot.context_id(c_uri, context_id="context")
context = redfoot.get_context(context_uri)# TODO:
label = Literal("Comment by %s regarding %s on %s" % (uid, uri, name))
redfoot.index.add((context_uri, RDFS.label, label))
context.add((uri, COMMENT.comment, c_uri))
context.add((c_uri, RDF.type, COMMENT.Comment))
context.add((c_uri, DCTERMS.created, Literal(date_time())))
label = Literal("%s..." % comment.strip()[0:20])
context.add((c_uri, RDFS.label, label))
context.add((c_uri, RDFS.comment, comment))
context.add((c_uri, DC.creator, uid))
redfoot.remove((uri, SERVER.last_modified, None))
context.add((uri, SERVER.last_modified, Literal("%s" % time())))
try:
redfoot.dispatcher.dispatch(comment_module.CommentCreatedEvent(uri=c_uri))
except Exception, e:
_logger.exception(e)
try:
redfoot.xmpp.send(REDFOOT.Admin, "%s just added a comment regarding %s. See: %s" % (redfoot.label(uid) or uid, redfoot.label(uri) or uri, c_uri.concrete()))
except Exception, e:
_logger.exception(e)
?>
<div kid:if="uri is None">
<h2>Error: No comment submitted</h2>
</div>
<div kid:if="uri is not None">
<h2>Thank you for your comment</h2>
<pre>${comment}</pre>
<p>Return to <a href="${request.relative(uri)}">${redfoot.label(uri.abstract()) or redfoot.label(uri) or uri}</a></p>
</div>
</span>
Comments regarding http://redfoot.net/3.0/comment/add_comment_content
Login to submit a comment.