# Path: ldaptor/protocols/ldap/ldapsyntax.py
# class PasswordSetAggregateError(Exception):
# class PasswordSetAborted(Exception):
# class DNNotPresentError(Exception):
# class ObjectInBadStateError(Exception):
# class ObjectDeletedError(ObjectInBadStateError):
# class ObjectDirtyError(ObjectInBadStateError):
# class NoContainingNamingContext(Exception):
# class CannotRemoveRDNError(Exception):
# class MatchNotImplemented(NotImplementedError):
# class JournaledLDAPAttributeSet(attributeset.LDAPAttributeSet):
# class LDAPEntryWithClient(entry.EditableLDAPEntry):
# class LDAPEntryWithAutoFill(LDAPEntry):
#     def __init__(self, errors):
#     def __str__(self):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, key, val=None):
#     def __str__(self):
#     def __init__(self, op):
#     def __str__(self):
#     def __init__(self, ldapObject, *a, **kw):
#     def add(self, value):
#     def update(self, sequence):
#     def remove(self, value):
#     def clear(self):
#     def __init__(self, client, dn, attributes={}, complete=0):
#     def buildAttributeSet(self, key, values):
#     def _canRemove(self, key, value):
#     def _canRemoveAll(self, key):
#     def _checkState(self):
#     def journal(self, journalOperation):
#     def __getitem__(self, *a, **kw):
#     def get(self, *a, **kw):
#     def has_key(self, *a, **kw):
#     def __contains__(self, key):
#     def keys(self):
#     def items(self):
#     def __str__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __len__(self):
#     def __nonzero__(self):
#     def bind(self, password):
#     def _handle_bind_msg(self, msg):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def undo(self):
#     def _commit_success(self, msg):
#     def commit(self):
#     def _cbMoveDone(self, msg, newDN):
#     def move(self, newDN):
#     def _cbDeleteDone(self, msg):
#     def delete(self):
#     def _cbAddDone(self, msg, dn):
#     def addChild(self, rdn, attributes):
#     def _cbSetPassword_ExtendedOperation(self, msg):
#     def setPassword_ExtendedOperation(self, newPasswd):
#     def setPassword_Samba(self, newPasswd, style=None):
#     def setPasswordMaybe_Samba(self, newPasswd):
#     def _cbSetPassword(self, dl, names):
#     def _cbSetPassword_one(self, result):
#     def _ebSetPassword_one(self, fail):
#     def _setPasswordAll(self, results, newPasswd, prefix, names):
#             def cb((success, info)):
#     def setPassword(self, newPasswd):
#         def _passwordChangerPriorityComparison(me, other):
#     def _cbNamingContext_Entries(self, results):
#     def namingContext(self):
#     def _cbFetch(self, results, overWrite):
#     def fetch(self, *attributes):
#     def _cbSearchEntry(self, callback, objectName, attributes, complete):
#     def _cbSearchMsg(self, msg, d, callback, complete, sizeLimitIsNonFatal):
#     def search(self,
#                filterText=None,
#                filterObject=None,
#                attributes=(),
#                scope=None,
#                derefAliases=None,
#                sizeLimit=0,
#                sizeLimitIsNonFatal=False,
#                timeLimit=0,
#                typesOnly=0,
#                callback=None):
#             def rerouteerr(e):
#     def lookup(self, dn):
#     def __repr__(self):
#     def __init__(self, *args, **kwargs):
#     def _cb_addAutofiller(self, r, autoFiller):
#     def addAutofiller(self, autoFiller):
#     def journal(self, journalOperation):
# 
# Path: ldaptor/apps/webui/uriquote.py
# def uriUnquote(q):
#     q=str(q)
#     return urllib.unquote(q)
# 
# Path: ldaptor/apps/webui/i18n.py
# def render():
# 
# Path: ldaptor/apps/webui/i18n.py
# def render():
# 
# Path: ldaptor/apps/webui/search.py
# class IMove(Interface):
#     """Entries being moved in the tree."""
#     pass


from zope.interface import implements
from webut.skin import iskin
from ldaptor.protocols.ldap import ldapsyntax
from ldaptor.apps.webui.uriquote import uriUnquote
from nevow import rend, loaders, url, inevow
from ldaptor.apps.webui.i18n import _
from ldaptor.apps.webui import i18n
from ldaptor.apps.webui.search import IMove
import os


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 = []

