[Checkins] SVN: z3c.password/trunk/src/z3c/password/ - Corrected
errors to use correct API.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Oct 18 02:32:51 EDT 2006
Log message for revision 70770:
- Corrected errors to use correct API.
- Added transaltions.
- Some other fixes.
Changed:
A z3c.password/trunk/src/z3c/password/SETUP.cfg
U z3c.password/trunk/src/z3c/password/__init__.py
A z3c.password/trunk/src/z3c/password/configure.zcml
U z3c.password/trunk/src/z3c/password/field.py
U z3c.password/trunk/src/z3c/password/interfaces.py
A z3c.password/trunk/src/z3c/password/locales/
A z3c.password/trunk/src/z3c/password/locales/de/
A z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/
A z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/z3c.password.mo
A z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/z3c.password.po
A z3c.password/trunk/src/z3c/password/locales/z3c.password.pot
U z3c.password/trunk/src/z3c/password/password.py
U z3c.password/trunk/src/z3c/password/principal.py
A z3c.password/trunk/src/z3c/password/z3c.password-configure.zcml
-=-
Added: z3c.password/trunk/src/z3c/password/SETUP.cfg
===================================================================
--- z3c.password/trunk/src/z3c/password/SETUP.cfg 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/SETUP.cfg 2006-10-18 06:32:50 UTC (rev 70770)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+ z3c.password-*.zcml
+</data-files>
Modified: z3c.password/trunk/src/z3c/password/__init__.py
===================================================================
--- z3c.password/trunk/src/z3c/password/__init__.py 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/__init__.py 2006-10-18 06:32:50 UTC (rev 70770)
@@ -1 +1,4 @@
# Make a package.
+
+import zope.i18nmessageid
+MessageFactory = zope.i18nmessageid.MessageFactory('z3c.password')
Added: z3c.password/trunk/src/z3c/password/configure.zcml
===================================================================
--- z3c.password/trunk/src/z3c/password/configure.zcml 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/configure.zcml 2006-10-18 06:32:50 UTC (rev 70770)
@@ -0,0 +1,8 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ i18n_domain="z3c.password">
+
+ <i18n:registerTranslations directory="locales" />
+
+</configure>
Property changes on: z3c.password/trunk/src/z3c/password/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: z3c.password/trunk/src/z3c/password/field.py
===================================================================
--- z3c.password/trunk/src/z3c/password/field.py 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/field.py 2006-10-18 06:32:50 UTC (rev 70770)
@@ -39,5 +39,8 @@
super(Password, self).validate(value)
old = None
if self.context is not None:
- old = self.get(self.context)
+ try:
+ old = self.get(self.context)
+ except AttributeError:
+ pass
self.checker.verify(value, old)
Modified: z3c.password/trunk/src/z3c/password/interfaces.py
===================================================================
--- z3c.password/trunk/src/z3c/password/interfaces.py 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/interfaces.py 2006-10-18 06:32:50 UTC (rev 70770)
@@ -20,31 +20,39 @@
import zope.schema
from zope.exceptions.interfaces import UserError
+from z3c.password import MessageFactory as _
+
class InvalidPassword(zope.schema.ValidationError):
"""Invalid Password"""
- def __init__(self, reason):
- self.reason = reason
- Exception.__init__(self)
+class NoPassword(InvalidPassword):
+ __doc__ = _('''No new password specified.''')
- def __str__(self):
- return self.reason.encode('utf-8')
+class TooShortPassword(InvalidPassword):
+ __doc__ = _('''Password is too short.''')
+class TooLongPassword(InvalidPassword):
+ __doc__ = _('''Password is too long.''')
-class PasswordExpired(UserError):
- """The password has expired."""
+class TooSimilarPassword(InvalidPassword):
+ __doc__ = _('''Password is too similar to old one.''')
+class TooManyGroupCharacters(InvalidPassword):
+ __doc__ = _('''Password contains too many characters of one group.''')
+
+class PasswordExpired(Exception):
+ __doc__ = _('''The password has expired.''')
+
def __init__(self, principal):
self.principal = principal
- UserError.__init__(self)
+ Exception.__init__(self, self.__doc__)
+class TooManyLoginFailures(Exception):
+ __doc__ = _('''The password was entered incorrectly too often.''')
-class TooManyLoginFailures(UserError):
- """The password was entered incorrectly too often."""
-
def __init__(self, principal):
self.principal = principal
- UserError.__init__(self)
+ Exception.__init__(self, self.__doc__)
class IPasswordUtility(zope.interface.Interface):
@@ -56,8 +64,8 @@
"""
description = zope.schema.Text(
- title=u'Description',
- description=u'A description of the password utility.',
+ title=_(u'Description'),
+ description=_(u'A description of the password utility.'),
required=False)
def verify(new, ref=None):
@@ -87,14 +95,14 @@
"""A password utility for very secure passwords."""
minLength = zope.schema.Int(
- title=u'Minimum Length',
- description=u'The minimum length of the password.',
+ title=_(u'Minimum Length'),
+ description=_(u'The minimum length of the password.'),
required=False,
default=None)
maxLength = zope.schema.Int(
- title=u'Maximum Length',
- description=u'The maximum length of the password.',
+ title=_(u'Maximum Length'),
+ description=_(u'The maximum length of the password.'),
required=False,
default=None)
@@ -106,15 +114,15 @@
u"Minimum lnegth must be greater than the maximum length.")
groupMax = zope.schema.Int(
- title=u'Maximum Characters of Group',
- description=u'The maximum amount of characters that a password can '
- u'have from one group. The groups are: digits, letters, '
- u'punctuation.',
+ title=_(u'Maximum Characters of Group'),
+ description=_(u'The maximum amount of characters that a password can '
+ u'have from one group. The groups are: digits, letters, '
+ u'punctuation.'),
required=False,
default=None)
maxSimilarity = zope.schema.Float(
- title=u'Old/New Similarity',
- description=u'',
+ title=_(u'Old/New Similarity'),
+ description=(u'The similarity ratio between the new and old password.'),
required=False,
default=None)
Added: z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/z3c.password.mo
===================================================================
(Binary files differ)
Property changes on: z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/z3c.password.mo
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/z3c.password.po
===================================================================
--- z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/z3c.password.po 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/locales/de/LC_MESSAGES/z3c.password.po 2006-10-18 06:32:50 UTC (rev 70770)
@@ -0,0 +1,93 @@
+# translation of z3c.password.po to German
+##############################################################################
+#
+# Copyright (c) 2003-2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+# Stephan Richter <stephan.richter at tufts.edu>, 2006.
+##############################################################################
+msgid ""
+msgstr ""
+"Project-Id-Version: z3c.password\n"
+"POT-Creation-Date: Tue Oct 17 23:25:44 2006\n"
+"PO-Revision-Date: 2006-10-17 23:36-0400\n"
+"Last-Translator: Stephan Richter <stephan.richter at tufts.edu>\n"
+"Language-Team: German <zope3-dev at zope.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: zope/app/locales/extract.py\n"
+"X-Generator: KBabel 1.11.4\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: src/z3c/password/interfaces.py:104
+msgid "Maximum Length"
+msgstr "Maximale Länge"
+
+#: src/z3c/password/interfaces.py:105
+msgid "The maximum length of the password."
+msgstr "Die maximale Länge des Passwortes."
+
+#: src/z3c/password/interfaces.py:117
+msgid "Maximum Characters of Group"
+msgstr "Maximale Yeichen einer Gruppe"
+
+#: src/z3c/password/interfaces.py:118
+msgid "The maximum amount of characters that a password can have from one group. The groups are: digits, letters, punctuation."
+msgstr "Die maximale Anzahl von Zeichen welche das Passwort von einer Gruppe enthalten darf. Die Gruppen sind: Zahlen, Buchstaben, Zeichen."
+
+#: src/z3c/password/interfaces.py:125
+msgid "Old/New Similarity"
+msgstr "Alt/Neu Ãhnlichkeit"
+
+#: src/z3c/password/interfaces.py:29
+msgid "No new password specified."
+msgstr "Kein Passwort wurde andgegeben."
+
+#: src/z3c/password/interfaces.py:32
+msgid "Password is too short."
+msgstr "Passwort ist zu kurz."
+
+#: src/z3c/password/interfaces.py:35
+msgid "Password is too long."
+msgstr "Passwort ist zu lang."
+
+#: src/z3c/password/interfaces.py:38
+msgid "Password is too similar to old one."
+msgstr "Passwort ist zu aehnlich zum Alten."
+
+#: src/z3c/password/interfaces.py:41
+msgid "Password contains too many characters of one group."
+msgstr "Passwort enthaelt zu viele Zeichen einer Gruppe."
+
+#: src/z3c/password/interfaces.py:44
+msgid "The password has expired."
+msgstr "Das Passwort ist abgelaufen."
+
+#: src/z3c/password/interfaces.py:51
+msgid "The password was entered incorrectly too often."
+msgstr "Das Passwort wurde zu oft falsch eingegeben."
+
+#: src/z3c/password/interfaces.py:67
+msgid "Description"
+msgstr "Beschreibung"
+
+#: src/z3c/password/interfaces.py:68
+msgid "A description of the password utility."
+msgstr "Eine BEschreibung des Passwortdienstes."
+
+#: src/z3c/password/interfaces.py:98
+msgid "Minimum Length"
+msgstr "Minimale Länge"
+
+#: src/z3c/password/interfaces.py:99
+msgid "The minimum length of the password."
+msgstr "Die minimale Länge des Passwortes."
+
Added: z3c.password/trunk/src/z3c/password/locales/z3c.password.pot
===================================================================
--- z3c.password/trunk/src/z3c/password/locales/z3c.password.pot 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/locales/z3c.password.pot 2006-10-18 06:32:50 UTC (rev 70770)
@@ -0,0 +1,89 @@
+##############################################################################
+#
+# Copyright (c) 2003-2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+msgid ""
+msgstr ""
+"Project-Id-Version: Development/Revision: 70761\n"
+"POT-Creation-Date: Tue Oct 17 23:25:44 2006\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: Zope 3 Developers <zope3-dev at zope.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: zope/app/locales/extract.py\n"
+
+#: src/z3c/password/interfaces.py:104
+msgid "Maximum Length"
+msgstr ""
+
+#: src/z3c/password/interfaces.py:105
+msgid "The maximum length of the password."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:117
+msgid "Maximum Characters of Group"
+msgstr ""
+
+#: src/z3c/password/interfaces.py:118
+msgid "The maximum amount of characters that a password can have from one group. The groups are: digits, letters, punctuation."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:125
+msgid "Old/New Similarity"
+msgstr ""
+
+#: src/z3c/password/interfaces.py:29
+msgid "No new password specified."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:32
+msgid "Password is too short."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:35
+msgid "Password is too long."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:38
+msgid "Password is too similar to old one."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:41
+msgid "Password contains too many characters of one group."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:44
+msgid "The password has expired."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:51
+msgid "The password was entered incorrectly too often."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:67
+msgid "Description"
+msgstr ""
+
+#: src/z3c/password/interfaces.py:68
+msgid "A description of the password utility."
+msgstr ""
+
+#: src/z3c/password/interfaces.py:98
+msgid "Minimum Length"
+msgstr ""
+
+#: src/z3c/password/interfaces.py:99
+msgid "The minimum length of the password."
+msgstr ""
+
Modified: z3c.password/trunk/src/z3c/password/password.py
===================================================================
--- z3c.password/trunk/src/z3c/password/password.py 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/password.py 2006-10-18 06:32:50 UTC (rev 70770)
@@ -76,18 +76,18 @@
'''See interfaces.IHighSecurityPasswordUtility'''
# 0. Make sure we got a password.
if not new:
- raise interfaces.InvalidPassword(u'No new password specified.')
+ raise interfaces.NoPassword()
# 1. Make sure the password has the right length.
- if len(new) < self.minLength or len(new) > self.maxLength:
- raise interfaces.InvalidPassword(
- u'New password is too long or too short.')
+ if len(new) < self.minLength:
+ raise interfaces.TooShortPassword()
+ if len(new) > self.maxLength:
+ raise interfaces.TooLongPassword()
# 2. Ensure that the password is sufficiently different to the old
# one.
if ref is not None:
sm = difflib.SequenceMatcher(None, new, ref)
if sm.ratio() > self.maxSimilarity:
- raise interfaces.InvalidPassword(
- u'New password too similar to old one.')
+ raise interfaces.TooSimilarPassword()
# 3. Ensure that the password's character set is complex enough.
num_lower_letters = 0
num_upper_letters = 0
@@ -110,8 +110,7 @@
num_digits > self.groupMax or
num_specials > self.groupMax or
num_others > self.groupMax):
- raise interfaces.InvalidPassword(
- u'New password contains too many characters of one group.')
+ raise interfaces.TooManyGroupCharacters()
return
def generate(self, ref=None):
Modified: z3c.password/trunk/src/z3c/password/principal.py
===================================================================
--- z3c.password/trunk/src/z3c/password/principal.py 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/principal.py 2006-10-18 06:32:50 UTC (rev 70770)
@@ -35,6 +35,7 @@
def setPassword(self, password, passwordManagerName=None):
super(PrincipalMixIn, self).setPassword(password, passwordManagerName)
self.passwordSetOn = datetime.datetime.now()
+ self.failedAttempts = 0
password = property(getPassword, setPassword)
Added: z3c.password/trunk/src/z3c/password/z3c.password-configure.zcml
===================================================================
--- z3c.password/trunk/src/z3c/password/z3c.password-configure.zcml 2006-10-18 03:10:50 UTC (rev 70769)
+++ z3c.password/trunk/src/z3c/password/z3c.password-configure.zcml 2006-10-18 06:32:50 UTC (rev 70770)
@@ -0,0 +1 @@
+<include package="z3c.password" />
Property changes on: z3c.password/trunk/src/z3c/password/z3c.password-configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list