def new_user(principal, event):
    """Initialise the dashboard for a new user
    """
    principal = IEduMember(principal)
    #defaults = IDefaultDashboard(principal, None)
    defaults = DefaultDashboard()
    if defaults is None:
        return
    
    userid = principal.getId()
    portlets = defaults()
    for name in ('plone.dashboard1', 'plone.dashboard2', 'plone.dashboard3', 'plone.dashboard4'):
        assignments = portlets.get(name)
        if assignments:
            column = queryUtility(IPortletManager, name=name)
            if column is not None:
                category = column.get(USER_CATEGORY, None)
                if category is not None:
                    manager = category.get(userid, None)
                    if manager is None:
                        manager = category[userid] = UserPortletAssignmentMapping()
                    chooser = INameChooser(manager)
            
                    for assignment in assignments:
                        manager[chooser.chooseName(None, assignment)] = assignment
def verifyGroups(obj, event):
    """
    Consolidation for all the groups that the user belogs to
    """
    print "Modify %s on %s" % (obj.getPhysicalPath(), event)
    #IEduMember(obj).verifyGroups()

    context = IEduMember(obj)
    tctool = getToolByName(context, 'portal_tctool')
    parent = context.aq_inner.aq_parent
    parent = parent.getGroupId()
    user_groups = context.getGroups()
    
    dinamic_grps = [x for x in user_groups if x.startswith(parent+'_group')]
    static_grps = []
    
    #First, Make a list with all the static groups
    #company_division
    #Is a MultiSelectionWidget. Returns a list
    company_division = context.getCompany_division()
    if company_division:
        static_grps.extend(company_division)

    #company_work_area
    #It is a SelectionWidget. It always returns an string
    company_work_area = context.getCompany_work_area()
    if company_work_area:
        static_grps.append(company_work_area)
    
    #company_position
    #It is a SelectionWidget. It always returns an string
    company_position = context.getCompany_position()
    if company_position:
        static_grps.append(company_position)
    
    #Join all dynamic and static groups along with the
    #corresponding training center group.
    
    new_grps=[parent,] # add user to training center group
    new_grps.extend(dinamic_grps)
    new_grps.extend(static_grps)

    user_groups = frozenset(user_groups)
    new_grps = frozenset(new_grps)
    remove = user_groups - new_grps
    final = (user_groups | new_grps) - remove
    if remove:
        print "\nRemove from EduMember",list(remove)
        tctool.removeGroupUser(user=context.getId(),groups=list(remove))

    tctool.addGroupUser(user=context.getId(),groups=list(final))
    
    ########### assign the main group ######   
    main_group = context.getMain_group()
    if not main_group:
        context.setMain_group(parent)