예제 #1
0
파일: render.py 프로젝트: rjweir/warp
    def render_create(self, request):

        presets = json.loads(request.args.get('presets', [''])[0] or '{}')
        noEdit = json.loads(request.args.get('noedit', [''])[0] or '[]')

        template = templateLookup.get_template("/crud/form.mak")

        fakeObj = self.model()

        # XXX TODO - Take a counter argument from the request here, 
        # so Javascript can product lots of these which don't conflict.
        fakeObj.fakeID = '*1'
        fakeObj.noEdit = noEdit

        for (k,v) in presets.iteritems():
            setattr(fakeObj, k, v)

        # We do an add/rollback dance here to work around some strange Storm
        # behaviour, where references don't get a value unless their object
        # is added, even if it isn't committed.
        store.add(fakeObj)

        rv =  helpers.renderTemplateObj(request, template, 
                                        obj=self.crudModel(fakeObj))

        store.rollback()

        return rv
예제 #2
0
파일: render.py 프로젝트: foamdino/warp
    def render_save(self, request):
        objects = json.load(request.content)
        (success, info) = form.applyForm(objects, request)
    
        if not success:
            store.rollback()
            return json.dumps({
                    'success': False,
                    'errors': info
                    })

        else:
            store.commit()

            results = dict((k, [o.id for o in v])
                           for (k,v) in info.iteritems())

            return json.dumps({
                    "success": True,
                    "results": results,
                    })
예제 #3
0
파일: site.py 프로젝트: foamdino/warp
 def finish(self):
     rv = Request.finish(self)
     store.rollback()
     store.commit()
     return rv
예제 #4
0
파일: site.py 프로젝트: foamdino/warp
 def processingFailed(self, reason):
     rv = Request.processingFailed(self, reason)
     store.rollback()
     store.commit()
     return rv