content,
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:kid="http://purl.org/kid/ns#"
kid:strip=""
>
<?python
import logging
_logger = logging.getLogger(__uri__)
documents_module = redfoot.module(URIRef("#module", base=__uri__))
DOCUMENT = redfoot.namespace(URIRef("#", base=__uri__))
label = request.parameters.get("label")
comment = request.parameters.get("comment")
content_type = request.parameters.get("content_type")
file = request.parameters.get("file")
if file:
from base64 import b64encode
SERVER = redfoot.namespace("http://redfoot.net/3.0/server#")
import sha
uri = URIRef("%s/document/%s/" % (request.host, sha.new(file).hexdigest()))
cid = redfoot.context_id(uri, "context")
context = redfoot.get_context(cid, creator=request.user_id)
context.add((cid, RDFS.label, Literal(label)))
context.add((cid, RDF.type, DOCUMENT.DocumentContext))
base64Binary = URIRef("http://www.w3.org/2001/XMLSchema#base64Binary")
value = Literal(b64encode(file), datatype=base64Binary)
context.add((uri, RDFS.label, Literal(label)))
context.add((uri, RDFS.comment, Literal(comment)))
context.add((uri, RDF.type, DOCUMENT.Document))
context.set((uri, RDF.value, value))
context.set((uri, SERVER.content_type, Literal(content_type)))
keywords = request.parameters.get("keywords")
if keywords:
for s in keywords.split(","):
s = s.strip()
# TODO: push this functionality down somewhere
s = s.lower().replace(" ", "_")
s.replace("#", "_")
s.replace("/", "_")
keyword = URIRef("%s/keyword/%s#" % (request.host, s))
context.add((keyword, RDF.type, DOCUMENT.Keyword))
context.add((keyword, RDFS.label, Literal(s)))
context.add((keyword, RDFS.member, uri))
try:
redfoot.dispatcher.dispatch(documents_module.DocumentCreatedEvent(uri=uri))
except Exception, e:
_logger.exception(e)
?>
<p kid:if="file">
Thank you for submiting <a href="${uri}">${label}</a>
</p>
<p kid:if="not file">
No file specified?
</p>
</div>
Comments regarding Upload Process Page Part Handler
Login to submit a comment.