- Timestamp:
- 10 Sep 2012, 11:05:07 (12 years ago)
- Location:
- main/waeup.kofa/branches/uli-async-update
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-async-update
- Property svn:mergeinfo changed
-
main/waeup.kofa/branches/uli-async-update/src/waeup/kofa/userscontainer.py
r8757 r9169 23 23 from waeup.kofa.interfaces import IUsersContainer 24 24 from waeup.kofa.utils.logger import Logger 25 from waeup.kofa.utils.batching import ExporterBase 26 from waeup.kofa.interfaces import ICSVExporter 27 from waeup.kofa.interfaces import MessageFactory as _ 28 25 29 26 30 class UsersContainer(grok.Container, Logger): … … 60 64 del self[name] 61 65 #self.logger.info('User account %s deleted.' % name) 66 67 68 class UsersExporter(grok.GlobalUtility, ExporterBase): 69 """Exporter for user accounts. 70 """ 71 grok.implements(ICSVExporter) 72 grok.name('users') 73 74 #: Fieldnames considered by this exporter 75 fields = ('name', 'title', 'public_name', 'description', 76 'email', 'phone', 'roles', 'local_roles', 'password') 77 78 #: The title under which this exporter will be displayed 79 title = _(u'Users') 80 81 def mangle_value(self, value, name, context=None): 82 """Treat location values special. 83 """ 84 85 if name == 'local_roles' and context is not None: 86 local_roles = context.getLocalRoles() 87 value = {} 88 for role in local_roles.keys(): 89 objects = local_roles[role] 90 object_list = [] 91 for object in objects: 92 object.__class__.__name__ 93 object_list.append((object.__name__, object.__class__.__name__)) 94 value[role] = object_list 95 return super( 96 UsersExporter, self).mangle_value( 97 value, name, context=context) 98 99 def export(self, users, filepath=None): 100 """Export `users`, an iterable, as CSV file. 101 102 If `filepath` is ``None``, a raw string with CSV data is returned. 103 """ 104 writer, outfile = self.get_csv_writer(filepath) 105 for user in users: 106 self.write_item(user, writer) 107 return self.close_outfile(filepath, outfile) 108 109 def export_all(self, site, filepath=None): 110 """Export users into filepath as CSV data. 111 112 If `filepath` is ``None``, a raw string with CSV data is returned. 113 """ 114 writer, outfile = self.get_csv_writer(filepath) 115 users = site.get('users', {}) 116 return self.export(users.values(), filepath)
Note: See TracChangeset for help on using the changeset viewer.