def from_xpf(request): xml_handle = urllib.urlopen(request.POST["xpfurl"]) xmldata = xml_handle.read() p = Puzzle.fromXML(xmldata) t = get_template('puzzle.html') html = t.render(RequestContext(request, {'puzzle': p})) return HttpResponse(html)
def main_landing(request): logger = logging.getLogger('xw.access') logger.info(" main page request from %s : %s" % (request.META['REMOTE_ADDR'], request.META['QUERY_STRING'])); t = get_template('puzzle.html') p = None solver = None try: author = request.GET['author'] title = request.GET['title'] atname = author + "-" + title atname = atname.replace('/','_') atname = atname.replace('.','_') atname = atname.replace(' ','_') atname = atname.lower() table = RawPuzzles if request.GET.has_key('solve') or request.GET.has_key('solver'): t = get_template('solve.html') if request.GET.has_key('solver'): solver = request.GET['solver'] atname = solver + '-' + atname table = SolvePuzzles puz = table.objects.filter(author_title=atname) if len(puz) > 0: p = Puzzle.fromXML(smart_str(puz[0].contents)) if request.GET.has_key('print'): t = get_template('print.html') if request.GET.has_key('printall'): t = get_template('printall.html') if request.GET.has_key('xpf'): t = get_template('xpf.xml') except: pass if p == None: gridstrs = Grid.objects.filter(Q(format__startswith='15u')) p = Puzzle.fromGrid(gridstrs[randrange(len(gridstrs))].format) if solver: p.solver = solver html = t.render(RequestContext(request, {'puzzle': p})) if request.GET.has_key('xpf'): return HttpResponse(html, content_type='text/xml') else: return HttpResponse(html)
def main_landing(request): logger = logging.getLogger("xw.access") logger.info(" main page request from %s : %s" % (request.META["REMOTE_ADDR"], request.META["QUERY_STRING"])) t = get_template("puzzle.html") p = None solver = None try: author = request.GET["author"] title = request.GET["title"] atname = author + "-" + title atname = atname.replace("/", "_") atname = atname.replace(".", "_") atname = atname.replace(" ", "_") atname = atname.lower() table = RawPuzzles if request.GET.has_key("solve") or request.GET.has_key("solver"): t = get_template("solve.html") if request.GET.has_key("solver"): solver = request.GET["solver"] atname = solver + "-" + atname table = SolvePuzzles puz = table.objects.filter(author_title=atname) if len(puz) > 0: p = Puzzle.fromXML(smart_str(puz[0].contents)) if request.GET.has_key("print"): t = get_template("print.html") if request.GET.has_key("printall"): t = get_template("printall.html") if request.GET.has_key("xpf"): t = get_template("xpf.xml") except: pass if p == None: gridstrs = Grid.objects.filter(Q(format__startswith="15u")) p = Puzzle.fromGrid(gridstrs[randrange(len(gridstrs))].format) if solver: p.solver = solver html = t.render(RequestContext(request, {"puzzle": p})) if request.GET.has_key("xpf"): return HttpResponse(html, content_type="text/xml") else: return HttpResponse(html)