Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 3
0
    def test_old(self):
        class OldClass:
            pass

        old = OldClass()
        self.assertIn(reflect.getClass(OldClass).__name__, self.oldClassNames)
        self.assertEqual(reflect.getClass(old).__name__, 'OldClass')
Ejemplo n.º 4
0
    def test_new(self):
        class NewClass(object):
            pass

        new = NewClass()
        self.assertEqual(reflect.getClass(NewClass).__name__, 'type')
        self.assertEqual(reflect.getClass(new).__name__, 'NewClass')
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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')
Ejemplo n.º 8
0
 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)
Ejemplo n.º 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
Ejemplo n.º 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))))
Ejemplo n.º 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)
         ])
Ejemplo n.º 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)
Ejemplo n.º 13
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)
Ejemplo n.º 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')]
Ejemplo n.º 15
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')]
Ejemplo n.º 16
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))))
Ejemplo n.º 17
0
 def __init__(self):
     self.logCategory = \
             reflect.qual(reflect.getClass(self)).replace('__main__.', '')
Ejemplo n.º 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
Ejemplo n.º 19
0
Archivo: task.py Proyecto: 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)])
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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')