How to use the ming.utils.LazyProperty function in Ming

To help you get started, we’ve selected a few Ming examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / allura / Allura / allura / lib / app_globals.py View on Github external
    @LazyProperty
    def server_name(self):
        p1 = Popen(['hostname', '-s'], stdout=PIPE)
        server_name = p1.communicate()[0].strip()
        p1.wait()
        return server_name
github apache / allura / Allura / allura / model / repository.py View on Github external
    @LazyProperty
    def size(self):
        return self.repo.blob_size(self)
github apache / allura / Allura / allura / model / index.py View on Github external
    @LazyProperty
    def artifact(self):
        '''Look up the artifact referenced'''
        aref = self.artifact_reference
        try:
            cls = loads(str(aref.cls))
            with h.push_context(aref.project_id):
                return cls.query.get(_id=aref.artifact_id)
        except:
            log.exception('Error loading artifact for %s: %r',
                          self._id, aref)
github apache / allura / Allura / allura / model / repository.py View on Github external
    @LazyProperty
    def authored_user(self):
        return User.by_email_address(self.authored.email)
github apache / allura / Allura / allura / lib / security.py View on Github external
    @LazyProperty
    def roles_that_reach(self):
        def _iter():
            visited = set()
            to_visit = list(self)
            while to_visit:
                r = to_visit.pop(0)
                if r['_id'] in visited:
                    continue
                visited.add(r['_id'])
                yield r
                pr_rindex = self.cred.project_roles(
                    r['project_id']).reverse_index
                to_visit += pr_rindex[r['_id']]
        return RoleCache(self.cred, _iter())
github apache / allura / ForgeClassic / sfx / model / mailman.py View on Github external
    @LazyProperty
    def _sitedb_row(self):
        q = T.mail_group_list.select(T.mail_group_list.c.list_name==self.name)
        q = q.where(
            T.mail_group_list.c.group_id==context.project.get_tool_data('sfx', 'group_id'))
        return q.execute().first()
github apache / allura / Allura / allura / model / project.py View on Github external
    @LazyProperty
    def allowed_tool_status(self):
        return ['production'] + self._extra_tool_status
github apache / allura / Allura / allura / model / repository.py View on Github external
    @LazyProperty
    def changed_paths(self):
        '''
        Returns a list of paths changed in this commit.
        Leading and trailing slashes are removed, and
        the list is complete, meaning that if a sub-path
        is changed, all of the parent paths are included
        (including '' to represent the root path).

        Example:

            If the file /foo/bar is changed in the commit,
            this would return ['', 'foo', 'foo/bar']
        '''
        changes = self.repo.get_changes(self._id)
        changed_paths = set()
        for change in changes:
github apache / allura / Allura / allura / model / repository.py View on Github external
    @LazyProperty
    def _content_type_encoding(self):
        return self.repo.guess_type(self.name)
github apache / allura / Allura / allura / lib / plugin.py View on Github external
    @LazyProperty
    def remove_socialnetwork_form(self):
        '''
        :return: None, or an easywidgets Form to render on  the user preferences page to
                 allow removing a social network account.
        '''
        from allura.lib.widgets.forms import RemoveSocialNetworkForm
        return RemoveSocialNetworkForm(action='/auth/preferences/remove_social_network')