javascript - The Web 2.0 Ecosystem/Stack -


being new front-end website development, can understand stuff, things routes, orm, etc. don't understand how play together. understanding is, there bunch of components website built pyramid/django etc:

  1. a templating engine: abstract away html code. makes sense.

  2. sqlalchemy et al: orm. fine.

  3. a renderer. no idea.

  4. js libraries: jquery et al: no idea use these except adding pretty effects. how interact templating engine? how interact entire framework? can write code jquery in pyramid, or write js separately, plug in js file template or...?

  5. form templating libraries (formish, formalchemy et al): how these relate big picture? plug in?

any other important components i'm missing?

so, me out , explain stack?

1) templating engine: abstract away html code. makes sense.

there's several of these available. mako tries utilize many common python idioms in templates avoid having learn many new concepts. jinja2 similar django, more functionality. genshi if xml based templating.

as new whole thing, it's hard easiest begin unfortunately. perhaps jinja2.

2) sqlalchemy et al. orm. fine.

yep.

3) renderer. no idea.

a renderer pyramid view configuration option, tells pyramid if view returns dict, should passed given 'renderer'. renderers setup work extension names, , pyramid comes several built-in: http://docs.pylonsproject.org/projects/pyramid/1.0/narr/renderers.html#built-in-renderers

in short, renderer option merely looks @ name pass it, , finds template engine matches extension (.mak, .pt, 'json', 'string', .etc), , renders dict results it.

in many frameworks don't designate renderer configuration, instead have code inside view looks this:

def somefunc(request):     return render_to_response('/some/template.mak', {}) 

in pyramid, same thing with:

@view_config(renderer='/some/template.mak') def somefunc(request):     return {} 

there several reasons latter useful capability:

  1. when it's entirely in configuration, can override renderer without having change view code logic.

  2. you can add multiple configurations change renderer based on other conditions.

consider example changes renderer based on if http request xhr (ajax request wants json formatted result, instead of general http request wants html spit out template engine).

@view_config(renderer='json', xhr=true) @view_config(renderer='/some/template.mak') def somefunc(request):     # lookup some_dict_data in db, etc.     return some_dict_data 

4) js libraries: jquery et al. no idea use these except adding pretty effects. how interact templating engine? how interact entire framework? can write code jquery in pyramid, or write js separately, plug in js file template or...?

js libraries make easier write javascript. interact in browser dom, , have no interaction pyramid beyond sending http requests web application might want json formatted results.

to begin with, i'd suggest ignoring javascript entirely until you're more familiar html, dom tree, , getting site works html, css, , web-application.

5) form templating libraries (formish, formalchemy et al) how these relate big picture? plug in?

i highly suggest ignoring entirely, , writing basic html form elements. you're new whole web stack, , there's no need jump straight advanced aspects of web development without getting familiar basics first.

what need though, after writing basic forms, want form validation library makes easier verify form submitted contains valid parameters. in old days of php, people write hundreds of lines of if/else statements went through forms (some still do! ack!).

nowadays use form validation libraries make easy declare valid parameters form. i'd suggest formencode begin with, easy use just validation. pyramid, easiest way going formencode pyramid_simpleform: http://packages.python.org/pyramid_simpleform/

for now, ignore form rendering part , write html form elements in template yourself, , use pyramid_simpleform easy formencode integration.

in short, start displaying html pages links using view functions , templates (and use url dispatch, easier grasp traversal beginners). add forms, html , validation, add css start styling things.

next can start basic javascript jquery make things move around on page, , work way interacting webapp via ajax more data. don't tackle @ once, , should easier see how fit together.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -