Back to index

plone3  3.1.7
Functions | Variables
referencebrowser_startupDirectory Namespace Reference

Functions

def filterPortalFactory
def checkPath

Variables

tuple props = getToolByName(context, 'portal_properties')
 startups = props.refwidget_startupdirectories
string ownpath = '/'
string purl = '/'
tuple psplit = pathdef.split(':')
list dopath = psplit[1]

Function Documentation

Definition at line 71 of file referencebrowser_startupDirectory.py.

00071 
00072 def checkPath(path):
00073     if path.startswith('/'):
00074         portal_url = getToolByName (context, 'portal_url')
00075         return portal_url () + path
00076     else:
00077         return path
00078 
00079 #
00080 # Main execution
00081 #
00082 
00083 # Default case - if no directory is given, search for a property
00084 # refwidget_startupdirectories in portal_properties/site_properties
00085 # that is a lines field having the following
00086 # form:
00087 #    path1:path2
00088 # path1 is the path where all widgets being under it set startup_directory
# to path2 if no startup_directory is set.
Return context's url + the relative url given, but remove any
reference to portal_factory.

Definition at line 30 of file referencebrowser_startupDirectory.py.

00030 
00031 def filterPortalFactory (url):
00032     """Return context's url + the relative url given, but remove any
00033     reference to portal_factory.
00034     """
00035 
00036     portal_factory = getToolByName (context, 'portal_factory')
00037 
00038     # Prepend / to ensure proper path separation, and ensure url is a string
00039     if url:
00040         url = '/' + url
00041     else:
00042         url = ''
00043     basePath = ''
00044 
00045     if portal_factory.isTemporary (context):
00046         pathParts = context.getPhysicalPath ()
00047 
00048         # Remove the factory from the path
00049         pathParts = pathParts[:-3]
00050 
00051         # If the object is in the portal factory, we'll be relative to the
00052         # parent folder, not the temporary object which does not yet exist,
00053         # so remove any explicit ../ from the relative path
00054         if url.startswith ('/..'):
00055             url = url[3:]
00056 
00057         basePath = '/'.join (pathParts)
00058     else:
00059         basePath = context.absolute_url (relative = 1)
00060 
00061 
00062     # Resolve the URL
00063     try:
00064         targetPath = basePath + url
00065         object = context.restrictedTraverse (targetPath)
00066         return object.absolute_url ()
00067     except:
00068         return context.absolute_url ()
00069 
00070 # checks if path starts with / - if, then
# path is relative to portal root

Variable Documentation

Definition at line 103 of file referencebrowser_startupDirectory.py.

Definition at line 94 of file referencebrowser_startupDirectory.py.

tuple referencebrowser_startupDirectory.props = getToolByName(context, 'portal_properties')

Definition at line 91 of file referencebrowser_startupDirectory.py.

tuple referencebrowser_startupDirectory.psplit = pathdef.split(':')

Definition at line 101 of file referencebrowser_startupDirectory.py.

Definition at line 97 of file referencebrowser_startupDirectory.py.

referencebrowser_startupDirectory.startups = props.refwidget_startupdirectories

Definition at line 93 of file referencebrowser_startupDirectory.py.