rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
product_prefix = product_dir while product_prefix: product_prefix, module = os.path.split( product_prefix ) if module == 'Products': break
product_dir = package_home( globals() ) product_prefix = os.path.join( os.path.split(product_dir)[:-1] )
def directlyProvides(obj, *interfaces): obj.__implements__ = ( getattr( obj.__class__, '__implements__', () ) + tuple( interfaces ) )
self._file_mod_time = mtime self._readFile(1)
def _updateFromFS(self): parsed = self._parsed if not parsed or Globals.DevelopmentMode: fp = expandpath(self._filepath) try: mtime=stat(fp)[8] except: mtime=0 if not parsed or mtime != self._file_mod_time: self._parsed = 1 self._file_mod_time = mtime self._readFile(1)
def _compareDOM( self, found_text, expected_text ):
def _compareDOM( self, found_text, expected_text, debug=False ):
def _compareDOM( self, found_text, expected_text ):
security.declareObjectProtected(View) security.declareProtected(View, 'index_html')
security.declareObjectProtected( View ) security.declareProtected( ManageSeleniumTestCases, 'manage_main' ) manage_main = DTMLFile( 'suiteMain', _WWW_DIR ) security.declareProtected( View, 'index_html' )
def _makeFile(filename): path = os.path.join(_SUPPORT_DIR, filename) return File(id=filename, title='', file=open(path).read())
return self._actions or None
return self._actions or []
def listActions( self, info=None ):
'category': tdef.actbox_category}))
'category': tdef.actbox_category, 'transition':tdef}}))
if tdef is not None and tdef.trigger_type == TRIGGER_USER_ACTION: if tdef.actbox_name: if self._checkTransitionGuard(tdef, ob): res.append((tid, { 'id': tid, 'name': tdef.actbox_name % info, 'url': tdef.actbox_url % info, 'permissions': (), # Predetermined. 'category': tdef.actbox_category}))
err_msg = '<pre>%s</pre>' % replace( err[1], "\'", "'" )
err_msg = '<pre>%s</pre>' % replace( str(err[1]), "\'", "'" )
def pt_render(self, source=0, extra_context={}): self._updateFromFS() # Make sure the template has been loaded. try: if not source: # Hook up to caching policy.
cfg = CMFConfigParser() cfg.read(self._filename + '.metadata')
self._properties = {} self._security = {} try: cfg = CMFConfigParser() cfg.read(self._filename + '.metadata')
def _readMetadata(self): """ Read the new file format using ConfigParser """ cfg = CMFConfigParser() cfg.read(self._filename + '.metadata')
self._properties = self._getSectionDict(cfg, 'default') self._security = self._getSectionDict(cfg, 'security', self._securityParser)
self._properties = self._getSectionDict(cfg, 'default') self._security = self._getSectionDict(cfg, 'security', self._securityParser) except: LOG('FSMetadata', ERROR, 'Error parsing .metadata file', error=exc_info())
def _readMetadata(self): """ Read the new file format using ConfigParser """ cfg = CMFConfigParser() cfg.read(self._filename + '.metadata')
return ( { 'name' : 'Dummy', 'action' : 'manage_addFolder' }, )
return [ { 'name' : 'Dummy', 'action' : 'manage_addFolder' } ]
def extra_meta_types(): return ( { 'name' : 'Dummy', 'action' : 'manage_addFolder' }, )
req._auth = 'basic %s' % ac
req._auth = 'Basic %s' % ac
def modifyRequest(self, req, resp): # Returns flags indicating what the user is trying to do.
body_file = self.metadata['url'][7:].replace('/',',')
body_file = (self.host + self.path).replace('/', ',')
def __init__(self, input_file): try: # Read the configuration file config_path = os.path.expanduser('~/.zope-external-edit') self.config = Configuration(config_path)
self.ssl = self.metadata['url'].startswith('https:') url = self.metadata['url'][7:] path_start = url.find('/') if path_start == -1: self.host = url self.path = '/' else: self.host = url[:path_start] self.path = url[path_start:]
def __init__(self, input_file): try: # Read the configuration file config_path = os.path.expanduser('~/.zope-external-edit') self.config = Configuration(config_path)
from DCWorkflow.Default import createDefaultWorkflowClassic
from Products.DCWorkflow.Default \ import createDefaultWorkflowClassic
def setupWorkflow(self, p): wftool = getToolByName(p, 'portal_workflow', None) if wftool is None: return try: from DCWorkflow.Default import createDefaultWorkflowClassic except ImportError: return id = 'default_workflow' wftool._setObject( id, createDefaultWorkflowClassic(id) )
return self._site
return aq_self(self._site)
def getSite( self ):
return self._lambdas[ 0 ]( *args, **kw )
if self._lambdas[ 0 ]( *args, **kw ): return True raise Unauthorized
def validate( self, *args, **kw ): return self._lambdas[ 0 ]( *args, **kw )
response = self.zope_request('PUT', headers, body)
response = self.zopeRequest('PUT', headers, body)
def putChanges(self): """Save changes to the file back to Zope""" if int(self.options.get('use_locks', 0)) and \ not hasattr(self, 'lock_token'): # We failed to get a lock initially, so try again before saving if not self.lock(): # Confirm save without lock if not askYesNo('Could not acquire lock. ' 'Attempt to save to...
sys.stderr.write('Error occurred during HTTP put:\n%d %s\n' \ % (response.status, response.reason)) sys.stderr.write('\n----\n%s\n----\n' % response.read()) message = response.getheader('Bobo-Exception-Type') if askRetryCancel('Could not save to Zope.\nError ' 'occurred during HTTP put:\n%d %s\n%s' \ % (response.statu...
if self.askRetryAfterError(response, 'Could not save to Zope.\n' 'Error occurred during HTTP put'):
def putChanges(self): """Save changes to the file back to Zope""" if int(self.options.get('use_locks', 0)) and \ not hasattr(self, 'lock_token'): # We failed to get a lock initially, so try again before saving if not self.lock(): # Confirm save without lock if not askYesNo('Could not acquire lock. ' 'Attempt to save to...
response = self.zope_request('LOCK', headers, body)
response = self.zopeRequest('LOCK', headers, body)
def lock(self): """Apply a webdav lock to the object in Zope""" headers = {'Content-Type':'text/xml; charset="utf-8"', 'Timeout':'infinite', 'Depth':'infinity', } body = ('<?xml version="1.0" encoding="utf-8"?>\n' '<d:lockinfo xmlns:d="DAV:">\n' ' <d:lockscope><d:exclusive/></d:lockscope>\n' ' <d:locktype><d:write/>...
message = '\n(Object already locked)' else: message = response.getheader('Bobo-Exception-Type') sys.stderr.write('Error occurred during lock request:\n%d %s\n' \ % (response.status, response.reason)) sys.stderr.write('\n----\n%s\n----\n' % response.read()) if askRetryCancel('Lock request failed:\n%d %s\n%s' \ % (resp...
message = '(object already locked)' else: message = '' if self.askRetryAfterError(response, 'Lock request failed', message):
def lock(self): """Apply a webdav lock to the object in Zope""" headers = {'Content-Type':'text/xml; charset="utf-8"', 'Timeout':'infinite', 'Depth':'infinity', } body = ('<?xml version="1.0" encoding="utf-8"?>\n' '<d:lockinfo xmlns:d="DAV:">\n' ' <d:lockscope><d:exclusive/></d:lockscope>\n' ' <d:locktype><d:write/>...
response = self.zope_request('UNLOCK', headers)
response = self.zopeRequest('UNLOCK', headers)
def unlock(self): """Remove webdav lock from edited zope object""" if not hasattr(self, 'lock_token'): return 0 headers = {'Lock-Token':self.lock_token} response = self.zope_request('UNLOCK', headers) if response.status / 100 != 2: # Captain, she's still locked! message = response.getheader('Bobo-Exception-Type') sys...
message = response.getheader('Bobo-Exception-Type') sys.stderr.write('Error occurred during unlock request:' '\n%d %s\n%s\n' \ % (response.status, response.reason, message)) sys.stderr.write('\n----\n%s\n----\n' % response.read()) if askRetryCancel('Unlock request failed:\n%d %s' % (response.status, response.reason)):
if self.askRetryAfterError(response, 'Unlock request failed'):
def unlock(self): """Remove webdav lock from edited zope object""" if not hasattr(self, 'lock_token'): return 0 headers = {'Lock-Token':self.lock_token} response = self.zope_request('UNLOCK', headers) if response.status / 100 != 2: # Captain, she's still locked! message = response.getheader('Bobo-Exception-Type') sys...
def zope_request(self, method, headers={}, body=''):
def zopeRequest(self, method, headers={}, body=''):
def zope_request(self, method, headers={}, body=''): """Send a request back to Zope""" try: if self.ssl: h = HTTPSConnection(self.host) else: h = HTTPConnection(self.host)
class NullResponse: def getheader(n,d): return d
class NullResponse: def getheader(self, n, d=None): return d
def zope_request(self, method, headers={}, body=''): """Send a request back to Zope""" try: if self.ssl: h = HTTPSConnection(self.host) else: h = HTTPConnection(self.host)
if not hasattr(globals(), 'tk_root'):
def has_tk(): """Sets up a suitable tk root window if one has not already been setup. Returns true if tk is happy, false if tk throws an error (like its not available)""" if not hasattr(globals(), 'tk_root'): # create a hidden root window to make Tk happy try: global tk_root from Tkinter import Tk tk_root = Tk() tk_roo...
if has_tk:
if has_tk():
def askYesNo(message): if has_tk: from tkMessageBox import askyesno r = askyesno(title, message) has_tk() # must...make...tk...happy return r
RESPONSE.setHeader('Pragma', 'no-cache')
RESPONSE.setHeader('Last-Modified', rfc1123_date())
def index_html(self, REQUEST, RESPONSE, path=None): """Publish the object to the external editor helper app""" security = getSecurityManager() if path is None: parent = self.aq_parent try: ob = parent[REQUEST['target']] # Try getitem except KeyError: ob = getattr(parent, REQUEST['target']) # Try getattr except Attribu...
w_self = ImplicitAcquisitionWrapper(aq_base(self), parent)
w_self = ImplicitAcquisitionWrapper(self, parent)
def __of__(self, parent): ''' Sneakily sets up the portal skin then returns the wrapper that Acquisition.Implicit.__of__() would return. ''' w_self = ImplicitAcquisitionWrapper(aq_base(self), parent) try: w_self.setupCurrentSkin() except: # This shouldn't happen, even if the requested skin # does not exist. import sys ...
config_path = path.expanduser('~\\ZopeEdit.ini') global_config = path.join(sys.path[0], 'ZopeEdit.ini') if not path.exists(config_path) \
config_path = os.path.expanduser('~\\ZopeEdit.ini') global_config = os.path.join(sys.path[0] or '', 'ZopeEdit.ini') if not os.path.exists(config_path) \
def __init__(self, input_file): try: # Read the configuration file if win32: # Check the home dir first and then the program dir config_path = path.expanduser('~\\ZopeEdit.ini') global_config = path.join(sys.path[0], 'ZopeEdit.ini') if not path.exists(config_path) \ and os.path.exists(global_config): config_path = glob...
config_path = path.expanduser('~/.zope-external-edit')
config_path = os.path.expanduser('~/.zope-external-edit')
def __init__(self, input_file): try: # Read the configuration file if win32: # Check the home dir first and then the program dir config_path = path.expanduser('~\\ZopeEdit.ini') global_config = path.join(sys.path[0], 'ZopeEdit.ini') if not path.exists(config_path) \ and os.path.exists(global_config): config_path = glob...
temp = path.expanduser(self.options['temp_dir'])
temp = os.path.expanduser(self.options['temp_dir'])
def __init__(self, input_file): try: # Read the configuration file if win32: # Check the home dir first and then the program dir config_path = path.expanduser('~\\ZopeEdit.ini') global_config = path.join(sys.path[0], 'ZopeEdit.ini') if not path.exists(config_path) \ and os.path.exists(global_config): config_path = glob...
if not path.exists(content_file):
if not os.path.exists(content_file):
def __init__(self, input_file): try: # Read the configuration file if win32: # Check the home dir first and then the program dir config_path = path.expanduser('~\\ZopeEdit.ini') global_config = path.join(sys.path[0], 'ZopeEdit.ini') if not path.exists(config_path) \ and os.path.exists(global_config): config_path = glob...
last_mtime = path.getmtime(self.content_file)
last_mtime = os.path.getmtime(self.content_file)
def launch(self): """Launch external editor""" save_interval = float(self.options.get('save_interval')) use_locks = int(self.options.get('use_locks', 0)) launch_success = 0 last_mtime = path.getmtime(self.content_file) command = self.getEditorCommand() if command.find('%1') > -1: command = command.replace('%1', self.co...
mtime = path.getmtime(self.content_file)
mtime = os.path.getmtime(self.content_file)
def launch(self): """Launch external editor""" save_interval = float(self.options.get('save_interval')) use_locks = int(self.options.get('use_locks', 0)) launch_success = 0 last_mtime = path.getmtime(self.content_file) command = self.getEditorCommand() if command.find('%1') > -1: command = command.replace('%1', self.co...
def whereIs(filename): """Given a filename, returns the full path to it based on the PATH environment variable. If no file was found, None is returned """ pathExists = os.path.exists if pathExists(filename): return filename pathJoin = os.path.join paths = os.environ['PATH'].split(os.pathsep) for path in paths: file_...
def whereIs(filename): """Given a filename, returns the full path to it based on the PATH environment variable. If no file was found, None is returned """ pathExists = os.path.exists if pathExists(filename): return filename pathJoin = os.path.join paths = os.environ['PATH'].split(os.pathsep) for path in paths: file_...
'Usage: zopeedit.py inputfile')
'Usage: zopeedit inputfile')
def whereIs(filename): """Given a filename, returns the full path to it based on the PATH environment variable. If no file was found, None is returned """ pathExists = os.path.exists if pathExists(filename): return filename pathJoin = os.path.join paths = os.environ['PATH'].split(os.pathsep) for path in paths: file_...
self.unlock(token)
self.unlock()
def unlock(self, interactive=1): """Remove webdav lock from edited zope object""" if not self.did_lock or self.lock_token is None: return 0 # nothing to do headers = {'Lock-Token':self.lock_token} response = self.zopeRequest('UNLOCK', headers) if interactive and response.status / 100 != 2: # Captain, she's still lock...
, REQUEST
, REQUEST=None
def addPolicy( self , policy_id , predicate # TALES expr (def. 'python:1') , mtime_func # TALES expr (def. 'content/modified') , max_age_secs # integer, seconds (def. 0) , no_cache # boolean (def. 0) , no_store # boolean (def. 0) , must_revalidate # boolean (def. 0) , vary ...
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url() + '/manage_cachingPolicies' + '?manage_tabs_message=Policy+added.' )
if REQUEST is not None: REQUEST[ 'RESPONSE' ].redirect( self.absolute_url() + '/manage_cachingPolicies' + '?manage_tabs_message=' + 'Policy+added.' )
def addPolicy( self , policy_id , predicate # TALES expr (def. 'python:1') , mtime_func # TALES expr (def. 'content/modified') , max_age_secs # integer, seconds (def. 0) , no_cache # boolean (def. 0) , no_store # boolean (def. 0) , must_revalidate # boolean (def. 0) , vary ...
, REQUEST ):
, REQUEST=None ):
def updatePolicy( self , policy_id , predicate # TALES expr (def. 'python:1') , mtime_func # TALES expr (def. 'content/modified') , max_age_secs # integer, seconds , no_cache # boolean (def. 0) , no_store # boolean (def. 0) , must_revalidate # boolean (def. 0) , vary , REQUEST ):...
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url() + '/manage_cachingPolicies' + '?manage_tabs_message=Policy+updated.' )
if REQUEST is not None: REQUEST[ 'RESPONSE' ].redirect( self.absolute_url() + '/manage_cachingPolicies' + '?manage_tabs_message=' + 'Policy+updated.' )
def updatePolicy( self , policy_id , predicate # TALES expr (def. 'python:1') , mtime_func # TALES expr (def. 'content/modified') , max_age_secs # integer, seconds , no_cache # boolean (def. 0) , no_store # boolean (def. 0) , must_revalidate # boolean (def. 0) , vary , REQUEST ):...
def movePolicyUp( self, policy_id, REQUEST ):
def movePolicyUp( self, policy_id, REQUEST=None ):
def movePolicyUp( self, policy_id, REQUEST ): """ Move a caching policy up in the list. """ policy_ids = list( self._policy_ids ) ndx = policy_ids.index( policy_id ) if ndx == 0: msg = "Policy+already+first." else: self._reorderPolicy( policy_id, ndx - 1 ) msg = "Policy+moved." REQUEST[ 'RESPONSE' ].redirect( self.abso...
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
if REQUEST is not None: REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
def movePolicyUp( self, policy_id, REQUEST ): """ Move a caching policy up in the list. """ policy_ids = list( self._policy_ids ) ndx = policy_ids.index( policy_id ) if ndx == 0: msg = "Policy+already+first." else: self._reorderPolicy( policy_id, ndx - 1 ) msg = "Policy+moved." REQUEST[ 'RESPONSE' ].redirect( self.abso...
def movePolicyDown( self, policy_id, REQUEST ):
def movePolicyDown( self, policy_id, REQUEST=None ):
def movePolicyDown( self, policy_id, REQUEST ): """ Move a caching policy down in the list. """ policy_ids = list( self._policy_ids ) ndx = policy_ids.index( policy_id ) if ndx == len( policy_ids ) - 1: msg = "Policy+already+last." else: self._reorderPolicy( policy_id, ndx + 1 ) msg = "Policy+moved." REQUEST[ 'RESPONSE...
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
if REQUEST is not None: REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
def movePolicyDown( self, policy_id, REQUEST ): """ Move a caching policy down in the list. """ policy_ids = list( self._policy_ids ) ndx = policy_ids.index( policy_id ) if ndx == len( policy_ids ) - 1: msg = "Policy+already+last." else: self._reorderPolicy( policy_id, ndx + 1 ) msg = "Policy+moved." REQUEST[ 'RESPONSE...
def removePolicy( self, policy_id, REQUEST ):
def removePolicy( self, policy_id, REQUEST=None ):
def removePolicy( self, policy_id, REQUEST ): """ Remove a caching policy. """ self._removePolicy( policy_id ) REQUEST[ 'RESPONSE' ].redirect( self.absolute_url() + '/manage_cachingPolicies' + '?manage_tabs_message=Policy+removed.' )
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
if REQUEST is not None: REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
def removePolicy( self, policy_id, REQUEST ): """ Remove a caching policy. """ self._removePolicy( policy_id ) REQUEST[ 'RESPONSE' ].redirect( self.absolute_url() + '/manage_cachingPolicies' + '?manage_tabs_message=Policy+removed.' )
def manage_doCustomize(self, folder_path, data=None, RESPONSE=None):
def manage_doCustomize(self, folder_path, RESPONSE=None):
def manage_doCustomize(self, folder_path, data=None, RESPONSE=None): """Makes a ZODB Based clone with the same data.
FSObject.manage_doCustomize(self, folder_path, data, RESPONSE)
FSObject.manage_doCustomize(self, folder_path, RESPONSE)
def manage_doCustomize(self, folder_path, data=None, RESPONSE=None): """Makes a ZODB Based clone with the same data.
self.config.set('general', 'editor', path)
self.config.set('general', 'editor', editor)
def getEditorCommand(self): """Return the editor command""" editor = self.options.get('editor') if win32 and editor is None: from _winreg import HKEY_CLASSES_ROOT, OpenKeyEx, \ QueryValueEx, EnumKey from win32api import FindExecutable import pywintypes # Find editor application based on mime type and extension content...
def namedLink(self, doc, level, output): """\ XXX Trial subclassed implementation of HTMLClass as default implementation seems to be broken... """ name = doc.getNodeValue() if name[:2] == '..': name = name[2:] output('<a name="%s">[%s]</a>' % (name, name))
def namedLink(self, doc, level, output): """\ XXX Trial subclassed implementation of HTMLClass#namedLink(), as default implementation seems to be broken... """ name = doc.getNodeValue() if name[:2] == '..': name = name[2:] output('<a name="%s">[%s]</a>' % (name, name))
sdef.setPermission(p_access, 1, (r_anon, r_manager, r_reviewer)) sdef.setPermission(p_view, 1, (r_anon, r_manager, r_reviewer))
sdef.setPermission(p_access, 1, (r_manager, r_owner, r_reviewer)) sdef.setPermission(p_view, 1, (r_manager, r_owner, r_reviewer))
sdef = wf.states['pending']
self.cook()
self._reading = 1 try: self.cook() finally: self._reading = 0
def _readFile(self, reparse): fp = expandpath(self._filepath) file = open(fp, 'rb') try: data = file.read() finally: file.close() self.raw = data if reparse: self.cook()
self._updateFromFS()
if not self._reading: self._updateFromFS()
def read_raw(self): self._updateFromFS() return Globals.HTML.read_raw(self)
file=None, fileid=None):
file=None, fileid=None, lower=string.lower):
def _send_update_notice(self, action, actor, orig_status=None, additions=None, removals=None, file=None, fileid=None): """Send email notification about issue event to relevant parties."""
new_status = string.split(self.status(), '_')[0]
new_status = self.status()
def _send_update_notice(self, action, actor, orig_status=None, additions=None, removals=None, file=None, fileid=None): """Send email notification about issue event to relevant parties."""
if orig_status and not ('accepted' == string.lower(new_status) == string.lower(orig_status)):
continuing_accepted = (lower(orig_status) in ['accepted', 'accepted_confidential'] and lower(new_status) in ['accepted', 'accepted_confidential']) if orig_status and not continuing_accepted:
def _send_update_notice(self, action, actor, orig_status=None, additions=None, removals=None, file=None, fileid=None): """Send email notification about issue event to relevant parties."""
if not exit_pid: launched = 1
if exit_pid != pid: launched = 1
def launch(self): """Launch external editor""" editor = self.getEditorPath() file = self.body_file last_fstat = os.stat(file) pid = os.spawnl(os.P_NOWAIT, editor, editor, file) use_locks = int(self.options.get('use_locks')) if use_locks: self.lock() exit_pid = 0 save_interval = self.config.getfloat('general', 'save_i...
If 'kw' passed, use them to filter the results further, qua the standard Zope filter interface. """ spec = self._morphSpec( spec ) ids = self.objectIds( spec )
""" if spec is None: ids = self.objectIds() else: spec = self._morphSpec(spec) ids = self.objectIds(spec)
def contentIds( self, spec=None, filter=None): """ Provide a filtered view onto 'objectIds', allowing only PortalFolders and PortalContent-derivatives to show through.
spec = self._morphSpec( spec ) ids = self.objectIds( spec )
if spec is None: ids = self.objectIds() else: spec = self._morphSpec(spec) ids = self.objectIds(spec)
def contentValues( self, spec=None, filter=None ): """ Provide a filtered view onto 'objectValues', allowing only PortalFolders and PortalContent-derivatives to show through. """ spec = self._morphSpec( spec ) ids = self.objectIds( spec ) return map( lambda item: item[1], self._filteredItems( ids, filter ) )
items = self.contentValues(spec=spec, filter=contentFilter)
items = self.contentItems(spec=spec, filter=contentFilter)
def listFolderContents( self, spec=None, contentFilter=None ): """ Hook around 'contentValues' to let 'folder_contents' be protected. Duplicating skip_unauthorized behavior of dtml-in. """ items = self.contentValues(spec=spec, filter=contentFilter) l = [] for obj in items: id = obj.getId() v = obj # validate() can eit...
for obj in items: id = obj.getId() v = obj
for id, obj in items:
def listFolderContents( self, spec=None, contentFilter=None ): """ Hook around 'contentValues' to let 'folder_contents' be protected. Duplicating skip_unauthorized behavior of dtml-in. """ items = self.contentValues(spec=spec, filter=contentFilter) l = [] for obj in items: id = obj.getId() v = obj # validate() can eit...
if getSecurityManager().validate(self, self, id, v):
if getSecurityManager().validate(self, self, id, obj):
def listFolderContents( self, spec=None, contentFilter=None ): """ Hook around 'contentValues' to let 'folder_contents' be protected. Duplicating skip_unauthorized behavior of dtml-in. """ items = self.contentValues(spec=spec, filter=contentFilter) l = [] for obj in items: id = obj.getId() v = obj # validate() can eit...
spec = self._morphSpec( spec ) ids = self.objectIds( spec )
if spec is None: ids = self.objectIds() else: spec = self._morphSpec(spec) ids = self.objectIds(spec)
def contentItems( self, spec=None, filter=None ): """ Provide a filtered view onto 'objectItems', allowing only PortalFolders and PortalContent-derivatives to show through. """ spec = self._morphSpec( spec ) ids = self.objectIds( spec ) return self._filteredItems( ids, filter )
self.predicates.append(lambda x, pt=portal_type: x.getPortalTypeName() in pt)
self.predicates.append( lambda x, pt=portal_type: hasattr(aq_base(x), 'getPortalTypeName') and x.getPortalTypeName() in pt )
def __init__( self , Title=MARKER , Creator=MARKER , Subject=MARKER , Description=MARKER , created=MARKER , created_usage='range:min' , modified=MARKER , modified_usage='range:min' , Type=MARKER , portal_type=MARKER , **Ignored ):
changes = 1
def edit(self, title=None, description=None, abbrev=None, email=None, managers=None, supporters=None, dispatching=None, topics=None, classifications=None, importances=None, version_info_spiel=None):
self._write(data)
self._write(data, reparse)
def _readFile(self, reparse): """Read the data from the filesystem. Read the file (indicated by exandpath(self._filepath), and parse the data if necessary. """ fp = expandpath(self._filepath) file = open(fp, 'r') try: data = file.read() finally: file.close() self._write(data)
ps = PythonScript(self.id) ps._body = self._body ps._params = self._params return ps.read()
self._updateFromFS() return self._source
def read(self): ps = PythonScript(self.id) ps._body = self._body ps._params = self._params return ps.read()
return self.read()
return self._source
def document_src(self, REQUEST=None, RESPONSE=None): """Return unprocessed document source."""
def _write(self, text):
def _write(self, text, compile): ''' Parses the source, storing the body, params, title, bindings, and source in self. If compile is set, compiles the function. '''
def _write(self, text): ps = PythonScript(self.id) ps.write(text) ps._makeFunction() ps._editedBindings() self._v_f = f = ps._v_f self._body = ps._body self._params = ps._params fc = f.func_code self._setFuncSignature(f.func_defaults, fc.co_varnames, fc.co_argcount)
ps._makeFunction() ps._editedBindings() self._v_f = f = ps._v_f
if compile: ps._makeFunction(1) self._v_f = f = ps._v_f if f is not None: fc = f.func_code self._setFuncSignature(f.func_defaults, fc.co_varnames, fc.co_argcount) else: self._setFuncSignature()
def _write(self, text): ps = PythonScript(self.id) ps.write(text) ps._makeFunction() ps._editedBindings() self._v_f = f = ps._v_f self._body = ps._body self._params = ps._params fc = f.func_code self._setFuncSignature(f.func_defaults, fc.co_varnames, fc.co_argcount)
fc = f.func_code self._setFuncSignature(f.func_defaults, fc.co_varnames, fc.co_argcount)
self.title = ps.title self._setupBindings(ps.getBindingAssignments().getAssignedNames()) self._source = ps.read() def func_defaults(self): self.func_defaults = None self._write(self._source, 1) return self.func_defaults func_defaults = ComputedAttribute(func_defaults, 1) def func_code(self): self.func_code = None...
def _write(self, text): ps = PythonScript(self.id) ps.write(text) ps._makeFunction() ps._editedBindings() self._v_f = f = ps._v_f self._body = ps._body self._params = ps._params fc = f.func_code self._setFuncSignature(f.func_defaults, fc.co_varnames, fc.co_argcount)
arrow_right_gif = ImageFile( 'www/arrow-right.gif', globals() ) arrow_left_gif = ImageFile( 'www/arrow-left.gif', globals() ) arrow_up_gif = ImageFile( 'www/arrow-up.gif', globals() ) arrow_down_gif = ImageFile( 'www/arrow-down.gif', globals() )
def authenticateCredentials( self, credentials ):
enumeratePrincipals = plugin.enumerateUsers local_key = 'userid' principal_type = 'user' title_key = 'login' title_pattern = "%s" else: enumeratePrincipals = plugin.enumerateGroups local_key = 'groupid' principal_type = 'group' title_key = 'groupid' title_pattern = "(Group) %s"
user_info = plugin.enumerateUsers( id=principal_id , exact_match=True ) if user_info: local_key = 'userid' principal_type = 'user' title_key = 'login' title_pattern = "%s" if getattr( aq_base( plugin ), 'enumerateGroups', None ): group_info = plugin.enumerateGroups( id=principal_id , exact_match=True ) if group_info: l...
def searchPrincipals(self, groups_first=False, **kw): """ Search for principals (users, groups, or both) """ exact_match = kw.get( 'exact_match', False ) max_results = kw.get( 'max_results', '' )
principal_info = enumeratePrincipals( id=principal_id , exact_match=True )
principal_info = filter(None, (user_info + group_info))
def searchPrincipals(self, groups_first=False, **kw): """ Search for principals (users, groups, or both) """ exact_match = kw.get( 'exact_match', False ) max_results = kw.get( 'max_results', '' )
launch_success = 0
def launch(self): """Launch external editor""" use_locks = int(self.options.get('use_locks', 0)) if use_locks and self.metadata.get('lock-token'): # A lock token came down with the data, so the object is # already locked, see if we can borrow the lock if (int(self.options.get('always_borrow_locks', 0)) or self.metadata...
Calls SkinsContainer.getSkinByName().
Calls SkinsContainer.getSkinByPath().
def testSkinPath(self, p): ''' Calls SkinsContainer.getSkinByName(). ''' self.getSkinByPath(p, raise_exc=1)
items = self.contentValues(filter=contentFilter)
items = self.contentValues(spec=spec, filter=contentFilter)
def listFolderContents( self, spec=None, contentFilter=None ): # XXX """ Hook around 'contentValues' to let 'folder_contents' be protected. Duplicating skip_unauthorized behavior of dtml-in. """ items = self.contentValues(filter=contentFilter) l = [] for obj in items: id = obj.getId() v = obj # validate() can either r...
if platform == 'nt':
if platform == 'win32':
def __init__(self, filepath, minimal_fp, ignore=ignore): self._filepath = filepath self._minimal_fp = minimal_fp self.ignore=base_ignore + tuple(ignore) if platform == 'nt': self._walker = _walker(self.ignore) subdirs = [] for entry in _filtered_listdir(self._filepath, ignore=self.ignore): entry_filepath = path.join(se...
changes.append("(Managers set must be non-empty)")
changes.append("Managers can't be empty - including initial" " owner")
def edit(self, title=None, description=None, abbrev=None, email=None, managers=None, supporters=None, dispatching=None, topics=None, classifications=None, importances=None, version_info_spiel=None):
changes.append("(Managers may not deenlist themselves)")
changes.append("Managers cannot de-enlist themselves")
def edit(self, title=None, description=None, abbrev=None, email=None, managers=None, supporters=None, dispatching=None, topics=None, classifications=None, importances=None, version_info_spiel=None):
changes = []
change_notes = [] changed = 0
def _adjust_staff_roles(self, no_reindex=0): """Adjust local-role assignments to track staff roster settings. Ie, ensure: only designated supporters and managers have 'Reviewer' local role, only designated managers have 'Manager' local role.
changes.append("Populated empty managers roster")
change_notes.append("Populated empty managers roster") changed = 1
def _adjust_staff_roles(self, no_reindex=0): """Adjust local-role assignments to track staff roster settings. Ie, ensure: only designated supporters and managers have 'Reviewer' local role, only designated managers have 'Manager' local role.
changes.append("Managers")
changed = 1
def _adjust_staff_roles(self, no_reindex=0): """Adjust local-role assignments to track staff roster settings. Ie, ensure: only designated supporters and managers have 'Reviewer' local role, only designated managers have 'Manager' local role.
changes.append("Supporters") if changes and not no_reindex:
changed = 1 if changed and not no_reindex:
def _adjust_staff_roles(self, no_reindex=0): """Adjust local-role assignments to track staff roster settings. Ie, ensure: only designated supporters and managers have 'Reviewer' local role, only designated managers have 'Manager' local role.
return changes
return change_notes
def _adjust_staff_roles(self, no_reindex=0): """Adjust local-role assignments to track staff roster settings. Ie, ensure: only designated supporters and managers have 'Reviewer' local role, only designated managers have 'Manager' local role.
def reinstate_catalog(self, internal_only=0):
def reinstate_catalog(self, internal_only=1):
def reinstate_catalog(self, internal_only=0): """Recreate and reload internal catalog, to accommodate drastic changes.""" try: self._delObject(INTERNAL_CATALOG_ID) except AttributeError: pass self._setup_internal_catalog() for i in self.objectValues(spec='CMF Collector Issue'): # Normalize security_related setting if i...
for i in self.objectValues(spec='CMF Collector Issue'): if i.security_related not in [0, 1]: i.security_related = (i.security_related and 1) or 0
def reinstate_catalog(self, internal_only=0): """Recreate and reload internal catalog, to accommodate drastic changes.""" try: self._delObject(INTERNAL_CATALOG_ID) except AttributeError: pass self._setup_internal_catalog() for i in self.objectValues(spec='CMF Collector Issue'): # Normalize security_related setting if i...
def _reindex_issues(self, internal_only=0):
def _reindex_issues(self, internal_only=1):
def _reindex_issues(self, internal_only=0): """For, eg, allowedRolesAndUsers recompute after local_role changes.""" for i in self.objectValues(spec='CMF Collector Issue'): i.reindexObject(internal_only=internal_only)
os.remove( '%s.tar.gz' % self._version_id ) os.remove( '%s.zip' % self._version_id )
try: os.remove( '%s.tar.gz' % self._version_id ) except OSError: pass try: os.remove( '%s.zip' % self._version_id ) except OSError: pass
def makeArchives( self ):
slurp_release [options] release_tag version_id userid password
slurp_release [options] release_tag version_id
def _usage( self ):
if int( response.status ) not in ( 200, 204, 302 ):
if int( response.status ) not in ( 200, 201, 204, 302 ):
def _uploadFile( self, filename ):
info['url'] = self.action and self.action( ec ) or ''
action_obj = self._getActionObject() info['url'] = action_obj and action_obj( ec ) or ''
def getAction( self, ec ):
security.declarePublic( 'getActionExpression' ) def getActionExpression( self ): """ Return the text of the TALES expression for our URL.
security.declarePrivate( '_getActionObject' ) def _getActionObject( self ): """ Find the action object, working around name changes.
def getAction( self, ec ):
members.manage_addPortalFolder(member_id)
f_title = "%s's Home" % member_id members.manage_addPortalFolder( id=member_id, title=f_title )
def createMemberarea(self, member_id): """ create a member area """ parent = self.aq_inner.aq_parent members = getattr(parent, 'Members', None)
launch_success = editor.isAlive()
def launch(self): """Launch external editor""" use_locks = int(self.options.get('use_locks', 0)) if use_locks and self.metadata.get('lock-token'): # A lock token came down with the data, so the object is # already locked, see if we can borrow the lock if (int(self.options.get('always_borrow_locks', 0)) or self.metadata...
if d.get('propagate-' + op, None) == "ON":
if lower(d.get('propagate-' + op, None)) == "on":
def setRegulations(self, d): """Set regulations for CMFWiki page """ offspring = None # clear local roles related to Wiki stuff self.clearLocalWikiRoles() for op in self.regOps(): # create, edit, comment, move usernames = d.get(op + '-usernames', []) category = d.get(op + '-category', None) self.setOp(op, usernames, ca...
if not source: REQUEST = getattr( self, 'REQUEST', None ) if REQUEST: content = aq_parent( self ) mgr = getToolByName( content , 'caching_policy_manager' , None ) if mgr: view_name = self.getId() RESPONSE = REQUEST[ 'RESPONSE' ] headers = mgr.getHTTPCachingHeaders( content , view_name , extra_context ) for key, va...
result = FSPageTemplate.inheritedAttribute('pt_render')( self, source, extra_context ) if not source: self._setCacheHeaders(extra_context) return result
def pt_render(self, source=0, extra_context={}): self._updateFromFS() # Make sure the template has been loaded. try: if not source: # Hook up to caching policy.
for user_wrapper in self._members.values(): memberProperty = user_wrapper.getProperty searched = memberProperty( search_param, None ) if searched is not None and searched.find(search_term) != -1: res.append( { 'username': memberProperty( 'id' ) , 'email' : memberProperty( 'email', '' ) } )
mtool = getToolByName(self, 'portal_membership') for member_id in self._members.keys(): user_wrapper = mtool.getMemberById( member_id ) if user_wrapper is not None: memberProperty = user_wrapper.getProperty searched = memberProperty( search_param, None ) if searched is not None and searched.find(search_term) != -...
def searchMemberDataContents( self, search_param, search_term ): """ Search members. This method will be deprecated soon. """ res = []
if self.data is None:
changed = 0 if Globals.DevelopmentMode: try: mtime = stat(expandpath(self.filepath))[8] except: mtime = 0 if mtime != self._v_last_read: self._v_last_read = mtime changed = 1 if self.data is None or changed:
def getContents(self, registry): if self.data is None: try: self.data, self.objects = self.prepareContents(registry) except: # DEBUG import traceback traceback.print_exc()