예제 #1
0
def tick():
    """store the current timestamp"""
    site = zoom.system.site
    events = zoom.store_of(Event)
    event = events.first(site=site.name) or Event(site=site.name, counter=1)
    event.timestamp = zoom.tools.now()
    event.counter += 1
    event_id = events.put(event)
    return event_id
예제 #2
0
    def index(self):
        site = zoom.system.site
        events = zoom.store_of(Event)
        event = events.first(site=site.name)

        if event:
            msg = 'Tick {event.counter:,} happened {event.when}'
            message = msg.format(event=event)
        else:
            message = 'No ticks yet.  Background process may not be active.'

        return zoom.page(message, title='Background')
예제 #3
0
    def index(self):
        """Show all images"""

        actions = 'Edit',

        tpl = """
        <a href="{image.access_url}" class="image-item-container">
          <img class="images-thumbnail" title="{image.image_name}" src="/content/images/{image.image_id}">
          <div class="images-linker-container">
            {image.markdown_linker}
          </div>
        </a>
        """

        content = ''.join(
            tpl.format(image=image) for image in zoom.store_of(Image))

        zoom.requires('fontawesome4')
        return zoom.page(content,
                         title='Images',
                         actions=actions,
                         css=css,
                         libs=('/content/static/markdown-linker.js', ))
예제 #4
0
    def index(self):
        """Returns a list of background jobs"""

        actions = []
        if zoom.system.user.is_admin:
            actions.append(('Clear Placeholders', 'jobs/clear'))

        jobs = zoom.sites.Site(zoom.system.site.path).background_jobs
        lookup = {
            job.qualified_name: job
            for job in zoom.store_of(zoom.background.BackgroundJobPlaceholder)
        }

        when = zoom.helpers.when

        labels = ('Name', 'Status', 'Trigger', 'Next Run', 'Last Run',
                  'Elapsed', 'Last Run Status')

        content = zoom.browse(
            ((job.name, job.status, job.trigger, when(job.next_run),
              when(
                  lookup.get(job.qualified_name)
                  and lookup.get(job.qualified_name).last_run) or 'never',
              timespan(
                  lookup.get(job.qualified_name).last_finished
                  if job.qualified_name in lookup else None,
                  lookup[job.qualified_name].last_run
                  if job.qualified_name in lookup else None,
              ), lookup[job.qualified_name].last_run_status
              if job.qualified_name in lookup
              and lookup[job.qualified_name].last_run_status else '-')
             for job in jobs),
            labels=labels,
        )

        title = 'Jobs'
        return zoom.page(content, title=title, actions=actions)
예제 #5
0
    def test_make_store_select(self):
        data = [
            dict(name='Alice', size=100, amount=2200),
            dict(name='Janice', size=510, amount=200),
            dict(name='Jimmy', size=200, amount=2100),
            dict(name='Ozzy', size=401, amount=1900),
            dict(name='Angus', size=510, amount=200),
        ]
        people = zoom.store_of(Person, self.db)
        for row in data:
            people.put(row)
        low = set([person.name for person in people.find(amount=200)])
        self.assertEqual(low, set(['Janice', 'Angus']))

        cmd = make_store_select('person', amount=less_than(2000), size=gt(401))
        rows = entify(self.db(cmd))
        by_id = lambda a: a['_id']
        self.assertEqual(
            sorted(rows, key=by_id),
            sorted([
                {'_id': 5, 'name': 'Janice', 'size': 510, 'amount': 200},
                {'_id': 8, 'name': 'Angus', 'size': 510, 'amount': 200},
            ], key=by_id)
        )
예제 #6
0
 def __init__(self, db, steps):
     self.db = db
     self.steps = steps
     self.revisions = zoom.store_of(SystemMigrationRecord)
예제 #7
0
파일: snippets.py 프로젝트: robinsax/zoom
def get_snippets(db=None):
    return zoom.store_of(Snippet, db=db)
예제 #8
0
 def clear(self):
     zoom.store_of(zoom.background.BackgroundJobPlaceholder).zap()
     return zoom.home('jobs')
예제 #9
0
 def __init__(self):
     self.settings = zoom.store_of(AppSettings)
     app = zoom.system.request.app
     user = zoom.system.request.user
     self.key = dict(app=app.name, user_id=user.user_id)
     self.values = None
예제 #10
0
 def __init__(self, site_name, config):
     self.site_name = site_name
     self.kind = SiteSettings
     self.settings = zoom.store_of(self.kind)
     self._values = None
     self.config = config
예제 #11
0
 def __init__(self, config):
     self.kind = SystemSettings
     self.settings = zoom.store_of(self.kind)
     self._values = None
     self.config = config