1 from zope.interface import implements
2 from twisted.internet import defer
3 from webut.skin import iskin
4 from ldaptor.protocols.ldap import ldapsyntax
5 from ldaptor import generate_password
6 from ldaptor.apps.webui.uriquote import uriUnquote
7 from twisted.internet import reactor
8 from ldaptor.apps.webui.i18n import _
9 from ldaptor.apps.webui import i18n
10
11 import os
12 from nevow import rend, inevow, loaders, url, tags
13 from formless import annotate, webform, configurable
14
19
76 d.addCallback(_gotPasswords, entries)
77 d.addCallback(MassPasswordChangeStatus)
78 return d
79
80
82 implements(iskin.ISkinnable)
83
84 title = _('Ldaptor Mass Password Change Page')
85
86 addSlash = True
87 docFactory = loaders.xmlfile(
88 'mass_change_password-really.xhtml',
89 templateDir=os.path.split(os.path.abspath(__file__))[0])
90
91 - def __init__(self, entries):
92 super(ReallyMassPasswordChangePage, self).__init__()
93 self.entries = entries
94
96 u=url.URL.fromContext(ctx)
97 u=u.parentdir().parentdir().clear()
98 l=[]
99 l.append(tags.a(href=u.sibling("search"))[_("Search")])
100 l.append(tags.a(href=u.sibling("add"))[_("add new entry")])
101 return l
102
103 - def configurable_(self, context):
104 request = context.locate(inevow.IRequest)
105 return MassPasswordChangeForm(self.entries)
106
108 return webform.renderForms()[context.tag]
109
110 - def render_passthrough(self, context, data):
111 return context.tag.clear()[data]
112
113 - def render_status(self, context, data):
114 try:
115 obj = context.locate(inevow.IHand)
116 except KeyError:
117 return context.tag.clear()
118
119 if not isinstance(obj, MassPasswordChangeStatus):
120 return context.tag.clear()[obj]
121
122 dl = tags.dl(compact="compact")
123 context.tag.clear()[dl]
124 for success, x in obj.deferlist:
125 if success:
126 entry, pwd = x
127 dl[tags.dt[entry.dn],
128 tags.dd[pwd]]
129 else:
130 context.tag[_('Failed: '), x.getErrorMessage()]
131
132 return context.tag
133
134 render_i18n = i18n.render()
135
137 implements(iskin.ISkinnable)
138
139 title = _('Ldaptor Mass Password Change Page')
140
141 addSlash = True
142 docFactory = loaders.xmlfile(
143 'mass_change_password.xhtml',
144 templateDir=os.path.split(os.path.abspath(__file__))[0])
145
146 - def __init__(self, baseObject):
149
150 - def render_url(self, context, data):
151 u = url.URL.fromContext(context)
152 return context.tag(href=u.parentdir().child('search'))
153
154 - def childFactory(self, context, name):
155 entry = inevow.ISession(context).getLoggedInRoot().loggedIn
156
157 filt = uriUnquote(name)
158
159 e=ldapsyntax.LDAPEntry(client=entry.client,
160 dn=self.baseObject)
161 d=e.search(filterText=filt, sizeLimit=20)
162 d.addCallback(ReallyMassPasswordChangePage)
163 return d
164
165 render_i18n = i18n.render()
166