Changeset 2643 for WAeUP_SRP/base


Ignore:
Timestamp:
13 Nov 2007, 15:34:43 (17 years ago)
Author:
joachim
Message:

resolve #396

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTool.py

    r2632 r2643  
    296296    ###)
    297297
     298    security.declareProtected(ManagePortal, 'listMembers') ###(
     299    def listMembers(self):
     300        "list all members"
     301        mtool = self.portal_membership
     302        member = mtool.getAuthenticatedMember()
     303        logger = logging.getLogger('WAeUPTool.listMembers')
     304        if str(member) not in ('admin','joachim'):
     305            logger.info('%s tried to list members' % (member))
     306            return None
     307        members = self.portal_directories.members
     308        all = members.listEntryIdsAndTitles()
     309        l = []
     310        for user_id,name in all:
     311            d = {}
     312            d['user_id'] = user_id
     313            d['name'] = name
     314            d['pw'] = getattr(getattr(members,user_id),'password')
     315            l += d,
     316        #import pdb;pdb.set_trace()
     317        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
     318        export_file = "%s/export/member_list_%s.csv" % (i_home,current,)
     319        logger.info('%s dumped memberlist to %s' % (member,export_file))
     320        fields = l[0].keys()
     321        headline = ','.join(fields)
     322        out = open(export_file,"wb")
     323        out.write(headline +'\n')
     324        out.close()
     325        out = open(export_file,"a")
     326        csv_writer = csv.DictWriter(out,fields,)
     327        csv_writer.writerows(l)
     328    ###)
     329   
    298330    security.declareProtected(ManagePortal, 'removeDeletedDocIds') ###(
    299331    def removeDeletedDocIds(self, max=1000):
Note: See TracChangeset for help on using the changeset viewer.