~divmod-dev/divmod.org/dangling-1091

« back to all changes in this revision

Viewing changes to ClickChronicle/cc.py

  • Committer: amir
  • Date: 2005-09-02 15:02:28 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:182
CamelCaps

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from axiom.item import Item
 
2
from axiom import attributes
 
3
from zope.interface import implements
 
4
from xmantissa.webnav import Tab
 
5
from xmantissa.ixmantissa import INavigableElement, IBenefactor
 
6
from xmantissa.webadmin import ParentCounterMixin
 
7
from nevow import loaders, rend, livepage
 
8
from twisted.python.components import registerAdapter
 
9
from xmantissa.webadmin import WebSite, PrivateApplication
 
10
 
 
11
#class ClickChronicleApplication( PrivateApplication ):
 
12
    #implements( INavigableElement )
 
13
    #typeName = 'clickchronicle_application'
 
14
    #schemaVersion = 1
 
15
    #urlCount = attributes.integer( default = 0 )
 
16
 
 
17
    #def install( self ):
 
18
    #    self.store.powerUp( self, INavigableElement )
 
19
 
 
20
    #def getTabs( self ):
 
21
    #    return [Tab('Admin', self.storeID, 0.0,
 
22
    #                [Tab('Magical', self.storeID, 0.1)])]
 
23
 
 
24
    #def createResource( self, a, b, c, d, e, f, g ):
 
25
    #    pass
 
26
#    pass
 
27
from xmantissa.ixmantissa import INavigableFragment
 
28
class Visit( Item ):
 
29
    timestamp = attributes.timestamp()
 
30
    url = attributes.text()
 
31
 
 
32
    schemaVersion = 1
 
33
    typeName = 'visit'
 
34
 
 
35
from nevow.inevow import IResource, IQ
 
36
 
 
37
class LinkList( rend.Page ):
 
38
    implements( IResource )
 
39
    docFactory = loaders.xmlfile( 'linklist.xml' )
 
40
 
 
41
    def __init__( self, *a, **k ):
 
42
        rend.Page.__init__( self, *a, **k )
 
43
        self.store = self.original.store
 
44
 
 
45
    def data_links( self, ctx, data ):
 
46
        for visit in self.store.query( Visit ):
 
47
            yield dict( timestamp = visit.timestamp, url = visit.url )
 
48
 
 
49
class ClickChronicleApplication( Item, ParentCounterMixin ):
 
50
    implements( INavigableElement )
 
51
    typeName = 'clickchronicle_application'
 
52
    schemaVersion = 1
 
53
    urlCount = attributes.integer( default = 0 )
 
54
 
 
55
    def install( self ):
 
56
        self.store.powerUp( self, INavigableElement )
 
57
 
 
58
    def getTabs( self ):
 
59
        return [Tab('Admin', self.storeID, 0.0,
 
60
                    [Tab('Magical', self.storeID, 0.1)])]
 
61
static = lambda value : lambda *a, **k: value
 
62
 
 
63
class ClickChronicleFragment( rend.Fragment ):
 
64
    fragmentName = 'click-chronicle-fragment'
 
65
    live = True
 
66
    docFactory = loaders.xmlfile( 'linklist.xml' )
 
67
    head = static( "" )
 
68
   
 
69
registerAdapter( ClickChronicleFragment, ClickChronicleApplication, INavigableFragment )
 
70
  
 
71
class ClickChronicleBenefactor( Item ):
 
72
    implements( IBenefactor )
 
73
    typeName = 'clickchronicle_benefactor'
 
74
    schemaVersion = 1
 
75
 
 
76
    endowed = attributes.integer( default = 0 )
 
77
 
 
78
    def endow(self, ticket, avatar):
 
79
        self.endowed += 1
 
80
        WebSite( store = avatar ).install()
 
81
        PrivateApplication( store = avatar ).install()
 
82
        ClickChronicleApplication( store = avatar ).install()
 
83
        #for item in ( WebSite, PrivateApplication ):
 
84
        #    item( store = avatar ).install()