ZopeMag's mascot the ZOPE fish


Article Finder
People
Issue 1 - Revision 5  /   June 14, 2002 


 
  ZopeMag Links:
Home Page
About the Fish
Issue 09
Issue 08
Issue 07
Issue 06
Issue 05
Issue 04
Issue 03
Issue 02
Issue 01
Latest Issue

 
 
Downloads
     
  Letter from the Editor:
   Welcome

Interviews:
In our first issue we interview the father of the Wiki and the inventor of Extreme Programming.

 Ward Cunningham

Tutorials:
Throughout the quarter we cover topics of interest to Zope developers, designers, and users.

  MetaFlow
  Databases and ZPTs
  Custom User Folders
  Zope and CSS
  Intranets

Product Review:
Every two weeks we review a new Zope Product

  Z Shrink
  External File
  DocumentLibrary
  ZWiki


 
 
Downloads
     
  Downloads:
Products we talk about in this issues Articles and Reviews

  ZShrink
  Zope Page Templates
  LocalFS
  SimpleZPTmyAdmin
  Extended User Folder
  MetaFlow
 
     



Customized User Folders Part I
Write your own product that suits you best.
- - - - - - - - - - - -

By Kristoph Kirchner | May 22, 2002


As mentioned before, you also need to change the standard forms for adding and editing a user. You can use the standard user folder forms and simply add a text row with an email textfield:

Listing 3: Additional Code for addUser.dtml
 
 <tr>
  <td align="left" valign="top">
   <div class="form-optional">
    E-Mail
   </div>
  </td>
  <td align="left" valign="top">
   <input type="text" name="email" size="30" value="" />
  </td>
 </tr>
 
 


Listing 4: Additional Code for editUser.dtml
 
 <TR>
  <TD VALIGN="TOP">
   <div class="form-optional">
    E-Mail
   </div>
  </TD>
  <TD VALIGN="TOP">
   <INPUT TYPE="TEXT" NAME="email" SIZE="30"
   VALUE="<dtml-if expr="user.email">
   <dtml-var expr="user.email"></dtml-if>" />
  </TD>
 </TR>
  
  

If you want to, you can also add a method that checks whether a valid email address was entered (Listing 5).

Listing 5: checkEmail() Method of the ExtendedUserFolder class
 

 def checkEmail(self, email):
		isEmail = 0
		if string.find(email, '@') <> -1:
			isEmail = 1
		return isEmail
  
 

Then you can use this method and refuse adding or changing a user if the email address does not appear to be a valid one. Listing 6 shows the additional lines that have to go into the _addUser() and the _changeUser() methods.



Listing 6: Additional Code for the _addUser() and the _changeUser() Methods
 
 if self.checkEmail(REQUEST['email']) != 1:
		return MessageDialog(
			title  ='Illegal value',
			message='Not a valid email address',
			action ='manage_main')

  
  
Summary

This article has given you an easy introduction on how to create your own user folder. The next part in this series will show you how to store user information in a relational database and how to retrieve it from there.

.  1  2  3
Tutorial End


Kristoph Kirchner: was born in Berlin in 1977 and finished school in 1996. After completing a degree in Commercial Correspondence, Kirchner went on to study Computer Sciences at the Technical University of Berlin. Since then Kirchner has been working for beehive writing e-books on Zope and documentation for projects of beehive's customers. Kirchner also co-authored the first German Zope book "Zope: Content Management and Web Application Server", the book "Zope: Web Application Construction Kit" and the book "Zope: How to Build and Deliver Web Applications".


shim
shim  ZopeMag is committed to bringing you the best in Zope Documentation. shim
shim


Home   Subscribe   FAQ   Contact   Write for us   Privacy Policy   Weekly News   PyZine   opensourcexperts.com  

Reproduction of material from any of ZopeMag's pages without prior written permission is strictly prohibited. Copyright 2003 - 2005 ZopeMag Zope/Plone hosting by Nidelven IT