diff --git a/admin/nevow-xmlgettext b/admin/nevow-xmlgettext
deleted file mode 100755
index dbbcc50d..00000000
--- a/admin/nevow-xmlgettext
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-### from nevow.scripts.xmlgettext
-
-import sys
-from xml.dom import pulldom
-from twisted.python import usage
-from twisted.application import app
-import nevow
-
-def process(filename, msgs):
- events = pulldom.parse(filename)
-
- for (event, node) in events:
- if event == pulldom.START_ELEMENT:
- get = getattr(node, 'getAttributeNS', None)
- if get is not None:
- value = get('http://nevow.com/ns/nevow/0.1', 'render')
- if value == 'i18n':
- events.expandNode(node)
- msg = tuple([child.toxml('utf-8') for child in node.childNodes])
- # TODO get line number out of pulldom
- msgs.setdefault(msg, []).append(filename)
-
-def report(msgs):
- msgs = msgs.items()
- msgs.sort()
- for msg, locations in msgs:
- for filename in locations:
- print '#: %s' % filename
- print 'msgid ""'
- for s in msg:
- s = s.replace('\\', '\\\\')
- s = s.replace('"', '\\"')
- s = s.replace('\n', '\\n')
- print '"%s"' % s
- print 'msgstr ""'
- print
-
-class GettextOptions(usage.Options):
- def opt_version(self):
- print 'Nevow version:', nevow.__version__
- usage.Options.opt_version(self)
-
- def parseArgs(self, *files):
- self['files'] = files
-
-def runApp(config):
- msgs = {}
- for filename in config['files']:
- process(filename, msgs)
- report(msgs)
-
-def run():
- from twisted.application import app
- app.run(runApp, GettextOptions)
-
-if __name__=='__main__':
- run()
diff --git a/admin/run-twill b/admin/run-twill
deleted file mode 100755
index 21afea3f..00000000
--- a/admin/run-twill
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/usr/bin/python
-import os, sys, shutil, subprocess, socket, errno, signal, time
-
-def waitUntilListening(port):
- print 'waitUntilListening', 'start'
- s = socket.socket()
- while True:
- try:
- s.connect(('127.0.0.1', port))
- except socket.error, e:
- if e.args[0] == errno.ECONNREFUSED:
- print 'waitUntilListening', 'connection refused'
- time.sleep(1)
- pass
- else:
- print 'waitUntilListening', 'other error'
- s.close()
- raise
- else:
- print 'waitUntilListening', 'connected successfully'
- s.close()
- break
-
-def mustNotListenYet(port):
- s = socket.socket()
- try:
- s.connect(('127.0.0.1', port))
- except socket.error, e:
- if e.args[0] == errno.ECONNREFUSED:
- pass
- else:
- s.close()
- raise
- else:
- s.close()
- print >>sys.stderr, '%s: port %d must not be listening yet.' % (sys.argv[0], port)
- sys.exit(1)
-
-def run():
- testroots = sys.argv[1:]
- if not testroots:
- testroots = ['ldaptor/test']
-
- tests = []
- for testroot in testroots:
- if testroot.endswith('.twill'):
- tests.append(testroot)
- continue
- for root, dirs, files in os.walk(testroot):
- dirs[:] = [d for d in dirs
- if not d.startswith('.')
- and not d.startswith('_')]
-
- l = []
- for test in files:
- if (test.startswith('.')
- or test.startswith('_')):
- continue
- if not test.endswith('.twill'):
- continue
- l.append(os.path.join(root, test))
- tests.extend(l)
-
- if not tests:
- raise RuntimeError('No tests found.')
-
- twillEnv = {}
- twillEnv.update(os.environ)
- twillEnv['PYTHONPATH'] = ':'.join(['.',
- # TODO work around missing twill features,
- # needs my hacked twill
- os.path.expanduser('~/src/twill/trunk'),
- twillEnv.get('PYTHONPATH', '.')])
- returncode = subprocess.call(args=[
- os.path.expanduser('~/src/twill/trunk/twill-sh'),
- '--url', 'http://localhost:38980/',
- ] + tests,
- env=twillEnv)
-
- if returncode < 0:
- print >>sys.stderr, "%s: twill exited with signal %d" % (
- sys.argv[0], -returncode)
- sys.exit(1)
- elif returncode >0:
- print >>sys.stderr, "%s: twill exited with code %d" % (
- sys.argv[0], returncode)
- sys.exit(1)
-
-
-
-mustNotListenYet(38942)
-mustNotListenYet(38980)
-
-ldapsrv = subprocess.Popen(args=['twistd',
- '-n', '-o', '-y',
- 'test-ldapserver.tac',
- '--pidfile', 'test-ldapserver.pid'],
- close_fds=True,
- env=os.environ)
-
-try:
- waitUntilListening(38942)
-
- twistdEnv = {}
- twistdEnv.update(os.environ)
- twistdEnv['PYTHONPATH'] = ':'.join(['.',
- twistdEnv.get('PYTHONPATH', '.')])
- twistd = subprocess.Popen(args=['twistd',
- '-n', '-o', '-y',
- 'test-webui.tac',
- '--pidfile', 'test-webui.pid'],
- close_fds=True,
- env=twistdEnv)
-
- try:
- waitUntilListening(38980)
- run()
- finally:
- os.kill(twistd.pid, signal.SIGTERM)
- returncode = twistd.wait()
- if returncode < 0:
- if returncode != -signal.SIGTERM:
- print >>sys.stderr, "%s: twistd exited with signal %d" % (
- sys.argv[0], -returncode)
- sys.exit(1)
- elif returncode >0:
- print >>sys.stderr, "%s: twistd exited with code %d" % (
- sys.argv[0], returncode)
- sys.exit(1)
-
-finally:
- os.kill(ldapsrv.pid, signal.SIGTERM)
- returncode = ldapsrv.wait()
- if returncode < 0:
- if returncode != -signal.SIGTERM:
- print >>sys.stderr, "%s: ldapsrv exited with signal %d" % (
- sys.argv[0], -returncode)
- sys.exit(1)
- elif returncode >0:
- print >>sys.stderr, "%s: ldapsrv exited with code %d" % (
- sys.argv[0], returncode)
- sys.exit(1)
diff --git a/ldaptor/test/mockweb.py b/ldaptor/test/mockweb.py
deleted file mode 100644
index 035c78de..00000000
--- a/ldaptor/test/mockweb.py
+++ /dev/null
@@ -1,79 +0,0 @@
-"""I mock the web."""
-
-from nevow import url
-from twisted.internet import address
-from twisted.web import client
-
-from nevow import testutil
-from ldaptor.test import util
-
-class FakeChannel(testutil.FakeChannel):
- def requestDone(self, request):
- self.transport.loseConnection()
-
-class MyHTTPPageGetter(client.HTTPPageGetter):
- def handleStatus_301(self):
- if not self.followRedirect:
- client.HTTPPageGetter.handleStatus_301(self)
- return
-
- l = self.headers.get('location')
- if not l:
- self.handleStatusDefault()
- url = l[0]
- self.factory.setURL(url)
-
- _getPage_connect(clientFactory=self.factory,
- serverAddress=address.IPv4Address(
- 'TCP', self.factory.host, self.factory.port),
- clientAddress=None)
- self.quietLoss = 1
- self.transport.loseConnection()
-
-class HTTPClientFactory_noCookies(client.HTTPClientFactory):
- def gotHeaders(self, headers):
- client.HTTPClientFactory.gotHeaders(self, headers)
- self.cookies.clear()
-
-def _getPage_connect(clientFactory,
- serverAddress,
- clientAddress):
- clientProto = clientFactory.buildProtocol(serverAddress)
- serverProto = clientFactory.site.buildProtocol(clientAddress)
- pump = util.returnConnected(serverProto, clientProto,
- serverAddress=serverAddress,
- clientAddress=clientAddress)
-
-def getPage(site, u, extraInfo=False,
- factoryClass=client.HTTPClientFactory,
- *a, **kw):
- u = url.URL.fromString(str(u))
- clientFactory = factoryClass(str(u), *a, **kw)
- clientFactory.protocol = MyHTTPPageGetter
- clientFactory.site = site
- if ':' in u.netloc:
- host, port = u.netloc.split(':', 1)
- else:
- host, port = u.netloc, 80
- serverAddress = address.IPv4Address('TCP', host, port)
- clientAddress = address.IPv4Address('TCP', 'localhost', 1024)
- _getPage_connect(clientFactory, serverAddress, clientAddress)
-
- if extraInfo:
- def _cb(page):
- return {'status': clientFactory.status,
- 'version': clientFactory.version,
- 'message': clientFactory.message,
- 'headers': clientFactory.headers,
- 'page': page,
- 'url': url.URL.fromString(clientFactory.url),
- }
- clientFactory.deferred.addCallback(_cb)
- return clientFactory.deferred
-
-def getPage_noCookies(*a, **kw):
- defaults = {
- 'factoryClass': HTTPClientFactory_noCookies,
- }
- defaults.update(kw)
- return getPage(*a, **defaults)
diff --git a/ldaptor/weave.py b/ldaptor/weave.py
deleted file mode 100644
index b6ac8fac..00000000
--- a/ldaptor/weave.py
+++ /dev/null
@@ -1,164 +0,0 @@
-from zope.interface import Interface, implements
-from twisted.python import components
-from nevow import tags, inevow, flat
-from ldaptor.protocols.ldap import ldapsyntax, distinguishedname
-from ldaptor import interfaces
-
-def keyvalue(context, data):
- """
- Render items in a mapping using patterns found in the children
- of the element.
-
- Keyvalue recognizes the following patterns:
-
- - header: Rendered at the start, before the first item. If
- multiple header patterns are provided they are rendered
- together in the order they were defined.
-
- - footer: Just like the header only renderer at the end, after
- the last item.
-
- - item: Rendered once for each item in the sequence. Can contain
- subpatterns key and value.
-
- If multiple item patterns are provided then the pattern is
- cycled in the order defined.
-
- - divider: Rendered once between each item in the
- sequence. Multiple divider patterns are cycled.
-
- - empty: Rendered instead of item and divider patterns when the
- sequence contains no items.
-
- Example::
-
-
-
- name |
- email |
-
-
- name goes here |
- email goes here |
-
-
- name goes here |
- email goes here |
-
-
- they've all gone! |
-
-
-
- """
- headers = context.tag.allPatterns('header')
- item = context.tag.patternGenerator('item')
- divider = context.tag.patternGenerator('divider', default=tags.invisible)
- content = []
- for key, value in data.items():
- content.append(item(data=(key, value)))
- content.append(divider(data=(key, value)))
- if not content:
- content = context.tag.allPatterns('empty')
- else:
- ## No divider after the last thing.
- del content[-1]
- footers = context.tag.allPatterns('footer')
- return context.tag.clear()[ headers, content, footers ]
-
-def keyvalue_item(context, data):
- key, value = data
-
- k = context.tag.patternGenerator('key')
- v = context.tag.patternGenerator('value')
-
- return context.tag.clear()[ k(data=key), v(data=value) ]
-
-class _DictLike(object):
- implements(inevow.IContainer)
-
- def __init__(self, original):
- self.original = original
-
- def child(self, context, name):
- return self.original.get(name, None)
-
- def items(self):
- return self.original.items()
-
-class LDAPEntryContainer(object):
- implements(inevow.IContainer)
-
- def __init__(self, original):
- self.original = original
-
- def child(self, context, name):
- if name == 'dn':
- return self.original.dn
- elif name == 'attributes':
- return _DictLike(self.original)
- else:
- return None
-
-components.registerAdapter(
- LDAPEntryContainer,
- ldapsyntax.LDAPEntryWithClient,
- inevow.IContainer)
-
-def dnSerializer(original, context):
- return flat.serialize(str(original), context)
-
-flat.registerFlattener(dnSerializer,
- distinguishedname.DistinguishedName)
-
-def entrySerializer(original, context):
- ul = tags.ul()
- for a,l in original.items():
- if len(l)==0:
- ul[tags.li[a, ': none']]
- elif len(l)==1:
- for attr in l:
- first = attr
- break
- ul[tags.li[a, ': ', first]]
- else:
- li=tags.li[a, ':']
- ul[li]
- liul=tags.ul()
- li[liul]
- for i in l:
- liul[tags.li[i]]
- return flat.serialize(ul, context)
-
-flat.registerFlattener(entrySerializer,
- interfaces.ILDAPEntry)
-
-class IZebraStyle(Interface):
- """Marker interface for zebra."""
- pass
-
-def zebra(styles=['zebra-odd', 'zebra-even']):
- """
- Provide alternating background colors for e.g. zebra tables.
-
- @param styles: Two or more CSS class names to iterate.
-
- Use like this::
-
- render_zebra = weave.zebra()
-
-
- """
- styles = list(styles)
- def f(self, ctx, data):
- request = inevow.IRequest(ctx)
- state = IZebraStyle(request, styles)
- r = ctx.tag(class_="%s" % state[0])
- request.setComponent(IZebraStyle, state[1:]+state[:1])
-
- return r
- return f