Mercurial > repos > rhope
comparison framework.rhope @ 148:f582fd6c75ee
Fixed framework port, works for said.rhope example
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 22 Nov 2010 01:37:05 -0500 |
parents | f3686f60985d |
children | 47ab97730865 |
comparison
equal
deleted
inserted
replaced
147:f3686f60985d | 148:f582fd6c75ee |
---|---|
35 final page <- Val[handler page] | 35 final page <- Val[handler page] |
36 ncon <- Val[con] | 36 ncon <- Val[con] |
37 } | 37 } |
38 string,out headers <- [final page]Render | 38 string,out headers <- [final page]Render |
39 | 39 |
40 after headers <- HTTP OK[ncon, Get Content Type[".html"], [string]Byte Length, out headers] | 40 [[string]Write to File[HTTP OK[ncon, Get Content Type[".html"], [string]Byte Length, out headers]]]Close |
41 { Print["Sent status"] | |
42 { [[string]Write to File[after headers]]Close | |
43 { Print["Wrote data"] }}} | |
44 } | 41 } |
45 | 42 |
46 Handler Fixer[handler:out] | 43 Handler Fixer[handler:out] |
47 { | 44 { |
48 [(List(),List Leaf())]Find[=[?,Blueprint Of[handler]]] | 45 [(List(),List Leaf())]Find[=[?,Blueprint Of[handler]]] |
421 okey <- URL Decode[key] | 418 okey <- URL Decode[key] |
422 } | 419 } |
423 | 420 |
424 Process POST[page,con,headers:out,ncon] | 421 Process POST[page,con,headers:out,ncon] |
425 { | 422 { |
426 ,ncon <- [con]Read[[headers]Index["Content-Length"]] | 423 ,ncon <- [con]Read[Int32[[headers]Index["Content-Length"]]] |
427 { | 424 { |
428 post string <- [String[~]]Replace["+"," "] | 425 post string <- [String[~]]Replace["+"," "] |
429 } | 426 } |
430 post data <- Key Value Map[Dict Split[post string, "=", "&"], Decode Pair[?]] | 427 post data <- Key Value Map[Dict Split[post string, "=", "&"], Decode Pair[?]] |
431 out <- [page]Postback[post data] | 428 out <- [page]Postback[post data] |
507 out <- in | 504 out <- in |
508 events <- List[] | 505 events <- List[] |
509 } | 506 } |
510 | 507 |
511 Set Session@String[in,session:out] | 508 Set Session@String[in,session:out] |
509 { | |
510 out <- in | |
511 } | |
512 | |
513 Render@String Cat[string:out,headers] | |
514 { | |
515 out <- [Web Text[string,""]]Render | |
516 } | |
517 | |
518 Name@String Cat[string:out,none] | |
519 { | |
520 none <- string | |
521 } | |
522 | |
523 Postback@String Cat[in,post data:out,events] | |
524 { | |
525 out <- in | |
526 events <- List[] | |
527 } | |
528 | |
529 Set Session@String Cat[in,session:out] | |
530 { | |
531 out <- in | |
532 } | |
533 | |
534 Render@String Slice[string:out,headers] | |
535 { | |
536 out <- [Web Text[string,""]]Render | |
537 } | |
538 | |
539 Name@String Slice[string:out,none] | |
540 { | |
541 none <- string | |
542 } | |
543 | |
544 Postback@String Slice[in,post data:out,events] | |
545 { | |
546 out <- in | |
547 events <- List[] | |
548 } | |
549 | |
550 Set Session@String Slice[in,session:out] | |
512 { | 551 { |
513 out <- in | 552 out <- in |
514 } | 553 } |
515 | 554 |
516 Blueprint Web Field | 555 Blueprint Web Field |
610 Use Cookies | 649 Use Cookies |
611 Data | 650 Data |
612 Dirty | 651 Dirty |
613 } | 652 } |
614 | 653 |
615 Get Unique ID[:out] uses Session | 654 _Get Counter[:out] uses Session |
616 { | 655 { |
617 Print["Get Unique ID"] | 656 out <- Val[Session::ID] |
618 out <- [[String[Session::ID]]Append["_"]]Append[String[Random[]]] | 657 { Session::ID <- [~]+[1] } |
619 { Session::ID <- [Session::ID]+[1] } | 658 } |
659 | |
660 Get Unique ID[:out] | |
661 { | |
662 out <- [[String[_Get Counter[]]]Append["_"]]Append[String[Random[]]] | |
620 } | 663 } |
621 | 664 |
622 Session[:out] | 665 Session[:out] |
623 { | 666 { |
624 out <- [[[[Build[Session()]]Session ID <<[Get Unique ID[]]]Use Cookies <<[No]]Data <<[Dictionary[]]]Dirty <<[No] | 667 out <- [[[[Build[Session()]]Session ID <<[Get Unique ID[]]]Use Cookies <<[No]]Data <<[Dictionary[]]]Dirty <<[No] |
625 { Print["Built session"] } | 668 } |
626 } | 669 |
627 | 670 _Load Session[queryvars,headers:out,makenew] uses Session |
628 Load Session[queryvars,headers:out] uses Session | |
629 { | 671 { |
630 ,checkquery <- [headers]Index["Cookie"] | 672 ,checkquery <- [headers]Index["Cookie"] |
631 { | 673 { |
632 parts <- Dict Split[~, "=", "; "] | 674 parts <- Dict Split[~, "=", "; "] |
633 ,checkquery <- [parts]Index["session_id"] | 675 ,checkquery <- [parts]Index["session_id"] |
645 ,makenew <- [queryvars]Index["session_id"] | 687 ,makenew <- [queryvars]Index["session_id"] |
646 { | 688 { |
647 out, makenew <- [Session::Sessions]Index[~] | 689 out, makenew <- [Session::Sessions]Index[~] |
648 } | 690 } |
649 } | 691 } |
650 | 692 } |
651 Val[makenew] | 693 |
694 Load Session[queryvars,headers:out] | |
695 { | |
696 out <- _Load Session[queryvars,headers] {} | |
652 { | 697 { |
653 out <- Session[] | 698 out <- Session[] |
654 } | 699 } |
655 } | 700 } |
656 | 701 |
698 } | 743 } |
699 | 744 |
700 Save@Session[session:out] uses Session | 745 Save@Session[session:out] uses Session |
701 { | 746 { |
702 Session::Sessions <- [Session::Sessions]Set[[session]Session ID >>, session] | 747 Session::Sessions <- [Session::Sessions]Set[[session]Session ID >>, session] |
748 out <- Yes | |
703 } | 749 } |
704 | 750 |
705 Finalize@Session[session,headers:out headers] | 751 Finalize@Session[session,headers:out headers] |
706 { | 752 { |
707 If[[session]Dirty >>] | 753 If[[session]Dirty >>] |