Mine værktøjer
Du er her: Forside Python program eksempler. Plone: tidy up users

Plone: tidy up users

Tilbage

Hent filen

Licens GPL

Plone External method script to tidy up in users. Find members who has not responded to login mail within 24 hours via a login and delete them This is due to those robots out there continiusly knocking your site and create accounts. Tested on Plone 2.1.4-rc1, Zope (Zope 2.8.8-final, python 2.4.4, linux2), Python 2.4.4 (#5, Apr 18 2007, 09:19:16) [GCC 3.3.5 20050117 (prerelease) (SUSE Linux)],

#!usr/bin/python
# -*- coding: UTF-8 -*-
# File: memberdelete.py
"""
Plone External method script to tidy up in users.

find members who has not responded to login mail
within 24 hours via a login and delete them
This is due to those robots out there continiusly knocking your site 
and create accounts.

Tested on 
 Plone 2.1.4-rc1,
 Zope (Zope 2.8.8-final, python 2.4.4, linux2),
 Python 2.4.4 (#5, Apr 18 2007, 09:19:16) [GCC 3.3.5 20050117 (prerelease) (SUSE Linux)],
"""
okey_member=[\
    "Tommy Jensen",
    "kate Salling",
]

# comment columns you dont want in your report.
columns= [\
    'fullname',
    # 'last_login_time',
    'login_time',
    'bobo_mod_time',
    'login',
    # 'password',
    # 'email',
    'delete',
    ]
# map function to fetch data for the columns
functions = {
    'fullname'          :"getattr(member, 'fullname')",
    'last_login_time'   :"getattr(member, 'last_login_time')",
    'login_time'        :"getattr(member, 'login_time')",
    'login'             :"getattr(member, 'name')",
    'bobo_mod_time'     :"member.bobobase_modification_time()",
    'password'          :"str(member.getPassword()).strip()",
    'email'             :"getattr(member, 'email')",
    'delete'            :"deleteMember(self,member)",
}

def deleteMember( self, member ):
    """ Boolean;
    Decide if member should bee removed
    """
    fullname = eval( functions[ 'fullname' ] )
    if fullname in okey_member:
        return False
    boboTime = eval( functions[ 'bobo_mod_time' ] )
    loginTime = eval( functions[ 'login_time' ] )
    return boboTime + 1 < self.ZopeTime() and boboTime < loginTime

def memberDelete(self):
    """ get site members """
    from Products.CMFCore.utils import getToolByName
    acl_users = self.acl_users
    text = ['<html><meta http-equiv="content-type" content="text/html;charset=utf-8" />']

    text.append( "<table><th>" )
    text.append( "</th><th>".join(columns) )
    text.append( "</th>" )
    membership = getToolByName(self, 'portal_membership')

    format = "<tr><td>"
    format += "</td><td>".join( ["%%(%s)s" % (c) for c in columns] )
    format += "</td></tr>"
    dato_limit = "2000/01/01"
    for member in membership.listMembers():
        data = {}
        for p in columns:
            data[ p ] = eval( functions.get( p ) )
        text.append( format % data )
        if deleteMember( self, member ):
            login = eval( functions[ 'login' ] )
            acl_users.userFolderDelUsers( [ login ] )

    text.append( "</table></html>" )
    return "".join( text )


« august 2018 »
søn man tir ons tor fre lør
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Chat Rooms
Dyrk motion

Trim ballerup

 

Powered by Plone, the Open Source Content Management System