Re: pl-web, almost a web development framework

2013-05-08 Thread Jon Kleiser

Hi Henrik,

I just tried your simple-web-app, using 32-bit PicoLisp (3.1.2.6 C) on 
my Mac. It seems to work, except for uploading files. I've tried 
uploading a .jpg and a .txt file, but each time the server failed to 
return a response, probably hanging. I just got two empty files in the 
uploads folder. Do you have a newer version of your code?


/Jon

On 2/4/12 12:48 PM, Henrik Sarvell wrote:

Hi guys!

This time I've also attached the sample web app. You know where things
are to be and how to start the http server if you read the prior post.

So pl-web is getting more feature complete, we can now also:

1.) Upload files, in the test application they end up in the
app/uploads folder in the sample web app ( http://localhost:8080/login
).
2.) Redirect, go to http://localhost:8080/to-whoami to see it in effect.
3.) Download / load mime files, try
http://localhost:8080/public/test.html and
http://localhost:8080/public/test.txt

In addition to that sessions will now get wiped (if it works correctly
which I think but I'm not 100), in the main.l of the simple web app
you have the following at the top: (setq *SClI '(3600 . 5)) (Session
Clear Information) which means it should remove sessions that are
older than one hour and there's a 5% chance of the swipe being
initiated everytime someone accesses the site. Depending on how busy
the site is and how accurately you want to be able to remove old
sessions these values should be changed. I know, it's ugly but it's
what I can come up with.

We now have something like the PL equivalent of the environment /
capabilities you have when you start out with an empty PHP script.

If you inspect the code you will see that in addition to the http
function a few others have been redefined, I have removed basically
everything from _htSet and have no idea if now something essential is
missing or if it was just stuff pertaining to the GUI framework. It's
a monkey in a spaceship situation here, I suppose I'll find out soon
enough as my intention is to now go ahead and create some kind of
framework on top of pl-web.

I've also modified Alex JSON code and included it in pl-web. The
following now looks like it works (didn't try to eval with JS but
visually it looks good):

(class +Person)

(dm T (Name Age)
(=: nm Name)
(=: age Age))

(setq Anna (new '(+Person) Anna 25))
(setq Peter (new '(+Person) Peter 30))

(printJson
(list
   (list two-people [] Anna Peter)
   '(name . Smith)
   '(age . 25)
   '(a-bool . T)
   '(some-bools [] T NIL T T T NIL NIL)
   '(address
  (street . 21 2nd Street)
  (city . New York)
  (state . NY)
  (zip . 10021) )
   '(phone [] 212 555-1234 646 555-4567) ) )

I think comments on the above are superfluous. I never managed to
flip/reverse the pairs so that mapcar over the getl is the result of
that inability.

Anyway, it now basically works like I want.


On Sat, Jan 28, 2012 at 4:25 PM, Henrik Sarvellhsarv...@gmail.com  wrote:

OK so I've got a first draft of something simple.

As opposed to what has been requested before this is NOT a web
development framework in the sense of RoR or even Ring.

Instead I've opted to create a simple environment from which
frameworks utilizing conventions and such can be built, both a RoR
type of thing or a simpler Ring style framework is possible to create
from pl-web.

What we have is a few basic things:

1.) An ability to inspect the current look of the URL (se line 87 and
120 in pl-web.l).

2.) File based sessions (ugly yes but will not make demands on how any
database should look like). See line 109 in pl-web.l.

3.) Trying as hard as we can to utilize Linux system
functions/commands in order to alleviate the need for libraries (see
cmd.l).

How to test:

1.) Unpack the attached file into /opt/picolisp and create
/tmp/pl-web/sessions/.

2.) Create a folder called simple-web-app in /opt/picolisp/projects
and paste the following into a main.l file there:

(load
   pl-web/pl-web.l
   pl-web/pl-html.l)

(de login (Msg)
   (plw-form  NIL 
  (span  NIL Username:)
  (plw-field  text username (gReq username))
  (br)
  (span  NIL Password:)
  (plw-field  password password )
  (br)
  (submit  Submit)
  (br)
  (span  NIL Msg) ) )

(de app ()
   (fatApp
  (html 0 PL Web *Css NIL
 (div  NIL (println Post:  *Post  Cookies:  *Cookies))
 (cond
((= (car *Urll) login)
 (ifn (and (= (gReq password) test) (= (gReq
username) test))
(login (if (gReq username)
  User not found.
  Please login. ) )
(sSess 'logged-in-user test)
(div  NIL Login successful.) ) )
((= (car *Urll) whoami)
 (div  NIL (prin You are:  (gSess 'logged-in-user))) )
(T (Nothing to do.)) ) ) ) )

(de start ()
   (off *JS))

(de go ()
   (server 8080 !start) )

3.) Start it: 

Re: pl-web, almost a web development framework

2013-05-08 Thread Henrik Sarvell
I do but nowadays it's dependent on namespacing so only 64bit I'm afraid.

However the uploading worked when I tested and this code has not been
changed either in the current version. Maybe it's a permission issue on the
upload folder?


On Wed, May 8, 2013 at 4:32 PM, Jon Kleiser jon.klei...@usit.uio.no wrote:

 Hi Henrik,

 I just tried your simple-web-app, using 32-bit PicoLisp (3.1.2.6 C) on my
 Mac. It seems to work, except for uploading files. I've tried uploading a
 .jpg and a .txt file, but each time the server failed to return a response,
 probably hanging. I just got two empty files in the uploads folder. Do you
 have a newer version of your code?

 /Jon


 On 2/4/12 12:48 PM, Henrik Sarvell wrote:

 Hi guys!

 This time I've also attached the sample web app. You know where things
 are to be and how to start the http server if you read the prior post.

 So pl-web is getting more feature complete, we can now also:

 1.) Upload files, in the test application they end up in the
 app/uploads folder in the sample web app ( http://localhost:8080/login
 ).
 2.) Redirect, go to 
 http://localhost:8080/to-**whoamihttp://localhost:8080/to-whoamito see it 
 in effect.
 3.) Download / load mime files, try
 http://localhost:8080/public/**test.htmlhttp://localhost:8080/public/test.htmland
 http://localhost:8080/public/**test.txthttp://localhost:8080/public/test.txt

 In addition to that sessions will now get wiped (if it works correctly
 which I think but I'm not 100), in the main.l of the simple web app
 you have the following at the top: (setq *SClI '(3600 . 5)) (Session
 Clear Information) which means it should remove sessions that are
 older than one hour and there's a 5% chance of the swipe being
 initiated everytime someone accesses the site. Depending on how busy
 the site is and how accurately you want to be able to remove old
 sessions these values should be changed. I know, it's ugly but it's
 what I can come up with.

 We now have something like the PL equivalent of the environment /
 capabilities you have when you start out with an empty PHP script.

 If you inspect the code you will see that in addition to the http
 function a few others have been redefined, I have removed basically
 everything from _htSet and have no idea if now something essential is
 missing or if it was just stuff pertaining to the GUI framework. It's
 a monkey in a spaceship situation here, I suppose I'll find out soon
 enough as my intention is to now go ahead and create some kind of
 framework on top of pl-web.

 I've also modified Alex JSON code and included it in pl-web. The
 following now looks like it works (didn't try to eval with JS but
 visually it looks good):

 (class +Person)

 (dm T (Name Age)
 (=: nm Name)
 (=: age Age))

 (setq Anna (new '(+Person) Anna 25))
 (setq Peter (new '(+Person) Peter 30))

 (printJson
 (list
(list two-people [] Anna Peter)
'(name . Smith)
'(age . 25)
'(a-bool . T)
'(some-bools [] T NIL T T T NIL NIL)
'(address
   (street . 21 2nd Street)
   (city . New York)
   (state . NY)
   (zip . 10021) )
'(phone [] 212 555-1234 646 555-4567) ) )

 I think comments on the above are superfluous. I never managed to
 flip/reverse the pairs so that mapcar over the getl is the result of
 that inability.

 Anyway, it now basically works like I want.


 On Sat, Jan 28, 2012 at 4:25 PM, Henrik Sarvellhsarv...@gmail.com
  wrote:

 OK so I've got a first draft of something simple.

 As opposed to what has been requested before this is NOT a web
 development framework in the sense of RoR or even Ring.

 Instead I've opted to create a simple environment from which
 frameworks utilizing conventions and such can be built, both a RoR
 type of thing or a simpler Ring style framework is possible to create
 from pl-web.

 What we have is a few basic things:

 1.) An ability to inspect the current look of the URL (se line 87 and
 120 in pl-web.l).

 2.) File based sessions (ugly yes but will not make demands on how any
 database should look like). See line 109 in pl-web.l.

 3.) Trying as hard as we can to utilize Linux system
 functions/commands in order to alleviate the need for libraries (see
 cmd.l).

 How to test:

 1.) Unpack the attached file into /opt/picolisp and create
 /tmp/pl-web/sessions/.

 2.) Create a folder called simple-web-app in /opt/picolisp/projects
 and paste the following into a main.l file there:

 (load
pl-web/pl-web.l
pl-web/pl-html.l)

 (de login (Msg)
(plw-form  NIL 
   (span  NIL Username:)
   (plw-field  text username (gReq username))
   (br)
   (span  NIL Password:)
   (plw-field  password password )
   (br)
   (submit  Submit)
   (br)
   (span  NIL Msg) ) )

 (de app ()
(fatApp
   (html 0 PL Web *Css NIL
  (div  NIL (println Post:  *Post  Cookies:  *Cookies))
  (cond
 ((= (car *Urll) login)
 

Re: pl-web, almost a web development framework

2013-05-08 Thread Jon Kleiser

Hi Henrik,

No, the problem wasn't the permissions on the upload folder. (It was 
'drwxr-xr-x@'.) And if it had been, I quess that I wouldn't have got the 
empty files. The problem was that I only specified one file each time, 
while your form has two file input elements. Uploading two files at the 
same time works. I guess I should be able to fix that bug.
Another thing I'd like to fix are the file names. Now I just get names 
like this:


4135dc2f27063048e073bc22d8a6e489
jpg

.. and it even seems to be a newline character before the extension 
.. Have you experienced this?


/Jon

On 5/8/13 1:55 PM, Henrik Sarvell wrote:

I do but nowadays it's dependent on namespacing so only 64bit I'm afraid.

However the uploading worked when I tested and this code has not been 
changed either in the current version. Maybe it's a permission issue 
on the upload folder?



On Wed, May 8, 2013 at 4:32 PM, Jon Kleiser jon.klei...@usit.uio.no 
mailto:jon.klei...@usit.uio.no wrote:


Hi Henrik,

I just tried your simple-web-app, using 32-bit PicoLisp (3.1.2.6
C) on my Mac. It seems to work, except for uploading files. I've
tried uploading a .jpg and a .txt file, but each time the server
failed to return a response, probably hanging. I just got two
empty files in the uploads folder. Do you have a newer version of
your code?

/Jon




--090602050506030505090900
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

html
 head
   meta content=text/html; charset=ISO-8859-1
 http-equiv=Content-Type
 /head
 body bgcolor=#FF text=#00
   Hi Henrik,br
   br
   No, the problem wasn't the permissions on the upload folder. (It was
   'drwxr-xr-x@'.) And if it had been, I quess that I wouldn't have got
   the empty files. The problem was that I only specified one file each
   time, while your form has two file input elements. Uploading two
   files at the same time works. I guess I should be able to fix that
   bug.br
   Another thing I'd like to fix are the file names. Now I just get
   names like this:br
   br
   4135dc2f27063048e073bc22d8a6e489br
   .jpgbr
   br
   ... and it even seems to be a newline character before the extension
   .. Have you experienced this?br
   br
   /Jonbr
   br
   On 5/8/13 1:55 PM, Henrik Sarvell wrote:
   blockquote
cite=mid:calnd_wasruejuabxxmqygfan9ysup_5ntztn4wvtqf8e7db...@mail.gmail.com
 type=cite
 div dir=ltr
   divI do but nowadays it's dependent on namespacing so only
 64bit I'm afraid.br
 br
   /div
   However the uploading worked when I tested and this code has not
   been changed either in the current version. Maybe it's a
   permission issue on the upload folder?br
 /div
 div class=gmail_extrabr
   br
   div class=gmail_quoteOn Wed, May 8, 2013 at 4:32 PM, Jon
 Kleiser span dir=ltrlt;a moz-do-not-send=true
 href=mailto:jon.klei...@usit.uio.no; 
target=_blankjon.klei...@usit.uio.no/agt;/span
 wrote:br
 blockquote class=gmail_quote style=margin:0 0 0
   .8ex;border-left:1px #ccc solid;padding-left:1exHi Henrik,br
   br
   I just tried your simple-web-app, using 32-bit PicoLisp
   (3.1.2.6 C) on my Mac. It seems to work, except for
   uploading files. I've tried uploading a .jpg and a .txt
   file, but each time the server failed to return a response,
   probably hanging. I just got two empty files in the uploads
   folder. Do you have a newer version of your code?br
   br
   /Jonbr
 /blockquote
   /div
 /div
   /blockquote
   br
 /body
/html

--090602050506030505090900--
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pl-web, almost a web development framework

2012-02-04 Thread Henrik Sarvell
Hi guys!

This time I've also attached the sample web app. You know where things
are to be and how to start the http server if you read the prior post.

So pl-web is getting more feature complete, we can now also:

1.) Upload files, in the test application they end up in the
app/uploads folder in the sample web app ( http://localhost:8080/login
).
2.) Redirect, go to http://localhost:8080/to-whoami to see it in effect.
3.) Download / load mime files, try
http://localhost:8080/public/test.html and
http://localhost:8080/public/test.txt

In addition to that sessions will now get wiped (if it works correctly
which I think but I'm not 100), in the main.l of the simple web app
you have the following at the top: (setq *SClI '(3600 . 5)) (Session
Clear Information) which means it should remove sessions that are
older than one hour and there's a 5% chance of the swipe being
initiated everytime someone accesses the site. Depending on how busy
the site is and how accurately you want to be able to remove old
sessions these values should be changed. I know, it's ugly but it's
what I can come up with.

We now have something like the PL equivalent of the environment /
capabilities you have when you start out with an empty PHP script.

If you inspect the code you will see that in addition to the http
function a few others have been redefined, I have removed basically
everything from _htSet and have no idea if now something essential is
missing or if it was just stuff pertaining to the GUI framework. It's
a monkey in a spaceship situation here, I suppose I'll find out soon
enough as my intention is to now go ahead and create some kind of
framework on top of pl-web.

I've also modified Alex JSON code and included it in pl-web. The
following now looks like it works (didn't try to eval with JS but
visually it looks good):

(class +Person)

(dm T (Name Age)
   (=: nm Name)
   (=: age Age))

(setq Anna (new '(+Person) Anna 25))
(setq Peter (new '(+Person) Peter 30))

(printJson
   (list
  (list two-people [] Anna Peter)
  '(name . Smith)
  '(age . 25)
  '(a-bool . T)
  '(some-bools [] T NIL T T T NIL NIL)
  '(address
 (street . 21 2nd Street)
 (city . New York)
 (state . NY)
 (zip . 10021) )
  '(phone [] 212 555-1234 646 555-4567) ) )

I think comments on the above are superfluous. I never managed to
flip/reverse the pairs so that mapcar over the getl is the result of
that inability.

Anyway, it now basically works like I want.


On Sat, Jan 28, 2012 at 4:25 PM, Henrik Sarvell hsarv...@gmail.com wrote:

 OK so I've got a first draft of something simple.

 As opposed to what has been requested before this is NOT a web
 development framework in the sense of RoR or even Ring.

 Instead I've opted to create a simple environment from which
 frameworks utilizing conventions and such can be built, both a RoR
 type of thing or a simpler Ring style framework is possible to create
 from pl-web.

 What we have is a few basic things:

 1.) An ability to inspect the current look of the URL (se line 87 and
 120 in pl-web.l).

 2.) File based sessions (ugly yes but will not make demands on how any
 database should look like). See line 109 in pl-web.l.

 3.) Trying as hard as we can to utilize Linux system
 functions/commands in order to alleviate the need for libraries (see
 cmd.l).

 How to test:

 1.) Unpack the attached file into /opt/picolisp and create
 /tmp/pl-web/sessions/.

 2.) Create a folder called simple-web-app in /opt/picolisp/projects
 and paste the following into a main.l file there:

 (load
   pl-web/pl-web.l
   pl-web/pl-html.l)

 (de login (Msg)
   (plw-form NIL 
      (span NIL Username:)
      (plw-field text username (gReq username))
      (br)
      (span NIL Password:)
      (plw-field password password )
      (br)
      (submit Submit)
      (br)
      (span NIL Msg) ) )

 (de app ()
   (fatApp
      (html 0 PL Web *Css NIL
         (div NIL (println Post:  *Post  Cookies:  *Cookies))
         (cond
            ((= (car *Urll) login)
             (ifn (and (= (gReq password) test) (= (gReq
 username) test))
                (login (if (gReq username)
                          User not found.
                          Please login. ) )
                (sSess 'logged-in-user test)
                (div NIL Login successful.) ) )
            ((= (car *Urll) whoami)
             (div NIL (prin You are:  (gSess 'logged-in-user))) )
            (T (Nothing to do.)) ) ) ) )

 (de start ()
   (off *JS))

 (de go ()
   (server 8080 !start) )

 3.) Start it: henrik@henrik-laptop:/opt/picolisp$ ./pil
 projects/simple-web-app/main.l -go

 4.) Browse to: http://localhost:8080/login and submit the form with
 test in both fields.

 5.) Browse to: http://localhost:8080/whoami

 That's it, I think inspection of the code plus testing in #4 and #5
 above should be enough to understand how this works.

 A few TODO/Thoughts:

 1.) Swiping stale sessions in the sessions folder. 

Re: pl-web, almost a web development framework

2012-01-28 Thread Henrik Sarvell
Ops, the httpHead redifinition part in pl-web.l can be removed, I
think I thought I would need to make changes there but I did not.


On Sat, Jan 28, 2012 at 4:25 PM, Henrik Sarvell hsarv...@gmail.com wrote:
 OK so I've got a first draft of something simple.

 As opposed to what has been requested before this is NOT a web
 development framework in the sense of RoR or even Ring.

 Instead I've opted to create a simple environment from which
 frameworks utilizing conventions and such can be built, both a RoR
 type of thing or a simpler Ring style framework is possible to create
 from pl-web.

 What we have is a few basic things:

 1.) An ability to inspect the current look of the URL (se line 87 and
 120 in pl-web.l).

 2.) File based sessions (ugly yes but will not make demands on how any
 database should look like). See line 109 in pl-web.l.

 3.) Trying as hard as we can to utilize Linux system
 functions/commands in order to alleviate the need for libraries (see
 cmd.l).

 How to test:

 1.) Unpack the attached file into /opt/picolisp and create
 /tmp/pl-web/sessions/.

 2.) Create a folder called simple-web-app in /opt/picolisp/projects
 and paste the following into a main.l file there:

 (load
   pl-web/pl-web.l
   pl-web/pl-html.l)

 (de login (Msg)
   (plw-form NIL 
      (span NIL Username:)
      (plw-field text username (gReq username))
      (br)
      (span NIL Password:)
      (plw-field password password )
      (br)
      (submit Submit)
      (br)
      (span NIL Msg) ) )

 (de app ()
   (fatApp
      (html 0 PL Web *Css NIL
         (div NIL (println Post:  *Post  Cookies:  *Cookies))
         (cond
            ((= (car *Urll) login)
             (ifn (and (= (gReq password) test) (= (gReq
 username) test))
                (login (if (gReq username)
                          User not found.
                          Please login. ) )
                (sSess 'logged-in-user test)
                (div NIL Login successful.) ) )
            ((= (car *Urll) whoami)
             (div NIL (prin You are:  (gSess 'logged-in-user))) )
            (T (Nothing to do.)) ) ) ) )

 (de start ()
   (off *JS))

 (de go ()
   (server 8080 !start) )

 3.) Start it: henrik@henrik-laptop:/opt/picolisp$ ./pil
 projects/simple-web-app/main.l -go

 4.) Browse to: http://localhost:8080/login and submit the form with
 test in both fields.

 5.) Browse to: http://localhost:8080/whoami

 That's it, I think inspection of the code plus testing in #4 and #5
 above should be enough to understand how this works.

 A few TODO/Thoughts:

 1.) Swiping stale sessions in the sessions folder. Some kind of
 timeout value might be needed, if combined with a random initializer
 we have recreated the ugliness of PHP session handling to perfection.

 2.) Port of the current xhtml.l library (which we are currently
 relying heavily on), as can be seen I've started a little in the
 pl-html.l file, all that *JS stuff etc needs to go.

 3.) Some brave soul needs to create a real, clever, framework from
 this that is beautiful enough that it might get some attention. What
 was that earlier suggestion, Bumblebee? Don't know about the name
 though as it brings to mind something that looks so heavy it should
 not be able to fly, yet does. Perhaps not something we want associated
 with PicoLisp.

 4.) If it would be possible for PL to have several databases open at
 the same time (I have a vague memory of discussing this at some point
 in the past) stuff like session handling could done through a DB
 instead and without making demands on the main application E/R.

 Comments?

 /Henrik Sarvell
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pl-web, almost a web development framework

2012-01-28 Thread Jakob Eriksson


On January 28, 2012 at 10:25 AM Henrik Sarvell hsarv...@gmail.com wrote:

 OK so I've got a first draft of something simple.

 As opposed to what has been requested before this is NOT a web
 development framework in the sense of RoR or even Ring.
 
 
But a very nice start! :-D
 
//Jakob
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe