Setting a custom field in flowscript alters value of another field

View: New views
4 Messages — Rating Filter:   Alert me  

Setting a custom field in flowscript alters value of another field

by Nick-89 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello All,

I've implemented a simple hit counter that adjusts a custom field ("HitCount")
on a document every time the document is refreshed. I'm doing this by calling an
extension that grabs the document, updates its hit count by calling:

document.setCustomField("HitCount", java.lang.Integer.parseInt(hits));
document.save();


On certain documents, I have a field called DocumentPostDate (not a custom
field, but one I defined in the Administration tab). This field contains a date
value that is set once when the document is created and then never adjusted.

The problem is, when I call setCustomField(), it (for some reason) is
decrementing the DocumentPostDate field. This happens no matter what custom
field I'm setting (I see the same problem if I change it to
document.setCustomField("NewField", "New Value")), and it stops happening as
soon as I comment out the call to setCustomField().

After some further testing with various fields, it looks like it always
decrements date values (but doesn't affect any other field types as far as I can
tell).

Does anybody have any clue what could be happening here?

Thanks in advance,

Nick


_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

Re: Setting a custom field in flowscript alters value of another field

by Paul Focke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Nick

Are you experiencing the same problems when adding custom fields through the default daisy editor?

Aside from this I'd also advise against using custom fields for document hit counts. First of all you'll probably get some errors when trying to record hit counts when someone is editing the document. Of course you might be able to solve this by using some kind of queuing system. Secondly when a document has been edited the navigation tree will be invalidated which means it'll have to rebuilt on the next request. Since everytime you consult a document you are changing it means that the whole navigation will be rebuilt on every request. Now for small navigation trees this won't really be a biggy but might become a pain when you have query based navigation nodes and a large document set. So maybe it would be better to store document hit counts in a separate database.

But that aside it is weird that editing a custom field has an influence on another field. If you are only getting this in your extension (not the document editor) then maybe it might be a good idea to look over the code to see that you aren't accidently modifing the date field. If you are getting this in the document editor then we might be dealing with a bug here. The daisy version you are using might also be useful to us.


Paul

On Thu, Jul 2, 2009 at 5:50 PM, Nick <mcdonaldn2000@...> wrote:
Hello All,

I've implemented a simple hit counter that adjusts a custom field ("HitCount")
on a document every time the document is refreshed. I'm doing this by calling an
extension that grabs the document, updates its hit count by calling:

document.setCustomField("HitCount", java.lang.Integer.parseInt(hits));
document.save();


On certain documents, I have a field called DocumentPostDate (not a custom
field, but one I defined in the Administration tab). This field contains a date
value that is set once when the document is created and then never adjusted.

The problem is, when I call setCustomField(), it (for some reason) is
decrementing the DocumentPostDate field. This happens no matter what custom
field I'm setting (I see the same problem if I change it to
document.setCustomField("NewField", "New Value")), and it stops happening as
soon as I comment out the call to setCustomField().

After some further testing with various fields, it looks like it always
decrements date values (but doesn't affect any other field types as far as I can
tell).

Does anybody have any clue what could be happening here?

Thanks in advance,

Nick


_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy


_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

Re: Setting a custom field in flowscript alters value of another field

by Nick-89 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paul Focke <paul@...> writes:

>
>
> Are you experiencing the same problems when adding custom fields through the
default daisy editor?

Hi Paul,

Thanks for the reply! I ran some tests in the default Daisy editor and I believe
I'm seeing the same behavior (so that if I add a custom field and save, my date
field decrements by one, if I add two custom fields, it decrements by two, etc.)

I'm confident that our code isn't touching the date field - if we comment out
the setCustomField() call (and no other code) the date field doesn't get updated.

We're running Daisy 2.2 - strangely, as far as I can tell, this only started
happening recently, and we didn't make any changes (to the extension or to Daisy
itself) that I know of.

Thanks for the tip on the hit count, too! We weren't aware of that - our
navigation trees are pretty small - generally ~40-80 documents in a tree for a
site - and statically defined (no queries). I'm not sure whether switching
implementations would be worth it right now, but I'll make sure to note it for
the future!

We've actually moved to a different implementation for this date field for now,
so it's not urgent for us to get this fixed. I'm still curious as to what
the problem could have been, though :). Let me know if I can provide any more
information!

Thanks,

Nick

_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

Re: Re: Setting a custom field in flowscript alters value of another field

by Bruno Dumon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I wonder if this could have something to do with timezones, testing
with a datetime field could reveal this.

On Fri, Jul 10, 2009 at 11:43 PM, Nick<mcdonaldn2000@...> wrote:

> Paul Focke <paul@...> writes:
>
>>
>>
>> Are you experiencing the same problems when adding custom fields through the
> default daisy editor?
>
> Hi Paul,
>
> Thanks for the reply! I ran some tests in the default Daisy editor and I believe
> I'm seeing the same behavior (so that if I add a custom field and save, my date
> field decrements by one, if I add two custom fields, it decrements by two, etc.)
>
> I'm confident that our code isn't touching the date field - if we comment out
> the setCustomField() call (and no other code) the date field doesn't get updated.
>
> We're running Daisy 2.2 - strangely, as far as I can tell, this only started
> happening recently, and we didn't make any changes (to the extension or to Daisy
> itself) that I know of.
>
> Thanks for the tip on the hit count, too! We weren't aware of that - our
> navigation trees are pretty small - generally ~40-80 documents in a tree for a
> site - and statically defined (no queries). I'm not sure whether switching
> implementations would be worth it right now, but I'll make sure to note it for
> the future!
>
> We've actually moved to a different implementation for this date field for now,
> so it's not urgent for us to get this fixed. I'm still curious as to what
> the problem could have been, though :). Let me know if I can provide any more
> information!
>
> Thanks,
>
> Nick
>

--
Bruno Dumon
Outerthought ~ http://outerthought.org/
Daisy ~ http://www.daisycms.org/
Kauri ~ http://www.kauriproject.org/
_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy