Lams/add_user.zpt:

<html>
  <head>
    <title>Leave Application Management System</title>
  </head>
  <body>
    <h1>Add User</h1>
    <form method="post" action="set_user" name="add_user_form">
      User name: <input type="text" name="user_name" /> <br/>
      Password: <input type="password" name="password" /> <br/>
      Role: <select name="roles:list" multiple>
        <option value="EM">EM - Employee</option>
        <option value="TL">TL - Techlead</option>
        <option value="PM">PM - Project Manager</option>
      </select><br/>
      <input type="submit" value="Add User">
    </form>
  </body>
</html>

Lams/apply_for_leave.zpt:

<html>
  <head>
    <title>Leave Application Management System</title>
  </head>
  <body>
    <h1>Aply for Leave</h1>
    <form method="post" action="save_leave_application" name="leave_form">

      <input type="submit" name="Add" />
    </form>
  </body>
</html>

Lams/index_html.zpt:

<html>
  <head>
    <title>Leave Application Management System</title>
  </head>
  <body>
    <a href="add_user">Add User</a> <br />
    <a href="apply_for_leave">Apply for Leave</a>
  </body>
</html>

Lams/manage_addform.zpt:

<html>
  <head>
    <title>Add Lams Instance</title>
  </head>
  <body>
  Please enter the id of the new Lams instance:<br/>
    <form method="get" name="form" action="manage_addLams"><br/>
      <input type="text" name="id" value="mylams"><br/>
      <input type="submit" value="Add">
    </form>
  </body>
</html>

Lams/__init__.py:

#Leave application management system - A Zope Product

from Lams import Lams, manage_addLams, manage_addLams_form

def initialize(context):

    context.registerClass(
        Lams,
        constructors=(manage_addLams_form,
                      manage_addLams))

Lams/Lams.py:

from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from OFS.Folder import Folder
from AccessControl import ClassSecurityInfo

manage_addLams_form = PageTemplateFile('manage_addform.zpt', globals())


def manage_addLams(self, id='mylams', REQUEST=None):
    """Function for adding Lams product"""
    lams = Lams(id)
    self._setObject(id, lams)
    if REQUEST is not None:
        try:
            url = self.DestinationURL()
        except:
            url = REQUEST['URL1']

        # Redirect to the management interface after installation
        REQUEST.RESPONSE.redirect('%s/manage_main' % url)


class Lams(Folder):

    meta_type = 'Lams'

    security = ClassSecurityInfo()

    security.declareProtected('Lams Access Basic System', 'index_html')

    index_html = PageTemplateFile('index_html.zpt', globals())

    security.declareProtected('Lams Manage User', 'add_user')

    add_user = PageTemplateFile('add_user.zpt', globals())

    apply_for_leave = PageTemplateFile('apply_for_leave.zpt', globals())

    def save_leave_application(self):
        """Save the leave application submitted by applicant"""
        pass

    def manage_afterAdd(self, *args):
        """This method is called after object is added"""

        roles = ('TL', 'PM', 'EM')

        role_and_permissions = [
            ('Lams Access Basic System', ('EM',)),
            ('Lams Manage User', ('PM',),),
            #('Lams Verify Leave Application', ('TL', 'PM')),
            ]

        for role in roles:
            self._addRole(role)

        self.manage_addUserFolder()

        uf = self.acl_users
        uf.userFolderAddUser('user1', 'passwd', ['EM',], [])
        uf.userFolderAddUser('user2', 'passwd', ['EM','TL'], [])
        uf.userFolderAddUser('user3', 'passwd', ['EM','PM'], [])

        for permission, roles in role_and_permissions:
            self.manage_permission(permission, roles, acquire=0)

    security.declareProtected('Lams Manage User', 'set_user')
    def set_user(self):
        """Add user"""
        uf = self.acl_users
        user_name = self.REQUEST['user_name']
        password = self.REQUEST['password']
        roles = self.REQUEST['roles']
        uf.userFolderAddUser(user_name, password, roles, [])
        pass

    security.declareProtected('Lams Manage User', 'delete_user')
    def delete_user(self):
        """Delete user"""
        pass