if not chunk:
return document.data('xml')
- xdoc = parser.WLDocument.from_string(document.data('xml'),\
- parse_dublincore=False)
+ xdoc = parser.WLDocument.from_string(document.data('xml'), parse_dublincore=False)
xchunk = xdoc.chunk(chunk)
@validate_form(forms.TextUpdateForm, 'POST')
@hglibrary
def create(self, request, form, docid, lib):
+ lock = lib.lock();
try:
revision = form.cleaned_data['revision']
msg = form.cleaned_data['message']
# do not allow changing not owned documents
# (for now... )
-
if user != request.user.username:
return response.AccessDenied().django_response({
'reason': 'insufficient-priviliges',
})
current = lib.document(docid, user)
- orig = lib.document_for_rev(revision)
+ orig = lib.document_for_revision(revision)
if current != orig:
return response.EntityConflict().django_response({
"provided_revision": orig.revision,
"latest_revision": current.revision })
- if form.cleaned_data.has_key('contents'):
+ if form.cleaned_data['contents']:
data = form.cleaned_data['contents']
else:
chunks = form.cleaned_data['chunks']
- xdoc = parser.WLDocument.from_string(current.data('xml'))
+ data = current.data('xml')
+ log.info(data[:600])
+ log.info(chunks)
+
+ xdoc = parser.WLDocument.from_string(data, parse_dublincore=False)
errors = xdoc.merge_chunks(chunks)
if len(errors):
data = xdoc.serialize()
+
# try to find any Xinclude tags
includes = [m.groupdict()['link'] for m in (re.finditer(\
XINCLUDE_REGEXP, data, flags=re.UNICODE) or []) ]
except RevisionNotFound, e:
return response.EntityNotFound(mimetype="text/plain").\
django_response(e.message)
+ finally:
+ lock.release()