# Path: ldaptor/protocols/ldap/ldapsyntax.py
# class PasswordSetAggregateError(Exception):
# class PasswordSetAborted(Exception):
# class DNNotPresentError(Exception):
# class ObjectInBadStateError(Exception):
# class ObjectDeletedError(ObjectInBadStateError):
# class ObjectDirtyError(ObjectInBadStateError):
# class NoContainingNamingContext(Exception):
# class CannotRemoveRDNError(Exception):
# class MatchNotImplemented(NotImplementedError):
# class JournaledLDAPAttributeSet(attributeset.LDAPAttributeSet):
# class LDAPEntryWithClient(entry.EditableLDAPEntry):
# class LDAPEntryWithAutoFill(LDAPEntry):
#     def __init__(self, errors):
#     def __str__(self):
#     def __repr__(self):
#     def __str__(self):
#     def __init__(self, key, val=None):
#     def __str__(self):
#     def __init__(self, op):
#     def __str__(self):
#     def __init__(self, ldapObject, *a, **kw):
#     def add(self, value):
#     def update(self, sequence):
#     def remove(self, value):
#     def clear(self):
#     def __init__(self, client, dn, attributes={}, complete=0):
#     def buildAttributeSet(self, key, values):
#     def _canRemove(self, key, value):
#     def _canRemoveAll(self, key):
#     def _checkState(self):
#     def journal(self, journalOperation):
#     def __getitem__(self, *a, **kw):
#     def get(self, *a, **kw):
#     def has_key(self, *a, **kw):
#     def __contains__(self, key):
#     def keys(self):
#     def items(self):
#     def __str__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __len__(self):
#     def __nonzero__(self):
#     def bind(self, password):
#     def _handle_bind_msg(self, msg):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def undo(self):
#     def _commit_success(self, msg):
#     def commit(self):
#     def _cbMoveDone(self, msg, newDN):
#     def move(self, newDN):
#     def _cbDeleteDone(self, msg):
#     def delete(self):
#     def _cbAddDone(self, msg, dn):
#     def addChild(self, rdn, attributes):
#     def _cbSetPassword_ExtendedOperation(self, msg):
#     def setPassword_ExtendedOperation(self, newPasswd):
#     def setPassword_Samba(self, newPasswd, style=None):
#     def setPasswordMaybe_Samba(self, newPasswd):
#     def _cbSetPassword(self, dl, names):
#     def _cbSetPassword_one(self, result):
#     def _ebSetPassword_one(self, fail):
#     def _setPasswordAll(self, results, newPasswd, prefix, names):
#             def cb((success, info)):
#     def setPassword(self, newPasswd):
#         def _passwordChangerPriorityComparison(me, other):
#     def _cbNamingContext_Entries(self, results):
#     def namingContext(self):
#     def _cbFetch(self, results, overWrite):
#     def fetch(self, *attributes):
#     def _cbSearchEntry(self, callback, objectName, attributes, complete):
#     def _cbSearchMsg(self, msg, d, callback, complete, sizeLimitIsNonFatal):
#     def search(self,
#                filterText=None,
#                filterObject=None,
#                attributes=(),
#                scope=None,
#                derefAliases=None,
#                sizeLimit=0,
#                sizeLimitIsNonFatal=False,
#                timeLimit=0,
#                typesOnly=0,
#                callback=None):
#             def rerouteerr(e):
#     def lookup(self, dn):
#     def __repr__(self):
#     def __init__(self, *args, **kwargs):
#     def _cb_addAutofiller(self, r, autoFiller):
#     def addAutofiller(self, autoFiller):
#     def journal(self, journalOperation):
# 
# Path: ldaptor/apps/webui/uriquote.py
# def uriUnquote(q):
#     q=str(q)
#     return urllib.unquote(q)
# 
# Path: ldaptor/apps/webui/i18n.py
# def render():
# 
# Path: ldaptor/apps/webui/i18n.py
# def render():
# 
# Path: ldaptor/apps/webui/search.py
# class IMove(Interface):
#     """Entries being moved in the tree."""
#     pass


# Path: ldaptor/apps/webui/move.py
from zope.interface import implements
from webut.skin import iskin
from ldaptor.protocols.ldap import ldapsyntax
from ldaptor.apps.webui.uriquote import uriUnquote
from nevow import rend, loaders, url, inevow
from ldaptor.apps.webui.i18n import _
from ldaptor.apps.webui import i18n
from ldaptor.apps.webui.search import IMove
import os



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)