Re: [Chicken-users] Spiffy - ssp-handler - how to extend ssp-eval-environment

2012-03-27 Thread Peter Bex
On Mon, Mar 26, 2012 at 07:08:38PM -0300, Arthur Maciel wrote:
 Dear Peter, thanks for the info!
 
 What I would like when doing web programming (and specially when using
 Awful, which should be called Wonderful) is to have a clear separation
 between data processing and its presentation (model/controller vs view
 separation) and ssp-handler seemed to do this for me.

ssp encourages mixing your logic with your presentation, just like PHP or
ERB does.

 I believe a good way to do this would be to have page definitions with
 Awful 'define-page' procedure, that at the end would call a procedure that
 would hold all the view part (html-tags code for example) with an alist
 with parameters.

That's fine and you don't need ssp for that.

 Am I doing it Wrong(TM)? Is the above example to PHPcentric or imperative?

Not at all.  In fact, it's a great way of doing things, and you don't need
ssp for that at all.  You can define the code in regular .scm files, which
can live outside the docroot (which is much more secure).

Then you can load this code from your Spiffy startup file.  If you want
reloadable code, you could look into the system egg for that.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Spiffy - ssp-handler - how to extend ssp-eval-environment

2012-03-26 Thread Peter Bex
On Mon, Mar 26, 2012 at 12:02:13AM -0300, Arthur Maciel wrote:
 Hello!

Hi!

 I would like to know how it is possible to extend 'ssp-eval-environment' to
 add variables that could be accessed when processing .ssp files with
 'ssp-stringize' or 'ssp-include'.

It's a regular old environment object that gets passed to eval.
It used to be that you could extend these environments, but I'm unsure
about the current state of first-class environments.  It used to be that
you could use the environments egg to extend these, but they've had
a major overhaul and I think that egg no longer functions.

Please note that ssp is deprecated and ugly as hell.  If you want
to program PHP, use the real thing and get the full experience ;)

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Spiffy - ssp-handler - how to extend ssp-eval-environment

2012-03-26 Thread Arthur Maciel
Dear Peter, thanks for the info!

What I would like when doing web programming (and specially when using
Awful, which should be called Wonderful) is to have a clear separation
between data processing and its presentation (model/controller vs view
separation) and ssp-handler seemed to do this for me.

I believe a good way to do this would be to have page definitions with
Awful 'define-page' procedure, that at the end would call a procedure that
would hold all the view part (html-tags code for example) with an alist
with parameters. Something like:

