Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
CMFDefault.Favorite.Favorite Class Reference
Inheritance diagram for CMFDefault.Favorite.Favorite:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.Favorite.Favorite:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getRemoteUrl
def getIcon
def getObject

Public Attributes

 id
 title
 remote_url
 description
 remote_uid

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _getUidByUrl
def _getObjectByUid
def _getRemoteUrlTheOldWay
def _edit

Static Private Attributes

 __implements__ = Link.__implements__

Detailed Description

A Favorite (special kind of Link).

Definition at line 46 of file Favorite.py.


Constructor & Destructor Documentation

def CMFDefault.Favorite.Favorite.__init__ (   self,
  id,
  title = '',
  remote_url = '',
  description = '' 
)

Definition at line 61 of file Favorite.py.

00061 
00062                 ):
00063         DefaultDublinCoreImpl.__init__(self)
00064         self.id=id
00065         self.title=title
00066         self.remote_url=remote_url
00067         self.description = description


Member Function Documentation

def CMFDefault.Favorite.Favorite._edit (   self,
  remote_url 
) [private]
Edit the Favorite. Unlike Links, Favorites have URLs that are
relative to the root of the site.

Definition at line 148 of file Favorite.py.

00148 
00149     def _edit( self, remote_url ):
00150         """
00151         Edit the Favorite. Unlike Links, Favorites have URLs that are
00152         relative to the root of the site.
00153         """
00154         # strip off scheme and machine from URL if present
00155         tokens = urlparse.urlparse( remote_url, 'http' )
00156         if tokens[1]:
00157             # There is a nethost, remove it
00158             t=('', '') + tokens[2:]
00159             remote_url=urlparse.urlunparse(t)
00160         # if URL begins with site URL, remove site URL
00161         portal_url = getToolByName(self, 'portal_url').getPortalPath()
00162         i = remote_url.find(portal_url)
00163         if i==0:
00164             remote_url=remote_url[len(portal_url):]
00165         # if site is still absolute, make it relative
00166         if remote_url[:1]=='/':
00167             remote_url=remote_url[1:]
00168         self.remote_url=remote_url
00169 
00170         # save unique id of favorite
00171         self.remote_uid = self._getUidByUrl()
00172 
00173 InitializeClass(Favorite)

Here is the call graph for this function:

Here is the caller graph for this function:

Registers and returns the uid of the remote object if
the unique id handler tool is available.

Definition at line 80 of file Favorite.py.

00080 
00081     def _getObjectByUid(self):
00082         """Registers and returns the uid of the remote object if
00083         the unique id handler tool is available.
00084         """
00085         # check for unique id handler tool
00086         handler = getToolByName(self, 'portal_uidhandler', None)
00087         if handler is None:
00088             return
00089 
00090         # check for remote uid info on object
00091         uid = getattr(aq_base(self), 'remote_uid', None)
00092         if uid is None:
00093             return
00094 
00095         return handler.queryObject(uid, None)

Here is the call graph for this function:

Here is the caller graph for this function:

Build the url without having taking the uid into account

Definition at line 113 of file Favorite.py.

00113 
00114     def _getRemoteUrlTheOldWay(self):
00115         """Build the url without having taking the uid into account
00116         """
00117         portal_url = getToolByName(self, 'portal_url')
00118         if self.remote_url:
00119             return portal_url() + '/' + self.remote_url
00120         else:
00121             return portal_url()
00122 

Here is the call graph for this function:

Here is the caller graph for this function:

Registers and returns the uid of the remote object if
the unique id handler tool is available.

Definition at line 68 of file Favorite.py.

00068 
00069     def _getUidByUrl(self):
00070         """Registers and returns the uid of the remote object if
00071         the unique id handler tool is available.
00072         """
00073         # check for unique id handler tool
00074         handler = getToolByName(self, 'portal_uidhandler', None)
00075         if handler is None:
00076             return
00077 
00078         obj = getUtility(ISiteRoot).restrictedTraverse(self.remote_url)
00079         return handler.register(obj)

Here is the call graph for this function:

def CMFDefault.Favorite.Favorite.getIcon (   self,
  relative_to_portal = 0 
)
Instead of a static icon, like for Link objects, we want
to display an icon based on what the Favorite links to.

Definition at line 124 of file Favorite.py.

00124 
00125     def getIcon(self, relative_to_portal=0):
00126         """
00127         Instead of a static icon, like for Link objects, we want
00128         to display an icon based on what the Favorite links to.
00129         """
00130         try:
00131             return self.getObject().getIcon(relative_to_portal)
00132         except:
00133             return 'p_/broken'

Here is the call graph for this function:

Here is the caller graph for this function:

Get the actual object that the Favorite is linking to.

Definition at line 135 of file Favorite.py.

00135 
00136     def getObject(self):
00137         """ Get the actual object that the Favorite is linking to.
00138         """
00139         # try getting the remote object by unique id
00140         remote_obj = self._getObjectByUid()
00141         if remote_obj is not None:
00142             return remote_obj
00143 
00144         # XXX: can't use ISiteRoot because absolute_url() depends on REQUEST
00145         portal_url = getToolByName(self, 'portal_url')
00146         return portal_url.getPortalObject().restrictedTraverse(self.remote_url)

Here is the call graph for this function:

Here is the caller graph for this function:

    returns the remote URL of the Link

Definition at line 97 of file Favorite.py.

00097 
00098     def getRemoteUrl(self):
00099         """
00100             returns the remote URL of the Link
00101         """
00102         # try getting the remote object by unique id
00103         remote_url = self._getRemoteUrlTheOldWay()
00104         remote_obj = self._getObjectByUid()
00105         if remote_obj:
00106             url = remote_obj.absolute_url()
00107             # update the url when changed (avoid unnecessary ZODB writes)
00108             if url != remote_url:
00109                 self.edit(url)
00110             return url
00111 
00112         return remote_url

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

CMFDefault.Favorite.Favorite.__implements__ = Link.__implements__ [static, private]

Definition at line 52 of file Favorite.py.

Definition at line 66 of file Favorite.py.

Definition at line 63 of file Favorite.py.

Definition at line 170 of file Favorite.py.

Definition at line 65 of file Favorite.py.

tuple CMFDefault.Favorite.Favorite.security = ClassSecurityInfo() [static]

Definition at line 54 of file Favorite.py.

Definition at line 64 of file Favorite.py.


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