示例#1
0
    def testOld(self):
        class OldClass:
            pass

        old = OldClass()
        self.assertIn(reflect.getClass(OldClass).__name__, self.oldClassNames)
        self.assertEqual(reflect.getClass(old).__name__, "OldClass")
示例#2
0
    def test_new(self):
        class NewClass:
            pass

        new = NewClass()
        self.assertEqual(reflect.getClass(NewClass).__name__, "type")
        self.assertEqual(reflect.getClass(new).__name__, "NewClass")
示例#3
0
文件: test_reflect.py 项目: DT021/wau
    def test_old(self):
        class OldClass:
            pass

        old = OldClass()
        self.assertIn(reflect.getClass(OldClass).__name__, self.oldClassNames)
        self.assertEqual(reflect.getClass(old).__name__, 'OldClass')
示例#4
0
文件: test_reflect.py 项目: DT021/wau
    def test_new(self):
        class NewClass(object):
            pass

        new = NewClass()
        self.assertEqual(reflect.getClass(NewClass).__name__, 'type')
        self.assertEqual(reflect.getClass(new).__name__, 'NewClass')
示例#5
0
    def testOld(self):
        class OldClass:
            pass

        old = OldClass()
        self.assertIn(reflect.getClass(OldClass).__name__, ("class", "classobj"))
        self.assertEqual(reflect.getClass(old).__name__, "OldClass")
示例#6
0
    def testNew(self):
        class NewClass(object):
            pass

        new = NewClass()
        self.assertEqual(reflect.getClass(NewClass).__name__, "type")
        self.assertEqual(reflect.getClass(new).__name__, "NewClass")
示例#7
0
    def testOld(self):
        class OldClass:
            pass

        old = OldClass()
        self.assertIn(
            reflect.getClass(OldClass).__name__, ('class', 'classobj'))
        self.assertEquals(reflect.getClass(old).__name__, 'OldClass')
示例#8
0
文件: schema.py 项目: jrydberg/edgy
 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)
示例#9
0
    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
示例#10
0
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))))
示例#11
0
 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)
         ])
示例#12
0
    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)
示例#13
0
文件: loaders.py 项目: calston/tums
    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)
示例#14
0
    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')]
示例#15
0
文件: test_ssl.py 项目: Almad/twisted
    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')]
示例#16
0
文件: handler.py 项目: carze/vappio
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))))
示例#17
0
 def __init__(self):
     self.logCategory = \
             reflect.qual(reflect.getClass(self)).replace('__main__.', '')
示例#18
0
 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
示例#19
0
文件: task.py 项目: carze/vappio
 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)])
示例#20
0
 def testOld(self):
     class OldClass:
         pass
     old = OldClass()
     self.assertIn(reflect.getClass(OldClass).__name__, ('class', 'classobj'))
     self.assertEqual(reflect.getClass(old).__name__, 'OldClass')
示例#21
0
 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)
示例#22
0
 def testNew(self):
     class NewClass(object):
         pass
     new = NewClass()
     self.assertEquals(reflect.getClass(NewClass).__name__, 'type')
     self.assertEquals(reflect.getClass(new).__name__, 'NewClass')