Esempio n. 1
0
    def tag(self, obj, tagName, tagger=None):
        """
        """
        # check to see if that tag exists.  Put the object attribute first,
        # since each object should only have a handful of tags and the object
        # reference is indexed.  As long as this is the case, it doesn't matter
        # whether the name or catalog attributes are indexed because selecting
        # from a small set of results is fast even without an index.
        if self.store.findFirst(
                Tag,
                AND(Tag.object == obj, Tag.name == tagName,
                    Tag.catalog == self)):
            return

        # if the tag doesn't exist, maybe we need to create a new tagname object
        self.store.findOrCreate(_TagName, name=tagName, catalog=self)

        # Increment only if we are creating a new tag
        self.tagCount += 1
        Tag(store=self.store,
            object=obj,
            name=tagName,
            catalog=self,
            created=Time(),
            tagger=tagger)
Esempio n. 2
0
 def now(self):
     # Testing hook
     return Time()