;; --- controllers/example.scm
(define-page example/showvars
  (lambda()
(*data processing here*)
(let ((args `((var1 ,data1)
   (var2 ,data2
  (load my-view)
  (show args

;; --- views/my-view.scm
(define (show #!optional args)
  (++ (b (++ Var 1:  (assoc 'var1 args)))
  (br)
  (b (++ Var 2:  (assoc 'var2 args)

I am writing macros to transform the above into:

;; --- controllers/example.scm
(controller example
(define (showvars)
   (*data processing here*)
   (let ((args `((var1 ,data1)
   (var2 ,data2
(load-view my-view args

;; --- views/my-view.scm
(view
 (++ (b (++ Var 1:  (? 'var1)))
 (br)
 (b (++ Var 2:  (? 'var2)


Am I doing it Wrong(TM)? Is the above example to PHPcentric or imperative?
I really thought about separating data processing from view in order to
make it easy to maintain the code, specially by different programmers with
different development focus (ie. web design vs engine programming).
Probably I'll face this separation in the near future.

I always like your opinions! Thanks!
Arthur

-- Mensagem encaminhada --
 From: Peter Bex peter@xs4all.nl
 To: chicken-users chicken-users@nongnu.org
 Cc:
 Date: Mon, 26 Mar 2012 09:18:39 +0200
 Subject: Re: [Chicken-users] Spiffy - ssp-handler - how to extend
 ssp-eval-environment
 On Mon, Mar 26, 2012 at 12:02:13AM -0300, Arthur Maciel wrote:
  Hello!

 Hi!

  I would like to know how it is possible to extend 'ssp-eval-environment'
 to
  add variables that could be accessed when processing .ssp files with
  'ssp-stringize' or 'ssp-include'.

 It's a regular old environment object that gets passed to eval.
 It used to be that you could extend these environments, but I'm unsure
 about the current state of first-class environments.  It used to be that
 you could use the environments egg to extend these, but they've had
 a major overhaul and I think that egg no longer functions.

 Please note that ssp is deprecated and ugly as hell.  If you want
 to program PHP, use the real thing and get the full experience ;)

 Cheers,
 Peter
 --
 http://sjamaan.ath.cx
 --
 The process of preparing programs for a digital computer
  is especially attractive, not only because it can be economically
  and scientifically rewarding, but also because it can be an aesthetic
  experience much like composing poetry or music.
-- Donald Knuth

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Spiffy - ssp-handler - how to extend ssp-eval-environment

2012-03-26 Thread Arthur Maciel
Dear Moritz,

thanks for help! As Peter told me ssp-handler is 'deprecated and ugly as
hell' I gave up using it.

As atm I'm with a tight schedule I won't be able to test stuff that is not
(now) related to what I'm experimenting. Maybe in the near future. Sorry
for that and really thanks!

Best wishes,
Arthur

2012/3/26 Arthur Maciel arthurmac...@gmail.com

 Dear Peter, thanks for the info!

 What I would like when doing web programming (and specially when using
 Awful, which should be called Wonderful) is to have a clear separation
 between data processing and its presentation (model/controller vs view
 separation) and ssp-handler seemed to do this for me.

 I believe a good way to do this would be to have page definitions with
 Awful 'define-page' procedure, that at the end would call a procedure that
 would hold all the view part (html-tags code for example) with an alist
 with parameters. Something like:

 ;; --- controllers/example.scm
 (define-page example/showvars
   (lambda()
 (*data processing here*)
 (let ((args `((var1 ,data1)
(var2 ,data2
   (load my-view)
   (show args

 ;; --- views/my-view.scm
 (define (show #!optional args)
   (++ (b (++ Var 1:  (assoc 'var1 args)))
   (br)
   (b (++ Var 2:  (assoc 'var2 args)

 I am writing macros to transform the above into:

 ;; --- controllers/example.scm
 (controller example
 (define (showvars)
(*data processing here*)
(let ((args `((var1 ,data1)
(var2 ,data2
 (load-view my-view args

 ;; --- views/my-view.scm
 (view
  (++ (b (++ Var 1:  (? 'var1)))
  (br)
  (b (++ Var 2:  (? 'var2)


 Am I doing it Wrong(TM)? Is the above example to PHPcentric or imperative?
 I really thought about separating data processing from view in order to
 make it easy to maintain the code, specially by different programmers with
 different development focus (ie. web design vs engine programming).
 Probably I'll face this separation in the near future.

 I always like your opinions! Thanks!
 Arthur

 -- Mensagem encaminhada --
 From: Peter Bex peter@xs4all.nl
 To: chicken-users chicken-users@nongnu.org
 Cc:
 Date: Mon, 26 Mar 2012 09:18:39 +0200
 Subject: Re: [Chicken-users] Spiffy - ssp-handler - how to extend
 ssp-eval-environment
 On Mon, Mar 26, 2012 at 12:02:13AM -0300, Arthur Maciel wrote:
  Hello!

 Hi!

  I would like to know how it is possible to extend
 'ssp-eval-environment' to
  add variables that could be accessed when processing .ssp files with
  'ssp-stringize' or 'ssp-include'.

 It's a regular old environment object that gets passed to eval.
 It used to be that you could extend these environments, but I'm unsure
 about the current state of first-class environments.  It used to be that
 you could use the environments egg to extend these, but they've had
 a major overhaul and I think that egg no longer functions.

 Please note that ssp is deprecated and ugly as hell.  If you want
 to program PHP, use the real thing and get the full experience ;)

 Cheers,
 Peter
 --
 http://sjamaan.ath.cx
 --
 The process of preparing programs for a digital computer
  is especially attractive, not only because it can be economically
  and scientifically rewarding, but also because it can be an aesthetic
  experience much like composing poetry or music.
-- Donald Knuth


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users