From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan Wedekind Newsgroups: gmane.lisp.guile.user Subject: Re: Artanis web REPL Date: Fri, 24 Jun 2016 22:40:28 +0100 (BST) Message-ID: References: <1466788813.1489.61.camel@gmail.com> Reply-To: Jan Wedekind NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466804481 27528 80.91.229.3 (24 Jun 2016 21:41:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 Jun 2016 21:41:21 +0000 (UTC) Cc: guile-user@gnu.org To: Nala Ginrut Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jun 24 23:41:10 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bGYqb-0003AC-In for guile-user@m.gmane.org; Fri, 24 Jun 2016 23:41:09 +0200 Original-Received: from localhost ([::1]:47414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGYqa-0003y1-8l for guile-user@m.gmane.org; Fri, 24 Jun 2016 17:41:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGYq4-0003rZ-U2 for guile-user@gnu.org; Fri, 24 Jun 2016 17:40:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGYq0-0004Fp-N8 for guile-user@gnu.org; Fri, 24 Jun 2016 17:40:35 -0400 Original-Received: from basicbox4.server-home.net ([195.137.212.26]:54338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGYq0-0004EQ-D2 for guile-user@gnu.org; Fri, 24 Jun 2016 17:40:32 -0400 Original-Received: from wedemob.default (unknown [95.150.201.158]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by basicbox4.server-home.net (Postfix) with ESMTPSA id DFCA61530668; Fri, 24 Jun 2016 23:40:28 +0200 (CEST) X-X-Sender: jan@wedemob In-Reply-To: <1466788813.1489.61.camel@gmail.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 195.137.212.26 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:12700 Archived-At: Cheers for the simplifying the code [1]. That's really useful. However I only got part of the improvements working (I am using Artanis=20 version 0.1.2). When using the following code ... (post "/" #:from-post #t #:cookie '(name repl) (lambda (rc) (let* [(session (:cookies-ref rc 'repl "sid")) (line (uri-decode (:from-post rc 'get "line")))] (repl session line) (editor session)))) ... the session value is 'repl instead of the desired value. The code=20 with the other improvements works though: (post "/" #:from-post #t (lambda (rc) (let* [(session (cookie-ref (rc-cookie rc) "sid")) (line (uri-decode (:from-post rc 'get "line")))] (repl session line) (editor session)))) [1] https://gist.github.com/wedesoft/b571cc15e81cfcf98e513974085683ff On Sat, 25 Jun 2016, Nala Ginrut wrote: > Hi Jan! > First, thanks for sharing this code. > I've tried, it's sweet that I love it! > And I'm looking forward to someone could finish it as a complete > project just like IPython notebook or similar. > > On Fri, 2016-06-24 at 12:43 +0100, Jan Wedekind wrote: >> > =C2=A0 =C2=A0 =C2=A0(post "/" >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (lambda (rc) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let* [(session (cook= ie-ref=C2=A0 (rc-cookie rc) "sid")) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (post-data (map dot (generate-kv-from-post-qstr (rc- >> body rc)))) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (line=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (uri-decode (assoc= -ref post-data >> "line")))] >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (repl ses= sion line) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (editor s= ession)))) > > > It is embarrassing when I'm trying to point out the fancy "shortcut" > for saving code, but finally I realized there're bugs. ;-( > Anyway, they're just syntax sugar for convenience, it won't be harm if > you dismiss it. I'm working on the server core of Artanis, so I may fix > it next release. > But I still put my code here to shed some light. ;-P > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3Dcode=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > (post "/" #:from-post #t #:cookie '(name repl) =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 (lambda (rc) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 (let [(session (:cookies-ref rc 'repl "sid")) =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (line (uri-decode (:from-post rc 'ge= t "line")))] =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0 (repl session line) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0 (editor session)))) > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3Dend=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > Best regards. > >