Skip to content

Commit

Permalink
[fc] Repository: plone.resource
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2017-12-21T18:39:24+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/plone.resource@1199506

Fixed 'ValueError: substring not found' in ``FilesystemResourceDirectory`` representation.

This happens when you register a directory with a name that differs from the directory name.
Visiting the ``/++theme++myname`` url would then give this error.

We also avoid listing a longer part of the path in case the directory name happens to be in the path multiple times.
Case in point: if you would register the `template` dir of `plone.app.theming` as a plone static dir with name `theming`, and visit the `++theme++theming` url,
you would see something like this:

  &lt;FilesystemResourceDirectory object at theming-1.1.8-py2.7.egg/plone/app/theming/themes/template&gt;

That is just silly.
We simply show the name now:

  &lt;FilesystemResourceDirectory object at theming&gt;

If the name and the directory would have matched, which is the default when you do not give a name, then that would be what is shown anyway.

Files changed:
M CHANGES.rst
M plone/resource/directory.py
M plone/resource/tests/test_directory.py
Repository: plone.resource

Branch: refs/heads/master
Date: 2017-12-22T15:16:19+01:00
Author: Gil Forcada Codinachs (gforcada) <gil.gnome@gmail.com>
Commit: plone/plone.resource@88b0723

Merge pull request #21 from plone/fix-valueerror-in-repr-master

Fixed ValueError in FilesystemResourceDirectory repr [master]

Files changed:
M CHANGES.rst
M plone/resource/directory.py
M plone/resource/tests/test_directory.py
  • Loading branch information
gforcada committed Dec 22, 2017
1 parent 89d3b34 commit 86dcf65
Showing 1 changed file with 152 additions and 131 deletions.
283 changes: 152 additions & 131 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,181 +1,202 @@
Repository: plone.recipe.zeoserver
Repository: plone.resource


Branch: refs/heads/master
Date: 2017-12-18T00:03:25+01:00
Author: Mauro Amico (mamico) <mauro.amico@gmail.com>
Commit: https://github.com/plone/plone.recipe.zeoserver/commit/bead28cc44e6e64224c0d145b74b90117f6fb163
Date: 2017-12-21T18:39:24+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: https://github.com/plone/plone.resource/commit/1199506882e1fc7613f38f6820aee04f7b2dc701

wait for zeo connection (backport from ZEO's pack script)
Fixed 'ValueError: substring not found' in ``FilesystemResourceDirectory`` representation.

Files changed:
M src/plone/recipe/zeoserver/pack.py

diff --git a/src/plone/recipe/zeoserver/pack.py b/src/plone/recipe/zeoserver/pack.py
index 5b7628a..4098112 100644
--- a/src/plone/recipe/zeoserver/pack.py
+++ b/src/plone/recipe/zeoserver/pack.py
@@ -6,6 +6,7 @@
import os
import socket
import sys
+import time


def _main(host, port, unix=None, days=1, username=None, password=None,
@@ -30,9 +31,14 @@ def _main(host, port, unix=None, days=1, username=None, password=None,
username=username, password=password, realm=realm,
blob_dir=blob_dir, shared_blob_dir=shared_blob_dir,
)
- if not cs.is_connected():
+ for i in range(60):
+ if cs.is_connected():
+ break
+ time.sleep(1)
+ else:
logger.error("Could not connect to zeoserver. Please make sure it "
"is running.")
+ cs.close()
sys.exit(1)
try:
# The script should not exit until the packing is done.
This happens when you register a directory with a name that differs from the directory name.
Visiting the ``/++theme++myname`` url would then give this error.

We also avoid listing a longer part of the path in case the directory name happens to be in the path multiple times.
Case in point: if you would register the `template` dir of `plone.app.theming` as a plone static dir with name `theming`, and visit the `++theme++theming` url,
you would see something like this:

Repository: plone.recipe.zeoserver
&lt;FilesystemResourceDirectory object at theming-1.1.8-py2.7.egg/plone/app/theming/themes/template&gt;

That is just silly.
We simply show the name now:

Branch: refs/heads/master
Date: 2017-12-18T18:12:11+01:00
Author: Mauro Amico (mamico) <mauro.amico@gmail.com>
Commit: https://github.com/plone/plone.recipe.zeoserver/commit/c9304cf3ab3357644878b9f98f9252a24b6e2a35
&lt;FilesystemResourceDirectory object at theming&gt;

Merge remote-tracking branch 'upstream/master'
If the name and the directory would have matched, which is the default when you do not give a name, then that would be what is shown anyway.

Files changed:
M CHANGES.rst
M src/plone/recipe/zeoserver/tests/test_docs.py
M src/plone/recipe/zeoserver/tests/zeoserver.txt
M plone/resource/directory.py
M plone/resource/tests/test_directory.py

diff --git a/CHANGES.rst b/CHANGES.rst
index c688ace..f659df0 100644
index ee3f095..c64a6df 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -14,7 +14,7 @@ New features:
@@ -15,7 +15,12 @@ New features:

Bug fixes:

-- *add item here*
+- Fixed Travis tests by installing the ``hyperlink`` package. [maurits]
+- Fixed 'ValueError: substring not found' in ``FilesystemResourceDirectory`` representation.
+ This happens when you register a directory with a name that differs from the directory name.
+ Visiting the ``/++theme++myname`` url would then give this error.
+ We also avoid listing a longer part of the path in case the directory name happens to be in the path multiple times.
+ [maurits]
+

1.2.1 (2016-12-30)
------------------
diff --git a/plone/resource/directory.py b/plone/resource/directory.py
index 9ac7d3e..f62c3b4 100644
--- a/plone/resource/directory.py
+++ b/plone/resource/directory.py
@@ -215,8 +215,7 @@ def __parent__(self, value):
self._parent = value

1.4.0 (2017-06-16)
diff --git a/src/plone/recipe/zeoserver/tests/test_docs.py b/src/plone/recipe/zeoserver/tests/test_docs.py
index 5b0991e..fafee1c 100644
--- a/src/plone/recipe/zeoserver/tests/test_docs.py
+++ b/src/plone/recipe/zeoserver/tests/test_docs.py
@@ -26,6 +26,7 @@ def setUp(test):
install('constantly', test)
install('attrs', test)
install('Twisted', test)
+ install('hyperlink', test)
dependencies = pkg_resources.working_set.require('ZODB3')
for dep in dependencies:
try:
diff --git a/src/plone/recipe/zeoserver/tests/zeoserver.txt b/src/plone/recipe/zeoserver/tests/zeoserver.txt
index c753552..f5bb8f4 100644
--- a/src/plone/recipe/zeoserver/tests/zeoserver.txt
+++ b/src/plone/recipe/zeoserver/tests/zeoserver.txt
@@ -614,4 +614,3 @@ The main script should have the initialization.
def __repr__(self):
- subpath = self.directory[self.directory.index(self.__name__):]
- return '<%s object at %s>' % (self.__class__.__name__, subpath)
+ return '<%s object at %s>' % (self.__class__.__name__, self.__name__)

>>> 'foo = 1' in open(join('bin', 'zeo' + suffix)).read()
True
-


Repository: plone.recipe.zeoserver


Branch: refs/heads/master
Date: 2017-12-18T18:15:04+01:00
Author: Mauro Amico (mamico) <mauro.amico@gmail.com>
Commit: https://github.com/plone/plone.recipe.zeoserver/commit/4a1e5ccf28a63c2a1187f76f052398f72ce6e349

changelog

Files changed:
M CHANGES.rst

diff --git a/CHANGES.rst b/CHANGES.rst
index f659df0..9ea7417 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -16,6 +16,8 @@ Bug fixes:
def _resolveSubpath(self, path):
parts = path.split('/')
diff --git a/plone/resource/tests/test_directory.py b/plone/resource/tests/test_directory.py
index 9d4314a..2e78793 100644
--- a/plone/resource/tests/test_directory.py
+++ b/plone/resource/tests/test_directory.py
@@ -214,27 +214,32 @@ def _handleFileModified(event):
dir.writeFile('test', 'my test is modified')
self.assertTrue(isinstance(events[0], PloneResourceCreatedEvent))
self.assertEqual(
- str(events[0].object),
+ str(events[0].object),
'my test'
)
self.assertTrue(isinstance(events[1], PloneResourceModifiedEvent))
self.assertEqual(
- str(events[1].object),
+ str(events[1].object),
'my test is modified'
)
class TestFilesystemResourceDirectory(unittest.TestCase):

- Fixed Travis tests by installing the ``hyperlink`` package. [maurits]
- def _makeOne(self):
+ def _makeOne(self, name=None):
from plone.resource.directory import FilesystemResourceDirectory
path = os.path.join(os.path.dirname(__file__), 'resources')
- return FilesystemResourceDirectory(path)
+ return FilesystemResourceDirectory(path, name=name)

+- Fixed zeopack script for ZEO >= 5 (backport from original ZEO's script) [mamico]
def test_repr(self):
dir = self._makeOne()
- subpath = dir.directory[dir.directory.index(dir.__name__):]
- s = '<FilesystemResourceDirectory object at %s>' % subpath
+ s = '<FilesystemResourceDirectory object at resources>'
+ self.assertEqual(s, repr(dir))
+
+ def test_repr(self):
+ dir = self._makeOne(name='something-else')
+ s = '<FilesystemResourceDirectory object at something-else>'
+ # This used to give a ValueError: substring not found
self.assertEqual(s, repr(dir))

1.4.0 (2017-06-16)
------------------
def test_publishTraverse_directory(self):


Repository: plone.recipe.zeoserver
Repository: plone.resource


Branch: refs/heads/master
Date: 2017-12-18T18:33:01+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: https://github.com/plone/plone.recipe.zeoserver/commit/45774a459dee55c9338fe190283865d818070026
Date: 2017-12-22T15:16:19+01:00
Author: Gil Forcada Codinachs (gforcada) <gil.gnome@gmail.com>
Commit: https://github.com/plone/plone.resource/commit/88b0723359483f63bd2771eed5b90deb64503578

Merge pull request #25 from mamico/master
Merge pull request #21 from plone/fix-valueerror-in-repr-master

wait for zeo connection (backport from ZEO's pack script)
Fixed ValueError in FilesystemResourceDirectory repr [master]

Files changed:
M CHANGES.rst
M src/plone/recipe/zeoserver/pack.py
M plone/resource/directory.py
M plone/resource/tests/test_directory.py

diff --git a/CHANGES.rst b/CHANGES.rst
index f659df0..9ea7417 100644
index ee3f095..c64a6df 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -16,6 +16,8 @@ Bug fixes:
@@ -15,7 +15,12 @@ New features:

- Fixed Travis tests by installing the ``hyperlink`` package. [maurits]
Bug fixes:

+- Fixed zeopack script for ZEO >= 5 (backport from original ZEO's script) [mamico]
-- *add item here*
+- Fixed 'ValueError: substring not found' in ``FilesystemResourceDirectory`` representation.
+ This happens when you register a directory with a name that differs from the directory name.
+ Visiting the ``/++theme++myname`` url would then give this error.
+ We also avoid listing a longer part of the path in case the directory name happens to be in the path multiple times.
+ [maurits]
+

1.4.0 (2017-06-16)
1.2.1 (2016-12-30)
------------------
diff --git a/src/plone/recipe/zeoserver/pack.py b/src/plone/recipe/zeoserver/pack.py
index 5b7628a..4098112 100644
--- a/src/plone/recipe/zeoserver/pack.py
+++ b/src/plone/recipe/zeoserver/pack.py
@@ -6,6 +6,7 @@
import os
import socket
import sys
+import time


def _main(host, port, unix=None, days=1, username=None, password=None,
@@ -30,9 +31,14 @@ def _main(host, port, unix=None, days=1, username=None, password=None,
username=username, password=password, realm=realm,
blob_dir=blob_dir, shared_blob_dir=shared_blob_dir,
diff --git a/plone/resource/directory.py b/plone/resource/directory.py
index 9ac7d3e..f62c3b4 100644
--- a/plone/resource/directory.py
+++ b/plone/resource/directory.py
@@ -215,8 +215,7 @@ def __parent__(self, value):
self._parent = value

def __repr__(self):
- subpath = self.directory[self.directory.index(self.__name__):]
- return '<%s object at %s>' % (self.__class__.__name__, subpath)
+ return '<%s object at %s>' % (self.__class__.__name__, self.__name__)

def _resolveSubpath(self, path):
parts = path.split('/')
diff --git a/plone/resource/tests/test_directory.py b/plone/resource/tests/test_directory.py
index 9d4314a..2e78793 100644
--- a/plone/resource/tests/test_directory.py
+++ b/plone/resource/tests/test_directory.py
@@ -214,27 +214,32 @@ def _handleFileModified(event):
dir.writeFile('test', 'my test is modified')
self.assertTrue(isinstance(events[0], PloneResourceCreatedEvent))
self.assertEqual(
- str(events[0].object),
+ str(events[0].object),
'my test'
)
self.assertTrue(isinstance(events[1], PloneResourceModifiedEvent))
self.assertEqual(
- str(events[1].object),
+ str(events[1].object),
'my test is modified'
)
- if not cs.is_connected():
+ for i in range(60):
+ if cs.is_connected():
+ break
+ time.sleep(1)
+ else:
logger.error("Could not connect to zeoserver. Please make sure it "
"is running.")
+ cs.close()
sys.exit(1)
try:
# The script should not exit until the packing is done.


class TestFilesystemResourceDirectory(unittest.TestCase):

- def _makeOne(self):
+ def _makeOne(self, name=None):
from plone.resource.directory import FilesystemResourceDirectory
path = os.path.join(os.path.dirname(__file__), 'resources')
- return FilesystemResourceDirectory(path)
+ return FilesystemResourceDirectory(path, name=name)

def test_repr(self):
dir = self._makeOne()
- subpath = dir.directory[dir.directory.index(dir.__name__):]
- s = '<FilesystemResourceDirectory object at %s>' % subpath
+ s = '<FilesystemResourceDirectory object at resources>'
+ self.assertEqual(s, repr(dir))
+
+ def test_repr(self):
+ dir = self._makeOne(name='something-else')
+ s = '<FilesystemResourceDirectory object at something-else>'
+ # This used to give a ValueError: substring not found
self.assertEqual(s, repr(dir))

def test_publishTraverse_directory(self):


0 comments on commit 86dcf65

Please sign in to comment.