def _create_content(self, title, type_name): assert title, 'Must have a title to create content' newcontentid = normalize(title) container = self.aq_parent.aq_parent newcontentid = container.invokeFactory(type_name, id=newcontentid, title=title) return getattr(self.context, newcontentid)
def manageLinks(self, new_links): # this has been heavily optimized # @@ but asyncing backlinking would help scope = self.wfilter.scope dups = set(self.removeLinks(new_links)) resolver = self.resolver norm = tuple() for link in new_links: normalled = normalize(link) norm += normalled, self.resolver.aggregate(link, normalled, scope) for link, normalled in zip(new_links, norm): match = self.getMatch(link, resolver.agg_brains, normalled=normalled) if not match: match = self.getMatch(link, resolver.agg_scoped_brains, normalled=normalled) if not match: continue if match.UID != MissingValue and match.UID in dups: continue self.manageLink(match, normalled)
def match(self, brain, getlink): """ mmmm....turtle. @@ make efficient """ link = getlink(brain.getId, getlink(normalize(brain.Title), None)) if link: return True
def _create_content(self, title, type_name): assert title, 'Must have a title to create content' id_=self.context.generateUniqueId(type_name) new_content = self.context.restrictedTraverse('portal_factory/%s/%s' % (type_name, id_)) transaction_note('Initiated creation of %s with id %s in %s' % \ (new_content.getTypeInfo().getId(), id_, self.context.absolute_url())) new_content.setTitle(title) newcontentid = normalize(title) new_content.setId(newcontentid) return new_content
def _create_content(self, title, type_name): assert title, 'Must have a title to create content' id_ = self.context.generateUniqueId(type_name) new_content = self.context.restrictedTraverse('portal_factory/%s/%s' % (type_name, id_)) transaction_note('Initiated creation of %s with id %s in %s' % \ (new_content.getTypeInfo().getId(), id_, self.context.absolute_url())) new_content.setTitle(title) newcontentid = normalize(title) new_content.setId(newcontentid) return new_content
def manageLinks(self, new_links): # this has been heavily optimized # @@ but asyncing backlinking would help scope=self.wfilter.scope dups = set(self.removeLinks(new_links)) resolver = self.resolver norm=tuple() for link in new_links: normalled=normalize(link) norm+=normalled, self.resolver.aggregate(link, normalled, scope) for link, normalled in zip(new_links, norm): match = self.getMatch(link, resolver.agg_brains, normalled=normalled) if not match: match = self.getMatch(link, resolver.agg_scoped_brains, normalled=normalled) if not match: continue if match.UID != MissingValue and match.UID in dups: continue self.manageLink(match, normalled)
def _preplinks(self, links=dict()): return links and dict([(normalize(link), link) for link in links]) \ or dict()