def _process2(self, changes, context, rdn, kw): cfg = context.locate(interfaces.ILDAPConfig) user = context.locate(inevow.ISession).getLoggedInRoot().loggedIn if not changes: return _("No changes!") #TODO changes_desc="" mod={} for attr,new in changes: if new: if attr not in mod: mod[attr]=[] mod[attr].extend(new) changes_desc=changes_desc+"<br>adding %s: %s"%(repr(attr), ', '.join(map(repr, new))) if not mod: return _("No changes (2)!") #TODO e = ldapsyntax.LDAPEntryWithClient(client=user.client, dn=iwebui.ICurrentDN(context)) d = e.addChild(rdn, mod) #d.addCallback(lambda e: "Added %s successfully." % e.dn) d.addErrback(lambda reason: _("Failed: %s.") % reason.getErrorMessage()) return d
def render_status(self, context, data): try: obj = context.locate(inevow.IHand) except KeyError: return context.tag.clear() if not isinstance(obj, EditStatus): return context.tag.clear()[obj] u=url.URL.fromContext(context) u=u.parentdir().parentdir().clear() return context.tag.clear()[ _("Edited "), tags.a(href=u.parentdir() .child(obj.entry.dn) .child("search"))[obj.entry.dn], _(" successfully. "), # TODO share implementation with entryLinks '[', tags.a(href=u.sibling('move').child(uriQuote(obj.entry.dn)))[_('move')], '|', tags.a(href=u.sibling('delete').child(uriQuote(obj.entry.dn)))[_('delete')], '|', tags.a(href=u.sibling('change_password').child(uriQuote(obj.entry.dn)))[_('change password')], ']', tags.p[obj.changes], ]
def data_header(self, ctx, data): u=url.URL.fromContext(ctx).up().clear() l=[] l.append(tags.a(href=u.sibling("search"))[_("Search")]) l.append(tags.a(href=u.sibling("add"))[_("add new entry")]) l.append(tags.a(href=u.sibling("edit").child(str(self.dn)))[_("edit")]) return l
def bind_edit(self, ctx): formFields=self._getFormFields() return annotate.MethodBinding( 'edit', annotate.Method(arguments=formFields, label=_('Edit')), action=_('Edit'))
def data_header(self, ctx, data): u = url.URL.fromContext(ctx).up().clear() l = [] l.append(tags.a(href=u.sibling("search"))[_("Search")]) l.append(tags.a(href=u.sibling("add"))[_("add new entry")]) l.append(tags.a(href=u.sibling("edit").child(str(self.dn)))[_("edit")]) return l
def data_header(self, ctx, data): u=url.URL.fromContext(ctx) u=u.parentdir().parentdir().clear() l=[] l.append(tags.a(href=u.sibling("search"))[_("Search")]) l.append(tags.a(href=u.sibling("add"))[_("add new entry")]) return l
def _process2(self, changes, context, rdn, kw): cfg = context.locate(interfaces.ILDAPConfig) user = context.locate(inevow.ISession).getLoggedInRoot().loggedIn if not changes: return _("No changes!") #TODO changes_desc = "" mod = {} for attr, new in changes: if new: if attr not in mod: mod[attr] = [] mod[attr].extend(new) changes_desc = changes_desc + "<br>adding %s: %s" % ( repr(attr), ', '.join(map(repr, new))) if not mod: return _("No changes (2)!") #TODO e = ldapsyntax.LDAPEntryWithClient(client=user.client, dn=iwebui.ICurrentDN(context)) d = e.addChild(rdn, mod) #d.addCallback(lambda e: "Added %s successfully." % e.dn) d.addErrback( lambda reason: _("Failed: %s.") % reason.getErrorMessage()) return d
def data_header(self, ctx, data): u = url.URL.fromContext(ctx) u = u.parentdir().parentdir().clear() l = [] l.append(tags.a(href=u.sibling("search"))[_("Search")]) l.append(tags.a(href=u.sibling("add"))[_("add new entry")]) return l
def bind_search(self, ctx): l = [] l.append(annotate.Argument("ctx", annotate.Context())) for field in config.getSearchFieldNames(): l.append(annotate.Argument("search_%s" % field, annotate.String(label=field))) l.append(annotate.Argument("searchfilter", annotate.String(label=_("Advanced search")))) l.append( annotate.Argument( "scope", annotate.Choice( label=_("Search depth"), choices=[ pureldap.LDAP_SCOPE_wholeSubtree, pureldap.LDAP_SCOPE_singleLevel, pureldap.LDAP_SCOPE_baseObject, ], stringify=strScope, default=pureldap.LDAP_SCOPE_wholeSubtree, ), ) ) return annotate.MethodBinding( name="search", action=_("Search"), typeValue=annotate.Method(arguments=l, label=_("Search")) )
def bind_delete(self, ctx): return annotate.MethodBinding( 'delete', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), ], label=_('Confirm delete')), action=_('Delete'))
def bind_remove(self, ctx): return annotate.MethodBinding('remove', annotate.Method(arguments=[ annotate.Argument( 'ctx', annotate.Context()), ], label=_('Remove')), action=_('Remove'))
def bind_generateRandom(self, ctx): return annotate.MethodBinding( 'generateRandom', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), ], label=_('Generate random')), action=_('Generate random'))
def bind_cancel(self, ctx): return annotate.MethodBinding( 'cancel', annotate.Method(arguments=[ annotate.Argument('context', annotate.Context()), ], label=_('Cancel')), action=_('Cancel'))
def bind_remove(self, ctx): return annotate.MethodBinding( 'remove', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), ], label=_('Remove')), action=_('Remove'))
def strScope(scope): if scope == pureldap.LDAP_SCOPE_wholeSubtree: return _('whole subtree') elif scope == pureldap.LDAP_SCOPE_singleLevel: return _('single level') elif scope == pureldap.LDAP_SCOPE_baseObject: return _('baseobject') else: raise RuntimeError, 'scope is not known: %r' % scope
def strScope(scope): if scope == pureldap.LDAP_SCOPE_wholeSubtree: return _("whole subtree") elif scope == pureldap.LDAP_SCOPE_singleLevel: return _("single level") elif scope == pureldap.LDAP_SCOPE_baseObject: return _("baseobject") else: raise RuntimeError, "scope is not known: %r" % scope
def render_entryLinks(self, ctx, data): u = url.URL.fromContext(ctx).parentdir().clear() l = [ (u.sibling("edit").child(uriQuote(data)), _("edit")), (u.sibling("move").child(uriQuote(data)), _("move")), (u.sibling("delete").child(uriQuote(data)), _("delete")), (u.sibling("change_password").child(uriQuote(data)), _("change password")), ] return self.render_sequence(ctx, l)
def render_overview(self, ctx, data): if self.auxiliaryObjectClasses: return ctx.tag.clear()[_('Using objectclasses %s and %s.') % ( self.structuralObjectClass.name[0], ', '.join([oc.name[0] for oc in self.auxiliaryObjectClasses]), )] else: return ctx.tag.clear()[_('Using objectclass %s.') % (self.structuralObjectClass.name[0], )]
def bind_add(self, ctx): return annotate.MethodBinding( 'add', annotate.Method(arguments=[ annotate.Argument('context', annotate.Context()), annotate.Argument('smartObjectClass', annotate.Choice(choices=self.plugins)), ], label=_('Add')), action=_('Add'))
def render_entryLinks(self, ctx, data): u = url.URL.fromContext(ctx).parentdir().clear() l = [ (u.sibling('edit').child(uriQuote(data)), _('edit')), (u.sibling('move').child(uriQuote(data)), _('move')), (u.sibling('delete').child(uriQuote(data)), _('delete')), (u.sibling('change_password').child(uriQuote(data)), _('change password')), ] return self.render_sequence(ctx, l)
def render_overview(self, ctx, data): if self.auxiliaryObjectClasses: return ctx.tag.clear()[ _('Using objectclasses %s and %s.') % ( self.structuralObjectClass.name[0], ', '.join([oc.name[0] for oc in self.auxiliaryObjectClasses]), )] else: return ctx.tag.clear()[ _('Using objectclass %s.') % ( self.structuralObjectClass.name[0], )]
def bind_setServicePassword(self, ctx): return annotate.MethodBinding( 'setServicePassword', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), annotate.Argument('newPassword', annotate.PasswordEntry(required=True, label=_('New password'))), annotate.Argument('again', annotate.PasswordEntry(required=True, label=_('Again'))), ], label=_('Set password')), action=_('Set password'))
def bind_go(self, ctx): return annotate.MethodBinding( 'go', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), annotate.Argument( 'baseDN', LDAPDN(label=_('Base DN'), description=_( "The top-level LDAP DN you want" " to browse, e.g. dc=example,dc=com"))), ], label=_('Go')), action=_('Go'))
def bind_setServicePassword(self, ctx): return annotate.MethodBinding( 'setServicePassword', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), annotate.Argument( 'newPassword', annotate.PasswordEntry(required=True, label=_('New password'))), annotate.Argument( 'again', annotate.PasswordEntry(required=True, label=_('Again'))), ], label=_('Set password')), action=_('Set password'))
class LoginPage(rend.Page): """The resource that is returned when you are not logged in""" implements(iskin.ISkinnable) title = _('Login') docFactory = loaders.xmlfile( 'login.xhtml', templateDir=os.path.split(os.path.abspath(__file__))[0]) def __init__(self, history): self.history = history super(LoginPage, self).__init__() def locateChild(self, request, segments): return LoginPage(self.history + list(segments)), [] def render_form(self, context, data): current = url.URL.fromContext(context) action = getActionURL(current, self.history) context.fillSlots('action-url', str(action)) return context.tag render_i18n = i18n.render()
class MovePage(rend.Page): implements(iskin.ISkinnable) title = _('Ldaptor Move Page') addSlash = True docFactory = loaders.xmlfile('move.xhtml', templateDir=os.path.split( os.path.abspath(__file__))[0]) def render_url(self, ctx, data): u = url.URL.fromContext(ctx) return ctx.tag(href=u.parentdir().child('search')) def childFactory(self, context, name): dn = uriUnquote(name) session = inevow.ISession(context) userEntry = session.getLoggedInRoot().loggedIn move = session.getComponent(IMove) if move is None: move = [] session.setComponent(IMove, move) e = ldapsyntax.LDAPEntryWithClient(dn=dn, client=userEntry.client) move.append(e) u = url.URL.fromContext(context).sibling('search') return u render_i18n = i18n.render()
def generatePasswords(self, request, **kw): entries = [] for k, v in kw.items(): if not k.startswith('dn_'): continue k = k[len('dn_'):] if not v: continue assert k in self.ldapObjects entries.append(self.ldapObjects[k]) if not entries: return _('No passwords to change.') d = generate_password.generate(reactor, len(entries)) def _gotPasswords(passwords, entries): assert len(passwords) == len(entries) l = [] for entry, pwd in zip(entries, passwords): d = entry.setPassword(newPasswd=pwd) def _cb(entry, pwd): return (entry, pwd) d.addCallback(_cb, pwd) l.append(d) return defer.DeferredList(l, consumeErrors=True) d.addCallback(_gotPasswords, entries) d.addCallback(MassPasswordChangeStatus) return d
class MassPasswordChangePage(rend.Page): implements(iskin.ISkinnable) title = _('Ldaptor Mass Password Change Page') addSlash = True docFactory = loaders.xmlfile('mass_change_password.xhtml', templateDir=os.path.split( os.path.abspath(__file__))[0]) def __init__(self, baseObject): super(MassPasswordChangePage, self).__init__() self.baseObject = baseObject def render_url(self, context, data): u = url.URL.fromContext(context) return context.tag(href=u.parentdir().child('search')) def childFactory(self, context, name): entry = inevow.ISession(context).getLoggedInRoot().loggedIn filt = uriUnquote(name) e = ldapsyntax.LDAPEntry(client=entry.client, dn=self.baseObject) d = e.search(filterText=filt, sizeLimit=20) d.addCallback(ReallyMassPasswordChangePage) return d render_i18n = i18n.render()
def generatePasswords(self, request, **kw): entries = [] for k,v in kw.items(): if not k.startswith('dn_'): continue k = k[len('dn_'):] if not v: continue assert k in self.ldapObjects entries.append(self.ldapObjects[k]) if not entries: return _('No passwords to change.') d=generate_password.generate(reactor, len(entries)) def _gotPasswords(passwords, entries): assert len(passwords)==len(entries) l=[] for entry, pwd in zip(entries, passwords): d=entry.setPassword(newPasswd=pwd) def _cb(entry, pwd): return (entry, pwd) d.addCallback(_cb, pwd) l.append(d) return defer.DeferredList(l, consumeErrors=True) d.addCallback(_gotPasswords, entries) d.addCallback(MassPasswordChangeStatus) return d
def setPassword(self, ctx, newPassword, again): d = defer.maybeDeferred(checkPasswordTypos, newPassword, again) d.addCallback(lambda dummy: self._setPassword(ctx, newPassword)) d.addCallback(lambda dummy: _('Password set.')) def eb(fail): return _("Failed: %s") % fail.getErrorMessage() d.addErrback(eb) return d
def bind_go(self, ctx): return annotate.MethodBinding( "go", annotate.Method( arguments=[ annotate.Argument("ctx", annotate.Context()), annotate.Argument( "baseDN", LDAPDN( label=_("Base DN"), description=_("The top-level LDAP DN you want" " to browse, e.g. dc=example,dc=com"), ), ), ], label=_("Go"), ), action=_("Go"), )
def cb(dummy): basedn = iwebui.ICurrentDN(ctx) while (basedn != '' and self.dn.contains(basedn)): basedn = basedn.up() u = url.URL.fromContext(ctx) u = u.parentdir().parentdir() if basedn != '': u = u.child(basedn).child('search') request.setComponent(iformless.IRedirectAfterPost, u) return _("Deleted %s.") % self.dn
def render_error_or_pass(self, context, data): if isinstance(data, ErrorWrapper): return context.tag.clear() \ [ tags.strong(style="color: red;") \ [ _('An error occurred: '), data.value.getErrorMessage(), ] ] else: return context.tag
def cb(dummy): basedn = iwebui.ICurrentDN(ctx) while (basedn != '' and self.dn.contains(basedn)): basedn = basedn.up() u=url.URL.fromContext(ctx) u=u.parentdir().parentdir() if basedn != '': u=u.child(basedn).child('search') request.setComponent(iformless.IRedirectAfterPost, u) return _("Deleted %s.") % self.dn
class ReallyMassPasswordChangePage(rend.Page): implements(iskin.ISkinnable) title = _('Ldaptor Mass Password Change Page') addSlash = True docFactory = loaders.xmlfile('mass_change_password-really.xhtml', templateDir=os.path.split( os.path.abspath(__file__))[0]) def __init__(self, entries): super(ReallyMassPasswordChangePage, self).__init__() self.entries = entries def data_header(self, ctx, data): u = url.URL.fromContext(ctx) u = u.parentdir().parentdir().clear() l = [] l.append(tags.a(href=u.sibling("search"))[_("Search")]) l.append(tags.a(href=u.sibling("add"))[_("add new entry")]) return l def configurable_(self, context): request = context.locate(inevow.IRequest) return MassPasswordChangeForm(self.entries) def render_form(self, context, data): return webform.renderForms()[context.tag] def render_passthrough(self, context, data): return context.tag.clear()[data] def render_status(self, context, data): try: obj = context.locate(inevow.IHand) except KeyError: return context.tag.clear() if not isinstance(obj, MassPasswordChangeStatus): return context.tag.clear()[obj] dl = tags.dl(compact="compact") context.tag.clear()[dl] for success, x in obj.deferlist: if success: entry, pwd = x dl[tags.dt[entry.dn], tags.dd[pwd]] else: context.tag[_('Failed: '), x.getErrorMessage()] return context.tag render_i18n = i18n.render()
def move(self, context): cfg = context.locate(interfaces.ILDAPConfig) newDN = distinguishedname.DistinguishedName( self.original.dn.split()[:1] + iwebui.ICurrentDN(context).split()) origDN = self.original.dn d = self.original.move(newDN) d.addCallback(lambda dummy: _('Moved %s to %s.') % (origDN, newDN)) def _cb(r, context): self._remove(context) return r d.addCallback(_cb, context) return d
def move(self, context): cfg = context.locate(interfaces.ILDAPConfig) newDN = distinguishedname.DistinguishedName(self.original.dn.split()[:1] + iwebui.ICurrentDN(context).split()) origDN = self.original.dn d = self.original.move(newDN) d.addCallback(lambda dummy: _("Moved %s to %s.") % (origDN, newDN)) def _cb(r, context): self._remove(context) return r d.addCallback(_cb, context) return d
def bind_search(self, ctx): l = [] l.append(annotate.Argument('ctx', annotate.Context())) for field in config.getSearchFieldNames(): l.append(annotate.Argument('search_%s' % field, annotate.String(label=field))) l.append(annotate.Argument('searchfilter', annotate.String(label=_("Advanced search")))) l.append(annotate.Argument( 'scope', annotate.Choice(label=_("Search depth"), choices=[ pureldap.LDAP_SCOPE_wholeSubtree, pureldap.LDAP_SCOPE_singleLevel, pureldap.LDAP_SCOPE_baseObject, ], stringify=strScope, default=pureldap.LDAP_SCOPE_wholeSubtree))) return annotate.MethodBinding( name='search', action=_("Search"), typeValue=annotate.Method(arguments=l, label=_('Search')))
class LdaptorWebUIGadget2(rend.Page): implements(iskin.ISkinnable) title = _('Ldaptor Web Interface') addSlash = True def __init__(self, baseObject): super(LdaptorWebUIGadget2, self).__init__() self.baseObject = baseObject def child_(self, context): return inevow.IRequest(context).URLPath().child('search') def child_search(self, context): return search.getSearchPage() def child_edit(self, context): if not inevow.ISession(context).getLoggedInRoot().loggedIn: return login.LoginPage([str(self.baseObject), 'edit']) return edit.EditPage() def child_move(self, context): if not inevow.ISession(context).getLoggedInRoot().loggedIn: return login.LoginPage([str(self.baseObject), 'move']) return move.MovePage() def child_add(self, context): if not inevow.ISession(context).getLoggedInRoot().loggedIn: return login.LoginPage([str(self.baseObject), 'add']) return add.getResource(baseObject=self.baseObject, request=inevow.IRequest(context)) def child_delete(self, context): if not inevow.ISession(context).getLoggedInRoot().loggedIn: return login.LoginPage([str(self.baseObject), 'delete']) return delete.getResource() def child_mass_change_password(self, context): if not inevow.ISession(context).getLoggedInRoot().loggedIn: return login.LoginPage( [str(self.baseObject), 'mass_change_password']) return mass_change_password.MassPasswordChangePage( baseObject=self.baseObject) def child_change_password(self, context): if not inevow.ISession(context).getLoggedInRoot().loggedIn: return login.LoginPage([str(self.baseObject), 'change_password']) return change_password.getResource()
def __init__(self, objectClasses): super(AddOCForm, self).__init__(None) structural = [] auxiliary = [] for oc in objectClasses: if oc.type == 'STRUCTURAL': structural.append(oc) elif oc.type == 'AUXILIARY': auxiliary.append(oc) structural.sort() auxiliary.sort() class KludgeNevowChoice(object): """ A kludge that allows using Choice with both Nevow 0.3 and newer. """ def __init__(self, oc): self.name = oc.name self.desc = oc.desc def __str__(self): """ For Choice in Nevow 0.4 and newer. Nevow 0.3 will use integer indexes. Actual stringification for display purposes happens in strObjectClass. """ return self.name[0] formFields = [ annotate.Argument('ctx', annotate.Context()), annotate.Argument('request', annotate.Request()), annotate.Argument( 'structuralObjectClass', annotate.Choice( label=_('Object type to create'), choices=[KludgeNevowChoice(x) for x in structural], stringify=strObjectClass)), ] for oc in auxiliary: formFields.append( annotate.Argument( 'auxiliary_%s' % oc.name[0], annotate.Boolean(label=oc.name[0], description=oc.desc or ''))) self.formFields = formFields
def __init__(self, objectClasses): super(AddOCForm, self).__init__(None) structural = [] auxiliary = [] for oc in objectClasses: if oc.type == 'STRUCTURAL': structural.append(oc) elif oc.type == 'AUXILIARY': auxiliary.append(oc) structural.sort() auxiliary.sort() class KludgeNevowChoice(object): """ A kludge that allows using Choice with both Nevow 0.3 and newer. """ def __init__(self, oc): self.name = oc.name self.desc = oc.desc def __str__(self): """ For Choice in Nevow 0.4 and newer. Nevow 0.3 will use integer indexes. Actual stringification for display purposes happens in strObjectClass. """ return self.name[0] formFields = [ annotate.Argument('ctx', annotate.Context()), annotate.Argument('request', annotate.Request()), annotate.Argument('structuralObjectClass', annotate.Choice(label=_('Object type to create'), choices=[KludgeNevowChoice(x) for x in structural], stringify=strObjectClass)), ] for oc in auxiliary: formFields.append(annotate.Argument( 'auxiliary_%s' % oc.name[0], annotate.Boolean(label=oc.name[0], description=oc.desc or ''))) self.formFields = formFields
def render_status(self, context, data): try: obj = context.locate(inevow.IHand) except KeyError: return context.tag.clear() if not isinstance(obj, MassPasswordChangeStatus): return context.tag.clear()[obj] dl = tags.dl(compact="compact") context.tag.clear()[dl] for success, x in obj.deferlist: if success: entry, pwd = x dl[tags.dt[entry.dn], tags.dd[pwd]] else: context.tag[_('Failed: '), x.getErrorMessage()] return context.tag
def bind_add(self, ctx): return annotate.MethodBinding( 'add', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), annotate.Argument('serviceName', annotate.String(required=True, label=_('Service name'))), annotate.Argument('newPassword', annotate.PasswordEntry(required=False, label=_('New password'), description=_("Leave empty to generate random password."))), annotate.Argument('again', annotate.PasswordEntry(required=False, label=_('Again'))), ], label=_('Add')), action=_('Add'))
class GetDN(rend.Page): implements(iskin.ISkinnable) title = _('Ldaptor Delete Page') addSlash = True docFactory = loaders.xmlfile('delete-nodn.xhtml', templateDir=os.path.split( os.path.abspath(__file__))[0]) def render_url(self, context, data): u = url.URL.fromContext(context) return context.tag(href=u.parentdir().child('search')) def childFactory(self, context, name): unquoted = uriUnquote(name) try: dn = distinguishedname.DistinguishedName(stringValue=unquoted) except distinguishedname.InvalidRelativeDistinguishedName, e: # TODO There's no way to throw a FormException at this stage. return None r = ConfirmDelete(dn=dn) return r
def render_status(self, context, data): try: obj = context.locate(inevow.IHand) except KeyError: return context.tag.clear() e = interfaces.ILDAPEntry(obj, None) if e is not None: status = AddStatus(entry=e) else: status = IAddStatus(obj, None) if status is None: return context.tag.clear()[obj] e = status.entry u=url.URL.fromContext(context) u=u.parentdir().parentdir().parentdir().clear() msg = [ _("Added "), tags.a(href=u.parentdir().child(e.dn).child("search"))[e.dn], ] if status.password is not None: msg.extend([_(' with password '), status.password]) return context.tag.clear()[ msg, ' ', # TODO share implementation with entryLinks '[', tags.a(href=u.sibling('edit').child(uriQuote(e.dn)))[_('edit')], '|', tags.a(href=u.sibling('move').child(uriQuote(e.dn)))[_('move')], '|', tags.a(href=u.sibling('delete').child(uriQuote(e.dn)))[_('delete')], '|', tags.a(href=u.sibling('change_password').child(uriQuote(e.dn)))[_('change password')], ']', ]
def bind_add(self, ctx): return annotate.MethodBinding( 'add', annotate.Method(arguments=[ annotate.Argument('ctx', annotate.Context()), annotate.Argument( 'serviceName', annotate.String(required=True, label=_('Service name'))), annotate.Argument( 'newPassword', annotate.PasswordEntry( required=False, label=_('New password'), description=_( "Leave empty to generate random password."))), annotate.Argument( 'again', annotate.PasswordEntry(required=False, label=_('Again'))), ], label=_('Add')), action=_('Add'))
def render_status(self, context, data): try: obj = context.locate(inevow.IHand) except KeyError: return context.tag.clear() e = interfaces.ILDAPEntry(obj, None) if e is not None: status = AddStatus(entry=e) else: status = IAddStatus(obj, None) if status is None: return context.tag.clear()[obj] e = status.entry u = url.URL.fromContext(context) u = u.parentdir().parentdir().parentdir().clear() msg = [ _("Added "), tags.a(href=u.parentdir().child(e.dn).child("search"))[e.dn], ] if status.password is not None: msg.extend([_(' with password '), status.password]) return context.tag.clear( )[msg, ' ', # TODO share implementation with entryLinks '[', tags.a(href=u.sibling('edit').child(uriQuote(e.dn)))[_('edit')], '|', tags.a(href=u.sibling('move').child(uriQuote(e.dn)))[_('move')], '|', tags.a(href=u.sibling('delete').child(uriQuote(e.dn)))[_('delete')], '|', tags.a(href=u.sibling('change_password').child(uriQuote(e.dn)) )[_('change password')], ']', ]
def _report(name): return _('Removed service %r') % name
def _cb(e): for cn in e.get('cn', []): return cn raise RuntimeError, \ _("Service password entry has no attribute cn: %r") % e
def bind_generate(self, ctx): return annotate.MethodBinding('generatePasswords', annotate.Method( arguments=self.formFields, label=_('Generate passwords')), action=_('Generate passwords'))
def eb(fail): return _("Failed: %s") % fail.getErrorMessage()
def _status(newPassword, ctx): d = self._setPassword(ctx, newPassword) d.addCallback(lambda dummy: _('Password set to %s') % newPassword) return d
def checkPasswordTypos(newPassword, again): if newPassword != again: raise annotate.ValidateError( {}, formErrorMessage=_('Passwords do not match.'))
def _report(dummy, name): return _('Added service %r') % name