~divmod-dev/divmod.org/NULLIFY-versus-disallowNone-2736

« back to all changes in this revision

Viewing changes to Mantissa/xmantissa/publicweb.py

  • Committer: glyph
  • Date: 2006-01-11 17:00:20 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:4021

Author: glyph
Reviewer: moe

Fixes #382

This merge provides basic sharing functionality, such as the ability to give a
user a publicly-viewable web page (at /by/username, for the cool kids, or
/users, if you're a fuddy-duddy).

It also adds (working) support for a simple ClickChronicle public page at
/by/username/clicks, which exposes the "my clicks" page without the "actions"
column, and also (not working) Hyperbola at /by/username/blog which should some
day soon grow into a blog.  Patches accepted :).


Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
from twisted.internet import defer
9
9
from twisted import plugin
 
10
from twisted.python import util
10
11
 
11
 
from nevow import inevow, rend
 
12
from nevow import inevow, rend, static
12
13
 
13
14
from axiom import item, attributes, upgrade, userbase
14
15
 
15
 
from xmantissa import ixmantissa, website, publicresource, offering, plugins
 
16
from xmantissa import ixmantissa, website, publicresource, websharing, offering, plugins
16
17
 
17
18
class PublicWeb(item.Item, website.PrefixURLMixin):
18
19
    """
207
208
        publicresource.PublicPage.__init__(
208
209
            self, original, OfferingsFragment(original), staticContent, forUser)
209
210
 
 
211
    def locateChild(self, ctx, segments):
 
212
        result = super(PublicFrontPage, self).locateChild(ctx, segments)
 
213
        if result is not rend.NotFound:
 
214
            child, segments = result
 
215
            if self.username is not None:
 
216
                cust = ixmantissa.ICustomizable(child, None)
 
217
                if cust is not None:
 
218
                    return cust.customizeFor(self.username), segments
 
219
            return child, segments
 
220
        return rend.NotFound
 
221
 
210
222
    def child_(self, ctx):
211
223
        return self
212
224
 
 
225
    def child_by(self, ctx):
 
226
        return websharing.UserIndexPage(self.original.store.findUnique(userbase.LoginSystem))
 
227
 
 
228
    def child_Mantissa(self, ctx):
 
229
        # Cheating!  It *looks* like there's an app store, but there isn't
 
230
        # really, because this is the One Store To Bind Them All.
 
231
        return static.File(util.sibpath(__file__, "static"))
 
232
 
213
233
    def childFactory(self, ctx, name):
214
234
        offer = self.original.store.findFirst(
215
235
            offering.InstalledOffering,
217
237
        if offer is not None:
218
238
            pp = ixmantissa.IPublicPage(offer.application, None)
219
239
            if pp is not None:
220
 
                res = pp.getResource()
221
 
                if self.username is not None:
222
 
                    return res.customizeFor(self.username)
223
 
                return res
 
240
                return pp.getResource()
224
241
        return None
225
242
 
226
243
    def customizeFor(self, forUser):