def testOld(self): class OldClass: pass old = OldClass() self.assertIn(reflect.getClass(OldClass).__name__, self.oldClassNames) self.assertEqual(reflect.getClass(old).__name__, "OldClass")
def test_new(self): class NewClass: pass new = NewClass() self.assertEqual(reflect.getClass(NewClass).__name__, "type") self.assertEqual(reflect.getClass(new).__name__, "NewClass")
def test_old(self): class OldClass: pass old = OldClass() self.assertIn(reflect.getClass(OldClass).__name__, self.oldClassNames) self.assertEqual(reflect.getClass(old).__name__, 'OldClass')
def test_new(self): class NewClass(object): pass new = NewClass() self.assertEqual(reflect.getClass(NewClass).__name__, 'type') self.assertEqual(reflect.getClass(new).__name__, 'NewClass')
def testOld(self): class OldClass: pass old = OldClass() self.assertIn(reflect.getClass(OldClass).__name__, ("class", "classobj")) self.assertEqual(reflect.getClass(old).__name__, "OldClass")
def testNew(self): class NewClass(object): pass new = NewClass() self.assertEqual(reflect.getClass(NewClass).__name__, "type") self.assertEqual(reflect.getClass(new).__name__, "NewClass")
def testOld(self): class OldClass: pass old = OldClass() self.assertIn( reflect.getClass(OldClass).__name__, ('class', 'classobj')) self.assertEquals(reflect.getClass(old).__name__, 'OldClass')
def __init__(self, name, **kw): SchemaNode.__init__(self, name) self.elements = list() reflect.accumulateClassList(reflect.getClass(self), 'elements', self.elements) self.attributes = list() reflect.accumulateClassList(reflect.getClass(self), 'attributes', self.attributes) self.__dict__.update(kw)
def load(self, ctx=None): rendererFactoryClass = None if ctx is not None: r = inevow.IRendererFactory(ctx, None) if r is not None: rendererFactoryClass = getClass(r) cacheKey = (self._filename, self.pattern, rendererFactoryClass) try: cachedModified, doc = self._cache[cacheKey] except KeyError: cachedModified = doc = None currentModified = os.path.getmtime(self._filename) if currentModified == cachedModified: return doc doc = flatsax.parse(open(self._filename), self.ignoreDocType, self.ignoreComment) doc = flat.precompile(doc, ctx) if self.pattern is not None: doc = inevow.IQ(doc).onePattern(self.pattern) self._mtime = currentModified self._cache[cacheKey] = currentModified, doc return doc
def generatePage(cgiPage): """ Takes an instance of CGIPage and generates a page from it, sending the proper headers and all that """ cgitb.enable() ## # A bit evil, I know, but we want all output to go to a logging file fout = open('/tmp/webservices.log', 'a') logging.OUTSTREAM = fout logging.ERRSTREAM = fout try: ## # Execute the body first, it may want to add to headers or modify them in soem way as # well as contentType body = cgiPage.body() print cgiPage.contentType if cgiPage.headers: print '\n'.join( [h + ': ' + v for h, v in cgiPage.headers.iteritems()]) print print json.dumps(dict(success=True, data=body)) except Exception, err: print cgiPage.contentType print stream = StringIO() traceback.print_exc(file=stream) print json.dumps( dict(success=False, data=dict(stacktrace=stream.getvalue(), name=reflect.fullyQualifiedName( reflect.getClass(err)), msg=str(err))))
def addException(self, msg, exc, stacktrace): t = time.time() return self.update( timestamp=t, messages=self.messages + [ dict(mtype=MSG_ERROR, text=msg, name=reflect.fullyQualifiedName(reflect.getClass(exc)), stacktrace=stacktrace, timestamp=t) ])
def load(self, ctx=None, preprocessors=()): rendererFactoryClass = None if ctx is not None: r = inevow.IRendererFactory(ctx, None) if r is not None: rendererFactoryClass = getClass(r) cacheKey = (self._filename, self.pattern, rendererFactoryClass) cachedFile = self._cache.get(cacheKey) if cachedFile is None: cachedFile = self._cache[cacheKey] = CachedFile(self._filename, self._reallyLoad) return cachedFile.load(ctx, preprocessors)
def load(self, ctx=None, preprocessors=()): rendererFactoryClass = None if ctx is not None: r = inevow.IRendererFactory(ctx, None) if r is not None: rendererFactoryClass = getClass(r) cacheKey = (self._filename, self.pattern, rendererFactoryClass) cachedFile = self._cache.get(cacheKey) if cachedFile is None: cachedFile = self._cache[cacheKey] = CachedFile( self._filename, self._reallyLoad) return cachedFile.load(ctx, preprocessors)
def getHandleErrorCode(self): """ Return the argument L{SSL.Error} will be constructed with for this case. This is basically just a random OpenSSL implementation detail. It would be better if this test worked in a way which did not require this. """ # Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for # SSL.Connection.write for some reason. The twisted.protocols.tls # implementation of IReactorSSL doesn't suffer from this imprecation, # though, since it is isolated from the Windows I/O layer (I suppose?). # If test_properlyCloseFiles waited for the SSL handshake to complete # and performed an orderly shutdown, then this would probably be a # little less weird: writing to a shutdown SSL connection has a more # well-defined failure mode (or at least it should). name = fullyQualifiedName(getClass(reactor)) if platform.getType() == 'win32' and name != self._iocp: return errno.WSAENOTSOCK # This is terribly implementation-specific. return [('SSL routines', 'SSL_write', 'protocol is shutdown')]
def generatePage(cgiPage): """ Takes an instance of CGIPage and generates a page from it, sending the proper headers and all that """ cgitb.enable() ## # A bit evil, I know, but we want all output to go to a logging file fout = open('/tmp/webservices.log', 'a') logging.OUTSTREAM = fout logging.ERRSTREAM = fout try: ## # Execute the body first, it may want to add to headers or modify them in soem way as # well as contentType body = cgiPage.body() print cgiPage.contentType if cgiPage.headers: print '\n'.join([h + ': ' + v for h, v in cgiPage.headers.iteritems()]) print print json.dumps(dict(success=True, data=body)) except Exception, err: print cgiPage.contentType print stream = StringIO() traceback.print_exc(file=stream) print json.dumps(dict(success=False, data=dict(stacktrace=stream.getvalue(), name=reflect.fullyQualifiedName(reflect.getClass(err)), msg=str(err))))
def __init__(self): self.logCategory = \ reflect.qual(reflect.getClass(self)).replace('__main__.', '')
def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs self.fullClassName = getmodule(self).__name__ + '.' + getClass(self).__name__ # used to map this back to storage self.dbid = None
def addException(self, msg, exc, stacktrace): t = time.time() return self.update(timestamp=t, messages=self.messages + [dict(mtype=MSG_ERROR, text=msg, name=reflect.fullyQualifiedName(reflect.getClass(exc)), stacktrace=stacktrace, timestamp=t)])
def testOld(self): class OldClass: pass old = OldClass() self.assertIn(reflect.getClass(OldClass).__name__, ('class', 'classobj')) self.assertEqual(reflect.getClass(old).__name__, 'OldClass')
def __str__(self): args = ", ".join(map(str, self.args)) kwargs = ", ".join([ "%s=%s" % (k, v) for k, v in self.kwargs.items() ]) return "%s(%s, %s)" % (getClass(self).__name__, args, kwargs)
def testNew(self): class NewClass(object): pass new = NewClass() self.assertEquals(reflect.getClass(NewClass).__name__, 'type') self.assertEquals(reflect.getClass(new).__name__, 'NewClass')