<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>crud &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/crud/</link>
	<description>Feed of posts on WordPress.com tagged "crud"</description>
	<pubDate>Sun, 07 Sep 2008 16:30:30 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[What's In A Name: Reloaded]]></title>
<link>http://lightleandmartin.wordpress.com/?p=111</link>
<pubDate>Thu, 04 Sep 2008 18:51:13 +0000</pubDate>
<dc:creator>martin</dc:creator>
<guid>http://lightleandmartin.wordpress.com/?p=111</guid>
<description><![CDATA[Would a rose by any other name, smell as sweet?
I found out recently (last night) whilst titting abo]]></description>
<content:encoded><![CDATA[<p>Would a rose by any other name, smell as sweet?</p>
<p>I found out recently (last night) whilst titting about at Legendary Noodle, that it took my parents three weeks to name me*.</p>
<p>This was news to me but it seems on a recent trip to Van, my mother told my bestfriend Fragglehump this particular anecdote - and frankly, I have mixed feelings about it.</p>
<p>First up, I was a little miffed that I could be so characterless for the first few weeks of my life that they couldn't even pull something out of the hat in a temporary fashion. </p>
<p>Then I figured maybe I had <em>too much</em> character and nothing short of miraculous would do.  Most definitely that would have to be the answer.</p>
<p>But, on reading the below post (see: Lightle's masterpiece underneath) and with this new information, I have been thinking about names and nicknames all morning.</p>
<p>(All morning?  First thought was "I'm hungry", second was "Did I forget to put knickers on?", but you get the gist.)</p>
<p>So, what's in a name?</p>
<p>My name is Christa. </p>
<p>A lot of people know that.  I introduce myself to people I don't know all the time, because they are all just friends we haven't met yet, am I right?  I bandy it about like it's going out of fashion.</p>
<p>Yet.</p>
<p>Hardly anyone actually uses it.  Nobody who loves me certainly.  Nobody who likes me.  Only bosses and people who are pissed off with me ever really say it - and I like that.</p>
<p>I love the fact that with every person I am close to I can be someone new, someone unique and our relationship is our own.</p>
<p>Take for instance the aforementioned Fragglehump (AKA. Ellie).  She has called me Loobi ever since that fateful day when Pheobe made up a goofy name on Friends and I said I wanted to be renamed Faloolah.  Renamed I was and over the years it has been streamlined to Loobi.  Sometimes Loobina.</p>
<p>Now even Fragglehump's mother calls me Loobi.</p>
<p>My own mother, now she's got the hang of me actually having a name, calls me Bella.  As in Christa Bella.  Because I'm beautiful, apparently.</p>
<p>My brother calls me Crunch.  Or at least he did before he was cool.</p>
<p>To my other bestfriend, David, I am Dolores or simply 'D'.  This stems from a story we made up (soon to be novel) involving two friends called Dolores and Tarquin.  He's my T, you see.</p>
<p>To Char I'm Sexy Whore (self-explanatory), to Boo I am Pookie, to the Barman at the bar who possibly wanted to get inside my knicker elastic, I was 'English Girl' and then, promoted to 'Red' because, you see, I have red hair.</p>
<p>To the handyman in our building I am 'Smiley'.</p>
<p>As for my real name, the other day a kind soul told me it sounds like a porn stars name and in a sense I have to agree.</p>
<p>Growing up in England nobody at all had my name.  Subsequently nobody could ever get it right.  Spelling wise, pronunciation wise, the whole shebang.</p>
<p>I know.  It's a complex name, right? Chris-ta.  Ouch.</p>
<p>But then I got here and every second Soccor Mom or blonde Lulu Lemon-wearing bimbette is called Christa and I'm not unique anymore.</p>
<p>Which is why I embrace my monikers wholeheartedly. </p>
<p>And for the record, I like to use food or inanimate object based references for my friends and loved ones.</p>
<p>Lightle herself is always a foodstuff, usually 'Pumpkin' or 'Love Muffin'.  Fragglehump sometimes gets 'Spooky Shoe' - and Tarquin? </p>
<p>Well, he's my 'Sex Trumpet'.</p>
<p>What's your nickname?</p>
<p>*I jest.  I know how special I was/am to my mother and I appreciate that they didn't commit me to some godawful tag because they were pressurised by time.  Apparently one day they stumbled across my name and it all began to make sense, which is lovely.</p>
<p>And to my Daddy, I was always 'Gold Angel'.  So it all ends happily.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Procrastination, My Friend]]></title>
<link>http://lightleandmartin.wordpress.com/?p=62</link>
<pubDate>Thu, 28 Aug 2008 21:01:03 +0000</pubDate>
<dc:creator>martin</dc:creator>
<guid>http://lightleandmartin.wordpress.com/?p=62</guid>
<description><![CDATA[Since I forked out $120 for my gym membership (three weeks ago), I have attended twice. 
Both occas]]></description>
<content:encoded><![CDATA[<p><a href="http://lightleandmartin.files.wordpress.com/2008/08/14.jpg"><img class="alignleft size-thumbnail wp-image-67" src="http://lightleandmartin.wordpress.com/files/2008/08/14.jpg?w=86" alt="" width="86" height="96" /></a>Since I forked out $120 for my gym membership (three weeks ago), I have attended twice. </p>
<p>Both occasions called for a horizontal stint in the steam room, interrupted only by an over-jealous gym-harpy coming in and actually turning it on.</p>
<p>Tsk.</p>
<p>And since I got a 'proper' job with 'proper' hours, so I can concentrate on writing in the evenings and weekends, I have failed to even switch my laptop on.</p>
<p>What the hell is it with me and my friend, procrastination?</p>
<p>Why do we run so happily together?  He is always there, whispering in my ear (before I go and spoil it all by doing something stupid like, I don't know, getting off my arse): "Do it tomorrow, sweetie.  Or better still, next week."</p>
<p>I try to shrug him off but his breath in my ear feels warm and with his comforting tone, I feel secure.</p>
<p>"Are you sure?" I ask him.</p>
<p>"Of course.  You can always do anything tomorrow, it will be better.  You can focus then."</p>
<p>I'm dubious of course, sometimes even purchasing a new notebook, a book on photography - coloured pencils - I square my shoulders, ready to start something, anything - and then he smiles at me in his way and I lose my strength.</p>
<p>"Tomorrow then." I look at my shuffling feet.</p>
<p>"Very good," he says, "you won't regret it."</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[pylons ไม่มีตัว generate CRUD เหมือน CakePHP กับ Rails แต่ก็ใช้ sed แทนได้]]></title>
<link>http://openil.wordpress.com/?p=479</link>
<pubDate>Tue, 26 Aug 2008 12:27:02 +0000</pubDate>
<dc:creator>वीर</dc:creator>
<guid>http://openil.wordpress.com/?p=479</guid>
<description><![CDATA[pylons ไม่มีตัว generate CRUD เหมือน CakePHP กับ Rails แต่]]></description>
<content:encoded><![CDATA[<p>pylons ไม่มีตัว generate CRUD เหมือน CakePHP กับ Rails แต่ก็ใช้ sed แทนได้ <a href="http://www.pylonsbook.com">pylonsbook.com</a> ก็เหมือนใช้ท่านี้เหมือนกัน คือ copy code เดิมมาแล้วก็ replace ซะงั้น. ใน folder: templates ก็ copy ดื้อๆ เลย cp -rp corpus language ... corpus นี้ประมาณว่าอันเก่า จะสร้างอันใหม่ชื่อ language. เข้าไปใน folder document แล้วก็สั่ง replace แบบนี้</p>
<p>for x in *.html;do n=/tmp/$$; cat $x &#124; sed 's/corpus/language/g' &#124; sed 's/Corpus/Language/g' &#124; sed 's/corpora/languages/g' &#124; sed 's/Corpora/Languages/g' &#62; $n &#38;&#38; mv $n $x ;done</p>
<p>เป็นอันใช้ได้ controller แก้เหมือนกันเอา for ออกก็พอ. ส่วนใน widgets ใช้ vim แก้มือเอาเพราะมันน้อย. ก็รวดเร็วใช้ได้อยู่ :-)</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[pylons-20080818 + tw.forms + elixir: Create Read Update Delete มั้ง]]></title>
<link>http://openil.wordpress.com/?p=441</link>
<pubDate>Thu, 21 Aug 2008 19:28:33 +0000</pubDate>
<dc:creator>वीर</dc:creator>
<guid>http://openil.wordpress.com/?p=441</guid>
<description><![CDATA[ลองใช้ pylons, tw.forms และ elixir ลองทำ application ง่ายๆ ต]]></description>
<content:encoded><![CDATA[<p>ลองใช้ pylons, tw.forms และ elixir ลองทำ application ง่ายๆ ตาม <a href="http://pylonsbook.com/alpha1/simplesite_tutorial">http://pylonsbook.com/alpha1/simplesite_tutorial</a> ดูก็ดัดแปลงนิดหน่อยๆ เลยอย่างจะเขียนรวมกันไว้ที่เดียว. อาจจะดูมั่วๆ บ้างไว้มี version ต่อไปค่อย post อีกทีแล้วกัน.</p>
<p>pylons (20080818) นี้เลือกได้เลยว่าให้สร้าง code ที่ support mako และ sqlalchemy ได้เลย แต่จะใช้ elixir และ tw.forms ก็ต้องมาแก้นิดๆ หน่อย. เอา elixir ก่อนแล้วกัน.</p>
<p>แก้ lib/base.py:</p>
<p>[sourcecode language='python']</p>
<p>from pylons.controllers import WSGIController<br />
from pylons.templating import render_mako as render</p>
<p>import elixir # เพิ่มนี้เข้ามา<br />
class BaseController(WSGIController):<br />
    def __call__(self, environ, start_response):<br />
        try:<br />
            return WSGIController.__call__(self, environ, start_response)<br />
        finally:<br />
            elixir.session.remove() # เพิ่มนี้เข้ามา<br />
[/sourcecode]</p>
<p>แก้ model/meta.py:</p>
<p>[sourcecode language='python']<br />
from sqlalchemy import MetaData<br />
from sqlalchemy.orm import scoped_session, sessionmaker<br />
__all__ = ['Session', 'metadata']<br />
engine = None<br />
[/sourcecode]</p>
<p>แก้ model/__init__.py:</p>
<p>[sourcecode language='python']<br />
import sqlalchemy as sa<br />
from sqlalchemy import orm<br />
from simple1.model import meta<br />
import elixir</p>
<p>sm = orm.sessionmaker(autoflush=True, autocommit=True)<br />
elixir.session = orm.scoped_session(sm)<br />
elixir.options_defaults.update({ 'shortnames': True })  </p>
<p>def init_model(engine):<br />
    elixir.metadata.bind = engine</p>
<p>from elixir import *<br />
from entities import *</p>
<p>elixir.setup_all()<br />
[/sourcecode]</p>
<p>แล้วก็แก้ websetup.py:</p>
<p>[sourcecode language='python']<br />
"""Setup the simple1 application"""<br />
import logging</p>
<p>from simple1.config.environment import load_environment</p>
<p>log = logging.getLogger(__name__)</p>
<p>def setup_app(command, conf, vars):<br />
    """Place any commands to setup simple1 here"""<br />
    load_environment(conf.global_conf, conf.local_conf)</p>
<p>    import elixir # ใส่ elixir ไปแทน<br />
    elixir.metadata.create_all(checkfirst=True) # บรรทัดนี้ด้วย<br />
[/sourcecode]</p>
<p>ส่วนที่ใส่ไปข้างบนนี้ไม่ขึ้นกับ app นะครับ ต่อไปก็เติม entity ใน model สักหน่อย ชื่อ Person ข้างในก็มีแค่ first name กับ last name :-P</p>
<p>แก้ model/entities.py:</p>
<p>[sourcecode language='python']<br />
from elixir import *<br />
class Person(Entity):<br />
    first_name = Field(String(1000))<br />
    last_name = Field(String(1000))<br />
[/sourcecode]</p>
<p>ว่าด้วยเรื่อง elixir ก็เกือบหมดแล้ว ที่เหลือก็อยู่ใน controller เลย.  เพื่อที่จะสร้าง model ก็ลองสร้าง database เลยสั่ง</p>
<p><em>paster setup-app development.ini</em></p>
<p>ต่อด้วย tw.forms โดยทั่วไปแล้วพอหลังลง package ก็ลงแก้ config/middleware.py: แต่มันยาว ก็แค่เพิ่มอะไรไปนิดๆ หน่อยๆ</p>
<p>[sourcecode language='python']<br />
...<br />
from tw.api import make_middleware  # แก้ตรงนี้ เพิ่มเข้ามา<br />
...<br />
    # แก้ตรงนี้<br />
    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)<br />
    app = make_middleware(app, {<br />
        'toscawidgets.framework' : 'pylons',<br />
        'toscawidgets.framework.default_view' : 'mako',<br />
        'toscawidgets.middleware.inject_resources' : True,<br />
        })<br />
   ...<br />
[/sourcecode]</p>
<p>ว่าด้วยเรื่อง view (template)</p>
<p>แก้ lib/helpers.py</p>
<p>[sourcecode language='python']<br />
from webhelpers import *<br />
from webhelpers.html.tags import *<br />
from routes import url_for<br />
from webhelpers.html import literal<br />
from webhelpers.pylonslib import Flash as _Flash<br />
from webhelpers import paginate<br />
flash = _Flash()<br />
[/sourcecode]</p>
<p>สร้าง widgets ก่อนจะได้เขียน template สั้นๆ สร้าง widgets/person.py</p>
<p>[sourcecode language='python']<br />
from tw import forms<br />
from tw.api import WidgetsList</p>
<p>forms.FormField.engine_name = 'mako'</p>
<p>class PersonForm(forms.TableForm):<br />
    class fields(WidgetsList):<br />
        first_name = forms.TextField()<br />
        last_name = forms.TextField()<br />
        submit = forms.SubmitButton(attrs = {'value': 'save'})</p>
<p>person_form = PersonForm(id = 'person_form')<br />
[/sourcecode]</p>
<p>สร้าง base template ใน template/base.html: ต่างจากใน tutorial นิดๆ ที่มี flash message ด้วย</p>
<p>[sourcecode language='html']<br />
## -*- coding: utf-8 -*-</p>
<p>< !DOCTYPE html<br />
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></p>
<p><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br />
<head><br />
    <title>${self.title()}</title><br />
    ${self.head()}<br />
</head><br />
<body><br />
    ${self.header()}<br />
    ${self.tabs()}<br />
    ${self.menu()}<br />
    ${self.heading()}<br />
    ${self.breadcrumbs()}<br />
    ${self.flash_messages()}<br />
    ${next.body()}<br />
    ${self.footer()}<br />
</body><br />
</html></p>
<p>< %def name="flash_messages()"><br />
< % messages = h.flash.pop_messages() %><br />
% if messages:</p>
<ul id="flash-messages">
    % for message in messages:</p>
<li>${message}</li>
<p>% endfor</ul>
<p>% endif</p>
<p>< %def name="title()">Simple1<br />
< %def name="head()"><br />
< %def name="header()"><a name="top"></a><br />
< %def name="tabs()"><br />
< %def name="menu()"><br />
< %def name="heading()"></p>
<h1>${c.heading or 'No Title'}</h1>
<p>< %def name="breadcrumbs()"><br />
< %def name="footer()"><br />
<a href="#top">Top ^</a><br />
[/sourcecode]</p>
<p>แก้ template/person/list.html:</p>
<p>[sourcecode language='html']<br />
< %inherit file="/base.html" /></p>
<p>< %def name="heading()"></p>
<h1 class="main">Person List</h1>
<ul id="titles">
% for person in c.paginator:</p>
<li>${person.first_name} ${person.last_name}<br />
        [${h.link_to('view', h.url_for(controller='person', action='view', id=person.id))}]<br />
        [${h.link_to('edit', h.url_for(controller='person', action='edit', id=person.id))}]<br />
        [${h.link_to('delete', h.url_for(controller='person', action='delete', id=person.id), onclick="return confirm('Are you sure you want to delete #" + str(person.id) + "?');")}]</li>
<p>% endfor</ul>
<p>< %def name="footer()"></p>
<p><a href="${h.url_for(controller='person', action='new', id=None)}">New person</a></p>
<p>${parent.footer()}</p>
<p>[/sourcecode]</p>
<p>แก้ template/person/new.html:</p>
<p>[sourcecode language='html']<br />
< %inherit file='/base.html'/></p>
<p>< %def name="heading()"></p>
<h1 class="main">Add person</h1>
<p>< % from simple1.widgets.person import person_form %><br />
${h.literal(person_form(action=h.url_for(controller='person', action='create')))}<br />
[/sourcecode]</p>
<p>แก้ template/person/new.html:</p>
<p>[sourcecode language='html']<br />
< %inherit file='/base.html'/></p>
<p>< %def name="heading()"></p>
<h1 class="main">Edit person info</h1>
<p>< % from simple1.widgets.person import person_form %><br />
${h.literal(person_form(action=h.url_for(controller='person', action='save')))}</p>
<p>< %def name="footer()"></p>
<p>  <a href="${h.url_for(controller='person', action='list')}">All people</a><br />
&#124; <a href="${h.url_for(controller='person', action='edit', id=c.person.id)}">Edit person</a><br />
&#124; <a onclick="return confirm('Are you sure you want to delete #${c.person.id}?');" href="${h.url_for(controller='person', action='delete', id=c.person.id)}">Delete person</a></p>
<p>${parent.footer()}</p>
<p>[/sourcecode]</p>
<p>แก้ template/person/view.html:</p>
<p>[sourcecode language='html']<br />
< %inherit file="/base.html"/><br />
< %def name="title()">View person<br />
< %def name="heading()"></p>
<h1>View person</h1>
<p>${c.person.first_name}<br />
${c.person.last_name}</p>
<p>< %def name="footer()"></p>
<p>  <a href="${h.url_for(controller='person', action='list')}">All people</a><br />
&#124; <a href="${h.url_for(controller='person', action='edit', id=c.person.id)}">Edit person</a><br />
&#124; <a onclick="return confirm('Are you sure you want to delete #${c.person.id}?');" href="${h.url_for(controller='person', action='delete', id=c.person.id)}">Delete person</a></p>
<p>${parent.footer()}</p>
<p>[/sourcecode]</p>
<p>สุดท้ายแล้วมั้งก็สร้าง controller แก้ controller/person.py:</p>
<p>[sourcecode language='python']<br />
import logging</p>
<p>from pylons import request, response, session<br />
from pylons import tmpl_context as c<br />
from pylons.controllers.util import abort, redirect_to</p>
<p>from simple1.lib.base import BaseController, render<br />
import simple1.model as model<br />
from simple1.lib import helpers as h</p>
<p>log = logging.getLogger(__name__)</p>
<p>from simple1.widgets.person import person_form<br />
from tw.mods.pylonshf import validate<br />
from webhelpers import paginate</p>
<p>import elixir</p>
<p>from formencode import htmlfill</p>
<p>def get_person(id):<br />
    if id is None:<br />
        abort(404)<br />
    person = model.Person.query.get(int(id))<br />
    if person is None:<br />
        abort(404)<br />
    return person</p>
<p>class PersonController(BaseController):</p>
<p>    def index(self):<br />
        return redirect_to(action='list')</p>
<p>    def list(self):<br />
        page_number = request.params.get('page', 1)<br />
        people = model.Person.query.all()<br />
        c.paginator = paginate.Page(people, page = page_number)<br />
        return render('/person/list.html')</p>
<p>    def new(self):<br />
        return render('/person/new.html')</p>
<p>    @validate(form=person_form, error_handler='new')<br />
    def create(self):<br />
        if request.method != 'POST':<br />
            about(500)<br />
        person = model.Person()<br />
        for k,v in self.form_result.items():<br />
            setattr(person, k, v)<br />
        elixir.session.flush()<br />
        h.flash("added person")<br />
        return redirect_to(action='index')</p>
<p>    def view(self, id):<br />
        c.person = model.Person.query.get(int(id))<br />
        return render('/person/view.html')</p>
<p>    def delete(self, id=None):<br />
        person = get_person(id)<br />
        person.delete()<br />
        elixir.session.flush()<br />
        h.flash("deleted person")<br />
        #referer = request.headers.get('REFERER', '/')<br />
        #return redirect_to(referer)<br />
        return redirect_to(action='list')</p>
<p>    def edit(self, id=None):<br />
        person = get_person(id)<br />
        return htmlfill.render(render('/person/edit.html'), person.to_dict())</p>
<p>    @validate(form=person_form, error_handler='edit')<br />
    def save(self, id=None):<br />
        person = get_person(id)<br />
        for k,v in self.form_result.items():<br />
            setattr(person, k, v)<br />
        elixir.session.flush()<br />
        h.flash("edited person")<br />
        return redirect_to(action='view')<br />
[/sourcecode]</p>
<p>ดูอนาถๆ กลับมาอ่านทีหลังไม่รู้รู้เรื่องเปล่า</p>
<p>อ้างอิงเพิ่ม:<br />
<a href="http://toscawidgets.org/documentation/tw.forms/tutorials/pylons_one.html">http://toscawidgets.org/documentation/tw.forms/tutorials/pylons_one.html</a></p>
<p><a href="https://www.knowledgetap.com/hg/webhelpers/file/2eb9f423aafb/webhelpers/pylonslib.py">https://www.knowledgetap.com/hg/webhelpers/file/2eb9f423aafb/webhelpers/pylonslib.py</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[REST: risorse &quot;complesse&quot;]]></title>
<link>http://itlab.wordpress.com/2008/07/03/rest-risorse-complesse/</link>
<pubDate>Wed, 02 Jul 2008 14:00:19 +0000</pubDate>
<dc:creator>Andrea Gumina</dc:creator>
<guid>http://itlab.wordpress.com/2008/07/03/rest-risorse-complesse/</guid>
<description><![CDATA[La RFC 2396 (URI - Uniform Resource Identifier) definisce &#8220;risorsa&#8221; una qualunque cosa c]]></description>
<content:encoded><![CDATA[<p align="justify">La <a href="http://www.ietf.org/rfc/rfc2396.txt" target="_blank">RFC 2396 (URI - Uniform Resource Identifier)</a> definisce "risorsa" una qualunque cosa che abbia un'identità e che - concettualmente - possa corrispondere ad un'entità o un insieme.</p>
<p align="justify">E' un po' che mi chiedo se "dietro" una risorsa si possa "nascondere" qualcosa di più "complesso" (una serie di passi, ad esempio, una logica applicativa complicata a piacere, ecc.), continuando, però, a soddisfare i vincoli di REST (mi riferisco, sopratutto, <a href="http://itlab.wordpress.com/2008/06/09/rest-representational-state-transfer/" target="_blank">all'interfaccia uniforme e alla mancanza di stato</a>).</p>
<p align="justify">Stefan Tilkov, autore dell'articolo "<a href="http://www.infoq.com/articles/tilkov-rest-doubts">Addressing Doubts about REST</a>" (già citato in un articolo precedente "<a href="http://itlab.wordpress.com/2008/05/29/letture-consigliate-su-rest/" target="_blank">Letture consigliate su REST</a>"), spiega come <a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm" target="_blank">REST (REpresentational State Transfer)</a> non sia confinato alle sole operazioni <a href="http://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete" target="_blank">CRUD (Create, Read, Update and Delete)</a>: una URI tipo <em>http://example.com/calculation?a=2&#38;b=3</em>, infatti, può corrispondere alla somma tra <em>a </em>e <em>b</em>. L'articolo descrive una soluzione in sintonia con REST (implementato con HTTP): una POST che abbia come effetto la creazione della risorsa-risultato e come ritorno la URI corrispondente (da usare con una GET). </p>
<p align="justify">Il libro "<a href="http://www.amazon.com/RESTful-Web-Services-Leonard-Richardson/dp/0596529260" target="_blank">RESTful Web Services</a>" di Leonard Richardson e Sam Ruby, nella parte dedicata al disegno di risorse, illustra strategie simili.</p>
<p align="justify">Quindi dietro una risorsa si può celare qualcosa di più "complesso" di una "semplice" entità. Tale risorsa, però, non coincide con la risorsa-risultato cercata, è il punto di raccolta delle richieste ("<a href="http://www.amazon.com/RESTful-Web-Services-Leonard-Richardson/dp/0596529260" target="_blank">RESTful Web Services</a>" lo definisce <em>factory</em>): accoglie i POST (richiesta di creazione, non sicura, non idempotente), crea la risorsa-risultato (o ne accoda la richiesta) e ne ritorna l'URI da usare con una GET (richiesta di informazioni, sicura, idempotente).</p>
<p align="justify">Questo, che sicuramente rispetta i vincoli imposti da REST, mi sembra, oltre che macchinoso, richiedere al client una certa "consapevolezza" (che, in taluni casi, potrebbe rafforzare l'accoppiamento): alla POST deve seguire necessariamente una (o più) GET con cui recuperare la risorsa-risultato (o richiederne lo stato di esecuzione - in tal caso il client deve farsi carico anche di una DELETE per eliminare la risorsa temporanea). Conseguenza dell'interfaccia uniforme (i metodi con semantica indipendente dalle risorse sono generici, non specializzati e, talvolta, impongono al client di soddisfare un flusso di lavoro ben preciso) e della mancanza, per alcune situazioni, di soluzioni REST collaudate.</p>
<p align="justify">Un codice <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html" target="_blank">201 ("Created")</a>, in risposta alla POST, che oltre alla URI della risorsa creata riportasse la sua rappresentazione, o un codice <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html" target="_blank">303 ("See Other")</a> che "inviterebbe"&#160; ad eseguire "automaticamente" una GET verso la URI ritornata (la risorsa-risposta), potrebbero isolare la logica di business del client dalle logiche del colloquio HTTP; sono soluzioni, comunque, da studiare di volta in volta.</p>
<p style="text-align:center;">----&#62;&#60;---- </p>
<p style="text-align:center;"><span style="font-size:0.9em;">Hai trovato questo post interessante? <a href="http://feeds.feedburner.com/itlab" target="_blank">Segui il feed</a> e <a href="http://itlab.wordpress.com/">commenta!</a></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[อะไรคล้ายๆ Django admin site ใน Framework อื่นๆ]]></title>
<link>http://openil.wordpress.com/?p=297</link>
<pubDate>Wed, 11 Jun 2008 15:13:32 +0000</pubDate>
<dc:creator>वीर</dc:creator>
<guid>http://openil.wordpress.com/?p=297</guid>
<description><![CDATA[เมื่อ 2-3 ปีก่อนเห็นจะได้ ผมเปิดดู Tutorial ]]></description>
<content:encoded><![CDATA[<p>เมื่อ 2-3 ปีก่อนเห็นจะได้ ผมเปิดดู Tutorial ของ Django แล้วก็งงๆ จนปิดไป. แต่ว่าตอนนี้ก็พออ่านรู้เรื่องขึ้นบ้างเพราะว่ามีประสบการณ์กับ web framework อื่นๆ มาพอสมควร กอปรกับพี่ต้นเริ่มเขียนอะไรบน Django ไปบ้างแล้ว ผมก็พลอยได้ดูตัวอย่างไปด้วย.</p>
<p>ผมก็เริ่มจาก install เลย บน Ubuntu มันง่ายมากๆ</p>
<pre>sudo aptitude install python-django</pre>
<p>แค่คำสั่งเดียวเสร็จเลย :-P ... แต่ว่าอันนี้ไม่รวม deploy ด้วย mod_python หรือ fastcgi นะครับ. เรื่อง deploy ผมหวังพึ่ง<a href="http://lewcpe.com/">ลิ่ว</a>อย่างเดียว :-P.</p>
<p>ต่อจากนั้นผมก็เข้าไปดู Tutorial ที่ web ของ Django แต่ว่าก็ต้องระวังนิด เพราะว่า Tutorial ที่ link ไปจากหน้าแรกเป็นของ development version ซึ่งมันต่างจาก stable version อยู่ (ทำตาม tutorial แล้วเจ๊งแน่นอน ...ประมาณนั้น)</p>
<p>สำหรับ Django 0.96 เข้าไปหน้า <a href="http://www.djangoproject.com/documentation/0.96/tutorial01/">http://www.djangoproject.com/documentation/0.96/tutorial01/</a> ได้เลย. ผมก็ทำตามก็ใช้ได้ ... ใช้ก็รู้สึกว่าเนียนและเร็วดี พอจนกระทั่งมาถึง admin site ที่อาจจะเรียกว่าเป็น highlight อย่างหนึ่งของ Django เลย. ลองใช้ดูแล้วก็เนียนดีอีกเหมือนกัน ... เท่าที่เล่นอย่างผิวเผินมันก็คล้ายๆ phpmyadmin นี้เอง เอาไว้ให้ admin มาแก้ database.</p>
<p>[เข้าเรื่อง]</p>
<p>*อาจจะ* เป็นเพราะว่า Django ออกมานานพอสมควร framework ตัวอื่นๆ ก็มักจะมีอะไรคล้ายๆ Django admin site มาเหมือนกัน เช่น <a href="http://docs.turbogears.org/1.0/Catwalk">Catwalk</a> ของ Turbogears และสำหรับ Pylons เท่าที่ search มาได้ก็มี <a href="http://adminpylon.devjavu.com/">adminpylon</a> (ผ่าน<a href="http://www.mail-archive.com/pylons-discuss@googlegroups.com/msg06359.html">เว็บนี้</a>) กับ <a href="http://code.google.com/p/pails-admin/">pails-admin</a>, ส่วน CakePHP ทำ admin site เป็นแบบ CRUD เลย เป็นต้น</p>
<p>Catwalk เท่าที่ดูผ่านๆ ก็เข้าไปเขียน code เพิ่มเข้าไปใน model เหมือน Django แต่ผมไม่รู้ว่า customize อย่างไร. CakePHP ต่างออกไปคือเพิ่ม action เข้าไปใน controller แล้วที่เหลือก็ทำแบบ CRUD ธรรมดา. เท่าที่ดูผ่านๆ อีกเหมือนกัน pails-admin ผมอ่านไม่รู้เรื่อง :-P. adminpylon เหมือนจะสร้าง controller แยกออกมาอีกต่างหากเลย แล้วก็ดูจะคล้ายๆ จะ customize ได้แบบของ Django.</p>
<p>อีกตัวหนึ่งที่อาจจะจัดเข้ากลุ่มนี้ได้คือ FastData ของ Turbogears ปกติเอาไว้ทำ CRUD ถ้าจัดการเรื่อง admin route หน่อย (ไม่รู้ Turbogears ทำได้หรือเปล่า) ก็อาจจะออกมาคล้ายๆ CakePHP ... แต่เหมือน Catwalk ไม่รู้ว่า customize อย่างไร</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[VSTS 2008 Database Edition GDR]]></title>
<link>http://scarydba.wordpress.com/?p=64</link>
<pubDate>Tue, 10 Jun 2008 14:17:29 +0000</pubDate>
<dc:creator>scarydba</dc:creator>
<guid>http://scarydba.wordpress.com/?p=64</guid>
<description><![CDATA[OK. I&#8217;m jazzed about this. I&#8217;m diving in to test it out &amp; try it out. &lt;kicking de]]></description>
<content:encoded><![CDATA[<p>OK. I'm jazzed about this. I'm diving in to test it out &#38; try it out. &#60;kicking desk&#62; I can't convert existing projects to it... CRUD!</p>
<p>Fine. Reverse engineering a database and then building all the customizations by hand will be a good learning experience. Yes, that sound you hear is my teeth grinding, not tectonic plates shifting... CRUD!</p>
<p>A quick &#38; easy test, no real work was that too much to ask?</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[The Toxic Garden State]]></title>
<link>http://strangelatitudes.wordpress.com/?p=579</link>
<pubDate>Tue, 10 Jun 2008 02:48:13 +0000</pubDate>
<dc:creator>rich</dc:creator>
<guid>http://strangelatitudes.wordpress.com/?p=579</guid>
<description><![CDATA[One of the things about The Two Marks and their wonderful magazine, Weird New Jersey: they often fea]]></description>
<content:encoded><![CDATA[<p>One of the things about The Two Marks and their <a href="http://www.weirdnj.com/misc/main.asp">wonderful magazine, Weird New Jersey</a>: they often feature a lot of photographs of weird chemical shit.  Of course, New Jersey has a few nuclear power plants.   For a time, I always thought the pollution was just local folklore -- you know, the sort of things that New Yorkers and people from Philadelphia often cook up to poke fun at The Garden State  Then, in one of my usual pointless walks through Ocean Grove, Neptune, and Asbury Park with my camera, I notice this shit in one of the small man made lakes:</p>
<p><img src="http://lh5.ggpht.com/richristow/SE3nxfK2AvI/AAAAAAAAACw/PUyUdRShtUU/Picture%20078.jpg?imgmax=512" alt="" width="512" height="384" /></p>
<p>Here's a close up:</p>
<p><img src="http://lh5.ggpht.com/richristow/SE3n04WYXWI/AAAAAAAAAC4/iD-pK4IWxho/Picture%20079.jpg?imgmax=512" alt="" width="512" height="384" /></p>
<p>And that wasn't the only sludge floating around.  There's was also this, floating in the same lake:</p>
<p><img src="http://lh4.ggpht.com/richristow/SE3q_RpxcqI/AAAAAAAAADY/UQ_-SFQ1LAc/Picture%20083.jpg?imgmax=512" alt="" width="512" height="384" /></p>
<p>There's a horror story waiting to be found in this.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Summer!]]></title>
<link>http://insertwittynamehere.wordpress.com/?p=7</link>
<pubDate>Sun, 08 Jun 2008 20:26:28 +0000</pubDate>
<dc:creator>insertwittynamehere</dc:creator>
<guid>http://insertwittynamehere.wordpress.com/?p=7</guid>
<description><![CDATA[Ah, &#8217;tis finally summer. And I have a cold.
God probably thinks he had a sudden stroke of iron]]></description>
<content:encoded><![CDATA[<p>Ah, 'tis finally summer. And I have a cold.</p>
<p>God probably thinks he had a sudden stroke of ironic genuis and is rolling on the floor laughing right now. How cruel.</p>
<p>And I have absolutely nothing fit for warm weather in my closet aside from 5 t-shirts, two pairs of athletic shorts, and two tennis skirts. Oh, and two pairs of flip-flops.</p>
<p>See, the problem is, my legs are too long and thin and my waist is too small. If the length is correct, the waistline is not, and a belt causes it to poof out. If the waist fits correctly, the legs are too short. I would love a pair of short-shorts, but my waist is too small to fit any I like. I would also love a cute summer dress, but just trying to convince my mom to buy me one would most likely result in death, injury, or even punishment.</p>
<p> I would wear one of my four tank tops, but unfortunately an awful sunburn paired with unsightly peeling has nixed that option.</p>
<p>So I guess I'll just have to be content with hiding inside all summer except when on the tennis court. Poo.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[So sorry!]]></title>
<link>http://wilkefamily.wordpress.com/?p=90</link>
<pubDate>Sun, 27 Apr 2008 02:57:57 +0000</pubDate>
<dc:creator>Lucia</dc:creator>
<guid>http://wilkefamily.wordpress.com/?p=90</guid>
<description><![CDATA[I was checking out my blog stats and noticed that someone found this blog yesterday via search engin]]></description>
<content:encoded><![CDATA[<p>I was checking out my blog stats and noticed that someone found this blog yesterday via search engine using the search words "<strong>oozing yellow scales babies head</strong>" which means the search engine pointed them to <a href="http://wilkefamily.wordpress.com/2008/03/19/crud/" target="_self">this post</a>. For the person that was searching with those search words, I'm sorry for you! It means you have a baby with oozing yellow scales on your baby's head. :( The only things that have worked for us is: baby oil,  Head &#38; Shoulders shampoo and Cortaid (hydrocortisone). Chelsea gets a bath every other day. Once in her baby bath, I rub baby oil all over her body and scalp and let it sit for awhile. I put a wet wash cloth on her head to help moisten/loosen the scales. After I wash her body with Baby Aveeno baby wash (label on bottle says it is for baby skin with eczema), I wash her head/hair with H&#38;S being careful not to get the soap in her eyes. I use a baby hair brush to brush/rub her scalp to get rid of the scales as best as I can. After I take her out of the bath and dry her off, I rub Cortaid (cream or ointment, not sure which I like better) on the irritated parts of her skin and in the creases/folds because they tend to become red. The rest of her body gets a thin coat of Vaseline. These methods seem to help. With this treatment, her skin is better than it was mid March, but it's still not perfect and occasionally gets worse before getting better again.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[One false move and I'll]]></title>
<link>http://funckiedunckieknits.wordpress.com/?p=55</link>
<pubDate>Mon, 21 Apr 2008 23:51:29 +0000</pubDate>
<dc:creator>duncks</dc:creator>
<guid>http://funckiedunckieknits.wordpress.com/?p=55</guid>
<description><![CDATA[I bought myself a cheap lil present the other day.
A simple skein of Lily&#8217;s sugar &#8216;n cre]]></description>
<content:encoded><![CDATA[<p>I bought myself a cheap lil present the other day.</p>
<p>A simple skein of Lily's sugar 'n cream self striping cotton yarn in Lime Stripes.</p>
<p><img src="http://farm3.static.flickr.com/2064/2418194495_c3c29c522c.jpg" alt="" width="375" height="500" /></p>
<p>The color way was just to yummy to pass up (especially at $2.50... Guilt Free!) But what to make with it?</p>
<p>I DO NOT want to make a wash cloth.</p>
<p>Why must small amounts of cotton be relegated to washing things?</p>
<p>I decided to make a neck warmer. One suitable for summer nights. Heck, it would also be suitable for sweaty summer days. See? Cotton <strong><em>is</em></strong> your friend.</p>
<p>I was going to see if I could make it up myself as well.</p>
<p>Do you hear that eeery horror movie music? dun dun duuunnnn</p>
<p>I took this with me on my venture to BFE-North (aka Brit MN) to help a friend move.</p>
<p>All was going well.</p>
<p><img src="http://farm3.static.flickr.com/2036/2424693903_e13e117874.jpg?v=0" alt="" width="375" height="500" /></p>
<p>On the way, I decided that I was going to do a couple of runs of drop stitches. I figured it would give it more of a lacy feel and be a bit fancier/prettier than a plan cotton neckercheif.</p>
<p>dun dun duunnnn</p>
<p><img src="http://farm4.static.flickr.com/3227/2430578817_fc69430461.jpg?v=0" alt="" /></p>
<p>Oooh Aaah Pretty!</p>
<p>Things were (were? passed tense?) going along swimmingly.</p>
<p>Then I decided I wanted to have a run in the middle of the scarflet.</p>
<p>dun dun duuuuunnnnnnnn dun dun</p>
<p><img src="http://farm4.static.flickr.com/3233/2431392010_bfcb6b33d8.jpg?v=0" alt="" /></p>
<p>Crud.</p>
<p>One false move</p>
<p>One bad stitch dropped and it all came tumbling down like the Berlin wall oh so many years ago.</p>
<p>*sigh*</p>
<p>Time for a do over.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Un adevar care doare!]]></title>
<link>http://cezarsalahor.wordpress.com/?p=220</link>
<pubDate>Sat, 19 Apr 2008 17:00:00 +0000</pubDate>
<dc:creator>admin</dc:creator>
<guid>http://cezarsalahor.wordpress.com/?p=220</guid>
<description><![CDATA[Partea I
====

Partea II
=====

]]></description>
<content:encoded><![CDATA[<p>Partea I</p>
<p>====</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/9YnU6Ig1uJI'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/9YnU6Ig1uJI&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></span></p>
<p>Partea II</p>
<p>=====</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/11mA5Bg7KHg'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/11mA5Bg7KHg&rel=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed></object></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[ExtJS DataGrid]]></title>
<link>http://pitfalls.wordpress.com/?p=8</link>
<pubDate>Mon, 14 Apr 2008 06:14:21 +0000</pubDate>
<dc:creator>abhishekhurana</dc:creator>
<guid>http://pitfalls.wordpress.com/?p=8</guid>
<description><![CDATA[Author : Abhishek Khurana
In its second innings, World Wide Web has introduced a newer approach to i]]></description>
<content:encoded><![CDATA[<p>Author : Abhishek Khurana</p>
<p>In its second innings, World Wide Web has introduced a newer approach to interact, organize &#38; categorize information. With new Web 2.0 sites cropping up all over the place, the value of tools (&#38; libraries) coming up to facilitate creativity and giving browser a bigger role to play in business interaction are talk of the town for the developers all around the world.</p>
<p>Apart from Ext JS library (<a href="http://extjs.com/"><strong>http://extjs.com/</strong></a>), JackBuilder (JackBe), Flex (Adobe), GWT (Google), GI (Tibco) are other few Ajaxified GUI development tools that come to my mind, serving the similar cause. This article is first up in the series of Web 2.0 technologies that we will continue, and star of the show today is <strong>ext js</strong>.<!--more--></p>
<p>There are already a few good articles available on ext js forum that talk about integrating Ext with DWR. Here's one that I would recommend: <a href="http://extjs.com/forum/showthread.php?t=5586"><strong>http://extjs.com/forum/showthread.php?t=5586</strong></a>. Taking this further, the scope of this article would be creating a Data Grid (using Ext) for CRUD operations. Refer Ext API docs at <a href="http://extjs.com/deploy/dev/docs/"><strong>http://extjs.com/deploy/dev/docs/</strong></a>. The package you need to emphasize for this article is <code>Ext.data.*</code></p>
<p>1. Ext Data Grid (<code>Ext.grid.GridPanel</code>) can be percieved as a Table where each row is a Record (<code>Ext.data.Record</code>). These records will be fetched from the server and cached using <code>Ext.data.Store</code> object.</p>
<p>2. <code>Ext.data.DataProxy</code>, an abstract class extended by <code>Ext.data.DWRProxy</code> (refer DWR article from the link mentioned above), is the proxy configured for <code>Ext.data.Store</code> object to fetch data objects from server.</p>
<p>3. Now this store object is totally agnostic to the format of the data returned by the Proxy. This allow developer provide their own configured implementation of <code>Ext.data.DataReader</code> to convert these data objects into records and make them available.</p>
<p>Lets start on how one can create a proxy to be used by GridPanel.</p>
<pre style="overflow:auto;width:440px;height:288px;text-align:left;margin:0;padding:6px;">ds = new Ext.data.Store({
    proxy: new Ext.data.DWRProxy(., true),
    reader: new Ext.data.ListRangeReader({
        id: 'field1',
        totalProperty: 'totalSize'
        }, Ext.data.Record.create([{
                name: "field1",
                mapping: "field1",
                type: "int"
            }, {
                name: "field2",
                mapping: "field2",
                type: "string"
           }]
        )
    )
});</pre>
<p>
To instantiate Ext.data.Store, the config object passed to the constructor included two properties; proxy &#38; reader.</p>
<ul>
<li>The property proxy is an instance of <code>Ext.data.DWRProxy</code>. As I said before, this being an extension of the DWR article I have already referenced, so my DWRProxy implementation remains same. Other subclasses of <code>Ext.data.DataProxy</code> (provided by ext js) are <code>Ext.data.HttpProxy</code>, <code>Ext.data.MemoryProxy</code>, <code>Ext.data.ScriptTagProxy</code>.</li>
<li>The property reader is instantiated as <code>Ext.data.ListRangeReader</code>. The reader object is chosen according to the format of resultset that your dwr method returns. Other extensions of <code>Ext.data.DataReader</code> are <code>Ext.data.JsonReader</code>, <code>Ext.data.XmlReader</code> &#38; <code>Ext.data.ArrayReader</code>.</li>
</ul>
<p>Every Reader is different in a way the format used by the server to return the data objects alongwith the addon properties needed like, total number of records etc. The constructor for a <code>DataReader</code> needs two things. A config object and a Record definition. The config object includes:</p>
<ul>
<li><em>id</em> to specify which field will be used as the identifier for each row.</li>
<li><em>totalProperty</em> to specify which field contains information about total number of records the server returns.</li>
</ul>
<p>The other argument, Record object, is an array of objects which provides mapping of property elements in data object to those in a grid record.
</p>
<p>To make it more clearer, the result for which a <code>ListRangeReader</code> is appropriate looks like this:</p>
<pre style="overflow:auto;width:400px;height:195px;text-align:left;margin:0;padding:6px;">
{
    data: [{
        "field1": 1001,
        "field2": "data1"
    },{
        "field1": 1010,
        "field2": "data2"
    }],
    totalSize: 2
}</pre>
<p>For JsonReader, check out <a href="http://extjs.com/deploy/dev/docs/output/Ext.data.JsonReader.html"><strong>http://extjs.com/deploy/dev/docs/output/Ext.data.JsonReader.html</strong></a></p>
<p>Thanks to Ext API docs, creating Grid comes easy. The instantiation is self-informative enough to get in one's head.</p>
<pre style="overflow:auto;width:443px;height:430px;text-align:left;margin:0;padding:6px;">
grid = new Ext.grid.GridPanel({
            el: "div_to_render",
            autoScroll: true,
            autoHeight: true,
            autoWidth: true,
            ds: ds,
            cm: new Ext.grid.ColumnModel([{
                header: 'Field1 Header',
                width: 250,
                sortable: true,
                dataIndex: 'field1'
            }, {
                header: 'Field2 Header',
                width: 250,
                sortable: true,
                dataIndex: 'field2'
            }]),
            sm: new Ext.grid.RowSelectionModel({
                singleSelect: true,
                listeners: {
                     rowselect: function(smObj, rowIndex, record) {
                         selRecordStore = record;
                    }
               }
            }),
            autoSizeColumns: true,
            trackMouseOver: true,

            tbar: [new Ext.Toolbar.Button({
                        text: 'Add',
                        handler: function(){
                        //Load New Form
                     }
            }), new Ext.Toolbar.Button({
                        text: 'Edit',
                        handler: function(){
                        //Load New Form
                        //Load Data

                        <em>form</em>.loadRecord(selRecordStore);
                  }
            }), new Ext.Toolbar.Button({
                        text: 'Delete',
                        handler: function(){
                        //Call for Delete for the record with this identifier
                        var id = selRecordStore["field1"]
                }
            })],

            bbar: new Ext.PagingToolbar({
                        pageSize: 2,
                        store: ds,
                        displayInfo: true,
                        displayMsg: 'Displaying Records {0} - {1} of {2}',
                        emptyMsg: &#34;No Records to display&#34;,
                        items: ['-']
            })
});
</pre>
<p>Wondering, if I haven't deviated away from the scope of this write up, notice that I have configured a listener for the Grid Selection Model which stores the reference of the records mapped for the row selected. This record is used by Toolbar Button handler for the actions specified.</p>
<p>This concludes my say on using Ajax based Ext JS Data Grid which looks difficult to use, first time u look at it, but provide us various features to configure, like Paging, Toolbar etc.</p>
<p>Note: For this being an introductory article to startup, I have tried my best to stay focussed on my scope. Based on the reviews/responses, I can follow it up with a working example.</p>
<p>References:<br />
1. <a href="http://extjs.com/forum">Ext JS Forum</a><br />
2. <a href="http://extjs.com/deploy/dev/docs/">Ext JS API Documentation</a></pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Basic Crud in Django]]></title>
<link>http://cachina.wordpress.com/?p=120</link>
<pubDate>Fri, 11 Apr 2008 01:10:03 +0000</pubDate>
<dc:creator>Mayron Cachina</dc:creator>
<guid>http://cachina.wordpress.com/?p=120</guid>
<description><![CDATA[
]]></description>
<content:encoded><![CDATA[<p>[slideshare id=140766&#38;doc=basic-crud-in-django-1192935516587314-4&#38;w=425]</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Pierdut in propria-mi umbra]]></title>
<link>http://ruin92.wordpress.com/?p=6</link>
<pubDate>Fri, 04 Apr 2008 20:44:22 +0000</pubDate>
<dc:creator>Ruin</dc:creator>
<guid>http://ruin92.wordpress.com/?p=6</guid>
<description><![CDATA[ Era anul 1967. Eram un important om de afaceri din Londra. Aveam o firma mare de tesaturi. Eram pa]]></description>
<content:encoded><![CDATA[<p> Era anul 1967. Eram un important om de afaceri din Londra. Aveam o firma mare de tesaturi. Eram patronul ei. Aveam o mosie destul de mare, in jurul Londrei, aveam doar 30 de ani si eram necasatorit. Desi nu ma puteam plange din cauza femeilor, caci detineam (si spun detineam pentru ca erau total dependente de mine) destule amante. Majoritatea, adica toate, nu erau atrase de mine datorita fizicului, care se compunea dintr-o burta relativ mare, si un fizic care nu a promis niciodata nimic nici macar cand erau adolescent. Nuuu...nu asta era motivul pentru care erau atrase de mine. Eu le atrageam prin puterea mea, financiara si politica. Desi majoritatea oamenilor care lucrau sub mine, ma considerau un tiran, un nemilos, zgarcit, eu ma consideram destul de rafinat. Casa mea, care ca si dimensiuni se apropia de un palat, a fost construita de foarte multi oameni care au trecut prin chinuri groaznice. Eram urat de foarte multa lume. Dar toate astea s-au schimbat, deoarece ei au scapat de mine. Acum povestesc toate astea, din Infern. Am fost ucis, dar nu ucis cum s-ar astepta toti. Am fost devorat. Am fost devorat de umbra faptelor mele. Dupa cum ziceam, casa mea era mare. Si neavand o femeie, o sotie, locuiam singur, cu o menajera. Saraca (nu stiu cum...dar am inceput sa compatimesc lumea care a lucrat cu mine) a avut o viata grea, a fost batuta, certata, chiar si violata. Nu s-a plans nimanui. Era loiala familiei mele. Avea o datorie de viata fata de tatal meu, care i-a salvat-o pe mama ei. Si a dorit sa plateasca datoria mea fata de mine. Cum ziceam, moartea mea a fost una sumbra. Pe care de abia acum, cand privesc in urma incep sa o inteleg.<br />
 Eram singur in casa, nici macar menajera, Marie, nu mai era. Era seara, destul de tarziu, stiam asta. M-am culcat, dar in scurt timp m-am sculat din cauza nevoilor mele personale. Era ciudat, desi ceasul arata ora 1 noaptea aproape, afara era soare, un soare intens de un rosu puternic. Un soare orbitor. M-am speriat...era ciudat, m-am speriat...la colt, era o umbra ciudata, ma uit inspre picioare, in spate...Realizez ca era umbra mea. Mie imi disparuse...Speriat ma intorc si incerc sa fug.</p>
<p>Ies din camera. Trebuia sa ajung in hol, dar ajung in bucatarie! E ciudat. Mi-e frica, incep si strig. Nu ma aud. Aud doar un ecou, dar care nu e al meu. Imi vad umbra in fata mea. Mi se face si mai frica, ma intorc si ies pe usa. Intru in baie! Acolo il vad pe Dracul insusi, statea si se holba la mine. Imi radea, ies pe usa, si ma trezesc afara. E ciudat...Murisem oare? Nu aveam cum, simteam, respiram, vedeam. Afara, realizez, ca sunt sufletele, umbrele de fapt ale tuturor oamenilor, ucisi, chinuiti, raniti de mine. Vin, ma inconjoara. Ii rog sa inceteze. Le zic ca le dau ce vor, dar nu. Ei continua. Se indreapta inspre mine. Vin, m-au inconjurat. Incep sa ma devoreze. Vad faptele in fata ochilor! NU VREAU SA MOR! MIE FRICA! Dar totul se termina. Ma trezesc. Imi zic, slava domnului, a fost doar un vis, ma ridic din pat, ma uit in spate. Am umbra. Slava domnului, am scapat. Si tocmai cand ma linsitisem, o Forta ma arunca jos, si imi vad umbra peste mine, cum incepe, sa ma chinuie, sa ma manance. Nu mai suport. Durerea e infioratoare! Sunt ucis de propria persoana. De propriile-mi fapte. Acum inteleg, inteleg greselile mele, inteleg ce simteau ceilalti, as mai vrea o sansa. E prea tarziu. Sunt o umbra, un suflet pierdut, un suflet pierdut in focurile eterne ale Iadului. Am fost pierdut in propria-mi umbra. Regret...</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[No CURDs for you!]]></title>
<link>http://glhlavkaworld.wordpress.com/?p=24</link>
<pubDate>Fri, 28 Mar 2008 02:33:53 +0000</pubDate>
<dc:creator>t-bone</dc:creator>
<guid>http://glhlavkaworld.wordpress.com/?p=24</guid>
<description><![CDATA[I love a good pun, even when (okay, especially when) it is mired in developer-speak.
We&#8217;ve bee]]></description>
<content:encoded><![CDATA[<p>I love a good pun, even when (okay, especially when) it is mired in developer-speak.</p>
<p>We've been doing a fair amount of research into CRUD frameworks at work (that's Create, Read, Update, Delete for the non-techies in the house).  One of my co-workers stumbled upon a whole PDF datasheet from some major company talking about their great CURD framework.  He sent it around with some comment about how cheesy their framework was.</p>
<p>My response: No whey!</p>
<p>Makes me chuckle, a couple of months later.</p>
<p>Rating: 5+ stars (out of 5) &#60;-- now that's cheesy... rating your own bad puns!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Using Silverlight with Ruby on Rails]]></title>
<link>http://techblogging.wordpress.com/2008/03/26/using-silverlight-with-rubyonrails/</link>
<pubDate>Wed, 26 Mar 2008 12:55:12 +0000</pubDate>
<dc:creator>techblogger</dc:creator>
<guid>http://techblogging.wordpress.com/2008/03/26/using-silverlight-with-rubyonrails/</guid>
<description><![CDATA[In this post I will be showing a really simple example of creating a Silverlight frontend for a Rail]]></description>
<content:encoded><![CDATA[<p>In this post I will be showing a really simple example of creating a Silverlight frontend for a Rails backend. This is what I think will be a three part series comparing Silverlight with Flex.</p>
<p>The steps will be:</p>
<ol>
<li>Creating a Rails application.
<li>Creating a frontend for it in silverlight.
<li>Creating a frontend for it in Flex.
<li>Comparing the approaches taken in both the frontends. </li>
</ol>
<p> I will try to keep changes in the backend Rails application to a minimum.</p>
</p>
<p><!--more-->
</p>
<h5><u>Creating a Rails Application</u></h5>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">F:\<span style="color:#0000ff;">&#62;</span>rails test
F:\<span style="color:#0000ff;">&#62;</span>cd test
F:\test<span style="color:#0000ff;">&#62;</span>ruby script\generate scaffold user name:string address:text
F:\test<span style="color:#0000ff;">&#62;</span>rake db:create
F:\test<span style="color:#0000ff;">&#62;</span>rake db:migrate
F:\test<span style="color:#0000ff;">&#62;</span>ruby script\server</pre>
</div>
<p>Before running the migrations add the following code in the first migration file (./db/migrate/001_create_users.rb) to create some initial data.&#160; So it should look like:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">class</span> CreateUsers &#60; ActiveRecord::Migration
  def self.up
    create_table :users <span style="color:#0000ff;">do</span> &#124;t&#124;
      t.<span style="color:#0000ff;">string</span> :name
      t.text :address
      t.timestamps
    end

    User.create(:name=&#62; <span style="color:#006080;">"Gaurav"</span>, :address=&#62; <span style="color:#006080;">"Gaurav's address"</span>)
    User.create(:name=&#62; <span style="color:#006080;">"Rishav"</span>, :address=&#62; <span style="color:#006080;">"Rishav's address"</span>)
    User.create(:name=&#62; <span style="color:#006080;">"Bhavesh"</span>, :address=&#62; <span style="color:#006080;">"Bhavesh's address"</span>)
  end

  def self.down
    drop_table :users
  end
end</pre>
</div>
<p>&#160;</p>
<h5><u>Creating a new C# based Silverlight project</u></h5>
<p>&#160;</p>
<p>Open up Visual Studio 2008 (with Silverlight <a href="http://techblogging.wordpress.com/2008/03/05/silverlight-20-beta-1-now-available-and-10-version-ported-to-nokia-mobiles/">tools</a> installed. You can also download a trial version of Visual Studio 2008 from <a href="http://msdn2.microsoft.com/en-us/vstudio/products/aa700831.aspx">here</a>). And create a new project:</p>
<p><a href="http://techblogging.files.wordpress.com/2008/03/vs-step1.png"><img style="border-width:0;" height="415" alt="vs_step1" src="http://techblogging.files.wordpress.com/2008/03/vs-step1-thumb.png" width="609" border="0"></a></p>
<p><a href="http://techblogging.files.wordpress.com/2008/03/vs-step2.png"><img style="border-width:0;" height="368" alt="vs_step2" src="http://techblogging.files.wordpress.com/2008/03/vs-step2-thumb.png" width="439" border="0"></a></p>
<p>&#160;</p>
<p>Open the page.xaml file and add a ListBox to it. It should look like:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&#60;</span><span style="color:#800000;">UserControl</span> <span style="color:#ff0000;">x:Class</span><span style="color:#0000ff;">="TestFrontEnd.Page"</span>
    <span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">="http://schemas.microsoft.com/client/2007"</span>
    <span style="color:#ff0000;">xmlns:x</span><span style="color:#0000ff;">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
    <span style="color:#ff0000;">Width</span><span style="color:#0000ff;">="400"</span> <span style="color:#ff0000;">Height</span><span style="color:#0000ff;">="300"</span><span style="color:#0000ff;">&#62;</span>
    <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="LayoutRoot"</span> <span style="color:#ff0000;">Background</span><span style="color:#0000ff;">="White"</span><span style="color:#0000ff;">&#62;</span>
        <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListBox</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userList"</span> <span style="color:#ff0000;">Height</span><span style="color:#0000ff;">="200"</span><span style="color:#0000ff;">/&#62;</span>
    <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">UserControl</span><span style="color:#0000ff;">&#62;</span></pre>
</div>
<p>&#160;</p>
<p>Now when the server responds with xml, we will parse that using <a href="http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx">Linq</a>. For that we need a User class that is like the user model on the Rails side. So it should have 3 fields:</p>
<ol>
<li>id
<li>name
<li>address </li>
</ol>
<p>It should look like:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">namespace</span> TestFrontEnd {
    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> User {
        <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> id { get; set; }
        <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> name { get; set; }
        <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> address { get; set; }
    }
}</pre>
</div>
<p>&#160;</p>
<p>To make things simpler I have created a HTTPService class that behaves something like the Flex based HTTPService class. <a href="http://pastie.caboo.se/170803">Here is the source</a> (too big to paste inline). Add it to your project. You will need to include System.Net assembly your project to to make it work. Its usage is quite simple.</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">HTTPService userIndexService = <span style="color:#0000ff;">new</span> HTTPService();
userIndexService.Url = <span style="color:#006080;">"http://localhost:3000/users.xml"</span>;
userIndexService.ServiceComplete += <span style="color:#0000ff;">new</span> HttpServiceCompleteEventHandler(userIndexService_ServiceComplete);
userIndexService.send();</pre>
</div>
<p>&#160;</p>
<p>You can also give the request method like:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">userIndexService.Method = <span style="color:#006080;">"POST"</span>;</pre>
</div>
<p>&#160;</p>
<p>Now add an ObservableCollection to the Page class:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> ObservableCollection&#60;User&#62; userListItems = <span style="color:#0000ff;">new</span> ObservableCollection&#60;User&#62;();</pre>
</div>
<p>&#160;</p>
<p>We will be using this for <a href="http://msdn2.microsoft.com/en-us/library/ms752347.aspx">databinding</a> with the ListBox to display all the users.</p>
<p>Add the System.Xml.Linq to your project. In the userIndexService_ServiceComplete event handler write:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">void</span> userIndexService_ServiceComplete(HttpServiceCompleteEventArgs e) {
    XDocument users = XDocument.Parse(e.Response);
    User[] usersList = (from x <span style="color:#0000ff;">in</span> users.Descendants(<span style="color:#006080;">"user"</span>)
            select <span style="color:#0000ff;">new</span> User
            {
                id = <span style="color:#0000ff;">int</span>.Parse(x.Descendants(<span style="color:#006080;">"id"</span>).First().Value),
                name = x.Descendants(<span style="color:#006080;">"name"</span>).First().Value,
                address = x.Descendants(<span style="color:#006080;">"address"</span>).First().Value,
            }).ToArray();
    <span style="color:#0000ff;">foreach</span> (User user <span style="color:#0000ff;">in</span> usersList)
        userListItems.Add(user);
}</pre>
</div>
<p>&#160;</p>
<p>So when the service completes all the users will be filled in the ObserveableCollection. Now to bind it to the userList ListBox. In the constructor of the Page class write:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;">userList.DataContext = userListItems;</pre>
</div>
<p>&#160;</p>
<p>And modify the code for the userList ListBox to look like:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListBox</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userList"</span> <span style="color:#ff0000;">Height</span><span style="color:#0000ff;">="200"</span> <span style="color:#ff0000;">ItemsSource</span><span style="color:#0000ff;">="{Binding}"</span> <span style="color:#ff0000;">DisplayMemberPath</span><span style="color:#0000ff;">="name"</span> <span style="color:#0000ff;">/&#62;</span></pre>
</div>
<p>&#160;</p>
<p>Add a crossdomain.xml file to the rails project's public folder:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&#60;?</span><span style="color:#800000;">xml</span> <span style="color:#ff0000;">version</span><span style="color:#0000ff;">="1.0"</span>?<span style="color:#0000ff;">&#62;</span>
<span style="color:#0000ff;">&#60;!</span><span style="color:#800000;">DOCTYPE</span> <span style="color:#ff0000;">cross-domain-policy</span> <span style="color:#ff0000;">SYSTEM</span> <span style="color:#0000ff;">"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"</span><span style="color:#0000ff;">&#62;</span>
<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">cross-domain-policy</span><span style="color:#0000ff;">&#62;</span>
  <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">allow-access-from</span> <span style="color:#ff0000;">domain</span><span style="color:#0000ff;">="*"</span> <span style="color:#0000ff;">/&#62;</span>
<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">cross-domain-policy</span><span style="color:#0000ff;">&#62;</span></pre>
</div>
<p>We are basically allowing our Silverlight app to access the rails server. You won't be requiring this file if the Rails server is serving the Silverlight application, but currently it is not the case.</p>
<p>Now when you run the code you should see:</p>
<p><a href="http://techblogging.files.wordpress.com/2008/03/vs-step3.png"><img style="border-width:0;" height="416" alt="vs_step3" src="http://techblogging.files.wordpress.com/2008/03/vs-step3-thumb.png" width="480" border="0"></a></p>
<p>Now I will add a few more lines of code to show the selected item in TextBox. Add/Update the following to page.xaml:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListBox</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userList"</span> <span style="color:#ff0000;">Height</span><span style="color:#0000ff;">="200"</span> <span style="color:#ff0000;">ItemsSource</span><span style="color:#0000ff;">="{Binding}"</span> <span style="color:#ff0000;">DisplayMemberPath</span><span style="color:#0000ff;">="name"</span> <span style="color:#ff0000;">SelectionChanged</span><span style="color:#0000ff;">="userList_SelectionChanged"</span><span style="color:#0000ff;">/&#62;</span>
<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">StackPanel</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="controls"</span><span style="color:#0000ff;">&#62;</span>
    <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">="{Binding name, Mode=Twoway}"</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userName"</span><span style="color:#0000ff;">/&#62;</span>
    <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">="{Binding address, Mode=Twoway}"</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userAddress"</span><span style="color:#0000ff;">/&#62;</span>
<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">StackPanel</span><span style="color:#0000ff;">&#62;</span></pre>
</div>
<p>The first TextBox is showing name and second is showing the password. The binding mode is set to TwoWay so that the changes in TextBox are automatically to the userListItems.</p>
<p>Add the corresponding event handler to Page class:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> userList_SelectionChanged(<span style="color:#0000ff;">object</span> sender, SelectionChangedEventArgs e) {
    controls.DataContext = userList.SelectedItem <span style="color:#0000ff;">as</span> User;
}</pre>
</div>
<p>&#160;</p>
<p>Now when you run the code you should see:</p>
<p><a href="http://techblogging.files.wordpress.com/2008/03/image6.png"><img style="border-width:0;" height="423" alt="image" src="http://techblogging.files.wordpress.com/2008/03/image-thumb6.png" width="481" border="0"></a></p>
<p>Download the code upto this point:</p>
<ul>
<li><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/test.rar">Rails code</a>
<li><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/TestFrontEnd.rar">Silverlight code</a> </li>
</ul>
<p>&#160;</p>
<h5>&#160;<u>Implementing the full <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> :</u></h5>
<p>&#160;</p>
<p>Firstly I willl be doing a bit of refactoring. Move the xml parsing code using Linq to the User class. So it should now look like:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> User {
    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> id { get; set; }
    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> name { get; set; }
    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> address { get; set; }

    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> User[] users_from_xml(String xml_string){
        XDocument users = XDocument.Parse(xml_string);
        <span style="color:#0000ff;">return</span> (from x <span style="color:#0000ff;">in</span> users.Descendants(<span style="color:#006080;">"user"</span>)
            select <span style="color:#0000ff;">new</span> User
            {
                id = <span style="color:#0000ff;">int</span>.Parse(x.Descendants(<span style="color:#006080;">"id"</span>).First().Value),
                name = x.Descendants(<span style="color:#006080;">"name"</span>).First().Value,
                address = x.Descendants(<span style="color:#006080;">"address"</span>).First().Value,
            }).ToArray();
    }

    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> User user_from_xml(String xml_string) {
        <span style="color:#0000ff;">return</span> users_from_xml(xml_string).First();
    }
}</pre>
</div>
<p>&#160;</p>
<p>Change the Page class to:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">using</span> System;
<span style="color:#0000ff;">using</span> System.Collections.Generic;
<span style="color:#0000ff;">using</span> System.Linq;
<span style="color:#0000ff;">using</span> System.Windows;
<span style="color:#0000ff;">using</span> System.Windows.Controls;
<span style="color:#0000ff;">using</span> System.Windows.Documents;
<span style="color:#0000ff;">using</span> System.Windows.Input;
<span style="color:#0000ff;">using</span> System.Windows.Media;
<span style="color:#0000ff;">using</span> System.Windows.Media.Animation;
<span style="color:#0000ff;">using</span> System.Windows.Shapes;
<span style="color:#0000ff;">using</span> System.Collections.ObjectModel;
<span style="color:#0000ff;">using</span> System.Xml.Linq;

<span style="color:#0000ff;">namespace</span> TestFrontEnd {
    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> Page : UserControl {
        <span style="color:#0000ff;">private</span> ObservableCollection&#60;User&#62; userListItems = <span style="color:#0000ff;">new</span> ObservableCollection&#60;User&#62;();

        <span style="color:#0000ff;">private</span> HTTPService userIndexService;
        <span style="color:#0000ff;">private</span> HTTPService userCreateService;
        <span style="color:#0000ff;">private</span> HTTPService userUpdateService;
        <span style="color:#0000ff;">private</span> HTTPService userDeleteService;

        <span style="color:#0000ff;">public</span> Page() {
            InitializeComponent();
            <span style="color:#008000;">// setting the databinding</span>
            userList.DataContext = userListItems;
            controls.DataContext = <span style="color:#0000ff;">new</span> User();

            <span style="color:#008000;">// service to get all te users form the server</span>
            userIndexService = <span style="color:#0000ff;">new</span> HTTPService();
            userIndexService.Url = <span style="color:#006080;">"http://localhost:3000/users.xml"</span>;
            userIndexService.ServiceComplete += <span style="color:#0000ff;">new</span> HttpServiceCompleteEventHandler(userIndexService_ServiceComplete);
            userIndexService.send();

            <span style="color:#008000;">// create a new user</span>
            userCreateService = <span style="color:#0000ff;">new</span> HTTPService();
            userCreateService.Url = <span style="color:#006080;">"http://localhost:3000/users.xml"</span>;
            userCreateService.Method = <span style="color:#006080;">"POST"</span>;
            userCreateService.ServiceComplete += <span style="color:#0000ff;">new</span> HttpServiceCompleteEventHandler(userCreateService_ServiceComplete);

            <span style="color:#008000;">// update a user, we will not be trapping the results</span>
            userUpdateService = <span style="color:#0000ff;">new</span> HTTPService();
            userUpdateService.Method = <span style="color:#006080;">"POST"</span>;

            <span style="color:#008000;">// delete a user</span>
            userDeleteService = <span style="color:#0000ff;">new</span> HTTPService();
            userDeleteService.Method = <span style="color:#006080;">"POST"</span>;
        }

        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> _userList_SelectionChanged(<span style="color:#0000ff;">object</span> sender, SelectionChangedEventArgs e) {
            controls.DataContext = userList.SelectedItem <span style="color:#0000ff;">as</span> User;
        }

        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> userIndexService_ServiceComplete(HttpServiceCompleteEventArgs e) {
            <span style="color:#0000ff;">foreach</span> (User user <span style="color:#0000ff;">in</span> User.users_from_xml(e.Response))
                userListItems.Add(user);
        }
        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> userCreateService_ServiceComplete(HttpServiceCompleteEventArgs e) {
            userListItems.Add(User.user_from_xml(e.Response));
        }

        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> createButton_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e) {
            userCreateService.send(String.Format(<span style="color:#006080;">"{0}={1}&#38;{2}={3}"</span>, <span style="color:#006080;">"user[name]"</span>, userName.Text, <span style="color:#006080;">"user[address]"</span>, userAddress.Text));
        }

        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> updateButton_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e) {
            User _selectedUser = userList.SelectedItem <span style="color:#0000ff;">as</span> User;
            userUpdateService.Url = <span style="color:#006080;">"http://localhost:3000/users/"</span> + _selectedUser.id.ToString() + <span style="color:#006080;">".xml"</span>;
            userUpdateService.send(String.Format(<span style="color:#006080;">"{0}={1}&#38;{2}={3}&#38;{4}={5}"</span>, <span style="color:#006080;">"user[name]"</span>, userName.Text, <span style="color:#006080;">"user[address]"</span>, userAddress.Text, <span style="color:#006080;">"_method"</span>, <span style="color:#006080;">"PUT"</span>));
            userListItems[userList.SelectedIndex] = _selectedUser;
        }

        <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> deleteButton_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e) {
            User _selectedUser = userList.SelectedItem <span style="color:#0000ff;">as</span> User;
            userDeleteService.Url = <span style="color:#006080;">"http://localhost:3000/users/"</span> + _selectedUser.id.ToString() + <span style="color:#006080;">".xml"</span>;
            userDeleteService.send(String.Format(<span style="color:#006080;">"{0}={1}"</span>, <span style="color:#006080;">"_method"</span>, <span style="color:#006080;">"DELETE"</span>));
            userListItems.Remove(_selectedUser);
        }

    }
}
</pre>
</div>
<p>&#160;</p>
<p>To understand the specific parameters to the "send()" method of the HTTPService class you will need a little bit of understanding of how REST is implemented in Rails and how parameters are passed to a url, which is out of scope of this blog post.</p>
<p>&#160;</p>
<p>Change Page.xaml to:</p>
<div>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">&#60;</span><span style="color:#800000;">UserControl</span> <span style="color:#ff0000;">x:Class</span><span style="color:#0000ff;">="TestFrontEnd.Page"</span>
    <span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">="http://schemas.microsoft.com/client/2007"</span>
    <span style="color:#ff0000;">xmlns:x</span><span style="color:#0000ff;">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
    <span style="color:#ff0000;">Width</span><span style="color:#0000ff;">="400"</span> <span style="color:#ff0000;">Height</span><span style="color:#0000ff;">="300"</span><span style="color:#0000ff;">&#62;</span>
    <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="LayoutRoot"</span> <span style="color:#ff0000;">Background</span><span style="color:#0000ff;">="White"</span><span style="color:#0000ff;">&#62;</span>
        <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">StackPanel</span> <span style="color:#ff0000;">Orientation</span><span style="color:#0000ff;">="Vertical"</span><span style="color:#0000ff;">&#62;</span>
            <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListBox</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userList"</span> <span style="color:#ff0000;">ItemsSource</span><span style="color:#0000ff;">="{Binding}"</span> <span style="color:#ff0000;">DisplayMemberPath</span><span style="color:#0000ff;">="name"</span> <span style="color:#ff0000;">SelectionChanged</span><span style="color:#0000ff;">="_userList_SelectionChanged"</span> <span style="color:#ff0000;">Height</span><span style="color:#0000ff;">="200"</span><span style="color:#0000ff;">/&#62;</span>
            <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">StackPanel</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="controls"</span><span style="color:#0000ff;">&#62;</span>
                <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">="{Binding name, Mode=Twoway}"</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userName"</span><span style="color:#0000ff;">/&#62;</span>
                <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">="{Binding address, Mode=Twoway}"</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="userAddress"</span><span style="color:#0000ff;">/&#62;</span>
            <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">StackPanel</span><span style="color:#0000ff;">&#62;</span>
            <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">StackPanel</span> <span style="color:#ff0000;">Orientation</span><span style="color:#0000ff;">="Horizontal"</span><span style="color:#0000ff;">&#62;</span>
                <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Button</span> <span style="color:#ff0000;">Content</span><span style="color:#0000ff;">="Create"</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="createButton"</span> <span style="color:#ff0000;">Click</span><span style="color:#0000ff;">="createButton_Click"</span><span style="color:#0000ff;">/&#62;</span>
                <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Button</span> <span style="color:#ff0000;">Content</span><span style="color:#0000ff;">="Update"</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="updateButton"</span> <span style="color:#ff0000;">Click</span><span style="color:#0000ff;">="updateButton_Click"</span><span style="color:#0000ff;">/&#62;</span>
                <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Button</span> <span style="color:#ff0000;">Content</span><span style="color:#0000ff;">="Delete"</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="deleteButton"</span> <span style="color:#ff0000;">Click</span><span style="color:#0000ff;">="deleteButton_Click"</span><span style="color:#0000ff;">/&#62;</span>
            <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">StackPanel</span><span style="color:#0000ff;">&#62;</span>
            <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">x:Name</span><span style="color:#0000ff;">="trace"</span> <span style="color:#0000ff;">/&#62;</span>
        <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">StackPanel</span><span style="color:#0000ff;">&#62;</span>
    <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">UserControl</span><span style="color:#0000ff;">&#62;</span>
</pre>
</div>
<p>&#160;</p>
<p>This is how it looks like now:</p>
<p><a href="http://techblogging.files.wordpress.com/2008/03/image7.png"><img style="border-width:0;" height="423" alt="image" src="http://techblogging.files.wordpress.com/2008/03/image-thumb7.png" width="481" border="0"></a></p>
<p>So this is full CRUD implementation using Silverlight as frontend.</p>
<p>This is not the most optimal way to implement CRUD it is very easy to understand. It also should be noted that I haven't added error checking of any type in the code and there is a lot of code repetition. But I guess that could be improved upon further once the most simple scenario is implemented. My style of coding is "First make it work and then optimize it", and as I have mentioned it before it is certainly not the most optimized way to code but it sure works :)</p>
<p>One microsoft releases better databinding capabilities in controls and some simpler classes for HTTP based communication, this code would be much more simpler.</p>
<p>Full code for this aplication can be downloaded from:</p>
<li><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/test.rar">Rails code</a>
<li><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/TestFrontEnd2.rar">Silverlight code</a></li>
<p>&#160;</p>
<div class="wlWriterSmartContent" id="5ce5ff6c-9474-4531-909c-9f79bda9013e" style="display:inline;margin:0;padding:0;">del.icio.us Tags: <a href="http://del.icio.us/popular/adobe" rel="tag">adobe</a>,<a href="http://del.icio.us/popular/C#" rel="tag">C#</a>,<a href="http://del.icio.us/popular/crud" rel="tag">crud</a>,<a href="http://del.icio.us/popular/flex" rel="tag">flex</a>,<a href="http://del.icio.us/popular/microsoft" rel="tag">microsoft</a>,<a href="http://del.icio.us/popular/rails" rel="tag">rails</a>,<a href="http://del.icio.us/popular/ruby%20on%20rails" rel="tag">ruby on rails</a>,<a href="http://del.icio.us/popular/silverlight" rel="tag">silverlight</a>,<a href="http://del.icio.us/popular/xaml" rel="tag">xaml</a></div>
]]></content:encoded>
</item>
<item>
<title><![CDATA[nu am inspiratie si prin urmare nu stiu ce titlu sa dau postului astuia.]]></title>
<link>http://lechevalblanc.wordpress.com/?p=67</link>
<pubDate>Mon, 24 Mar 2008 22:13:16 +0000</pubDate>
<dc:creator>lechevalblanc</dc:creator>
<guid>http://lechevalblanc.wordpress.com/?p=67</guid>
<description><![CDATA[Nu nu.I’m not dead yet.
Ce fac, nici eu nu stiu.
 Vine primavara si parca simt cum plesneste carn]]></description>
<content:encoded><![CDATA[<p><span><font face="Times New Roman">Nu nu.</font></span><span><font face="Times New Roman">I’m not dead yet.</font></span></p>
<p><span></span><span><font face="Times New Roman">Ce fac, nici eu nu stiu.</font></span></p>
<p><span><font face="Times New Roman"> Vine primavara si parca simt cum plesneste carnea si cum plesnesc venele si cum plesneste tot ce e verde si rosu si proaspat.</font></span><span><font face="Times New Roman">Am sentimentul ca sint inconjurata de cruditati. Incepand cu salate si ridichi si terminand cu chestii mai grave. Ceva ce scartaie intre dinti si scoate sunetul ala crud crud crud.</font></span><span><font face="Times New Roman">Fresh. Cool. Caldura. Florile. Zilele.</font></span></p>
<p><span></span><span><font face="Times New Roman">Ah, the golden spring ages (Prietenii stiu de ce. Sau daca nu stiu de ce, pot macar sa ghiceasca. Sau pot sa-si bata capul si sa nu se prinda. Prin urmare pot sa se oftice. Si sa ma intrebe. Uite, tu care citesti acum asta, nu-i asa ca te-ar interesa sa stii ce-i cu the golden spring ages? Nu-i asa ca esti un pic curios. Uite-te la tine. Si gandeste-te la mine. Si la motivele pentru care continui sa citesti ce-am scris aici…).</font></span></p>
<p><span></span><span><font face="Times New Roman">In afara de asta… am citit niste Bukowski. Si niste Murakami. Si acum servesc niste Eco.</font></span><span><font face="Times New Roman">Si m-am uitat la desene animate.</font></span></p>
<p><span></span><span><font face="Times New Roman">La naiba cu Eliot care zice ca april is the cruellest month.</font></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Urme de sare]]></title>
<link>http://aimoe.wordpress.com/?p=77</link>
<pubDate>Sat, 22 Mar 2008 08:47:31 +0000</pubDate>
<dc:creator>aimoe</dc:creator>
<guid>http://aimoe.wordpress.com/?p=77</guid>
<description><![CDATA[in crudul tau parfum excentric am ars fidel, in tremur
si buzele-mi parca gemeau calcate de fiori
ca]]></description>
<content:encoded><![CDATA[<p><i>in crudul tau parfum excentric am ars fidel, in tremur<br />
si buzele-mi parca gemeau calcate de fiori<br />
caci amorteau firav sub suflu-ti, ca de viori,<br />
ce ma-ncorda, in mute spasme, pe la femur.</p>
<p>ca un inel cu multe noduri te-nconjuram, cu tact,<br />
cand imi slabeam din incordare prea inervata mana,<br />
sub zambete, la colt de ochi, tot mineral se-aduna<br />
gingasele urme de sare, stropind intensul act.</i></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[CRUD Operations Using DOM]]></title>
<link>http://triaslama.wordpress.com/?p=73</link>
<pubDate>Fri, 21 Mar 2008 12:35:19 +0000</pubDate>
<dc:creator>triaslama</dc:creator>
<guid>http://triaslama.wordpress.com/?p=73</guid>
<description><![CDATA[CRUD  (Create, Read, Update, Delete) is common operations in data storage, but now I will try to use]]></description>
<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete">CRUD</a>  (Create, Read, Update, Delete) is common operations in data storage, but now I will try to use <a href="http://en.wikipedia.org/wiki/Document_Object_Model">DOM</a> (Document Object Model) doing CRUD operations toward document content (and I think that is one of DOM objective). DOM can be used for doing CRUD operations easily and effectively. OK that's enough for the buzz words let's make the job done!</p>
<p><b>1. Create an Element</b><br />
To create an element use <b>document.createElement(&#60;<i>elmName</i>&#62;)</b> method. This method receives one parameter that is the name of element that will be created. DOM method <b>document.createTextNode(&#60;<i>text</i>&#62;)</b> is similar to document.createElement but will create a text node instead of an element. The parameter received by document.createTextNode is text that will be created. The other DOM method that important in creating an element is <b>appendChild(&#60;<i>elem</i>&#62;), </b>this method will append the element specified as parameter to an element.<b> </b>Below is an example of add a &#60;li&#62; element to a &#60;ul&#62; element:<br />
<code><br />
var ul = document.getElementsByTagName("ul")[0];<br />
var li = document.createElement("li");<br />
var text = document.createTextNode("'li' element.");</code><code><br />
li.appendChild(text);<br />
ul.appendChild(li);<br />
</code></p>
<p><b>2. Read Text of an Element</b><br />
Please pay a special attention that a text in DOM is considered as a node, so we have to navigate to its text node first before we retrieve / read the node value. So, if 'elm' is a variable that point to a &#60;li&#62; element the following code:<code><br />
var text = elm.firstChild.nodeValue;</code><br />
will retrieve the text inside a &#60;li&#62; element and store the value to a variable named 'text'.</p>
<p><b>3. Update an Element Content</b><br />
Update operation really similar to read operation, except updating an element means we change the node value with the new one. If 'elm' point to a &#60;li&#62; element, the following code:<br />
<code><br />
var newValue = "New text node value";<br />
elm.firstChild.nodeValue = newValue;</code><br />
will change the node value inside &#60;li&#62; element with the content of 'newValue' variable.</p>
<p><b>4. Delete an Element </b><br />
Here, delete an element has two meanings. First delete the text node inside an element, second delete the element itself. Deleting an element can be accomplished using <b>removeChild(&#60;<i>elm</i>&#62;)</b> method. This method receives one parameter, that is child element that will be deleted.<br />
This line of code:<br />
<code>elm.parentNode.removeChild(elm);</code><br />
will remove 'elm' element.</p>
<p>I have write a simple code that demonstrate how to create, read, update, and delete (CRUD) the document content using DOM. I use the Javascript events and blend it with DOM to accomplished CRUD operations, so basic understanding of Javascript events will really helpful.</p>
<p>The code consists of two portions, first portion is html code (crud.htm):</p>
<div style="background-color:#eeeeee;font-family:'courier new';font-size:11px;"> &#60;html&#62;<br />
&#60;head&#62;<br />
&#60;title&#62;CRUD Operations: Complete&#60;/title&#62;<br />
&#60;script lang="javascript" type="text/javascript" src="crud.js" &#62;<br />
&#60;/script&#62;<br />
&#60;/head&#62;<br />
&#60;body&#62;<br />
Want to know why DOM is awesome??<br />
One of the possible answer is: with DOM we can create, read (retrieve), update, and delete document content quickly and easily.<br />
&#60;p/&#62;<br />
&#60;b&#62;Try the following example!&#60;/b&#62;<br />
&#60;br/&#62;<br />
&#60;b&#62;<br />
1. Press 'Add' button to add a new &#60;li&#62; element.&#60;br&#62;<br />
2. Move the mouse cursor over a &#60;li&#62; element below.&#60;br&#62;<br />
3. Click desired &#60;li&#62; element to read the node value.&#60;br&#62;<br />
4. Hold down 'Shift' key and click desired &#60;li&#62; element to update the node value.&#60;br&#62;<br />
5. Hold down 'Ctrl' key and click desired &#60;li&#62; element to delete the &#60;li&#62; element.&#60;br&#62;<br />
&#60;/b&#62;<br />
&#60;p&#62;<br />
&#60;form id="frm" name="frm" style="background-color:yellow; border:solid 2px; border-color:goldenrod;"&#62;<br />
&#60;ul&#62;&#60;b&#62; And here is the list of &#60;li&#62; element:&#60;/b&#62;<br />
&#60;li&#62;First li element.&#60;/li&#62;<br />
&#60;li&#62;Second li element.&#60;/li&#62;<br />
&#60;li&#62;Third li element.&#60;/li&#62;<br />
&#60;li&#62;Fourth li element.&#60;/li&#62;<br />
&#60;li&#62;Fifth li element.&#60;/li&#62;<br />
&#60;/ul&#62;<br />
&#60;p&#62;<br />
&#60;input type="button" id="btnCreate" onclick="addLiElement()" value="Add New &#60;li&#62; Element" /&#62;<br />
&#60;p&#62;<br />
&#60;/form&#62;<br />
&#60;/body&#62;<br />
&#60;/html&#62;</div>
<p>The other one is Javascript code (crud.js, this code is referred by html code), and this is the Javascript code:</p>
<div style="background-color:#eeeeef;font-family:'courier new';font-size:11px;"> <code><br />
window.onload = handleCRUD;<br />
</code><br />
<code><br />
function addLiElement()<br />
{<br />
// ask input text for new &#60;li&#62; element<br />
var txt = window.prompt("Text: ");<br />
var text = document.createTextNode(txt);<br />
// create &#60;li&#62; element<br />
var elm = document.createElement("li");<br />
/* retrieve the first &#60;ul&#62; element (and the only one). */<br />
var ul = document.getElementsByTagName("ul")[0];	elm.appendChild(text);<br />
ul.appendChild(elm);</code><code><br />
handleCRUD();<br />
}<br />
</code><br />
<code><br />
function handleCRUD()<br />
{<br />
var lis = document.getElementsByTagName("li");<br />
for (var i=0;i&#60;lis.length;i++) {<br />
lis[i].onmouseover = function()<br />
{<br />
this.style.backgroundColor = "gainsboro";<br />
};</code><br />
<code><br />
lis[i].onmouseout = function()<br />
{<br />
this.style.backgroundColor = "yellow";<br />
};<br />
</code><br />
/* 'click' event handles read, update, or delete operation */<br />
<code><br />
lis[i].onclick = function(e)<br />
{<br />
// IE handles event through window.event property<br />
e = e&#124;&#124;window.event;<br />
/* again IE handles target (source) element as srcElement */<br />
var elm = e.target&#124;&#124;e.srcElement;<br />
if (e.ctrlKey) {<br />
/* because 'ctrl' key is pressed, it will be delete operation */<br />
var txtNode = elm.firstChild;<br />
// first, delete the text node<br />
txtNode.parentNode.removeChild(txtNode);<br />
// second, delete the &#60;li&#62; element<br />
elm.parentNode.removeChild(elm);<br />
return;<br />
}<br />
if (e.shiftKey) {<br />
/* because 'shift' key is pressed, it will be update operation */<br />
var newValue = window.prompt("Enter new value: ");<br />
elm.firstChild.nodeValue = newValue;<br />
return;<br />
}<br />
else {<br />
/* neither 'ctrl' nor 'shift' key is pressed, it will be read<br />
operation */<br />
/* now, here we retrieve the content (text) of an element */<br />
var content = elm.firstChild.nodeValue;<br />
window.alert(content);<br />
return;<br />
}<br />
};</code><code><br />
}<br />
};<br />
</code></div>
<p>The javascript code started with <b>window.onload</b> that executed after the document is loaded, and passed <b>handleCRUD()</b> function to it. Inside handleCRUD we install mouseover, mouseout, and click events foreach &#60;li&#62; element exist in document.</p>
<p>What is done by each event can be explained as follow:</p>
<li>'Add' button onclick: adds an li element to the document.</li>
<li>onmouseover: changes the background color of a &#60;li&#62; element to 'gainsboro' when mouse cursor enters it.</li>
<li>onmouseout: restores the background color of a &#60;li&#62; element to 'yellow' when mouse cursor leaves it.</li>
<li>onclick, this event has three meanings:
<ol>
<li>when we click an &#60;li&#62; element along with 'Ctrl' key pressed, then the specified &#60;li&#62; element will be deleted.</li>
<li> when we click an &#60;li&#62; element along with 'Shift' key pressed, then the node value of specified &#60;li&#62; element will be updated.</li>
<li> when we click an &#60;li&#62; element and neither 'Ctrl' key nor 'Shift' key is pressed then we simply read the specified &#60;li&#62; element.</li>
</ol>
</li>
<p>onclick event handler receive one parameter that is event object ('e' in this code), but event object in Internet Explorer (IE) available through <b>window.event</b> property. So we need a regular checking 'e' will be still 'e' or if the browser is IE e will be filled with window.event.<br />
<code><br />
e = e&#124;&#124;window.event;<br />
</code></p>
<p>The target (non IE browser) / srcElement (IE) are properties of event object contains a reference to the element that fired to the event. We get target / source element with the following code:<br />
<code><br />
var elm = e.target&#124;&#124;e.srcElement;<br />
</code></p>
<p>This is screenshot output produced by crud.htm &#38; crud.js:</p>
<p><a href="http://triaslama.wordpress.com/files/2008/03/crud_view3.jpg" title="CRUD using DOM"><img src="http://triaslama.wordpress.com/files/2008/03/crud_view3.jpg" alt="CRUD using DOM" /></a></p>
<p>To make the same output as screenshot above puts crud.htm &#38; crud.js in the same directory, type the location in address bar of your browser and you should see the same result.</p>
<p>Thanks for your attentions, see you next time...</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Criando uma aplicação CRUD em Ruby on Rails]]></title>
<link>http://jrjuniorsp.wordpress.com/?p=120</link>
<pubDate>Tue, 18 Mar 2008 18:10:12 +0000</pubDate>
<dc:creator>jrjuniorsp</dc:creator>
<guid>http://jrjuniorsp.wordpress.com/?p=120</guid>
<description><![CDATA[Estou escrevendo uma série de 4 tópicos no meu blog em inglês sobre Rails.
Na verdade é um exemp]]></description>
<content:encoded><![CDATA[<p><img src="http://www.rubyonrails.org/images/rails.png" align="left" border="1" height="112" width="87" />Estou escrevendo uma série de 4 tópicos no meu blog em inglês sobre Rails.</p>
<p>Na verdade é um exemplo bem simples de um CRUD (Create, Read, Update, delete) em Ruby on Rails.</p>
<p>Por enquanto eu só cirei o primeiro e o segundo tópicos.</p>
<p><a href="http://myjavaworld.wordpress.com/2008/02/27/ror-creating-our-first-crud-application-part-1/" target="_blank">O primeiro fala basicamente sobre a configuração do Rails e como criar um form de cadastro (Create) usando vários componentes HTML.</a></p>
<p><a href="http://myjavaworld.wordpress.com/2008/03/18/ror-creating-our-first-crud-application-part-2/" target="_blank">O segundo mostra como fazer uma listagem dos valores do banco de dados. No segundo também, mostra como utilizar o mecanismo de <b>partial</b>, que é bastante usado em Rails. </a></p>
<p><a href="http://myjavaworld.wordpress.com/2008/03/20/ror-creating-our-first-crud-application-part-3/" target="_blank">O terceiro mostra a parte de exclusão (DELETE) e um exemplo de Ajax.</a></p>
<p><a href="http://myjavaworld.wordpress.com/2008/03/24/ror-creating-our-first-crud-application-part-4/" target="_blank">O quarto mostra a parte de alteração (UPDATE), exceção, log e CSS.</a></p>
<p>Para quem está começando em Rails e quer um exemplo simples, acredito que esses tópicos podem ser úteis.</p>
<p>Fica ai a dica.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[On events]]></title>
<link>http://maxtempleton.wordpress.com/?p=6</link>
<pubDate>Wed, 12 Mar 2008 17:48:24 +0000</pubDate>
<dc:creator>Max</dc:creator>
<guid>http://maxtempleton.wordpress.com/?p=6</guid>
<description><![CDATA[With the emerging adoption of event-driven architecture, arguably more important to the improvement ]]></description>
<content:encoded><![CDATA[<p>With the emerging adoption of event-driven architecture, arguably more important to the improvement of the corporate software infrastructure than service-oriented architecture, I thought we might take a fresh look at events per se. After a review, I'll make an argument for extending the standard taxonomy of events to include a new event type , 'observe,' and an argument for extending the standard event model to include the volitional entity who caused the state change. My working understanding of events comes primarily from studying the work of James J. Odell. Mr. Odell published a couple of articles on events in the Journal of Object-Oriented Programming back in the mid-90s. They were collected, along with a number of his other articles, into a book called 'Advanced Object-Oriented Analysis and Design Using UML' in the late 90s, and also eventually turned into a chapters in the books Odell did with James Martin on OOAD.</p>
<p>The state of an object is the current value of all its attributes, including its relationships to other objects.</p>
<p>Odell defines an event as 'a noteworthy change in state [of an object].' I don't agree, but we end up in the same place. I define an event as 'a change in the state of an object.' I believe the 'noteworthy' filter applies to a set of events, Odell that it applies to a set of state changes. I think the 'noteworthy' filter is a practical one, not a logical one. But we end up with a set of noteworthy state changes called events.</p>
<p>Odell holds that there are only two fundamental types of events ('type' is used here in a common sense sort of way - we will bring more meta-model rigor later): 'add' and 'remove'. Add brings something new into existence - a new attribute, a new value of an attribute, a new relationship. Remove destroys something - an existing attribute, the previous value of an attribute.</p>
<p>Odell suggests that these definitions are not 'user-friendly' - that it is useful both to name event types distinctly according to their use, and to combine events that happen in sequence into single event types. While I largely agree with the former, I don't think the latter is a function of convenience, but one that can be addressed in our model.</p>
<p>In Odell's naming events according to their use he is drawing a distinction between an entity's attributes and its relationships, and giving events related to each different names: 'classification' for attributes, 'connection' for relationships. Underlying this is the more fundamental notion that entities have identity, that is, that in instance of an entity has an identity, but that an instance of an attribute does not. The color blue has no discrete identity - we do not track it through time in its actions and relationships. More about identity in another rumination. For now, it is enough to know that there is a useful distinction between an entity's attributes and its relationships, and that Odell's naming convention maps to that distinction.</p>
<p>With respect to combining Odell's fundamental events into compound events, I think it is most useful to simply refine our definition of event to 'an instantaneous change in the state of an object.' This is the logical form. The implementation reality is that there may be some time involved. This is like the distinction between functions and procedures. Functions are timeless, procedures take time.</p>
<p>(On a complete tangent, I wonder about how we define events for continuous processes - those which we would have to capture with differentials. Is it the same?)</p>
<p>Odell ends up with this base taxonomy:</p>
<ul>
<li>Create: bring an object into existence</li>
<li>Terminate: sends an object into non-existence</li>
<li>Classify: an existing object is added to a new set - it gets a new attribute</li>
<li>Declassify: an existing object is removed from a set - it loses an attribute</li>
<li>Connect: add a new relationship between two (or more - my addition) objects</li>
<li>Disconnect: remove a relationship between two (or more) objects</li>
</ul>
<p>Odells goes on to list 'popular' compound events he belives are useful:</p>
<ul>
<li>Reclassification: to replace one classification with another</li>
<li>Reconnection: to replace one relationship with another</li>
</ul>
<p>And three others he is less sure of:</p>
<ul>
<li>Coalesce: combining two (or more - my change) objects into a single object</li>
<li>Decoalesce: splitting an object into two (or more) objects</li>
<li>Compound termination:  termination of an object and all its 'component'  objects</li>
</ul>
<p>Odell points out that reclassification and reconnection are useful in cases where the object is not in a valid overall state 'in between'. This brings another idea into our fundamental definition. A 'prestate' is the necessary state an object must be in for a given event to occur. A 'poststate' is the necessary state an object must be in after a given event occurs.</p>
<p>The entire set of valid transitions for an entity - the full connected prestates-&#62;poststates map - is its lifecycle or finite state machine.</p>
<p>So we again refine our definition of event: ''a instantaneous change in the state of an object from a valid prestate to a valid poststate.'<br />
With our extended definition, it is clear that reclassify, reconnect, coalesce, and decoalesce are first-tier events. (Implementing coalesce and decoalesce is a formidable implementation design challenge.)</p>
<p>Compound termination is not so clear. The example Odell gives for compound termination is that of a sailboat: if we destroy a sailboat, the hull and the motor are also destroyed.</p>
<p>If compound termination exists as an event, I think it may be only for those strong aggregation relationships we call 'composition.'</p>
<p>And my sense of composition is that it somehow works the other direction - akin to the distinction between centripital and centrifugal force. In the sailboat example, the sailboat and hull are in a composition relationship (I think Odell actually uses this example elsewhere in 'Advanced OOP with UML), but the sailboat and motor are not. If the hull is destroyed, the sailboat ceases to exist - new hull, new boat. But if the motor is destroyed, we just get a new motor. But going the other way it is less clear. Obviously if we atomize it (plasmacize it?) with a phaser, they are all destroyed. But that seems more of a simultaneous terminate event happening, not one that somehow logically (and instantly) cascades ('instantly cascades' sounds wrong, doesn't it?) But if the sailboat is destroyed in the sense of being separated into its constituent parts, hull, motor, sails, and we rebuild the boat around the same hull, is it the same boat? This goes back to our question about identity and the continuity of identity. We'll explore this in more detail in that coming rumination. We may find some clarity later here when we talk about agency. In the meantime, we'll leave compound termination off of our list of fundamental events. (In the real world, when a boat is stripped down and rebuilt it is generally rechistened. I spent a couple of days on the Edna, a 90' schooner that was in port in Portimao, Portugal. It was originally a sailboat. But it had been de-masted, motorized, rechistened, and employed as a cargo carrier in the North Sea. The new owners took the boat to Porto, Portugal, where craftsman skilled in work on large sailing ships re-masted it and converted it back into a sailing vessel. And they rechistened it. But I digress :))</p>
<p>Though in common use we call both an event and an event occurrence 'event,' we need to make a more clear distinction here. What we have been calling 'events' are really a supertype of events. We'll borrow from UML (for now) and call those 'Event Stereotypes.' An event is a type which itself is the instance of an event stereotype. An event is associated with a particular class or set of classes, not an object. An 'event occurrence' is an instance of that event type that is associated with a particular instance or set of instances of a class or set of classes, i.e. an object or set of objects.</p>
<p>So our working definition of event occurrence is this:  ''an instance of an event at a particular time for an object."</p>
<p>We can capture the complete history of an object, from creation to termination, by recording information about all of its event occurrences: object(s) (which are of particular types), event (which is a reference to the 'event' type, whose definition includes the prestates and poststates of the objects involved in the event), and time.What is missing from this list, of course, is agency. The state change is the effect - what is the cause? Event occurrences frequently do not occur spontaneously. While there may be some that do - think chrysallis to butterfly - most do not. Our event history, to be complete, should capture the agent of change. We can call these agents 'volitional entities' - that will be the subject of another rumination. For now, we simply recogize that our event history needs to capture the causal agent involved to be complete. If the event is the effect, we must have the cause, otherwise our history is incomplete, disconnected, and of little ultimate utility.</p>
<p>Our event history gets unity by being viewed from the perspective of the object's classes finite state machine - each object life history is the path it traverses through that FSM.</p>
<p>The other thing missing besides agency we can get at by examing the well-known acroynm for an object lifecycle 'CRUD.' CRUD may be defined as CReate, Update, Destroy. But it is more frequently used to mean Create, Read, Update, Destroy. There is a practical distinction between read only access to an entity, and access which writes to it.</p>
<p>But if we look at our taxonomy of events, there is a gap. We have no event whose occurrences will allow us to see the history of reads. In practice, this is a very useful thing to know.</p>
<p>So I suggest we add 'Observed' as a first class event. There is no prestate and poststate with respect to the object alone, but with respect to a given observer or class of observers, there is. If an agent has observed an entity they have knowledge of it.</p>
<p>I will try to expand this idea with real world examples as they come up.</p>
<p>We are left with our definitions and our taxonomy, with a massive debt to James J Odell:</p>
<p>Event stereotype: one of (create, terminate, classify, reclassify, declassify, connect, reconnect, disconnect, observe, coalesce, decoalese) each of which describes possible instantaneous changes of state for one or more objects.</p>
<p>Event: a type which is an instance of an event stereotype associated with a particular class or set of classes and which describes the valid prestates and poststates for the event.</p>
<p>Event occurence: an instance of an event at a particular time caused by a particular agent, which may be the object itself.</p>
<p>Event history: the complete set of event occurrences for a given object.</p>
<p>I will augment this with some pictures at some point - the explanation would benefit greatly from them.</p>
<p>But I think we have established some useful clarity around events. This clarity will be necessary as events inevitably emerge as a fundamental feature of the enterprise computing environment.</p>
]]></content:encoded>
</item>

</channel>
</rss>
