예제 #1
0
파일: oai.py 프로젝트: Kaltar5679/Telemeta
    def __init__(self, identity, datasource):
        self.identity = identity
        self.datasource = datasource

        impl = dom.getDOMImplementation()
        self.doc = impl.createDocument(None, 'OAI-PMH', None)
        self.root = self.doc.firstChild
        self.root.setAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/')
        self.root.setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')
        self.root.setAttribute('xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/ '
                                                     'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd')
        self.append_elements(self.root, {'responseDate': iso_time()})
        self.request = self.root.appendChild(self.doc.createElement('request'))
        for k, v in self.identity:
            if k == 'baseURL':
                url = v
                break
        self.request.appendChild(self.doc.createTextNode(url))
예제 #2
0
    def __init__(self, identity, datasource):
        self.identity = identity
        self.datasource = datasource

        impl = dom.getDOMImplementation()
        self.doc = impl.createDocument(None, 'OAI-PMH', None)
        self.root = self.doc.firstChild
        self.root.setAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/')
        self.root.setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')
        self.root.setAttribute('xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/ '
                                                     'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd')
        self.append_elements(self.root, {'responseDate': iso_time()})
        self.request = self.root.appendChild(self.doc.createElement('request'))
        for k, v in self.identity:
            if k == 'baseURL':
                url = v
                break
        self.request.appendChild(self.doc.createTextNode(url))
예제 #3
0
파일: rest.py 프로젝트: tannewt/menzies
	from libxml2dom import parseString,getDOMImplementation
	from libxml2dom import Node
	print "Using fast libxml2dom implementation"
	def toxml(node):
		return node.toString()
except:
	from xml.dom.minidom import parseString,getDOMImplementation
	from xml.dom import Node
	def toxml(node):
		return node.toxml().encode("utf-8")
	print "Using slow minidom.  Install libxml2dom for much better performance."

# Don't buffer stdout
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

impl = getDOMImplementation()
log = open("rest.log", "a")

class ForkingHTTPServer(SocketServer.ForkingTCPServer,BaseHTTPServer.HTTPServer):
	pass

class OpenStreetMapHandler (BaseHTTPServer.BaseHTTPRequestHandler):
	API_PREFIX="/api/0.6/"

	def log_message(self, format, *args):
		"""Log an arbitrary message.

		The first argument, FORMAT, is a format string for the
		message to be logged.  If the format string contains
		any % escapes requiring parameters, they should be
		specified as subsequent arguments (it's just like