librelist archives

« back to archive

Flask & ZODB

Flask & ZODB

From:
dalan.miller@gmail.com
Date:
2012-02-03 @ 22:56
For some reason my ZODB database seems to keep clearing, and I'm not quite
sure why.

Do I need to be using db.commit() at the end of the functions?

Daniel

Re: [flask] Flask & ZODB

From:
Ron DuPlain
Date:
2012-02-03 @ 23:00
On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
<dalan.miller@gmail.com> wrote:
> For some reason my ZODB database seems to keep clearing, and I'm not quite
> sure why.
>
> Do I need to be using db.commit() at the end of the functions?

If you are using Flask-ZODB, no.
https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48

-Ron

Re: [flask] Flask & ZODB

From:
dalan.miller@gmail.com
Date:
2012-02-03 @ 23:14
That is so weird. Basically what is happening is I have one page that
submits a post to another page, and then the new page reflects that
submitted data, and if I stay there and refresh a couple times (it seems to
be after a little bit of time) all of a sudden it's like the database
empties.

Any thoughts?

On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:

> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
> <dalan.miller@gmail.com> wrote:
> > For some reason my ZODB database seems to keep clearing, and I'm not
> quite
> > sure why.
> >
> > Do I need to be using db.commit() at the end of the functions?
>
> If you are using Flask-ZODB, no.
> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
>
> -Ron
>

Re: [flask] Flask & ZODB

From:
Ron DuPlain
Date:
2012-02-03 @ 23:29
Could you provide a paste or something that demonstrates the problem?
I'm on #pocoo on irc if you'd like to discuss there.
http://flask.pocoo.org/community/irc/

-Ron


On Fri, Feb 3, 2012 at 6:14 PM, dalan.miller@gmail.com
<dalan.miller@gmail.com> wrote:
> That is so weird. Basically what is happening is I have one page that
> submits a post to another page, and then the new page reflects that
> submitted data, and if I stay there and refresh a couple times (it seems to
> be after a little bit of time) all of a sudden it's like the database
> empties.
>
> Any thoughts?
>
>
> On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>>
>> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
>> <dalan.miller@gmail.com> wrote:
>> > For some reason my ZODB database seems to keep clearing, and I'm not
>> > quite
>> > sure why.
>> >
>> > Do I need to be using db.commit() at the end of the functions?
>>
>> If you are using Flask-ZODB, no.
>> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
>>
>> -Ron
>
>

Re: [flask] Flask & ZODB

From:
dalan.miller@gmail.com
Date:
2012-02-04 @ 00:22
Yeah for sure,

http://hastebin.com/dolisugijo.py

It seems like it happens whenever I'm looking at a /build/<build_date page
and then I modify the code, flask restarts, but the ZODB data is gone?




On Fri, Feb 3, 2012 at 3:29 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:

> Could you provide a paste or something that demonstrates the problem?
> I'm on #pocoo on irc if you'd like to discuss there.
> http://flask.pocoo.org/community/irc/
>
> -Ron
>
>
> On Fri, Feb 3, 2012 at 6:14 PM, dalan.miller@gmail.com
> <dalan.miller@gmail.com> wrote:
> > That is so weird. Basically what is happening is I have one page that
> > submits a post to another page, and then the new page reflects that
> > submitted data, and if I stay there and refresh a couple times (it seems
> to
> > be after a little bit of time) all of a sudden it's like the database
> > empties.
> >
> > Any thoughts?
> >
> >
> > On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain <ron.duplain@gmail.com>
> wrote:
> >>
> >> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
> >> <dalan.miller@gmail.com> wrote:
> >> > For some reason my ZODB database seems to keep clearing, and I'm not
> >> > quite
> >> > sure why.
> >> >
> >> > Do I need to be using db.commit() at the end of the functions?
> >>
> >> If you are using Flask-ZODB, no.
> >> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
> >>
> >> -Ron
> >
> >
>

Re: [flask] Flask & ZODB

From:
Ron DuPlain
Date:
2012-02-04 @ 01:02
The ZODB interactions look fine.  It looks like the date is handled
inconsistently.  Compare:

    date = request.form['date'].replace("/","_")

with:

    Build(request.form['date'],request.form, request.form['environ'])

-Ron


