[Checkins] SVN: gocept.registration/trunk/ completed functional testing

Christian Theune ct at gocept.com
Sat Mar 15 11:02:20 EDT 2008


Log message for revision 84662:
  completed functional testing
  

Changed:
  A   gocept.registration/trunk/README.txt
  U   gocept.registration/trunk/setup.py
  U   gocept.registration/trunk/src/gocept/registration/README.txt
  U   gocept.registration/trunk/src/gocept/registration/browser/confirmation.pt
  U   gocept.registration/trunk/src/gocept/registration/browser/confirmation_error.pt
  A   gocept.registration/trunk/src/gocept/registration/demo/README.txt
  U   gocept.registration/trunk/src/gocept/registration/demo/__init__.py
  U   gocept.registration/trunk/src/gocept/registration/demo/application.zcml
  U   gocept.registration/trunk/src/gocept/registration/tests.py

-=-
Added: gocept.registration/trunk/README.txt
===================================================================
--- gocept.registration/trunk/README.txt	                        (rev 0)
+++ gocept.registration/trunk/README.txt	2008-03-15 15:02:20 UTC (rev 84662)
@@ -0,0 +1,22 @@
+======================
+User self-registration
+======================
+
+This package provides functionality to implement user self-registration for
+applications.
+
+The general workflow requires that every user provides at least his email
+address but additional data may be provided, too.  After a user registered, an
+email is send out asking him to confirm his identity by clicking a link that
+is embedded in the email.  Once a registration is confirmed, the temporarily
+stored registration data is deleted.
+
+Applications can customize the registration behaviour by subscribing to events
+for registration and confirmation and providing application-specific views and
+adapters for registration and email creation.
+
+There is a demo application included in this package/buildout that shows how
+to use the basic views available to quickly create registration and
+confirmation views and customized emails for your application. Both the views
+and the email generation provide a good degree of flexibility so they can be
+re-used directly, but you can also provide your own.


Property changes on: gocept.registration/trunk/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: gocept.registration/trunk/setup.py
===================================================================
--- gocept.registration/trunk/setup.py	2008-03-15 13:15:08 UTC (rev 84661)
+++ gocept.registration/trunk/setup.py	2008-03-15 15:02:20 UTC (rev 84662)
@@ -48,6 +48,7 @@
         test=['zope.testing',
               'zope.app.twisted',
               'zope.app.securitypolicy',
+              'zope.testbrowser',
               'z3c.formui',
               'z3c.layer'])
     )

Modified: gocept.registration/trunk/src/gocept/registration/README.txt
===================================================================
--- gocept.registration/trunk/src/gocept/registration/README.txt	2008-03-15 13:15:08 UTC (rev 84661)
+++ gocept.registration/trunk/src/gocept/registration/README.txt	2008-03-15 15:02:20 UTC (rev 84662)
@@ -2,19 +2,6 @@
 User self-registration
 ======================
 
-This package provides functionality to implement user self-registration for
-applications.
-
-The general workflow requires that every user provides at least his email
-address but additional data may be provided, too.  After a user registered, an
-email is send out asking him to confirm his identity by clicking a link that
-is embedded in the email.  Once a registration is confirmed, the temporarily
-stored registration data is deleted.
-
-Applications can customize the registration behaviour by subscribing to events
-for registration and confirmation and providing application-specific views and
-adapters for registration and email creation.
-
 Registering a user
 ==================
 
@@ -148,7 +135,9 @@
 
   >>> from gocept.registration.email import send_registration_mail
   >>> zope.component.provideAdapter(ConfirmationEmail, (IRegistration,))
-  >>> zope.component.provideHandler(send_registration_mail, (IObjectAddedEvent,))
+  >>> zope.component.provideHandler(send_registration_mail, (IRegistration, IObjectAddedEvent,))
+  >>> from zope.component.event import objectEventNotify
+  >>> zope.component.provideHandler(objectEventNotify, (IObjectAddedEvent,))
   >>> from gocept.registration.tests import DummyMailer
   >>> zope.component.provideUtility(DummyMailer())
   >>> janine = registrations.register('janine at example.com')

Modified: gocept.registration/trunk/src/gocept/registration/browser/confirmation.pt
===================================================================
--- gocept.registration/trunk/src/gocept/registration/browser/confirmation.pt	2008-03-15 13:15:08 UTC (rev 84661)
+++ gocept.registration/trunk/src/gocept/registration/browser/confirmation.pt	2008-03-15 15:02:20 UTC (rev 84662)
@@ -1 +1,3 @@
-<h1>Hello, you are now registered!</h1>
+<h1>Success</h1>
+
+<p>Your registration was successful.</p>

Modified: gocept.registration/trunk/src/gocept/registration/browser/confirmation_error.pt
===================================================================
--- gocept.registration/trunk/src/gocept/registration/browser/confirmation_error.pt	2008-03-15 13:15:08 UTC (rev 84661)
+++ gocept.registration/trunk/src/gocept/registration/browser/confirmation_error.pt	2008-03-15 15:02:20 UTC (rev 84662)
@@ -1 +1,3 @@
-<h1>Booh! This wasn't a correct registration!</h1>
+<h1>Error</h1>
+
+<p>Your registration could not be confirmed.</p>

