def _renderHTTP(self, ctx): request = inevow.IRequest(ctx) ## XXX request is really ctx now, change the name here if self.addSlash and inevow.ICurrentSegments(ctx)[-1] != '': request.redirect(request.URLPath().child('')) return '' log.msg(http_render=None, uri=request.uri) self.rememberStuff(ctx) def finishRequest(): carryover = request.args.get('_nevow_carryover_', [None])[0] if carryover is not None and _CARRYOVER.has_key(carryover): del _CARRYOVER[carryover] if self.afterRender is not None: return util.maybeDeferred(self.afterRender,ctx) if self.buffered: io = StringIO() writer = io.write def finisher(result): request.write(io.getvalue()) return util.maybeDeferred(finishRequest).addCallback(lambda r: result) else: writer = request.write def finisher(result): return util.maybeDeferred(finishRequest).addCallback(lambda r: result) preprocessors = _getPreprocessors(self) doc = self.docFactory.load(ctx, preprocessors) ctx = WovenContext(ctx, tags.invisible[doc]) return self.flattenFactory(doc, ctx, writer, finisher)
def renderHTTP(self, ctx): request = inevow.IRequest(ctx) if inevow.ICurrentSegments(ctx)[-1] != '': request.redirect(request.URLPath().child('')) return '' d = defer.maybeDeferred(self.data_json, ctx, None) d.addCallback(lambda x: self.render_json(ctx, x)) return d
def renderHTTP(self, ctx): request = inevow.IRequest(ctx) if inevow.ICurrentSegments(ctx)[-1] != '': request.redirect(request.URLPath().child('')) return '' request.setHeader("Content-Type", "application/json; charset=UTF-8") d = defer.maybeDeferred(self.data_json, ctx, None) d.addCallback(lambda x: self.render_json(ctx, x)) return d
def calculatePostURL(context, data): postLocation = inevow.ICurrentSegments(context)[-1] if postLocation == '': postLocation = '.' try: configurableKey = context.locate(iformless.IConfigurableKey) except KeyError: #print "IConfigurableKey was not remembered when calculating full binding name for %s in node %s" % (configurable, context.key) configurableKey = '' bindingName = context.key return "%s/freeform_post!%s!%s" % (postLocation, configurableKey, bindingName)
def render_linkedDN(self, ctx, data): dn = data cfg = ctx.locate(interfaces.ILDAPConfig) baseDN = iwebui.ICurrentDN(ctx) ctx.tag.clear() while (dn!=baseDN and dn!=distinguishedname.DistinguishedName(stringValue='')): firstPart=dn.split()[0] u = url.here.parentdir().parentdir().child(dn) segments = inevow.ICurrentSegments(ctx) if segments[-1] == '': u = u.child(segments[-2]).child(segments[-1]) else: u = u.child(segments[-1]) for segment in inevow.IRemainingSegments(ctx): u = u.child(segment) ctx.tag[tags.a(href=u)[str(firstPart)], ','] dn=dn.up() ctx.tag['%s\n' % str(dn)] return ctx.tag