[ZWeb] Re: Counter on Products

Kapil Thangavelu k_vertigo@yahoo.com
Sat, 12 Aug 2000 14:35:20 -0700 (PDT)


--- zope-web-admin@zope.org wrote:

> 
> Today's Topics:
> 
>   1. Counter on Products (Spicklemire, Jerry)
> 
> --__--__--
> 
> Message: 1
> From: "Spicklemire, Jerry"
> <Jerry.Spicklemire@IFLYATA.COM>

> Subject: [ZWeb] Counter on Products
> Date: Fri, 11 Aug 2000 17:27:20 -0500
> 
> See:
> 
> 
>
http://www.zope.org/Members/srichter/Products/ZCounter
> 
> 

I was looking for a counter on Products to register
downloads on Zope.org for a product not a counter
product. Although ZCounter would suffice in that role
its not possible as a Product Developer to install it
on zope.org. Someone from DC would have to implement
it. i tried to play around with a very simple property
based counter but you can't overide or edit the
default Product or Software release ZClasses (I assume
Zclasses) pages to actually insert calls to change it.


Thinking about some of the security issues with
granting a user manage_changeProps permissions on the
product it makes the most sense to create a dtml doc
within the Software/Product release, perhaps named
Logs with a counter property and a dtml method
update_logs which increments for every page view of
the user. its relatively easy to make this only update
for unique ips if thats desired.

here are some basic inlined methods to do this, I used
them for my web pages on imeme.net based on a folder
Logs and a tokens property visitors. TMTOWTDI.

Kapil

dtml method add_visitor

<dtml-if "REMOTE_ADDR">
<dtml-in visitors>
        <dtml-if "REMOTE_ADDR==_['sequence-key']">
        
        <dtml-call "REQUEST.set('loopcounter',1 )">

        </dtml-if>
</dtml-in>
<dtml-if "REQUEST.has_key('loopcounter')">
<dtml-else>
	<dtml-call "REQUEST.set('visitors', visitors)">
	<dtml-call "visitors.append( (REMOTE_ADDR, ZopeTime()
) )">
	<dtml-call "manage_changeProperties(REQUEST)">	 
</dtml-if>
<dtml-else>
Already exist
</dtml-if>


dtml method view_logs

<dtml-var standard_html_header>
<table align="center" width="600">

<tr><td align="center"><h3>Visitors</h3></td></tr>
<tr><td align="center">

	<ul>
	<dtml-in visitors>
	<li><dtml-var sequence-item>:<dtml-var
sequence-key></li>	
	</dtml-in>
	</ul>
</td></tr>

<tr><td align="center"><a
href="clear_logs">Clear</a></td></tr>



</table>



__________________________________________________
Do You Yahoo!?
Yahoo! Mail – Free email you can access from anywhere!
http://mail.yahoo.com/