Skip to content

Commit

Permalink
Merge pull request #3 from tomgross/master
Browse files Browse the repository at this point in the history
Fixed location of temporary blobs
  • Loading branch information
witsch committed Oct 11, 2012
2 parents ed2d672 + 226aed5 commit bc0c487
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -16,6 +16,9 @@ Changelog
- check for unicode filename first in index_html
[vangheem]

- create a transaction savepoint in BlobField to have a correct temporary
path (eg for indexing in the same transaction)
[tomgross]

1.5.2 (2012-05-25)
------------------
Expand Down
1 change: 1 addition & 0 deletions src/plone/app/blob/field.py
Expand Up @@ -242,6 +242,7 @@ def set(self, instance, value, **kwargs):
blob.setContentType(kwargs.get('mimetype', blobbable.mimetype()))
blob.setFilename(kwargs.get('filename', blobbable.filename()))
super(BlobField, self).set(instance, blob, **kwargs)
savepoint(optimistic=True)

security.declarePrivate('fixAutoId')
def fixAutoId(self, instance):
Expand Down
11 changes: 10 additions & 1 deletion src/plone/app/blob/tests/test_replacements.py
Expand Up @@ -17,7 +17,7 @@
from plone.app.blob.field import BlobField
from plone.app.blob.content import ATBlob
from plone.app.blob.tests.utils import getImage, getData

from ZODB.blob import SAVEPOINT_SUFFIX

def permissionsFor(name, product):
from Products import meta_types
Expand Down Expand Up @@ -142,6 +142,15 @@ def testSearchableText(self):
self.assertTrue('Plone' in data, 'pdftohtml not installed?')
self.assertFalse('PDF' in data)

def testBlobPath(self):
foo = self.folder[self.folder.invokeFactory('File', 'foo',
title='foo', file=getData('plone.pdf'))]
field = foo.getField('file')
blobfile = field.get(foo).blob._p_blob_committed
tempdir = self.app._p_jar._storage.temporaryDirectory()
self.assertTrue(blobfile.endswith(SAVEPOINT_SUFFIX))
self.assertTrue(blobfile.startswith(tempdir))


class ImageReplacementTests(ReplacementTestCase):

Expand Down

0 comments on commit bc0c487

Please sign in to comment.