Exemplo n.º 1
0
class ScaffoldinglEntryPoint(ext.MultiAdapter):
    """ generate a index html. This html site will than
        load extjs framework with css and run the
        application.
    """
    ext.name('scaffolding')
    ext.adapts(IApplicationContext, IRequest)

    def __init__(self, context, request):
        self.context = context
        self.request = request

    def __call__(self):
        match = REGEX_URL.match(self.request.path_info)
        if match is None:
            raise HTTPNotFound()
        recipename, descname = match.groups()
        recipename, descname = recipename.lower(), descname.lower()

        descriptive = queryUtility(IRecipeDescriptive, descname)
        if descriptive is None:
            raise HTTPNotFound('No scaffolding for %s' % descname)
        recipe = queryMultiAdapter((self.context, descriptive, self.request,), IScaffoldingRecipe, recipename)
        if recipe is None:
            raise Exception('Missing Recipe to generate Exjs %s' % recipename)

        self.request.response.content_type = 'application/javascript'
        self.request.response.write(recipe())
Exemplo n.º 2
0
class Model(BaseRecipe):
    ext.name('model')
    ext.adapts(IApplicationContext, interfaces.IRecipeDescriptive, IRequest)

    def __call__(self):
        fields = list()
        for name, zfield in getFieldsInOrder(self.descriptive.interface):
            fields.append(
                getMultiAdapter((
                    self,
                    zfield,
                ), interfaces.IFieldBuilder)())
        model = dict(extend='Ext.data.Model', fields=fields)
        classname = self.classname(CLASS_NAMESPACE, 'model',
                                   self.descriptive.classname)
        return self.buildclass(classname, model)
Exemplo n.º 3
0
class EditGrid(Grid):
    ext.name('editgrid')
    ext.provides(interfaces.IScaffoldingRecipeEditGrid)
    ext.adapts(IApplicationContext, interfaces.IRecipeDescriptive, IRequest)

    def __call__(self):
        return self.render_template('editgrid.json.tpl')

    @property
    def alias(self):
        return 'widget.EditGrid%s' % self.descriptive.classname

    @property
    def name(self):
        return self.classname(CLASS_NAMESPACE, 'editgrid',
                              self.descriptive.classname)
Exemplo n.º 4
0
class LoginPageContext(ext.ApplicationContext):
    """ Base class to easily create a login page in your
        application. All you need is inherited in your project.
    """
    ext.baseclass()
    ext.name('login')

    title = 'Login Page'
    application = 'extjs.security.LoginPageApplication'
    namespace = 'extjs.security'
    resources = Resource(
        library,
        'application.js',
        depends=[ext.extjs_resources_skinless, themes['neptune'], style])

    credentials_pluggins = ('request_credentials', )
    authentication_pluggins = ()
Exemplo n.º 5
0
class DataManagerEntryPoint(ext.MultiAdapter):
    """ manager all ajax request with CRUD options.
    """
    ext.name('data')
    ext.adapts(IApplicationContext, IRequest)

    def __init__(self, context, request):
        self.context = context
        self.request = request

    def __call__(self):
        self.request.response.content_type = 'application/javascript'

        try:
            self.request.path_info_pop()
            entity = self.request.path_info_pop()
            transformer = getUtility(IModelTransformer, entity)
            batch = transformer.model(self.request)
            results = list()
            total = 0
            for model in batch:
                handler = getMultiAdapter((
                    model,
                    self.request,
                ), IModelHandler)
                result, subtotal = handler(model, batch)
                results += result
                total += subtotal
            data = transformer.json(results)
            self.successresponse('Data loaded from class %s' % model, data,
                                 total)
        except Exception as e:
            exceptionhandler = IJSONExceptionHandler(e)
            exceptionhandler(self.request)

    def successresponse(self, message, data, total):
        self.request.response.write(
            json.dumps(dict(success=True,
                            message=message,
                            total=total,
                            data=data),
                       indent=' ' * 4))
Exemplo n.º 6
0
class Grid(BaseRecipe):
    ext.name('grid')
    ext.adapts(IApplicationContext, interfaces.IRecipeDescriptive, IRequest)

    def __call__(self):
        return self.render_template('grid.json.tpl')

    @property
    def title(self):
        return self.descriptive.title

    @property
    def name(self):
        return self.classname(CLASS_NAMESPACE, 'grid',
                              self.descriptive.classname)

    @property
    def columns(self):
        columns = list()
        for name, zfield in getFieldsInOrder(self.descriptive.interface):
            columns.append(
                getMultiAdapter((
                    self,
                    zfield,
                ), interfaces.IFieldBuilder)())
        return columns

    @property
    def alias(self):
        return 'widget.Grid%s' % self.descriptive.classname

    @property
    def requires(self):
        return self.classname(CLASS_NAMESPACE, 'bufferedstore',
                              self.descriptive.classname)

    @property
    def store(self):
        name = self.classname(CLASS_NAMESPACE, 'bufferedstore',
                              self.descriptive.classname)
        return 'Ext.create("%s")' % name
Exemplo n.º 7
0
class BufferedStore(BaseStore):
    ext.name('bufferedstore')
    ext.adapts(IApplicationContext, interfaces.IRecipeDescriptive, IRequest)

    def __call__(self):
        return self.render_template('store.json.tpl')

    @property
    def name(self):
        return 'Buffered%s' % self.descriptive.classname

    @property
    def cname(self):
        return self.classname(CLASS_NAMESPACE, 'bufferedstore',
                              self.descriptive.classname)

    @property
    def buffered(self):
        return True

    @property
    def autoSync(self):
        return False
Exemplo n.º 8
0
class Display(BaseForm):
    ext.name('display')
    ext.adapts(IApplicationContext, interfaces.IRecipeDescriptive, IRequest)

    aliasprefix = 'Display'
Exemplo n.º 9
0
class Form(BaseForm):
    ext.name('form')
    ext.adapts(IApplicationContext, interfaces.IRecipeDescriptive, IRequest)
Exemplo n.º 10
0
class Store(BaseStore):
    ext.name('store')
    ext.adapts(IApplicationContext, interfaces.IRecipeDescriptive, IRequest)