]> gitweb.factorcode.org Git - factor.git/commitdiff
Clean up store stuff
authorSlava Pestov <slava@factorcode.org>
Mon, 10 Dec 2007 07:50:50 +0000 (02:50 -0500)
committerSlava Pestov <slava@factorcode.org>
Mon, 10 Dec 2007 07:50:50 +0000 (02:50 -0500)
extra/store/store.factor
extra/webapps/pastebin/pastebin.factor

index 38f078b2a881c22e8b3905b2927d90c4f55e6f3a..38c1d3a906eef45abd888804fbb6b576002e32cc 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2007 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs io io.files kernel namespaces serialize ;
+USING: assocs io io.files kernel namespaces serialize init ;
 IN: store
 
 TUPLE: store path data ;
@@ -30,3 +30,8 @@ C: <store> store
     ] [
         drop >r 2dup set-global r> set-at
     ] if ;
+
+: define-store ( path id -- )
+    over >r
+    [ >r resource-path load-store r> set-global ] 2curry
+    r> add-init-hook ;
index 9d6b949ee14ef9f9d1f69c81842a1078fc234327..d49863b12a23a9ca5f6c47368109ea04ec4be9d7 100755 (executable)
@@ -8,6 +8,12 @@ TUPLE: pastebin pastes ;
 : <pastebin> ( -- pastebin )
     V{ } clone pastebin construct-boa ;
 
+! Persistence
+SYMBOL: store
+"pastebin.store" store define-store
+<pastebin> pastebin store get store-variable
+: save-pastebin-store ( -- ) store get-global save-store ;
+
 TUPLE: paste
 summary author channel mode contents date
 annotations n ;
@@ -19,12 +25,6 @@ TUPLE: annotation summary author mode contents ;
 
 C: <annotation> annotation
 
-SYMBOL: store
-
-"pastebin.store" resource-path load-store store set-global
-
-<pastebin> \ pastebin store get store-variable
-
 : get-paste ( n -- paste )
     pastebin get pastebin-pastes nth ;
 
@@ -71,9 +71,6 @@ SYMBOL: store
 
 \ feed.xml { } define-action
 
-: save-pastebin-store ( -- )
-    store get-global save-store ;
-
 : add-paste ( paste pastebin -- )
     >r now over set-paste-date r>
     pastebin-pastes 2dup length swap set-paste-n push ;