Added: gocept.registration/trunk/src/gocept/registration/demo/README.txt
===================================================================
--- gocept.registration/trunk/src/gocept/registration/demo/README.txt	                        (rev 0)
+++ gocept.registration/trunk/src/gocept/registration/demo/README.txt	2008-03-15 15:02:20 UTC (rev 84662)
@@ -0,0 +1,74 @@
+=========================================
+Basic confirmation and registration views
+=========================================
+
+`gocept.registration` comes with a set of basic views and adapters that make it
+easy to set up registration-related views for your specific application.
+
+In general you need to provide a registration form where the user can fill in
+his data, and a confirmation view which takes the users hash.  In addition you
+need to provide configuration for sending out emails (like the from-address, a
+template for creating the URL to the confirmation view, and an email
+template).
+
+`gocept.registration.demo` demonstrates a simple integration using these
+standard components. Mail is being sent to the standard output of your
+application.
+
+The registration view is available everywhere with the name `register.html`:
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.open('http://localhost/register.html')
+  >>> print browser.contents
+  <!DOCTYPE ...
+      <title>gocept.registration demo</title>
+      ...
+      <div class="widget"><input type="text" id="form-widgets-email"
+         name="form.widgets.email"
+         class="text-widget required textline-field" value="" />
+      ...
+  >>> browser.getControl('Email address').value = 'john at example.com'
+  >>> browser.getControl('Register').click()
+  (Ad Ministrator <admin at example.com> -> [u'john at example.com'])
+  From: Ad Ministrator <admin at example.com>
+  To: john at example.com
+  Subject: Please confirm your registration
+  <BLANKLINE>
+  We received your registration. To activate it, please follow this confirmation
+  link:
+  <BLANKLINE>
+    http://localhost/confirm.html?hash=<SHA-HASH>
+
+The link embedded in the email can be clicked by the user, although we need to
+peek into our registration utility, to find the user's actual hash:
+
+  >>> import zope.component
+  >>> from gocept.registration.interfaces import IRegistrations
+  >>> registrations = zope.component.getUtility(IRegistrations)
+  >>> john = registrations.values()[0].hash
+  >>> browser.open('http://localhost/confirm.html?hash=%s' % john)
+  >>> print browser.contents
+  <!DOCTYPE...
+  <h1>Success</h1>...
+  <p>Your registration was successful.</p>
+  ...
+
+A registration can only be confirmed once. If the hash is used a second time,
+this will raise an error:
+
+  >>> browser.open('http://localhost/confirm.html?hash=%s' % john)
+  >>> print browser.contents
+  <!DOCTYPE...
+  <h1>Error</h1>...
+  <p>Your registration could not be confirmed.</p>
+  ...
+
+Probing random hashes will also result in an error:
+
+  >>> browser.open('http://localhost/confirm.html?hash=foo')
+  >>> print browser.contents
+  <!DOCTYPE...
+  <h1>Error</h1>...
+  <p>Your registration could not be confirmed.</p>
+  ...


Property changes on: gocept.registration/trunk/src/gocept/registration/demo/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: gocept.registration/trunk/src/gocept/registration/demo/__init__.py
===================================================================
--- gocept.registration/trunk/src/gocept/registration/demo/__init__.py	2008-03-15 13:15:08 UTC (rev 84661)
+++ gocept.registration/trunk/src/gocept/registration/demo/__init__.py	2008-03-15 15:02:20 UTC (rev 84662)
@@ -20,6 +20,7 @@
 import z3c.layer.pagelet
 import z3c.form.interfaces
 import zope.component
+import zope.security.management
 import gocept.registration.interfaces
 
 
@@ -49,4 +50,6 @@
     confirmation_template = DEMO_TEMPLATE
 
     def __init__(self, registration):
-        pass
+        request = zope.security.management.getInteraction().participations[0]
+        self.confirmation_url = (request.getApplicationURL() +
+                                 self.confirmation_url)

Modified: gocept.registration/trunk/src/gocept/registration/demo/application.zcml
===================================================================
--- gocept.registration/trunk/src/gocept/registration/demo/application.zcml	2008-03-15 13:15:08 UTC (rev 84661)
+++ gocept.registration/trunk/src/gocept/registration/demo/application.zcml	2008-03-15 15:02:20 UTC (rev 84662)
@@ -1,6 +1,7 @@
 <configure xmlns="http://namespaces.zope.org/zope"
   xmlns:browser="http://namespaces.zope.org/browser"
-  xmlns:z3c="http://namespaces.zope.org/z3c">
+  xmlns:z3c="http://namespaces.zope.org/z3c"
+  i18n_domain="gocept.registration.demo">
 
   <include package="zope.app.component" file="meta.zcml" />
   <include package="zope.app.component.browser" file="meta.zcml" />

Modified: gocept.registration/trunk/src/gocept/registration/tests.py
===================================================================
--- gocept.registration/trunk/src/gocept/registration/tests.py	2008-03-15 13:15:08 UTC (rev 84661)
+++ gocept.registration/trunk/src/gocept/registration/tests.py	2008-03-15 15:02:20 UTC (rev 84662)
@@ -49,4 +49,10 @@
         optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE,
         checker=checker, setUp=placelesssetup.setUp,
         tearDown=placelesssetup.tearDown))
+    demo = functional.FunctionalDocFileSuite(
+        os.path.join('demo', 'README.txt'),
+        optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE,
+        checker=checker)
+    demo.layer = RegistrationLayer
+    suite.addTest(demo)
     return suite



More information about the Checkins mailing list