use sqlalchemy4.5 with elixir
and the template system is moko
when I update the datebase then refresh the page
the updated items sometimes show and sometimes not
I think maybe the moko or sqlalchemy or elixir buffered the query result .
but how to solve this problem ?
thanks
--
博客:http://zsp.javaeye.com/
个人网站:http://zsp007.com.cn/
电子科大,7月就要毕业了,何去何从...
双学位:生物医学工程+计算机科学与技术
-- 张教主
> I write a web with pylons 0.97 dev beta3
>
> use sqlalchemy4.5 with elixir
>
> and the template system is moko
>
> when I update the datebase then refresh the page
>
> the updated items sometimes show and sometimes not
>
> I think maybe the moko or sqlalchemy or elixir buffered the query
> result .
>
> but how to solve this problem ?
>
clear out your session - session.clear().
but I still have some problems
It's to say I should clear session manual once I update the database ?
can I set timeout somewhere to auto do this job ?
--
> thanks for you answer :)
>
> but I still have some problems
>
> It's to say I should clear session manual once I update the database ?
>
> can I set timeout somewhere to auto do this job ?
>
for a web application, you usually use a Session for the lifespan of a
request - at the end of the request, you close it out.
Pylons tutorial has an illustration of this pattern over at http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons
. About halfway through, the example illustartes modifying the base
controller to say:
def __call__(self, environ, start_response):
try:
return WSGIController.__call__(self, environ, start_response)
finally:
meta.Session.remove()
SQLAlchemy 0.4.6 (likely version) will include an "auto-expire-on-
commit()" feature which will make this step unnecessary, if you use a
fully transactional Session.
I think maybe two reason:
1.elixir cached the query when I used Iike feed.posts ( OneToMany)
OR
2.mako cached the query result , because I did the feed.posts query in template
.................
A headache problem .
--
Blog(Chinese Edition):
http://zsp.javaeye.com/
Resume(Also Chinese):
http://zsp007.com.cn/
Where graduate soon , where to go ......
Double major:
Biomedical Engineering
Computer Science
-- Hierarch Zhang
> I tried both remove and clear
> but seems have no effect
>
> I think maybe two reason:
>
> 1.elixir cached the query when I used Iike feed.posts ( OneToMany)
mmm I dont think elixir is caching anything additional. However, if
you have a collection on an object, that is just a plain collection,
like a list - once its loaded, its loaded, unless you say
session.expire(object, ['collectionname']).
An alternative is to use a "Dynamic" relation, which will issue the
SQL to the database on each access (but still will return objects
cached in the Session if already found): http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_largecollections_dynamic
> 2.mako cached the query result , because I did the feed.posts query
> in template
only if you are using Mako cache options explicitly - nothing caches
by default.
class Feed(Entity):
has_property('posts',dynamic_loader(Post))
everything is ok !
My english is pool , so I don't know how to express the appreciate for
your help .
I just want to say THANKS VERY VERY MUCH :)
--