Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
wicked.at.backlink.ATBacklinkManager Class Reference

List of all members.

Public Member Functions

def __init__
def getLinks
def manageLinks
def manageLink
def removeLinks
def match
def remove
def unlink

Public Attributes

 wfilter
 context
 cm
 resolver
 getMatch
 refcat
 ATism: remove ASAP.
 suid

Static Public Attributes

 relation = config.BACKLINK_RELATIONSHIP
 refKlass = Backlink
tuple packBrain = staticmethod(packBrain)
tuple cleanUID = staticmethod(cleanUID)

Private Member Functions

def _preplinks

Detailed Description

Definition at line 15 of file backlink.py.


Constructor & Destructor Documentation

def wicked.at.backlink.ATBacklinkManager.__init__ (   self,
  wfilter,
  context 
)

Definition at line 25 of file backlink.py.

00025 
00026     def __init__(self, wfilter, context):
00027         self.wfilter = wfilter
00028         self.context = context
00029         self.cm = wfilter.cache
00030         self.resolver = wfilter.resolver
00031         self.getMatch = wfilter.getMatch
00032         ## ATism: remove ASAP
00033         self.refcat = getToolByName(self.context, 'reference_catalog')
00034         self.suid = IUID(self.context)

Here is the caller graph for this function:


Member Function Documentation

def wicked.at.backlink.ATBacklinkManager._preplinks (   self,
  links = dict() 
) [private]

Definition at line 47 of file backlink.py.

00047 
00048     def _preplinks(self, links=dict()):
00049         return links and dict([(normalize(link), link) for link in links]) \
00050                      or dict()

Here is the call graph for this function:

Here is the caller graph for this function:

Returns dataobjects representing backlinks

Definition at line 35 of file backlink.py.

00035 
00036     def getLinks(self):
00037         """
00038         Returns dataobjects representing backlinks
00039         """
00040         refbrains = self.refcat._queryFor(relationship=self.relation,
00041                                  tid=self.suid, sid=None)
00042         if refbrains:
00043             uids = [brain.sourceUID for brain in refbrains]
00044             ## XXX non-orthogonal
00045             return self.resolver.queryUIDs(uids)
00046         return []
    

Here is the caller graph for this function:

def wicked.at.backlink.ATBacklinkManager.manageLink (   self,
  obj,
  normalled 
)

Definition at line 75 of file backlink.py.

00075 
00076     def manageLink(self, obj, normalled):
00077         # need IObject iface for catalog brains
00078         if hasattr(obj, 'getObject'):
00079             # brain, other sort of pseudo object
00080             obj = obj.getObject()
00081 
00082         if not IReferenceable.providedBy(obj):
00083             # backlink not possible
00084             return
00085 
00086         mark(obj, IWickedTarget)
00087         self.refcat.addReference(obj,
00088                                  self.context,
00089                                  relationship=self.relation,
00090                                  referenceClass=self.refKlass)
00091         objuid = IUID(obj)
00092         path = '/'.join(obj.getPhysicalPath())
00093         data = dict(path=path,
00094                     icon=obj.getIcon(),
00095                     uid=objuid)
00096         
00097         self.cm.set((intern(normalled), objuid), [data])  

Here is the call graph for this function:

Here is the caller graph for this function:

def wicked.at.backlink.ATBacklinkManager.manageLinks (   self,
  new_links 
)

Definition at line 51 of file backlink.py.

00051 
00052     def manageLinks(self, new_links):
00053         # this has been heavily optimized
00054         # @@ but asyncing backlinking would help
00055                 
00056         scope=self.wfilter.scope
00057         dups = set(self.removeLinks(new_links))
00058 
00059         resolver = self.resolver
00060         norm=tuple()
00061         for link in new_links:
00062             normalled=normalize(link)
00063             norm+=normalled,
00064             self.resolver.aggregate(link, normalled, scope)
00065 
00066         for link, normalled in zip(new_links, norm):
00067             match = self.getMatch(link, resolver.agg_brains, normalled=normalled)            
00068             if not match:
00069                 match = self.getMatch(link, resolver.agg_scoped_brains, normalled=normalled)
00070             if not match:
00071                 continue
00072             if match.UID != MissingValue and match.UID in dups:
00073                 continue
00074             self.manageLink(match, normalled)

Here is the call graph for this function:

def wicked.at.backlink.ATBacklinkManager.match (   self,
  brain,
  getlink 
)
mmmm....turtle.
@@ make efficient

Definition at line 112 of file backlink.py.

00112 
00113     def match(self, brain, getlink):
00114         """
00115         mmmm....turtle.
00116         @@ make efficient
00117         """
00118         link = getlink(brain.getId,
00119                        getlink(normalize(brain.Title), None))
00120         if link:
00121             return True
                

Here is the call graph for this function:

Here is the caller graph for this function:

def wicked.at.backlink.ATBacklinkManager.remove (   self,
  brain 
)

Definition at line 122 of file backlink.py.

00122 
00123     def remove(self, brain):
00124         #XXX needs test
00125         objs = self.refcat._resolveBrains(\
00126             self.refcat._queryFor(self.suid, brain.UID, self.relation))
00127         for obj in objs:
00128             self.refcat._deleteReference(obj)
00129             self.cm.unset(obj.targetUID, use_uid=True)

Here is the caller graph for this function:

def wicked.at.backlink.ATBacklinkManager.removeLinks (   self,
  exclude = tuple() 
)

Definition at line 98 of file backlink.py.

00098 
00099     def removeLinks(self, exclude=tuple()):
00100         oldlinks = self.getLinks()
00101         if not oldlinks:
00102             return set()
00103         
00104         exclude = self._preplinks(exclude)        
00105         dups = set([brain for brain in oldlinks if \
00106                     self.match(brain, exclude.get)])
00107         
00108         [self.remove(brain) for brain in set(oldlinks) - dups]
00109         return [self.cleanUID(b) for b in dups]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 130 of file backlink.py.

00130 
00131     def unlink(self, uid):
00132         self.cm.remove(uid)

Member Data Documentation

Definition at line 110 of file backlink.py.

Definition at line 28 of file backlink.py.

Definition at line 27 of file backlink.py.

Definition at line 30 of file backlink.py.

Definition at line 23 of file backlink.py.

ATism: remove ASAP.

Definition at line 32 of file backlink.py.

Definition at line 21 of file backlink.py.

Definition at line 20 of file backlink.py.

Definition at line 29 of file backlink.py.

Definition at line 33 of file backlink.py.

Definition at line 26 of file backlink.py.


The documentation for this class was generated from the following file: