More REQUEST.set not incrementing SUCCESS!
Thanks to all the folks who responded with a bunch of good ides. The prize for the most appropriate solution for this particular problem goes to Jim Sanford, and here's the final code that did the trick : <dtml-call "REQUEST.set('z_t',_.string.split(_.str(ZopeTime()))[0])"> <dtml-call "REQUEST.set('u_all',_.string.atoi('0'))"> <dtml-call "REQUEST.set('u_logged',_.string.atoi('0'))"> <dtml-call "REQUEST.set('u_today',_.string.atoi('0'))"> <dtml-call "REQUEST.set('u_not',_.string.atoi('0'))"> <dtml-var u_all> <dtml-var u_logged> <dtml-var u_today><br> <dtml-in count_users_logged> <dtml-let t_all="u_all+1"> <dtml-call "REQUEST.set('u_all',t_all)"> </dtml-let> <dtml-if logged_on> <dtml-let t_logged="u_logged+1"> <dtml-call "REQUEST.set('u_logged',t_logged)"> </dtml-let> <dtml-if "_['z_t']==_.string.split(_.str(_.DateTime(logged_on)))[0]"> <dtml-let t_today="u_today+1"> <dtml-call "REQUEST.set('u_today',t_today)"> </dtml-let> </dtml-if> <dtml-else> <dtml-let t_not="u_not+1"> <dtml-call "REQUEST.set('u_not',t_not)"> </dtml-let> </dtml-if> </dtml-in> It looks (to me) like the reason this works, and other permutations failed, is that <dtml-let> bahaves slightly differently than <dtml-call "REQUEST.set">, as far as persistence of values. I'm not sure if this way of getting there suffers from the data.fs bloat problem, but I'll be watching to see if there's anything detectable. Of course the SQL Gurus out there will be thinking that a series of "select count queries might be faster, but we need to track new logins, which requires checking every row every day, so why not let Zope handle it. Thanks again, Jerry S.
On Wed, 12 Jan 2000 Jerry.Spicklemire@IFLYATA.COM wrote:
<dtml-call "REQUEST.set('z_t',_.string.split(_.str(ZopeTime()))[0])"> <dtml-call "REQUEST.set('u_all',_.string.atoi('0'))"> <dtml-call "REQUEST.set('u_logged',_.string.atoi('0'))"> <dtml-call "REQUEST.set('u_today',_.string.atoi('0'))"> <dtml-call "REQUEST.set('u_not',_.string.atoi('0'))">
<dtml-var u_all> <dtml-var u_logged> <dtml-var u_today><br> <dtml-in count_users_logged> <dtml-let t_all="u_all+1"> <dtml-call "REQUEST.set('u_all',t_all)"> </dtml-let> <dtml-if logged_on> <dtml-let t_logged="u_logged+1"> <dtml-call "REQUEST.set('u_logged',t_logged)"> </dtml-let> <dtml-if "_['z_t']==_.string.split(_.str(_.DateTime(logged_on)))[0]"> <dtml-let t_today="u_today+1"> <dtml-call "REQUEST.set('u_today',t_today)"> </dtml-let> </dtml-if> <dtml-else> <dtml-let t_not="u_not+1"> <dtml-call "REQUEST.set('u_not',t_not)"> </dtml-let> </dtml-if> </dtml-in>
Out of curiosity, does the following work? <dtml-call "REQUEST.set('z_t', _.string.split(_.str(ZopeTime()))[0])"> <dtml-call "REQUEST.set('u_all', 0)"> <dtml-call "REQUEST.set('u_logged', 0)"> <dtml-call "REQUEST.set('u_today', 0)"> <dtml-call "REQUEST.set('u_not', 0)"> <dtml-var u_all> <dtml-var u_logged> <dtml-var u_today><br> <dtml-in count_users_logged> <dtml-call "REQUEST.set('u_all', u_all + 1)"> <dtml-if logged_on> <dtml-call "REQUEST.set('u_logged', u_logged + 1)"> <dtml-if "_['z_t']==_.string.split(_.str(_.DateTime(logged_on)))[0]"> <dtml-call "REQUEST.set('u_today', u_today + 1)"> </dtml-if> <dtml-else> <dtml-call "REQUEST.set('u_not', u_not + 1)"> </dtml-if> </dtml-in> If not, what does it do wrong? I don't know about you, but the above looks MUCH easier to read to me, and seems less redundant.
I'm not sure if this way of getting there suffers from the data.fs bloat problem, but I'll be watching to see if there's anything detectable.
It should not have any effect on Data.fs. Data.fs is only affected when something in the ZODB is changed. In this case, nothing is being touched in the ZODB; in this case, variables are set in the REQUEST and incremented inside the <dtml-in> construct, which is not altering any persistent data, AFAICT.
Jerry S.
--Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
On Wed, 12 Jan 2000 Jerry.Spicklemire@IFLYATA.COM wrote:
It looks (to me) like the reason this works, and other permutations failed, is that <dtml-let> bahaves slightly differently than <dtml-call "REQUEST.set">, as far as persistence of values.
Variables set with dtml-let are only available in the enclosing namespace, whereas ones set with REQUEST.set are available in the whole namespace of an individual request. Probably your problem was related to this.
I'm not sure if this way of getting there suffers from the data.fs bloat problem, but I'll be watching to see if there's anything detectable.
No. The above code won't create any such problems. One more suggestion. The object DateTime includes many useful functions descriped in the source. For example: <dtml-if "_['z_t']==_.string.split(_.str(_.DateTime(logged_on)))[0]"> could be written like: <dtml-if "_.DateTime(logged_on).isCurrentDay()"> Pavlos
participants (3)
-
Jeff K. Hoffman -
Jerry.Spicklemire@IFLYATA.COM -
Pavlos Christoforou