Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 21 additions and 10 deletions.
  1. +8 −3 substanced/folder/__init__.py
  2. +13 −0 substanced/folder/tests.py
  3. +0 −7 tox.ini
View
11 substanced/folder/__init__.py
@@ -754,6 +754,7 @@ class SequentialAutoNamingFolder(Folder, _AutoNamingFolder):
_autoname_length = 7
_autoname_start = -1
+ _autoname_reset = False
def __init__(
self,
@@ -789,10 +790,14 @@ def next_name(self, subobject):
will be the value of this folder's ``autoname_start`` constructor
value.
"""
- try:
- maxkey = self.data.maxKey()
- except ValueError: # empty tree
+ if self._autoname_reset:
maxkey = self._autoname_start
+ self._autoname_reset = False
+ else:
+ try:
+ maxkey = self.data.maxKey()
+ except ValueError: # empty tree
+ maxkey = self._autoname_start
name = self._zfill(int(maxkey) + 1)
return name
View
13 substanced/folder/tests.py
@@ -938,6 +938,19 @@ def test_next_name_alternate_autoname_start(self):
inst = self._makeOne(autoname_start=0)
self.assertEqual(inst.next_name(None), '1'.zfill(7))
+ def test_next_name_empty_autoname_reset(self):
+ inst = self._makeOne()
+ inst._autoname_reset = True
+ self.assertEqual(inst.next_name(None), '0'.zfill(7))
+ self.assertFalse(inst._autoname_reset)
+
+ def test_next_name_nonempty_autoname_reset(self):
+ ob = DummyModel()
+ inst = self._makeOne({'0000005':ob})
+ inst._autoname_reset = True
+ self.assertEqual(inst.next_name(None), '0'.zfill(7))
+ self.assertFalse(inst._autoname_reset)
+
def test_add_not_intifiable(self):
ob = DummyModel()
inst = self._makeOne()
View
7 tox.ini
@@ -6,10 +6,6 @@ envlist =
commands =
python setup.py dev
python setup.py test -q
-deps =
- git+git://github.com/Pylons/pyramid.git#egg=pyramid
- git+git://github.com/Pylons/colander.git#egg=colander
- git+git://github.com/Pylons/hypatia.git#egg=hypatia
[testenv:cover]
basepython =
@@ -18,8 +14,5 @@ commands =
python setup.py dev
python setup.py nosetests --with-xunit --with-xcoverage
deps =
- git+git://github.com/Pylons/pyramid.git#egg=pyramid
- git+git://github.com/Pylons/colander.git#egg=colander
- git+git://github.com/Pylons/hypatia.git#egg=hypatia
nosexcover

No commit comments for this range

Something went wrong with that request. Please try again.