示例#1
0
    The renderer first 
    """
    def __init__(self):
        from luban.weaver.Object2Dict import Object2Dict
        self._obj2dict = Object2Dict()
        return

    # set obj2dict to provide custom behavior
    @property
    def obj2dict(self):
        return self._obj2dict

    @obj2dict.setter
    def _set_obj2dict(self, obj2dict):
        self._obj2dict = obj2dict
        return obj2dict

    def render(self, obj):
        asdict = self._obj2dict.convert(obj)
        injson = jsonEncode(asdict)
        return injson


from ._utils import jsonEncode

from luban import journal

debug = journal.debug('luban.weaver.web')

# End of file
示例#2
0
文件: Dict2Object.py 项目: yxqd/luban
# -*- Python -*-
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#                                   Jiao Lin
#                      California Institute of Technology
#                      (C) 2006-2009  All Rights Reserved
#
# {LicenseText}
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#


from luban import journal
debug = journal.debug('luban.weaver.Dict2Object')
#debug.activate()


class Dict2Object:


    def __init__(self):
        from ..ui.meta.TypeRegistry import registry
        self.typename2type = registry
        return


    def render(self, d):
        if isinstance(d, list) or isinstance(d, tuple):
            return list(map(self.render, d))
示例#3
0
def main():
    from luban import journal
    journal.debug('metaclass').active = True
    unittest.main()
    return
示例#4
0
#                      California Institute of Technology
#                      (C) 2006-2011  All Rights Reserved
#
# {LicenseText}
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#


from luban import py_major_ver
if py_major_ver == 2:
    from luban.ui import descriptors


from luban import journal
debug = journal.debug('luban.ui.elements.ElementBase')


from .AttributeContainer import AttributeContainer, Meta
# this works for python 2 and 3
ElementBaseBase = Meta('ElementBaseBase', (AttributeContainer,), {'abstract':True})


class ElementBase(ElementBaseBase):

    """base class for all ui element types"""
    
    # indicate this is abstract and cannot be instantiated
    abstract = True

    # don't override this
示例#5
0
    def __init__(self):
        self.includes = []
        self.main = []  # the main function
        return

    def include(self, script='', scripts=[]):
        if script and scripts:
            raise ValueError

        if script: scripts = [script]
        for s in scripts:
            self._include(s)
        return

    def _include(self, include):
        if include not in self.includes:
            self.includes.append(include)
        return

    pass  # end of JavaScriptDocument


from luban import journal
debug = journal.debug('javascriptdocument')

# version
__id__ = "$Id$"

# End of file
示例#6
0
文件: __init__.py 项目: yxqd/luban
        descriptor_type_name = "Dynamic" + typename
        docstr = "Dynamic %s descriptor: value can either be of %s type or an action that evaluates to %s type" % (
            typename, typename, typename)
    else:
        base = Property
        descriptor_type_name = typename
        docstr = "%s descriptor" % typename

    from . import _generated_descriptor_types as store
    template = "%s%s descriptor"
    if not hasattr(store, descriptor_type_name):

        class K(base):
            __doc__ = docstr
            pass

        K.__name__ = descriptor_type_name
        K.type = type
        setattr(store, descriptor_type_name, K)
    K = getattr(store, descriptor_type_name)
    return K()


from luban import journal
debug = journal.debug('luban.content.descriptors')

# version
__id__ = "$Id$"

# End of file
示例#7
0
        """
        return generateCtorDocStr(cls, ctor_name=ctor_name, skip=skip)
    

    def __repr__(self):
        t = self.__class__.__name__
        ps = list(self.iterAttributes())
        ps = ', '.join('%s=%s' % (k,v) for k,v in ps)
        return t + '(' + ps + ')'

    pass



from luban import journal
debug = journal.debug('luban.ui.AttributeContainer')




def generateCtorDocStr(
    cls,
    ctor_name=None,
    skip = None
    ):
    """produce a docstr for the ctor

    This method loop over all descriptors and create
    the ctor docstr by extracting metadata from the descriptors

    ctor_name: name of the constructor. could be name of a factory method too
示例#8
0
def main():
    from luban import journal
    journal.debug('luban.content.ElementContainer').active = 1
    journal.debug('luban.weaver.web.prerenderer').active = 1
    unittest.main()