<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1930213017396645687</id><updated>2012-03-20T02:03:49.525-06:00</updated><category term='facebook'/><category term='google maps'/><category term='truism'/><category term='defaction'/><category term='errorstack'/><category term='statcounter'/><category term='YQL'/><category term='firebug'/><category term='brightkite'/><category term='events'/><category term='linkedin'/><category term='edoism'/><category term='seo'/><category term='crud'/><category term='webhooks'/><category term='jquery'/><category term='iphone'/><category term='kynetx'/><category term='annotation'/><category term='css'/><category term='geolocation'/><category term='push'/><category term='aculis'/><category term='XPath'/><category term='twilio'/><category term='online identity'/><category term='twitter'/><category term='bigohoo'/><category term='oauth'/><category term='social media'/><category term='blogger template'/><category term='webapp'/><category term='JSON'/><category term='widget'/><category term='foursquare'/><category term='safari'/><title type='text'>edoism</title><subtitle type='html'>truism of ed orcutt</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://edoism.orcutt.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/-/crud'/><link rel='alternate' type='text/html' href='http://edoism.orcutt.org/search/label/crud'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ed Orcutt</name><uri>http://www.blogger.com/profile/01072069799127687951</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_tXU2PrpKxHU/SuDD5YwomTI/AAAAAAAAAII/hCrRNUZWOto/S220/edo_transjpg.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1930213017396645687.post-6280183698947686146</id><published>2011-10-10T16:29:00.001-06:00</published><updated>2011-10-11T16:55:27.153-06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='crud'/><category scheme='http://www.blogger.com/atom/ns#' term='kynetx'/><category scheme='http://www.blogger.com/atom/ns#' term='safari'/><title type='text'>KRL Safari: KRUD Redux - Kynetx CRUD with Persistent Variables</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-M78XHP61V9c/TRDz9tCmcpI/AAAAAAAAAPk/b2tHMk1vjHc/s1600/krl_safari_border.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="102" src="http://4.bp.blogspot.com/-M78XHP61V9c/TRDz9tCmcpI/AAAAAAAAAPk/b2tHMk1vjHc/s200/krl_safari_border.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;Recent updates to the Kynetx platform related to &lt;a href="http://docs.kynetx.com/docs/Literals#"&gt;Hash expressions&lt;/a&gt; has given me the opportunity to revisit &lt;a href="http://edoism.orcutt.org/2011/02/krl-safari-krud-kynetx-crud-with.html"&gt;my previous post&lt;/a&gt;. If your WebApp has modest requirements for storage of data it is worthwhile considering the use of &lt;a href="http://docs.kynetx.com/docs/Persistent_Variables"&gt;Persistent Variables&lt;/a&gt;. To demonstrate the salient principles of using persistent variables as a datastore, a simple Kynetx WebApp addressbook is provided.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a class="big_button" href="http://ktest.heroku.com/a169x426"&gt;View Demo Online&lt;/a&gt; &lt;a class="big_button" href="https://gist.github.com/1276723"&gt;Download Source Code&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The addressbook application stores the name, email and phone number of each person. The addressbook data is stored in a single persistant variable as key/value pairs. With the persons name used as the key:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript"&gt;"SomeName" : {&lt;br /&gt;    "Name"  : "SomeName",&lt;br /&gt;    "Email" : "SomeEmail",&lt;br /&gt;    "Phone" : "SomePhone"&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Since there is a lot of to wade through, so let me point out that parts specifically related to reading, writing and remove entries in the addressbook. In order to read all of the entries in the addressbook the following ruleset is used:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript"&gt;foreach ent:KRUDaddresss.keys() setting (addressKey)&lt;br /&gt;pre {&lt;br /&gt;  email = ent:KRUDaddresss{[addressKey, "Email"]};&lt;br /&gt;  phone = ent:KRUDaddresss{[addressKey, "Phone"]};&lt;br /&gt;  addressRow = &amp;amp;lt;&amp;amp;lt;&lt;br /&gt;      &lt;br /&gt;          #{addressKey}&lt;br /&gt;          #{email}&lt;br /&gt;          #{phone}&lt;br /&gt;          &lt;a class="KRUDaction" href="javascript:void(0);"&gt;Remove&lt;/a&gt;&lt;br /&gt;      &lt;br /&gt;  &amp;gt;&amp;gt;;&lt;br /&gt;}&lt;br /&gt;{&lt;br /&gt;  append('#panelAddressList .DataTable tbody', addressRow);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;New entries for the addressbook are entered via a standard HTML form. With a &lt;a href="http://docs.kynetx.com/docs/Watch"&gt;watch()&lt;/a&gt; placed on the submit the following rule captures the entry from the form, builds a new entry and adds it to the persistent variable:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript"&gt;select when submit "#formAddressAdd"&lt;br /&gt;pre {&lt;br /&gt;  formName  = event:param("formName");&lt;br /&gt;  formEmail = event:param("formEmail");&lt;br /&gt;  formPhone = event:param("formPhone");&lt;br /&gt;  formHash = {&lt;br /&gt;      "Name"  : formName,&lt;br /&gt;      "Email" : formEmail,&lt;br /&gt;      "Phone" : formPhone&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;  KRUDaddresss = ent:KRUDaddresss || {};&lt;br /&gt;}&lt;br /&gt;{ noop(); }&lt;br /&gt;fired {&lt;br /&gt;  set ent:KRUDaddresss{[formName]} formHash;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Entries are removed from the addressbook by calling the following rule with an entries name as the event parameter:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript"&gt;pre {&lt;br /&gt;  keyName = event:param("keyName");&lt;br /&gt;}&lt;br /&gt;{ noop(); }&lt;br /&gt;fired {&lt;br /&gt;  clear ent:KRUDaddresss{keyName};&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can play with the &lt;a href="http://ktest.heroku.com/a169x426"&gt;online demo&lt;/a&gt; to see the end results. And you can &lt;a href="https://gist.github.com/1276723"&gt;get the source code&lt;/a&gt; for the whole WebApp on GitHub. Heads up, there's a lot of code in the WebApp related to the GUI, that's why I wanted to call out the salient CRUD elements above. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;b&gt;11 Oct 2011:&lt;/b&gt; Revised code for adding new addressbook entries to use the new expression syntax for &lt;a href="http://docs.kynetx.com/docs/Persistent_Variables#Persistent_Hashes"&gt;Persistent Hashes&lt;/a&gt;. When these new expressions are used you avoid loading, binding and transferring the entire hash.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a class="big_button" href="http://ktest.heroku.com/a169x426"&gt;View Demo Online&lt;/a&gt; &lt;a class="big_button" href="https://gist.github.com/1276723"&gt;Download Source Code&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1930213017396645687-6280183698947686146?l=edoism.orcutt.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edoism.orcutt.org/feeds/6280183698947686146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://edoism.orcutt.org/2011/10/krl-safari-krud-redux-kynetx-crud-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/6280183698947686146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/6280183698947686146'/><link rel='alternate' type='text/html' href='http://edoism.orcutt.org/2011/10/krl-safari-krud-redux-kynetx-crud-with.html' title='KRL Safari: KRUD Redux - Kynetx CRUD with Persistent Variables'/><author><name>Ed Orcutt</name><uri>http://www.blogger.com/profile/01072069799127687951</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_tXU2PrpKxHU/SuDD5YwomTI/AAAAAAAAAII/hCrRNUZWOto/S220/edo_transjpg.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-M78XHP61V9c/TRDz9tCmcpI/AAAAAAAAAPk/b2tHMk1vjHc/s72-c/krl_safari_border.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1930213017396645687.post-907152792230902650</id><published>2011-02-04T10:25:00.000-07:00</published><updated>2011-02-04T10:25:37.569-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='crud'/><category scheme='http://www.blogger.com/atom/ns#' term='kynetx'/><category scheme='http://www.blogger.com/atom/ns#' term='safari'/><title type='text'>KRL Safari: KRUD - Kynetx CRUD with Persistant Variables</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_tXU2PrpKxHU/TRDz9tCmcpI/AAAAAAAAAPk/C2jMx5O-0IY/s1600/krl_safari_border.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="164" src="http://3.bp.blogspot.com/_tXU2PrpKxHU/TRDz9tCmcpI/AAAAAAAAAPk/C2jMx5O-0IY/s320/krl_safari_border.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;Got KRUD? In this KRL safari we will be using persistance variables as a database. While most web developers have written code to access a database, most Kynetx applications retrieve their data via RESTful web services. But there are times when a persistant data store is needed. Building a one off web service to host the data is certainly an option, but if the storage needs are moderate you can simply use a persistant variable. After all 2 million bytes of data can be stored in a persistant variable!&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;To keep the focus on the mechanics a simple data structure is used to demonstrate KRL CRUD ... an array of strings which will be used to implement a tag cloud. The &lt;a href="http://www.lobosllc.com/demo/krud/"&gt;demo &lt;/a&gt;provides a web interface to see all of the strings in the tag cloud, add new tags and delete tags. To permit the &lt;a href="http://www.lobosllc.com/demo/krud/"&gt;demo &lt;/a&gt;to be accessible to a broad audience, it has been distributed using a &lt;a href="http://docs.kynetx.com/docs/Distribute"&gt;site tag&lt;/a&gt;. Just &lt;a href="http://www.lobosllc.com/demo/krud/"&gt;visit the demo page &lt;/a&gt;to see all of the current tags which have been entered by all who have used the application. You can add a new tag by entering text into the form, then click the Add button. To delete a existing tag simply click on the text of the tag.&lt;br /&gt;&lt;br /&gt;While the KRL code has comments thoughout, it should be emphasized that application persistent variables accessed in the rule &lt;a href="http://docs.kynetx.com/docs/Prelude"&gt;prelude&lt;/a&gt;:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;TagCloud = app:TagCloud;&lt;/pre&gt;And the updated persistent variable are saved in the &lt;a href="http://docs.kynetx.com/docs/Postlude"&gt;postlude&lt;/a&gt;:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;set app:TagCloud TagCloud;&lt;/pre&gt;Adding a new value to the persistent variable is performed using the &lt;a href="http://docs.kynetx.com/docs/Sets#Union_.28A_.E2.88.AA_B.29"&gt;union operator&lt;/a&gt;:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;newCloud = TagCloud.union(cleanTag);&lt;/pre&gt;Removing a value from the persistent variable is done using the &lt;a href="http://docs.kynetx.com/docs/Sets#difference_.28A_.5C_B.29"&gt;difference operator&lt;/a&gt;:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;newCloud = TagCloud.difference(tagText);&lt;/pre&gt;To see the implementation using a complex data structure take a look at Kynetx App A Day 28 &lt;a href="http://kynetxappaday.wordpress.com/2010/12/29/day-28-updating-users-list-when-user-joins-app/"&gt;Updating User's List When User Joins App&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;script src="https://gist.github.com/810516.js?file=KRUD"&gt;&lt;/script&gt;&lt;br /&gt;Hey! Where's the U in KRUD? Multiple choice response:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Left as an exercise for the reader&lt;/li&gt;&lt;li&gt;Updated was not needed for demo&lt;/li&gt;&lt;li&gt;I'm lazy :)&lt;/li&gt;&lt;/ol&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1930213017396645687-907152792230902650?l=edoism.orcutt.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://edoism.orcutt.org/feeds/907152792230902650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://edoism.orcutt.org/2011/02/krl-safari-krud-kynetx-crud-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/907152792230902650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1930213017396645687/posts/default/907152792230902650'/><link rel='alternate' type='text/html' href='http://edoism.orcutt.org/2011/02/krl-safari-krud-kynetx-crud-with.html' title='KRL Safari: KRUD - Kynetx CRUD with Persistant Variables'/><author><name>Ed Orcutt</name><uri>http://www.blogger.com/profile/01072069799127687951</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://4.bp.blogspot.com/_tXU2PrpKxHU/SuDD5YwomTI/AAAAAAAAAII/hCrRNUZWOto/S220/edo_transjpg.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_tXU2PrpKxHU/TRDz9tCmcpI/AAAAAAAAAPk/C2jMx5O-0IY/s72-c/krl_safari_border.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
