Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into request_params#636
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed May 30, 2019
2 parents c011659 + 13849b6 commit dc5ab1c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/zdgbook/examples/Poll.py
@@ -1,5 +1,6 @@
from Interface import Base


class Poll(Base):
"A multiple choice poll"

Expand All @@ -17,4 +18,3 @@ def getResponses(self):

def getQuestion(self):
"Returns the question"

3 changes: 2 additions & 1 deletion docs/zdgbook/examples/PollImplementation.py
@@ -1,5 +1,6 @@
from Poll import Poll


class PollImplementation(object):
"""
A multiple choice poll, implements the Poll interface.
Expand All @@ -9,7 +10,7 @@ class PollImplementation(object):
number of votes.
"""

__implements__=Poll
__implements__ = Poll

def __init__(self, question, responses):
self._question = question
Expand Down
25 changes: 13 additions & 12 deletions docs/zdgbook/examples/PollProduct.py
@@ -1,10 +1,11 @@
from Poll import Poll
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from AccessControl.Role import RoleManager
from Acquisition import Implicit
from Globals import InitializeClass
from Globals import Persistent
from AccessControl.Role import RoleManager
from OFS.SimpleItem import Item
from Poll import Poll


class PollProduct(Implicit, Persistent, RoleManager, Item):
"""
Expand All @@ -15,45 +16,45 @@ class PollProduct(Implicit, Persistent, RoleManager, Item):
number of votes.
"""

__implements__=Poll
__implements__ = Poll

meta_type='Poll'
meta_type = 'Poll'

security=ClassSecurityInfo()
security = ClassSecurityInfo()

def __init__(self, id, question, responses):
self.id=id
self.id = id
self._question = question
self._responses = responses
self._votes = {}
for i in range(len(responses)):
self._votes[i] = 0

security.declareProtected('Use Poll', 'castVote')
@security.protected('Use Poll')
def castVote(self, index):
"Votes for a choice"
self._votes[index] = self._votes[index] + 1
self._votes = self._votes

security.declareProtected('View Poll Results', 'getTotalVotes')
@security.protected('View Poll Results')
def getTotalVotes(self):
"Returns total number of votes cast"
total = 0
for v in self._votes.values():
total = total + v
return total

security.declareProtected('View Poll Results', 'getVotesFor')
@security.protected('View Poll Results')
def getVotesFor(self, index):
"Returns number of votes cast for a given response"
return self._votes[index]

security.declarePublic('getResponses')
@security.public
def getResponses(self):
"Returns the sequence of responses"
return tuple(self._responses)

security.declarePublic('getQuestion')
@security.public
def getQuestion(self):
"Returns the question"
return self._question
Expand Down
20 changes: 4 additions & 16 deletions tox.ini
Expand Up @@ -62,8 +62,7 @@ deps =
isort

commands =
isort --apply --recursive {toxinidir}/src setup.py {posargs}
#isort --apply --recursive {toxinidir}/src/OFS {posargs}
isort --apply --recursive {toxinidir}/src {toxinidir}/docs setup.py {posargs}

[testenv:autopep8]
basepython = python3.6
Expand All @@ -77,7 +76,8 @@ commands =
autopep8 --verbose --in-place --recursive --aggressive --aggressive {toxinidir}/src setup.py
docformatter --in-place --recursive {toxinidir}/src setup.py

[lint]
[testenv:lint-py36]
basepython = python3.6
skip_install = true

deps =
Expand Down Expand Up @@ -105,17 +105,5 @@ deps =
#flake8-quotes

commands =
mkdir -p {toxinidir}/_build/flake8
- isort --check-only --recursive {toxinidir}/src setup.py
- flake8 --format=html --htmldir={toxinidir}/_build/flake8 src tests setup.py
flake8 src tests setup.py

whitelist_externals =
mkdir

[testenv:lint-py36]
basepython = python3.6
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}
flake8 src docs setup.py

0 comments on commit dc5ab1c

Please sign in to comment.