On Fri, Feb 3, 2012 at 7:22 PM, dalan.miller@gmail.com
<dalan.miller@gmail.com> wrote:
> Yeah for sure,
>
> http://hastebin.com/dolisugijo.py
>
> It seems like it happens whenever I'm looking at a /build/<build_date page
> and then I modify the code, flask restarts, but the ZODB data is gone?
>
>
>
>
> On Fri, Feb 3, 2012 at 3:29 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>>
>> Could you provide a paste or something that demonstrates the problem?
>> I'm on #pocoo on irc if you'd like to discuss there.
>> http://flask.pocoo.org/community/irc/
>>
>> -Ron
>>
>>
>> On Fri, Feb 3, 2012 at 6:14 PM, dalan.miller@gmail.com
>> <dalan.miller@gmail.com> wrote:
>> > That is so weird. Basically what is happening is I have one page that
>> > submits a post to another page, and then the new page reflects that
>> > submitted data, and if I stay there and refresh a couple times (it seems
>> > to
>> > be after a little bit of time) all of a sudden it's like the database
>> > empties.
>> >
>> > Any thoughts?
>> >
>> >
>> > On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain <ron.duplain@gmail.com>
>> > wrote:
>> >>
>> >> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
>> >> <dalan.miller@gmail.com> wrote:
>> >> > For some reason my ZODB database seems to keep clearing, and I'm not
>> >> > quite
>> >> > sure why.
>> >> >
>> >> > Do I need to be using db.commit() at the end of the functions?
>> >>
>> >> If you are using Flask-ZODB, no.
>> >> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
>> >>
>> >> -Ron
>> >
>> >
>
>

Re: [flask] Flask & ZODB

From:
dalan.miller@gmail.com
Date:
2012-02-06 @ 18:30
Hmmm I changed that, but it still seems to be doing that. After the /build
post request the "build" is added into ZODB but then say I'm viewing the
"build" /build/2012_02_06 for example if I then change the code and then
save, then flask restarts my app, everything in ZODB is now gone.

I was thinking that somewhere I had code that was resetting the db or
something but nothing yet =/. The weird thing is, is that I'm following (I
believe) pretty closely another app that I have been writing that uses ZODB
that doesn't have this problem. So I'm not quite sure what it is wrong.


On Fri, Feb 3, 2012 at 5:02 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:

> The ZODB interactions look fine.  It looks like the date is handled
> inconsistently.  Compare:
>
>    date = request.form['date'].replace("/","_")
>
> with:
>
>    Build(request.form['date'],request.form, request.form['environ'])
>
> -Ron
>
>
> On Fri, Feb 3, 2012 at 7:22 PM, dalan.miller@gmail.com
> <dalan.miller@gmail.com> wrote:
> > Yeah for sure,
> >
> > http://hastebin.com/dolisugijo.py
> >
> > It seems like it happens whenever I'm looking at a /build/<build_date
> page
> > and then I modify the code, flask restarts, but the ZODB data is gone?
> >
> >
> >
> >
> > On Fri, Feb 3, 2012 at 3:29 PM, Ron DuPlain <ron.duplain@gmail.com>
> wrote:
> >>
> >> Could you provide a paste or something that demonstrates the problem?
> >> I'm on #pocoo on irc if you'd like to discuss there.
> >> http://flask.pocoo.org/community/irc/
> >>
> >> -Ron
> >>
> >>
> >> On Fri, Feb 3, 2012 at 6:14 PM, dalan.miller@gmail.com
> >> <dalan.miller@gmail.com> wrote:
> >> > That is so weird. Basically what is happening is I have one page that
> >> > submits a post to another page, and then the new page reflects that
> >> > submitted data, and if I stay there and refresh a couple times (it
> seems
> >> > to
> >> > be after a little bit of time) all of a sudden it's like the database
> >> > empties.
> >> >
> >> > Any thoughts?
> >> >
> >> >
> >> > On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain <ron.duplain@gmail.com>
> >> > wrote:
> >> >>
> >> >> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
> >> >> <dalan.miller@gmail.com> wrote:
> >> >> > For some reason my ZODB database seems to keep clearing, and I'm
> not
> >> >> > quite
> >> >> > sure why.
> >> >> >
> >> >> > Do I need to be using db.commit() at the end of the functions?
> >> >>
> >> >> If you are using Flask-ZODB, no.
> >> >> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
> >> >>
> >> >> -Ron
> >> >
> >> >
> >
> >
>

Re: [flask] Flask & ZODB

From:
dalan.miller@gmail.com
Date:
2012-02-06 @ 18:40
[SOLVED!]

After reading something about ZODB tries not to overwrite things when it
doesn't have to, especially when it comes to immutable data structures. I
tried changing this:

db['BUILDS'].update({date:build})

to this:

a = db['BUILDS']
a.update({date:build})
db['BUILDS'] = a

I think the reassignment of the value of db['BUILDS'] is what makes the
difference, and has been working so far so good for now.

Dan

On Mon, Feb 6, 2012 at 10:30 AM, dalan.miller@gmail.com <
dalan.miller@gmail.com> wrote:

> Hmmm I changed that, but it still seems to be doing that. After the /build
> post request the "build" is added into ZODB but then say I'm viewing the
> "build" /build/2012_02_06 for example if I then change the code and then
> save, then flask restarts my app, everything in ZODB is now gone.
>
> I was thinking that somewhere I had code that was resetting the db or
> something but nothing yet =/. The weird thing is, is that I'm following (I
> believe) pretty closely another app that I have been writing that uses ZODB
> that doesn't have this problem. So I'm not quite sure what it is wrong.
>
>
> On Fri, Feb 3, 2012 at 5:02 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>
>> The ZODB interactions look fine.  It looks like the date is handled
>> inconsistently.  Compare:
>>
>>    date = request.form['date'].replace("/","_")
>>
>> with:
>>
>>    Build(request.form['date'],request.form, request.form['environ'])
>>
>> -Ron
>>
>>
>> On Fri, Feb 3, 2012 at 7:22 PM, dalan.miller@gmail.com
>> <dalan.miller@gmail.com> wrote:
>> > Yeah for sure,
>> >
>> > http://hastebin.com/dolisugijo.py
>> >
>> > It seems like it happens whenever I'm looking at a /build/<build_date
>> page
>> > and then I modify the code, flask restarts, but the ZODB data is gone?
>> >
>> >
>> >
>> >
>> > On Fri, Feb 3, 2012 at 3:29 PM, Ron DuPlain <ron.duplain@gmail.com>
>> wrote:
>> >>
>> >> Could you provide a paste or something that demonstrates the problem?
>> >> I'm on #pocoo on irc if you'd like to discuss there.
>> >> http://flask.pocoo.org/community/irc/
>> >>
>> >> -Ron
>> >>
>> >>
>> >> On Fri, Feb 3, 2012 at 6:14 PM, dalan.miller@gmail.com
>> >> <dalan.miller@gmail.com> wrote:
>> >> > That is so weird. Basically what is happening is I have one page that
>> >> > submits a post to another page, and then the new page reflects that
>> >> > submitted data, and if I stay there and refresh a couple times (it
>> seems
>> >> > to
>> >> > be after a little bit of time) all of a sudden it's like the database
>> >> > empties.
>> >> >
>> >> > Any thoughts?
>> >> >
>> >> >
>> >> > On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain <ron.duplain@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
>> >> >> <dalan.miller@gmail.com> wrote:
>> >> >> > For some reason my ZODB database seems to keep clearing, and I'm
>> not
>> >> >> > quite
>> >> >> > sure why.
>> >> >> >
>> >> >> > Do I need to be using db.commit() at the end of the functions?
>> >> >>
>> >> >> If you are using Flask-ZODB, no.
>> >> >> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
>> >> >>
>> >> >> -Ron
>> >> >
>> >> >
>> >
>> >
>>
>
>

Re: [flask] Flask & ZODB

From:
Ronny Pfannschmidt
Date:
2012-02-07 @ 11:22
I think this issue is related to plain python objects versus change 
tracking ZODB object,

the explicit assignment triggers the update

you might want to investigate what options ZODB has for persistent 
mappings in order to get rid of such workarounds

also it might be helpful to have mapping that doesn't need to be loaded 
completely into memory

-- Ronny

On 02/06/2012 07:40 PM, dalan.miller@gmail.com wrote:
> [SOLVED!]
>
> After reading something about ZODB tries not to overwrite things when it
> doesn't have to, especially when it comes to immutable data structures. I
> tried changing this:
>
> db['BUILDS'].update({date:build})
>
> to this:
>
> a = db['BUILDS']
> a.update({date:build})
> db['BUILDS'] = a
>
> I think the reassignment of the value of db['BUILDS'] is what makes the
> difference, and has been working so far so good for now.
>
> Dan
>
> On Mon, Feb 6, 2012 at 10:30 AM, dalan.miller@gmail.com<
> dalan.miller@gmail.com>  wrote:
>
>> Hmmm I changed that, but it still seems to be doing that. After the /build
>> post request the "build" is added into ZODB but then say I'm viewing the
>> "build" /build/2012_02_06 for example if I then change the code and then
>> save, then flask restarts my app, everything in ZODB is now gone.
>>
>> I was thinking that somewhere I had code that was resetting the db or
>> something but nothing yet =/. The weird thing is, is that I'm following (I
>> believe) pretty closely another app that I have been writing that uses ZODB
>> that doesn't have this problem. So I'm not quite sure what it is wrong.
>>
>>
>> On Fri, Feb 3, 2012 at 5:02 PM, Ron DuPlain<ron.duplain@gmail.com>  wrote:
>>
>>> The ZODB interactions look fine.  It looks like the date is handled
>>> inconsistently.  Compare:
>>>
>>>     date = request.form['date'].replace("/","_")
>>>
>>> with:
>>>
>>>     Build(request.form['date'],request.form, request.form['environ'])
>>>
>>> -Ron
>>>
>>>
>>> On Fri, Feb 3, 2012 at 7:22 PM, dalan.miller@gmail.com
>>> <dalan.miller@gmail.com>  wrote:
>>>> Yeah for sure,
>>>>
>>>> http://hastebin.com/dolisugijo.py
>>>>
>>>> It seems like it happens whenever I'm looking at a /build/<build_date
>>> page
>>>> and then I modify the code, flask restarts, but the ZODB data is gone?
>>>>
>>>>
>>>>
>>>>
>>>> On Fri, Feb 3, 2012 at 3:29 PM, Ron DuPlain<ron.duplain@gmail.com>
>>> wrote:
>>>>>
>>>>> Could you provide a paste or something that demonstrates the problem?
>>>>> I'm on #pocoo on irc if you'd like to discuss there.
>>>>> http://flask.pocoo.org/community/irc/
>>>>>
>>>>> -Ron
>>>>>
>>>>>
>>>>> On Fri, Feb 3, 2012 at 6:14 PM, dalan.miller@gmail.com
>>>>> <dalan.miller@gmail.com>  wrote:
>>>>>> That is so weird. Basically what is happening is I have one page that
>>>>>> submits a post to another page, and then the new page reflects that
>>>>>> submitted data, and if I stay there and refresh a couple times (it
>>> seems
>>>>>> to
>>>>>> be after a little bit of time) all of a sudden it's like the database
>>>>>> empties.
>>>>>>
>>>>>> Any thoughts?
>>>>>>
>>>>>>
>>>>>> On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain<ron.duplain@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
>>>>>>> <dalan.miller@gmail.com>  wrote:
>>>>>>>> For some reason my ZODB database seems to keep clearing, and I'm
>>> not
>>>>>>>> quite
>>>>>>>> sure why.
>>>>>>>>
>>>>>>>> Do I need to be using db.commit() at the end of the functions?
>>>>>>>
>>>>>>> If you are using Flask-ZODB, no.
>>>>>>> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
>>>>>>>
>>>>>>> -Ron
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>
>>
>

Re: [flask] Flask & ZODB

From:
Brice Leroy
Date:
2012-02-04 @ 00:33
Have you tried a non-relative path for the database (ZODB_STORAGE
parameter) ?

2012/2/3 dalan.miller@gmail.com <dalan.miller@gmail.com>

> Yeah for sure,
>
> http://hastebin.com/dolisugijo.py
>
> It seems like it happens whenever I'm looking at a /build/<build_date page
> and then I modify the code, flask restarts, but the ZODB data is gone?
>
>
>
>
> On Fri, Feb 3, 2012 at 3:29 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>
>> Could you provide a paste or something that demonstrates the problem?
>> I'm on #pocoo on irc if you'd like to discuss there.
>> http://flask.pocoo.org/community/irc/
>>
>> -Ron
>>
>>
>> On Fri, Feb 3, 2012 at 6:14 PM, dalan.miller@gmail.com
>> <dalan.miller@gmail.com> wrote:
>> > That is so weird. Basically what is happening is I have one page that
>> > submits a post to another page, and then the new page reflects that
>> > submitted data, and if I stay there and refresh a couple times (it
>> seems to
>> > be after a little bit of time) all of a sudden it's like the database
>> > empties.
>> >
>> > Any thoughts?
>> >
>> >
>> > On Fri, Feb 3, 2012 at 3:00 PM, Ron DuPlain <ron.duplain@gmail.com>
>> wrote:
>> >>
>> >> On Fri, Feb 3, 2012 at 5:56 PM, dalan.miller@gmail.com
>> >> <dalan.miller@gmail.com> wrote:
>> >> > For some reason my ZODB database seems to keep clearing, and I'm not
>> >> > quite
>> >> > sure why.
>> >> >
>> >> > Do I need to be using db.commit() at the end of the functions?
>> >>
>> >> If you are using Flask-ZODB, no.
>> >> https://github.com/dag/flask-zodb/blob/master/flask_zodb.py#L48
>> >>
>> >> -Ron
>> >
>> >
>>
>
>


-- 
blog: http://www.debrice.com
Time tracking tool: http://alpha.kaaloo.com
Django site generator: http://alpha.djangogenerator.com
linkedin: http://www.linkedin.com/in/bricepleroy