...
for a GET:
GET.1) sling determines the representation wanted and finds the handler (script/servlet)
GET.2) this is done by looking at sling:resourceType (an attachement to the JCR node) and calling "resourceresourceType/<extension>.js" (.js could be .py, .rb, whatever scripting language is available)
GET.2) handler runs with full access to its resource (JCR node)
...