def setUp(self): """ Set up stores and an offering. """ store = Store(dbdir=self.mktemp()) appStore1 = SubStore.createNew(store, ("app", "test1.axiom")) appStore2 = SubStore.createNew(store, ("app", "test2.axiom")) self.firstOffering = Offering(u'first offering', None, None, None, None, None, []) firstInstalledOffering = InstalledOffering( store=store, application=appStore1, offeringName=self.firstOffering.name) ss1 = appStore1.open() self.installApp(ss1) # (bypass Item.__setattr__) object.__setattr__(firstInstalledOffering, 'getOffering', lambda: self.firstOffering) secondOffering = Offering(u'second offering', None, None, None, None, None, []) secondInstalledOffering = InstalledOffering( store=store, application=appStore2, offeringName=secondOffering.name) # (bypass Item.__setattr__) object.__setattr__(secondInstalledOffering, 'getOffering', lambda: secondOffering) self.fragment = _OfferingsFragment(FrontPage(store=store))
def test_offeringWithStaticContent(self): """ L{StaticContent} has a L{File} child with the name of one of the offerings passed to its initializer which has a static content path. """ # Make a fake offering to get its static content rendered. offeringName = u'name of the offering' offeringPath = FilePath(self.mktemp()) offeringPath.makedirs() childName = 'content' childContent = 'the content' offeringPath.child(childName).setContent(childContent) self._fakeOfferings( self.store, { offeringName: Offering(offeringName, None, None, None, None, None, None, offeringPath, None) }) def rendered(request): self.assertEqual(request.accumulator, childContent) return self._verifyResource( '/static/%s/%s' % (offeringName.encode('ascii'), childName), rendered)
def test_switchFrontPage(self): """ 'axiomatic frontpage <offeringName>' switches the primary application (i.e., the one whose front page will be displayed on the site's root resource) to the one belonging to the named offering. """ off2 = Offering( name=u'test_offering2', description=u'Offering for creating a sample app store', siteRequirements=[], appPowerups=[TestAppPowerup], installablePowerups=[], loginInterfaces=[], themes=[]) installedOffering2 = installOffering(self.siteStore, off2, None) sfp = SetFrontPage() sfp.parent = self sfp.parseOptions(["test_offering"]) resource, segments = self.frontPage.produceResource( None, ('', ), self.webViewer) result, segs = resource.locateChild(None, ['']) self.assertIdentical(result.fragment.original.store, self.substore) self.assertEqual(segs, []) sfp.parseOptions(["test_offering2"]) resource, moreSegs = self.frontPage.produceResource( None, ('', ), self.webViewer) result, segs = resource.locateChild(None, ['']) self.assertEqual(segs, []) self.assertIdentical(result.fragment.original.store, installedOffering2.application.open()) self.assertRaises(UsageError, sfp.parseOptions, []) self.assertRaises(UsageError, sfp.parseOptions, ["nonexistent"])
def test_headRenderer(self): """ The I{head} renderer gets the head section for each installed theme by calling their C{head} method with the request being rendered and adds the result to the tag it is passed. """ headCalls = [] customHead = object() class CustomHeadTheme(object): priority = 0 themeName = "custom" def head(self, request, site): headCalls.append((request, site)) return customHead def getDocFactory(self, name, default): return default tech = FakeOfferingTechnician() tech.installOffering( Offering(name=u'fake', description=u'', siteRequirements=[], appPowerups=[], installablePowerups=[], loginInterfaces=[], themes=[CustomHeadTheme()])) self.siteStore.inMemoryPowerUp(tech, IOfferingTechnician) # Flush the cache, which is global, else the above fake-out is # completely ignored. theThemeCache.emptyCache() page = self.createPage(self.username) tag = div() ctx = context.WebContext(tag=tag) request = FakeRequest() ctx.remember(request, inevow.IRequest) result = page.render_head(ctx, None) self.assertEqual(result.tagName, 'div') self.assertEqual(result.attributes, {}) self.assertIn(customHead, result.children) self.assertEqual(headCalls, [(request, ISiteURLGenerator(self.siteStore))])
def test_getDocFactory(self): """ L{SiteTemplateResolver.getDocFactory} should return only installed themes for its store. """ class FakeTheme(object): priority = 0 def getDocFactory(self, templateName, default=None): if templateName == 'shell': return object() return default self.assertIdentical(self.getDocFactoryWithoutCaching('shell'), None) self.offeringTech.installOffering( Offering(u'an offering', None, [], [], [], [], [FakeTheme()])) self.assertNotIdentical(self.getDocFactoryWithoutCaching('shell'), None)
def setUp(self): """ Set up a store with an installed offering. """ self.siteStore = Store(dbdir=self.mktemp()) Mantissa().installSite(self.siteStore, u"localhost", u"", False) off = Offering( name=u'test_offering', description=u'Offering for creating a sample app store', siteRequirements=[], appPowerups=[TestAppPowerup], installablePowerups=[], loginInterfaces=[], themes=[], ) self.installedOffering = installOffering(self.siteStore, off, None) self.app = self.installedOffering.application self.substore = self.app.open() sharedItem = getEveryoneRole(self.substore).getShare( getDefaultShareID(self.substore)) self.frontPage = self.siteStore.findUnique(FrontPage) self.webViewer = IWebViewer(self.siteStore)
from twisted.python.filepath import FilePath from xmantissa.offering import Offering import methanal from methanal.theme import Theme from methanal.publicpage import MethanalPublicPage plugin = Offering( name=u'Methanal', description=u'A forms library for Mantissa', siteRequirements=[], appPowerups=[MethanalPublicPage], installablePowerups=[], loginInterfaces=[], themes=[Theme('methanal-base', 0)], staticContentPath=FilePath(methanal.__file__).sibling('static'))
from xmantissa.offering import Offering from cal import Calendar calendarOffering = Offering( name=u"Calendar", description=u"A simple appointment-tracking application.", siteRequirements=[], appPowerups=[], installablePowerups=[(u"Calendar", u"Appointment Tracking Powerup", Calendar)], loginInterfaces=[], themes=[], staticContentPath=None, version=None)
""" Dropin with Entropy offering. """ from xmantissa.offering import Offering from entropy.web import SimpleSiteFactory from entropy.store import ContentResource plugin = Offering(name=u'Entropy', description=u'A persistent, immutable object store.', siteRequirements=[(None, SimpleSiteFactory)], appPowerups=[ContentResource], installablePowerups=[], loginInterfaces=[], themes=[])