$ fetch \http://www.stackless.com/binaries/stackless-264-export.tar.bz2
$ tar -xvjf stackless-264-export.tar.bz2
$ cd stackless-2.6.4
$ ./configure --prefix=/usr/local/stackless
$ make
$ sudo make install
$ fetch \http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.4.5.tar.gz
$ tar -xvzf virtualenv-1.4.5.tar.gz
$ cd virtualenv-1.4.5
$ sudo /usr/local/stackless/bin/python ./virtualenv.py /usr/local/nagare
sudo /usr/local/nagare/bin/easy_install 'nagare[full]'
$ /usr/local/nagare/bin/nagare-admin create-app test1
Application 'test1' created.
Note:
1. Edit the file 'test1/setup.py' to set the informations about your new application.
2. Register your application with:
- cd "test1"
- "/usr/local/nagare/bin/python" setup.py develop
[application]
path = app test1
name = test1
debug = on
[database]
activated = on
uri = sqlite:///$here/../data/test1.db
metadata = test1.models:__metadata__
debug = on
$ sudo /usr/local/nagare/bin/python ./setup.py develop
$ /usr/local/nagare/bin/nagare-admin serve test1
Application 'app test1' registered as '/test1'
03/17/10 18:00:35 - serving on \http://127.0.0.1:8080
from elixir import * from sqlalchemy import MetaData __metadata__ = MetaData() class GuestBookRecord(Entity): text=Field(Unicode(1000)) name=Field(Unicode(50))
from elixir import * from sqlalchemy import MetaData __metadata__ = MetaData() class GuestBookRecord(Entity): text=Field(Unicode(1000)) name=Field(Unicode(50))
$ /usr/local/nagare/bin/nagare-admin create-db test1
2010-03-17 18:08:22,895 INFO sqlalchemy.engine.base.Engine.0x...ac6c PRAGMA table_info("test1_models_guestbookrecord")
2010-03-17 18:08:22,900 INFO sqlalchemy.engine.base.Engine.0x...ac6c ()
2010-03-17 18:08:22,934 INFO sqlalchemy.engine.base.Engine.0x...ac6c
CREATE TABLE test1_models_guestbookrecord (
id INTEGER NOT NULL,
text VARCHAR(1000),
name VARCHAR(50),
PRIMARY KEY (id)
)
2010-03-17 18:08:22,971 INFO sqlalchemy.engine.base.Engine.0x...ac6c ()
2010-03-17 18:08:22,982 INFO sqlalchemy.engine.base.Engine.0x...ac6c COMMIT
from __future__ import with_statement import os from nagare import presentation, var # from models import * class Test1(object): def __init__(self): self.name=var.Var("") # self.text=var.Var("") # # def add_rec(self): nr=GuestBookRecord() nr.name=self.name() nr.text=self.text() session.save(nr) @presentation.render_for(Test1) def render(self, h, *args): # h<<h.h1("Guest book") # with h.form: with h.table: with h.tr: with h.td: h<<"Name:" with h.td: h<<h.input(type="text", value=self.name()).action(lambda v: self.name(v)) with h.tr: with h.td(valign="top"): h<<"Text:" with h.td: with h.textarea().action(lambda v: self.text(v)): pass with h.tr: with h.td(colspan=2): h<<h.input(type="submit", value="Add").action(self.add_rec) h<<h.hr # : with h.table: recs=GuestBookRecord.query.all() for r in recs: with h.tr: with h.td(valign="top", align="right"): h<<hb(r.name)<<":" with h.td: h<<r.text return h.root # --------------------------------------------------------------- app = Test1
from __future__ import with_statement import os from nagare import presentation, var # from models import * class Test1(object): def __init__(self): self.name=var.Var("") # self.text=var.Var("") # # def add_rec(self): nr=GuestBookRecord() nr.name=self.name() nr.text=self.text() session.save(nr) @presentation.render_for(Test1) def render(self, h, *args): # h<<h.h1("Guest book") # with h.form: with h.table: with h.tr: with h.td: h<<"Name:" with h.td: h<<h.input(type="text", value=self.name()).action(lambda v: self.name(v)) with h.tr: with h.td(valign="top"): h<<"Text:" with h.td: with h.textarea().action(lambda v: self.text(v)): pass with h.tr: with h.td(colspan=2): h<<h.input(type="submit", value="Add").action(self.add_rec) h<<h.hr # : with h.table: recs=GuestBookRecord.query.all() for r in recs: with h.tr: with h.td(valign="top", align="right"): h<<hb(r.name)<<":" with h.td: h<<r.text return h.root # --------------------------------------------------------------- app = Test1
$ /usr/local/nagare/bin/nagare-admin serve test1
Source: https://habr.com/ru/post/87908/
All Articles