Skip to content

Commit

Permalink
Ensure Python 3 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
sallner committed Jul 13, 2016
1 parent 51882e0 commit 32c10e2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 21 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
language: python
python:
- 2.7
- 3.5
sudo: false
env:
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=py35
install:
- python bootstrap.py
- bin/buildout
- pip install tox
script:
- bin/test -v1
- tox
notifications:
email: false
email: false
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CHANGES

- Standardize namespace __init__

- Claim compatibility for Python 3.3, 3.4, and 3.5.

1.3 (2010-10-28)
================
Expand Down
10 changes: 9 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[buildout]
develop = .
parts = test console-scripts
versions=versions
find-links =
${buildout:directory}/zope.app.publication-4.0.0a1.dev0.tar.gz

[test]
recipe = zc.recipe.testrunner
Expand All @@ -11,4 +14,9 @@ recipe = zc.recipe.egg
eggs =
importchecker
pep8
createcoverage
createcoverage

[versions]
transaction =1.5.0
zope.app.publication = 4.0.0a1.dev0
Webtest =
9 changes: 5 additions & 4 deletions src/z3c/flashmessage/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
# $Id$
"""Flash message interfaces"""

from __future__ import unicode_literals
import zope.interface
import zope.schema


class IMessage(zope.interface.Interface):
"""A message that can be displayed to the user."""

message = zope.schema.TextLine(title=u"The message itself.")
message = zope.schema.TextLine(title="The message itself.")

type = zope.schema.TextLine(title=u"A classifier for the message",
default=u"message")
type = zope.schema.TextLine(title="A classifier for the message",
default="message")

def prepare(source):
"""Prepare for being received.
Expand All @@ -32,7 +33,7 @@ def prepare(source):

class IMessageSource(zope.interface.Interface):

def send(message, type=u"message"):
def send(message, type="message"):
"""Send a message to this source.
Message can either be a unicode string or an IMessage object.
Expand Down
6 changes: 3 additions & 3 deletions src/z3c/flashmessage/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
# $Id$
"""A simple message that can be displayed."""

from __future__ import unicode_literals
import persistent
import z3c.flashmessage.interfaces
import zope.interface


@zope.interface.implementer(z3c.flashmessage.interfaces.IMessage)
class BaseMessage(persistent.Persistent):
"""A message that is displayed to the user.
An (abstract) base class.
"""

zope.interface.implements(z3c.flashmessage.interfaces.IMessage)

def __init__(self, message, type=u"message"):
def __init__(self, message, type="message"):
self.message = message
self.type = type

Expand Down
3 changes: 1 addition & 2 deletions src/z3c/flashmessage/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import z3c.flashmessage.interfaces


@zope.interface.implementer(z3c.flashmessage.interfaces.IMessageReceiver)
class GlobalMessageReceiver(object):

zope.interface.implements(z3c.flashmessage.interfaces.IMessageReceiver)

def receive(self, type=None):
sources = zope.component.getAllUtilitiesRegisteredFor(
z3c.flashmessage.interfaces.IMessageSource)
Expand Down
9 changes: 4 additions & 5 deletions src/z3c/flashmessage/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# $Id$
"""A message source that stores messages in the session."""

from __future__ import unicode_literals
import zope.interface

import zope.session.interfaces
Expand All @@ -14,6 +15,7 @@
import z3c.flashmessage.message


@zope.interface.implementer(z3c.flashmessage.interfaces.IMessageSource)
class ListBasedMessageSource(object):
"""An (abstract) base class that stores messages
in a list.
Expand All @@ -23,9 +25,7 @@ class ListBasedMessageSource(object):
"""

zope.interface.implements(z3c.flashmessage.interfaces.IMessageSource)

def send(self, message, type=u"message"):
def send(self, message, type="message"):
"""Send a message to this source."""
if not z3c.flashmessage.interfaces.IMessage.providedBy(message):
# The programmer has passed in not a message, so we create a
Expand Down Expand Up @@ -72,15 +72,14 @@ def _get_storage(self, for_write=False):
persistent.list.PersistentList())


@zope.interface.implementer(z3c.flashmessage.interfaces.IMessageSource)
class RAMMessageSource(ListBasedMessageSource):
"""Source which stores its data in RAM.
Caution: This source is not able to store messages for individual users.
"""

zope.interface.implements(z3c.flashmessage.interfaces.IMessageSource)

def __init__(self):
super(RAMMessageSource, self).__init__()
self._storage = []
Expand Down
3 changes: 2 additions & 1 deletion src/z3c/flashmessage/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import zope.security.management


FlashMessageLayer = zope.app.wsgi.testlayer.BrowserLayer(z3c.flashmessage)
FlashMessageLayer = zope.app.wsgi.testlayer.BrowserLayer(
z3c.flashmessage, allowTearDown=True)


def setUp(test):
Expand Down

0 comments on commit 32c10e2

Please sign in to comment.