rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if type(self) != TemplateDict: raise TypeError,'''A call was made to DT_Util.namespace() with an incorrect "self" argument. It could be caused by a product which is not yet compatible with this version of Zope. The traceback information may contain more details.'''
def namespace(self, **kw): """Create a tuple consisting of a single instance whos attributes are provided as keyword arguments.""" # NOTE: the self argument needs to be a TemplateDict instance. return apply(self, (), kw)
if a level > 1
if a level > 1. This fix is lame. The problem should be fixed inside STXNG
def spacestrip(txt): """ dedent text by 2 spaces ! We need this to workaround a nasty bug in STXNG. STXNG creates empty <pre>..</pre> when then text start if a level > 1 """ l = [] for x in string.split(txt,"\n"): if len(x)>2 and x[:2]==' ': l.append(x[2:]) return string.join(l,'\n')
return self.manage_workspace(self, REQUEST, update_menu=1)
return self.manage_main(self, REQUEST, update_menu=1)
def manage_addFolder(self, id, title='', createPublic=0, createUserF=0, REQUEST=None): """Add a new Folder object with id *id*. If the 'createPublic' and 'createUserF' parameters are set to any true value, an 'index_html' and a 'UserFolder' objects are created respectively in the new folder. """ ob=Folder() ob.id=id ob.title=title self._setObject(id, ob) try: user=REQUEST['AUTHENTICATED_USER'] except: user=None if createUserF: if (user is not None) and not ( user.has_permission('Add User Folders', self)): raise 'Unauthorized', ( 'You are not authorized to add User Folders.' ) ob.manage_addUserFolder() if createPublic: if (user is not None) and not ( user.has_permission('Add Documents, Images, and Files', self)): raise 'Unauthorized', ( 'You are not authorized to add DTML Documents.' ) ob.manage_addDTMLDocument(id='index_html', title='') if REQUEST is not None: return self.manage_workspace(self, REQUEST, update_menu=1)
Append a value to a cookie
Append a value to a header.
def appendHeader(name, value, delimiter=","): ''' Append a value to a cookie Sets an HTTP return header "name" with value "value", appending it following a comma if there was a previous value set for the header.
$Id: Publish.py,v 1.26 1996/11/26 22:06:18 jim Exp $"""
$Id: Publish.py,v 1.27 1996/12/30 14:36:12 jim Exp $"""
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
__version__='$Revision: 1.26 $'[11:-2]
__version__='$Revision: 1.27 $'[11:-2]
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
"The parameter, %s, was ommitted from the request."
"The parameter, %s, was omitted from the request."
def badRequestError(self,name):
url.append(id)
url.append(quote(id))
def absolute_url(self, relative=0): """Return an absolute url to the object. Note that the url will reflect the acquisition path of the object if the object has been acquired.""" obj=self url=[] while hasattr(obj, 'aq_parent') and hasattr(obj.aq_parent, 'id'): id=callable(obj.id) and obj.id() or str(obj.id) url.append(id) obj=obj.aq_parent if not relative: url.append(self.aq_acquire('REQUEST').script) url.reverse() return quote(join(url, '/'))
return quote(join(url, '/'))
return join(url, '/')
def absolute_url(self, relative=0): """Return an absolute url to the object. Note that the url will reflect the acquisition path of the object if the object has been acquired.""" obj=self url=[] while hasattr(obj, 'aq_parent') and hasattr(obj.aq_parent, 'id'): id=callable(obj.id) and obj.id() or str(obj.id) url.append(id) obj=obj.aq_parent if not relative: url.append(self.aq_acquire('REQUEST').script) url.reverse() return quote(join(url, '/'))
getattr(self,id).propertysheets.permissions.manage_edit( selected=['Add %ss' % id]) getattr(self,id).manage_setPermissionMapping(
Z=self._getOb(id) Z.propertysheets.permissions.manage_edit( selected=['Add %ss' % id]) Z.manage_setPermissionMapping(
def manage_addZClass(self, id, title='', baseclasses=[], meta_type='', CreateAFactory=0, REQUEST=None): """Add a Z Class """ bases=[] for b in baseclasses: if Products.meta_classes.has_key(b): bases.append(Products.meta_classes[b]) else: base=find_class(self, b) bases.append(base) Z=ZClass(id,title,bases) if meta_type: Z._zclass_.meta_type=meta_type self._setObject(id, Z) if CreateAFactory and meta_type: self.manage_addDTMLMethod( id+'_addForm', id+' constructor input form', addFormDefault % {'id': id, 'meta_type': meta_type}, ) self.manage_addDTMLMethod( id+'_add', id+' constructor', addDefault % {'id': id}, ) self.manage_addPermission( id+'_add_permission', id+' constructor permission', 'Add %ss' % meta_type ) self.manage_addPrincipiaFactory( id+'_factory', id+' factory', meta_type, id+'_addForm', 'Add %ss' % meta_type ) getattr(self,id).propertysheets.permissions.manage_edit( selected=['Add %ss' % id]) getattr(self,id).manage_setPermissionMapping( permission_names=['Create class instances'], class_permissions=['Add %ss' % meta_type] ) if REQUEST is not None: return self.manage_main(self,REQUEST, update_menu=1)
if sys.modules.has_key(m):
if sys.modules.has_key(m) and sys.modules[m]._m.has_key(name):
def __getattr__(self, name): p=self.__dict__['_product'] d=p.__dict__ if hasattr(p,name) and d.has_key(name): m=d[name] w=getattr(m, '_permissionMapper', None) if w is not None: m=ofWrapper(aqwrap(m, getattr(w,'aq_base',w), self)) return m
def parens(s, parens_re=re.compile(r'(\|)').search):
def parens(s, parens_re=re.compile('[\(\)]').search):
def parens(s, parens_re=re.compile(r'(\|)').search): index = open_index = paren_count = 0 while 1: index = parens_re(s, index) if index is None : break if s[index] == '(': paren_count = paren_count + 1 if open_index == 0 : open_index = index + 1 else: paren_count = paren_count - 1 if paren_count == 0: return open_index, index else: index = index + 1 if paren_count == 0: # No parentheses Found return None else: raise QueryError, "Mismatched parentheses"
index = parens_re(s, index) if index is None : break
mo = parens_re(s, index) if mo is None : break index = mo.start(0)
def parens(s, parens_re=re.compile(r'(\|)').search): index = open_index = paren_count = 0 while 1: index = parens_re(s, index) if index is None : break if s[index] == '(': paren_count = paren_count + 1 if open_index == 0 : open_index = index + 1 else: paren_count = paren_count - 1 if paren_count == 0: return open_index, index else: index = index + 1 if paren_count == 0: # No parentheses Found return None else: raise QueryError, "Mismatched parentheses"
def close(self, unlink=0):
def close(self, unlink=1):
def close(self, unlink=0): """Close the file.
self._fp.close() if unlink: os.unlink(self._fp.name)
if self._fp: self._fp.close() if unlink or self._unlink: os.unlink(self._fp.name) self._fp = None
def close(self, unlink=0): """Close the file.
return unittest.makeSuite(BatchTests)
return makeSuite(BatchTests)
def test_suite(): return unittest.makeSuite(BatchTests)
r.data_record_id_ = 1
r.data_record_score__ = 1
def __getitem__(self, index, ttype=type(())): """ Returns instances of self._v_brains, or whatever is passed into self.useBrains. """
if ininstance(MONITOR_PORT, IntType):
if isinstance(MONITOR_PORT, IntType):
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
if instance(UID, StringType):
if isinstance(UID, StringType):
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
elif instance(UID, IntType):
elif isinstance(UID, IntType):
def _warn_nobody(): zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise " "your Zope files; consider using a " "dedicated user account for Zope") )
if v1 == "NA" or v2 == "NA": return "I" else: return (all[i] + all[i2]) / 2
if type(v1) is type('') or type(v2) is type(''): return "I" else: return (v1 + v2) / 2
def median(self): all = self.all() l = len(all) if l == 0: return "I" else: if l == 1: return all[0] elif l % 2 != 0: i = l/2 + 1 return all[i] else: i = l/2 - 1 i2 = i + 1 v1 = all[i] v2 = all[i2] if v1 == "NA" or v2 == "NA": return "I" else: return (all[i] + all[i2]) / 2
LOG('UnIndex', ERROR, ('unindex_object tried to retrieve set %s' 'from index %s but couldn\'t. This ' 'should not happen.' % (repr(set), str(k))))
def unindex_object(self, i): """ Unindex the object with integer id 'i' and don't raise an exception if we fail """ index = self._index unindex = self._unindex
'integer id %s from index.' % str(k)))
'integer id %s from index %s. This ' 'should not happen.' % (str(i), str(k)))) else: LOG('UnIndex', ERROR, ('unindex_object tried to retrieve set %s ' 'from index %s but couldn\'t. This ' 'should not happen.' % (repr(set),str(k))))
def unindex_object(self, i): """ Unindex the object with integer id 'i' and don't raise an exception if we fail """ index = self._index unindex = self._unindex
t="<p><strong>%s</strong><p>" % strip(ctag(t))
t="<p><strong>%s</strong></p>" % strip(ctag(t))
def head(self, before, t, level, d): if level > 0 and level < 6: return ('%s<h%d>%s</h%d>\n%s\n' % (before,level,strip(ctag(t)),level,d)) t="<p><strong>%s</strong><p>" % strip(ctag(t)) return ('%s<dl><dt>%s\n</dt><dd>%s\n</dd></dl>\n' % (before,t,d))
dbtab.databases.update(getattr(DB, 'databases', {})) DB.databases = dbtab.databases
databases.update(getattr(DB, 'databases', {})) DB.databases = databases
def startup(): global app # Import products OFS.Application.import_products() configuration = getConfiguration() # Open the database dbtab = configuration.dbtab try: # Try to use custom storage try: m=imp.find_module('custom_zodb',[configuration.testinghome]) except: m=imp.find_module('custom_zodb',[configuration.instancehome]) except: # if there is no custom_zodb, use the config file specified databases DB = dbtab.getDatabase('/', is_root=1) else: m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2]) sys.modules['Zope2.custom_zodb']=m if hasattr(m,'DB'): DB=m.DB dbtab.databases.update(getattr(DB, 'databases', {})) DB.databases = dbtab.databases else: DB = ZODB.DB(m.Storage, databases=dbtab.databases) Globals.BobobaseName = DB.getName() if DB.getActivityMonitor() is None: from ZODB.ActivityMonitor import ActivityMonitor DB.setActivityMonitor(ActivityMonitor()) Globals.DB = DB # Ick, this is temporary until we come up with some registry Zope2.DB = DB # Hook for providing multiple transaction object manager undo support: Globals.UndoManager=DB Globals.opened.append(DB) import ClassFactory DB.classFactory = ClassFactory.ClassFactory # "Log on" as system user newSecurityManager(None, AccessControl.User.system) # Set up the "app" object that automagically opens # connections app = App.ZApplication.ZApplicationWrapper( DB, 'Application', OFS.Application.Application, (), Globals.VersionNameName) Zope2.bobo_application = app # Initialize the app object application = app() OFS.Application.initialize(application) if Globals.DevelopmentMode: # Set up auto-refresh. from App.RefreshFuncs import setupAutoRefresh setupAutoRefresh(application._p_jar) application._p_jar.close() # "Log off" as system user noSecurityManager() global startup_time startup_time = asctime() Zope2.zpublisher_transactions_manager = TransactionsManager() Zope2.zpublisher_exception_hook = zpublisher_exception_hook Zope2.zpublisher_validated_hook = validated_hook Zope2.__bobo_before__ = noSecurityManager
DB = ZODB.DB(m.Storage, databases=dbtab.databases)
DB = ZODB.DB(m.Storage, databases=databases)
def startup(): global app # Import products OFS.Application.import_products() configuration = getConfiguration() # Open the database dbtab = configuration.dbtab try: # Try to use custom storage try: m=imp.find_module('custom_zodb',[configuration.testinghome]) except: m=imp.find_module('custom_zodb',[configuration.instancehome]) except: # if there is no custom_zodb, use the config file specified databases DB = dbtab.getDatabase('/', is_root=1) else: m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2]) sys.modules['Zope2.custom_zodb']=m if hasattr(m,'DB'): DB=m.DB dbtab.databases.update(getattr(DB, 'databases', {})) DB.databases = dbtab.databases else: DB = ZODB.DB(m.Storage, databases=dbtab.databases) Globals.BobobaseName = DB.getName() if DB.getActivityMonitor() is None: from ZODB.ActivityMonitor import ActivityMonitor DB.setActivityMonitor(ActivityMonitor()) Globals.DB = DB # Ick, this is temporary until we come up with some registry Zope2.DB = DB # Hook for providing multiple transaction object manager undo support: Globals.UndoManager=DB Globals.opened.append(DB) import ClassFactory DB.classFactory = ClassFactory.ClassFactory # "Log on" as system user newSecurityManager(None, AccessControl.User.system) # Set up the "app" object that automagically opens # connections app = App.ZApplication.ZApplicationWrapper( DB, 'Application', OFS.Application.Application, (), Globals.VersionNameName) Zope2.bobo_application = app # Initialize the app object application = app() OFS.Application.initialize(application) if Globals.DevelopmentMode: # Set up auto-refresh. from App.RefreshFuncs import setupAutoRefresh setupAutoRefresh(application._p_jar) application._p_jar.close() # "Log off" as system user noSecurityManager() global startup_time startup_time = asctime() Zope2.zpublisher_transactions_manager = TransactionsManager() Zope2.zpublisher_exception_hook = zpublisher_exception_hook Zope2.zpublisher_validated_hook = validated_hook Zope2.__bobo_before__ = noSecurityManager
'--config-file', action="callback", type="string",
'--config-file', action="callback", type="string", dest='config_file',
def load_config_file(option, opt, config_file, *ignored): config_file = os.path.abspath(config_file) print "Parsing %s" % config_file import Zope2 Zope2.configure(config_file)
Initialize Zope with the given config file.
Initialize Zope with the given configuration file.
def load_config_file(option, opt, config_file, *ignored): config_file = os.path.abspath(config_file) print "Parsing %s" % config_file import Zope2 Zope2.configure(config_file)
data = self.conn.recv(1024)
data = self.getLine()
def _check(self, lev='250'): data = self.conn.recv(1024) if data[:3] != lev: raise smtpError, "Expected %s, got %s from SMTP"%(lev, data[:3])
('View', ['index_html','view_image_or_file','getSize','getContentType']),
('View', ['index_html','view_image_or_file','getSize','getContentType', '']),
def manage_addFile(self,id,file,title='',precondition='',REQUEST=None): """Add a new File object. Creates a new file object 'id' with the contents of 'file'""" self._setObject(id, File(id,title,file,precondition)) if REQUEST is not None: return self.manage_main(self,REQUEST)
def view_image_or_file(self,REQUEST,RESPONSE):
def view_image_or_file(self,URL1):
def view_image_or_file(self,REQUEST,RESPONSE):
return self.index_html(REQUEST,RESPONSE)
raise 'Redirect', URL1
def view_image_or_file(self,REQUEST,RESPONSE):
n=chidren[0]
n=children[0]
def getFirstChild(self, type=type, st=type('')): """ The first child of this node. If there is no such node this returns None """ children = self.getChildren()
return self.GetNodeValue(type,st)
return self.getNodeValue(type,st)
def _get_NodeValue(self, type=type, st=type('')): return self.GetNodeValue(type,st)
try: db=self._p_jar.db() except: return Globals.BobobaseName else: return db.getName()
return self._p_jar.db().getName()
def db_name(self): try: db=self._p_jar.db() except: # BoboPOS 2 return Globals.BobobaseName else: # ZODB 3 return db.getName()
def dbconnections(self): return Globals.DB.connectionDebugInfo()
def rcdeltas(self): if self._v_rcs is None: self.rcsnapshot() nc=self.refdict() rc=self._v_rcs rd=[] for n, c in nc.items(): prev=rc[n] if c > prev: rd.append( (c - prev, (c, prev, n)) ) rd.sort() rd.reverse()
try: db=self._p_jar.db() except: pass else: t=db.pack(t) if REQUEST is not None: REQUEST['RESPONSE'].redirect( REQUEST['URL1']+'/manage_workspace') return t if self._p_jar.db is not Globals.Bobobase._jar.db: raise 'Version Error', ( '''You may not pack the application database while working in a <em>version</em>''') if Globals.Bobobase.has_key('_pack_time'): since=Globals.Bobobase['_pack_time'] if t <= since: if REQUEST: return self.manage_main(self, REQUEST) return Globals.Bobobase._jar.db.pack(t,0) Globals.Bobobase['_pack_time']=t get_transaction().note('') get_transaction().commit() if REQUEST: return self.manage_main(self, REQUEST)
db=self._p_jar.db() t=db.pack(t) if REQUEST is not None: REQUEST['RESPONSE'].redirect( REQUEST['URL1']+'/manage_workspace') return t
def manage_pack(self, days=0, REQUEST=None): """Pack the database"""
self.threshold = thresholdb
self.threshold = threshold
def manage_edit(self, RESPONSE, URL1, threshold=1000, REQUEST=None): """ edit the catalog """ self.threshold = thresholdb
if not hasattr(self, '_v_total'): self._v_total = 0
def catalog_object(self, obj, uid): """ wrapper around catalog """ if not hasattr(self, '_v_total'): self._v_total = 0 self._v_total = (self._v_total + self._catalog.catalogObject(obj, uid, self.threshold)) if self._v_total > self.threshold: get_transaction().commit(1) self._v_total = 0
try: traverse=object.__bobo_traverse__ except: traverse=None if traverse is not None:
if hasattr(object,'__bobo_traverse__'):
def publish(self, module_name, after_list, published='web_objects',
subobject=traverse(request,entry_name)
subobject=object.__bobo_traverse__(request,entry_name)
def publish(self, module_name, after_list, published='web_objects',
response.exception()
def publish_module(module_name, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, environ=os.environ, debug=0): must_die=0 status=200 after_list=[None] try: response=Response(stdout=stdout, stderr=stderr) publisher = ModulePublisher(stdin=stdin, stdout=stdout, stderr=stderr, environ=environ) response = publisher.response response = publisher.publish(module_name,after_list,debug=debug) except SystemExit: must_die=1 response.exception(must_die) except ImportError, v: if type(v)==types.TupleType and len(v)==3: sys.exc_type, sys.exc_value, sys.exc_traceback = v must_die=1 response.exception(must_die) except: status=response.getStatus() response.exception() if response: response=str(response) if response: stdout.write(response) # The module defined a post-access function, call it if after_list[0] is not None: after_list[0]() if must_die: raise sys.exc_type, sys.exc_value, sys.exc_traceback sys.exc_type, sys.exc_value, sys.exc_traceback = None, None, None return status
$Id: Publish.py,v 1.48 1997/09/08 14:47:11 jim Exp $"""
$Id: Publish.py,v 1.49 1997/09/09 20:25:21 jim Exp $"""
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
__version__='$Revision: 1.48 $'[11:-2]
__version__='$Revision: 1.49 $'[11:-2]
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
result=result or {}
if result is None: result={}
def parse_cookie(text, result=None, parmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)=\([^\0- =\"]+\)' '\([\0- ]*[;,]\)?[\0- ]*\)' ), qparmre=regex.compile( '\([\0- ]*' '\([^\0- ;,=\"]+\)="\([^"]*\)\"' '\([\0- ]*[;,]\)?[\0- ]*\)' ), ): result=result or {} if parmre.match(text) >= 0: name=lower(parmre.group(2)) value=parmre.group(3) l=len(parmre.group(1)) elif qparmre.match(text) >= 0: name=lower(qparmre.group(2)) value=qparmre.group(3) l=len(qparmre.group(1)) else: if not text or not strip(text): return result raise "InvalidParameter", text result[name]=value return apply(parse_cookie,(text[l:],result))
index_html=HTMLFile('dtml/APIHelpView', globals())
index_html=DTMLFile('dtml/APIHelpView', globals())
def __init__(self, id, title, file): self.id=id self.title=title dict={} execfile(file, dict) self.doc=dict.get('__doc__','')
view=HTMLFile('dtml/APIView', globals())
view=DTMLFile('dtml/APIView', globals())
def SearchableText(self): """ The full text of the API, for indexing purposes. """ text="%s %s" % (self.name, self.doc) for attribute in self.attributes: text="%s %s" % (text, attribute.name) for method in self.methods: text="%s %s %s" % (text, method.name, method.doc) return text
view=HTMLFile('dtml/attributeView', globals())
view=DTMLFile('dtml/attributeView', globals())
def __init__(self, name, value): self.name=name self.value=value
view=HTMLFile('dtml/methodView', globals())
view=DTMLFile('dtml/methodView', globals())
def _createFromFunc(self, func): if hasattr(func, 'im_func'): func=func.im_func
manage=ManageHTMLFile('AqueductDA/edit')
manage=HTMLFile('AqueductDA/edit')
def test_url_(self):
self.result_names=result.names() self.report_src=custom_default_report(result,action='/manage_testForm') report=DocumentTemplate.HTML(self.report_src)
result_names=result.names() report_src=custom_default_report(result,action='/manage_testForm') if result_names != self.result_names or report_src != self.report_src: self.result_names=names self.report_src=report_src report=DocumentTemplate.HTML(report_src)
def manage_test(self,REQUEST):
for p in instance_class.__ac_permissions__: if len(p) > 2: permissions.append((p[0],p[2])) else: permissions.append(p[0])
if hasattr(instance_class, '__ac_permissions__'): for p in instance_class.__ac_permissions__: if len(p) > 2: permissions.append((p[0],p[2])) else: permissions.append(p[0])
def registerClass(self, instance_class=None, meta_type='', permission=None, constructors=(), icon=None, permissions=None, legacy=(), ): """Register a constructor
if (not hasattr(user, 'hasRole') or not user.hasRole(None, roles)):
if (not hasattr(user, 'has_role') or not user.has_role(roles, self)):
def _verifyObjectPaste(self, ob, REQUEST): if not hasattr(ob, 'meta_type'): raise CopyError, MessageDialog( title='Not Supported', message='The object <EM>%s</EM> does not support this ' \ 'operation' % absattr(ob.id), action='manage_main') mt=ob.meta_type if not hasattr(self, 'all_meta_types'): raise CopyError, MessageDialog( title='Not Supported', message='Cannot paste into this object.', action='manage_main')
__getattr__=get=__getitem__
__getattr__=__getitem__ def get(self, key, default=None): return self.__getitem__(key, default)
def __getitem__(self,key, default=_marker, # Any special internal marker will do URLmatch=regex.compile('URL[0-9]+$').match, BASEmatch=regex.compile('BASE[0-9]+$').match, ): """Get a variable value
from CGIResponse import Response
from Response import Response
def publish_module_pm(module_name, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, environ=os.environ, debug=0): from CGIResponse import Response from Publish import ModulePublisher after_list=[None] request=None try: response=Response(stdout=stdout, stderr=stderr) publisher = ModulePublisher(stdin=stdin, stdout=stdout, stderr=stderr, environ=environ) response = publisher.response request=publisher.request response = publisher.publish(module_name,after_list,debug=debug) request.other={} response=str(response) finally: try: request.other={} except: pass if after_list[0] is not None: after_list[0]()
skip_names={'testrunner.py': None, 'test_logger.py': None, 'test_MultiMapping.py': None, 'test_Sync.py': None, 'test_ThreadLock.py': None, 'test_acquisition.py': None, 'test_add.py': None, 'test_binding.py': None, 'test_explicit_acquisition.py': None, 'test_func_attr.py': None, 'test_method_hook.py': None, 'test.py': None, } skip_name=skip_names.has_key
def __init__(self, basepath): # initialize python path self.basepath=path=basepath pjoin=os.path.join if sys.platform == 'win32': sys.path.insert(0, pjoin(path, 'lib/python')) sys.path.insert(1, pjoin(path, 'bin/lib')) sys.path.insert(2, pjoin(path, 'bin/lib/plat-win')) sys.path.insert(3, pjoin(path, 'bin/lib/win32')) sys.path.insert(4, pjoin(path, 'bin/lib/win32/lib')) sys.path.insert(5, path) else: sys.path.insert(0, pjoin(path, 'lib/python')) sys.path.insert(1, path)
skip_name = self.skip_name
def runPath(self, pathname): """Run all tests found in the directory named by pathname and all subdirectories.""" names=os.listdir(pathname) skip_name = self.skip_name for name in names: fname, ext=os.path.splitext(name) if name[:4]=='test' and name[-3:]=='.py' and \ (not skip_name(name)): filepath=os.path.join(pathname, name) self.runFile(filepath) for name in names: fullpath=os.path.join(pathname, name) if os.path.isdir(fullpath): self.runPath(fullpath)
(not skip_name(name)):
name != 'testrunner.py':
def runPath(self, pathname): """Run all tests found in the directory named by pathname and all subdirectories.""" names=os.listdir(pathname) skip_name = self.skip_name for name in names: fname, ext=os.path.splitext(name) if name[:4]=='test' and name[-3:]=='.py' and \ (not skip_name(name)): filepath=os.path.join(pathname, name) self.runFile(filepath) for name in names: fullpath=os.path.join(pathname, name) if os.path.isdir(fullpath): self.runPath(fullpath)
self.runFile(filepath)
if self.smellsLikeATest(filepath): self.runFile(filepath)
def runPath(self, pathname): """Run all tests found in the directory named by pathname and all subdirectories.""" names=os.listdir(pathname) skip_name = self.skip_name for name in names: fname, ext=os.path.splitext(name) if name[:4]=='test' and name[-3:]=='.py' and \ (not skip_name(name)): filepath=os.path.join(pathname, name) self.runFile(filepath) for name in names: fullpath=os.path.join(pathname, name) if os.path.isdir(fullpath): self.runPath(fullpath)
usage_msg="""Usage: python testrunner.py [options]
usage_msg="""Usage: python testrunner.py options
def main(args): usage_msg="""Usage: python testrunner.py [options] If run without options, testrunner will run all test suites found in all subdirectories of the current working directory. options: -a Run all tests found in all subdirectories of the current working directory. This is the default if no options are specified. -d dirpath Run all tests found in the directory specified by dirpath, and recursively in all its subdirectories. The dirpath should be a full system path. -f filepath Run the test suite found in the file specified. The filepath should be a fully qualified path to the file to be run.\n""" pathname=None filename=None test_all=None try: options, arg=getopt.getopt(args, 'ad:f:') for name, value in options: name=name[1:] if name == 'a': test_all=1 elif name == 'd': pathname=string.strip(value) elif name == 'f': filename=string.strip(value) else: err_exit(usage_msg) if not options: test_all=1 except: err_exit(usage_msg) testrunner=TestRunner(os.getcwd()) if test_all: testrunner.runAllTests() elif pathname: testrunner.runPath(pathname) elif filename: testrunner.runFile(filename) sys.exit(0)
If run without options, testrunner will run all test suites found in all subdirectories of the current working directory.
If run without options, testrunner will display this usage message. If you want to run all test suites found in all subdirectories of the current working directory, use the -a option.
def main(args): usage_msg="""Usage: python testrunner.py [options] If run without options, testrunner will run all test suites found in all subdirectories of the current working directory. options: -a Run all tests found in all subdirectories of the current working directory. This is the default if no options are specified. -d dirpath Run all tests found in the directory specified by dirpath, and recursively in all its subdirectories. The dirpath should be a full system path. -f filepath Run the test suite found in the file specified. The filepath should be a fully qualified path to the file to be run.\n""" pathname=None filename=None test_all=None try: options, arg=getopt.getopt(args, 'ad:f:') for name, value in options: name=name[1:] if name == 'a': test_all=1 elif name == 'd': pathname=string.strip(value) elif name == 'f': filename=string.strip(value) else: err_exit(usage_msg) if not options: test_all=1 except: err_exit(usage_msg) testrunner=TestRunner(os.getcwd()) if test_all: testrunner.runAllTests() elif pathname: testrunner.runPath(pathname) elif filename: testrunner.runFile(filename) sys.exit(0)
should be a fully qualified path to the file to be run.\n"""
should be a fully qualified path to the file to be run. -h Display usage information.\n"""
def main(args): usage_msg="""Usage: python testrunner.py [options] If run without options, testrunner will run all test suites found in all subdirectories of the current working directory. options: -a Run all tests found in all subdirectories of the current working directory. This is the default if no options are specified. -d dirpath Run all tests found in the directory specified by dirpath, and recursively in all its subdirectories. The dirpath should be a full system path. -f filepath Run the test suite found in the file specified. The filepath should be a fully qualified path to the file to be run.\n""" pathname=None filename=None test_all=None try: options, arg=getopt.getopt(args, 'ad:f:') for name, value in options: name=name[1:] if name == 'a': test_all=1 elif name == 'd': pathname=string.strip(value) elif name == 'f': filename=string.strip(value) else: err_exit(usage_msg) if not options: test_all=1 except: err_exit(usage_msg) testrunner=TestRunner(os.getcwd()) if test_all: testrunner.runAllTests() elif pathname: testrunner.runPath(pathname) elif filename: testrunner.runFile(filename) sys.exit(0)
options, arg=getopt.getopt(args, 'ad:f:')
options, arg=getopt.getopt(args, 'ahd:f:') if not options: err_exit(usage_msg)
def main(args): usage_msg="""Usage: python testrunner.py [options] If run without options, testrunner will run all test suites found in all subdirectories of the current working directory. options: -a Run all tests found in all subdirectories of the current working directory. This is the default if no options are specified. -d dirpath Run all tests found in the directory specified by dirpath, and recursively in all its subdirectories. The dirpath should be a full system path. -f filepath Run the test suite found in the file specified. The filepath should be a fully qualified path to the file to be run.\n""" pathname=None filename=None test_all=None try: options, arg=getopt.getopt(args, 'ad:f:') for name, value in options: name=name[1:] if name == 'a': test_all=1 elif name == 'd': pathname=string.strip(value) elif name == 'f': filename=string.strip(value) else: err_exit(usage_msg) if not options: test_all=1 except: err_exit(usage_msg) testrunner=TestRunner(os.getcwd()) if test_all: testrunner.runAllTests() elif pathname: testrunner.runPath(pathname) elif filename: testrunner.runFile(filename) sys.exit(0)
if not options: test_all=1
def main(args): usage_msg="""Usage: python testrunner.py [options] If run without options, testrunner will run all test suites found in all subdirectories of the current working directory. options: -a Run all tests found in all subdirectories of the current working directory. This is the default if no options are specified. -d dirpath Run all tests found in the directory specified by dirpath, and recursively in all its subdirectories. The dirpath should be a full system path. -f filepath Run the test suite found in the file specified. The filepath should be a fully qualified path to the file to be run.\n""" pathname=None filename=None test_all=None try: options, arg=getopt.getopt(args, 'ad:f:') for name, value in options: name=name[1:] if name == 'a': test_all=1 elif name == 'd': pathname=string.strip(value) elif name == 'f': filename=string.strip(value) else: err_exit(usage_msg) if not options: test_all=1 except: err_exit(usage_msg) testrunner=TestRunner(os.getcwd()) if test_all: testrunner.runAllTests() elif pathname: testrunner.runPath(pathname) elif filename: testrunner.runFile(filename) sys.exit(0)
def manage_editCataloger(self, default):
def manage_editCataloger(self, default, REQUEST):
def manage_editCataloger(self, default): """ """ self.default_catalog=default message = "Your changes have been saved" return self.manage_main(self, REQUEST, manage_tabs_message=message)
except: state=[]
except: state=[] if state: md['RESPONSE'].setCookie('state',quote(str(state)[1:-1]+',')) else: md['RESPONSE'].expireCookie('state')
def tpRender(self, md, section): # Check for collapse all, expand all, and state try: collapse_all=md['collapse_all'] except: collapse_all=None if collapse_all: state=[] else: try: expand_all=md['expand_all'] except: expand_all=None if expand_all: # in case of expand all - to maintain state correctly we # have to make state be the ids of ALL subobjects which # are non-empty (recursively). state=tpValuesIds(self) else: try: state=md['state'] if state[0] != '[': state=unquote(state) state=list(eval(state,{'__builtins__':{}})) except: state=[] # Try to save state in a cookie as well... # md['RESPONSE'].setCookie('state',state) root=md['URL'] l=rfind(root, '/') if l >= 0: root=root[l+1:] url='' data =[] data.append('<table cellspacing=0>\n') colspan=1+tpStateLevel(state) treeData={'tree-root-url': root} md.push(treeData) try: for item in self.tpValues(): data=tpRenderTABLE(item,root,url,state,state,data,colspan, section,md,treeData) data.append('</table>\n') result=join(data,'') finally: md.pop(1) return result
data.append('<table cellspacing=0>\n')
data.append('<TABLE CELLSPACING="0">\n')
def tpRender(self, md, section): # Check for collapse all, expand all, and state try: collapse_all=md['collapse_all'] except: collapse_all=None if collapse_all: state=[] else: try: expand_all=md['expand_all'] except: expand_all=None if expand_all: # in case of expand all - to maintain state correctly we # have to make state be the ids of ALL subobjects which # are non-empty (recursively). state=tpValuesIds(self) else: try: state=md['state'] if state[0] != '[': state=unquote(state) state=list(eval(state,{'__builtins__':{}})) except: state=[] # Try to save state in a cookie as well... # md['RESPONSE'].setCookie('state',state) root=md['URL'] l=rfind(root, '/') if l >= 0: root=root[l+1:] url='' data =[] data.append('<table cellspacing=0>\n') colspan=1+tpStateLevel(state) treeData={'tree-root-url': root} md.push(treeData) try: for item in self.tpValues(): data=tpRenderTABLE(item,root,url,state,state,data,colspan, section,md,treeData) data.append('</table>\n') result=join(data,'') finally: md.pop(1) return result
data.append('</table>\n')
data.append('</TABLE>\n')
def tpRender(self, md, section): # Check for collapse all, expand all, and state try: collapse_all=md['collapse_all'] except: collapse_all=None if collapse_all: state=[] else: try: expand_all=md['expand_all'] except: expand_all=None if expand_all: # in case of expand all - to maintain state correctly we # have to make state be the ids of ALL subobjects which # are non-empty (recursively). state=tpValuesIds(self) else: try: state=md['state'] if state[0] != '[': state=unquote(state) state=list(eval(state,{'__builtins__':{}})) except: state=[] # Try to save state in a cookie as well... # md['RESPONSE'].setCookie('state',state) root=md['URL'] l=rfind(root, '/') if l >= 0: root=root[l+1:] url='' data =[] data.append('<table cellspacing=0>\n') colspan=1+tpStateLevel(state) treeData={'tree-root-url': root} md.push(treeData) try: for item in self.tpValues(): data=tpRenderTABLE(item,root,url,state,state,data,colspan, section,md,treeData) data.append('</table>\n') result=join(data,'') finally: md.pop(1) return result
id=item.tpId() e=tpValuesIds(item) if e: id=[id,e] else: id=[id] r.append(id)
if item.tpValues(): id=item.tpId() e=tpValuesIds(item) if e: id=[id,e] else: id=[id] r.append(id)
def tpValuesIds(self): r=[] try: for item in self.tpValues(): try: id=item.tpId() e=tpValuesIds(item) if e: id=[id,e] else: id=[id] r.append(id) except: pass except: pass return r
output('<tr>') if level: output('<td></td>' * level)
output('<TR>\n') if level: output('<TD WIDTH="16"></TD>\n' * level)
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0): # We are being called from above try: items=self.tpValues() except: items=None tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<tr>') if level: output('<td></td>' * level) # Add tree expand/contract icon if items: output('<td valign=top>') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: del substate[exp-1] output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] else: output('<td>') output('</td>\n') # add item text output('<td colspan=%s valign=top>' % colspan) output(section(self, md)) output('</td></tr>\n') if exp: for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level+1) if not sub[1]: del sub[1] return data
output('<td valign=top>')
output('<TD WIDTH="16" VALIGN="TOP">')
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0): # We are being called from above try: items=self.tpValues() except: items=None tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<tr>') if level: output('<td></td>' * level) # Add tree expand/contract icon if items: output('<td valign=top>') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: del substate[exp-1] output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] else: output('<td>') output('</td>\n') # add item text output('<td colspan=%s valign=top>' % colspan) output(section(self, md)) output('</td></tr>\n') if exp: for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level+1) if not sub[1]: del sub[1] return data
output('<td>') output('</td>\n')
output('<TD WIDTH="16">') output('</TD>\n')
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0): # We are being called from above try: items=self.tpValues() except: items=None tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<tr>') if level: output('<td></td>' * level) # Add tree expand/contract icon if items: output('<td valign=top>') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: del substate[exp-1] output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] else: output('<td>') output('</td>\n') # add item text output('<td colspan=%s valign=top>' % colspan) output(section(self, md)) output('</td></tr>\n') if exp: for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level+1) if not sub[1]: del sub[1] return data
output('<td colspan=%s valign=top>' % colspan)
output('<TD COLSPAN="%s" VALIGN="TOP">' % (colspan-level))
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0): # We are being called from above try: items=self.tpValues() except: items=None tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<tr>') if level: output('<td></td>' * level) # Add tree expand/contract icon if items: output('<td valign=top>') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: del substate[exp-1] output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] else: output('<td>') output('</td>\n') # add item text output('<td colspan=%s valign=top>' % colspan) output(section(self, md)) output('</td></tr>\n') if exp: for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level+1) if not sub[1]: del sub[1] return data
output('</td></tr>\n')
output('</TD>\n</TR>\n')
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0): # We are being called from above try: items=self.tpValues() except: items=None tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<tr>') if level: output('<td></td>' * level) # Add tree expand/contract icon if items: output('<td valign=top>') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: del substate[exp-1] output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] else: output('<td>') output('</td>\n') # add item text output('<td colspan=%s valign=top>' % colspan) output(section(self, md)) output('</td></tr>\n') if exp: for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level+1) if not sub[1]: del sub[1] return data
icoSpace='<IMG SRC="%s/TreeDisplay/Blank_icon.gif" ' \ ' BORDER="0">' % SOFTWARE_URL icoPlus ='<IMG SRC="%s/TreeDisplay/Plus_icon.gif" BORDER="0"' \ ' ALT="+">' % SOFTWARE_URL icoMinus='<IMG SRC="%s/TreeDisplay/Minus_icon.gif" BORDER="0"' \ ' ALT="-">' % SOFTWARE_URL
def tpRenderTABLE(self, root_url, url, state, substate, data, colspan, section, md, treeData, level=0): # We are being called from above try: items=self.tpValues() except: items=None tpUrl=self.tpURL() url = (url and ('%s/%s' % (url, tpUrl))) or tpUrl treeData['tree-item-url']=url try: id=self.tpId() except: id=None if id is None: try: id=self._p_oid except: id=None if id is None: id=pyid(self) exp=0 sub=None output=data.append # Add prefix output('<tr>') if level: output('<td></td>' * level) # Add tree expand/contract icon if items: output('<td valign=top>') for i in range(len(substate)): sub=substate[i] if sub[0]==id: exp=i+1 break if exp: del substate[exp-1] output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoMinus)) substate.append(sub) else: substate.append([id]) output('<A HREF="%s?state=%s">%s</A>' % (root_url,quote(str(state)[1:-1]+','), icoPlus)) del substate[-1] else: output('<td>') output('</td>\n') # add item text output('<td colspan=%s valign=top>' % colspan) output(section(self, md)) output('</td></tr>\n') if exp: for item in items: if len(sub)==1: sub.append([]) data=tpRenderTABLE(item, root_url,url,state,sub[1],data, colspan, section, md, treeData, level+1) if not sub[1]: del sub[1] return data
for info in db.transaction_info(first_transaction, last_transaction, path):
try: trans_info=db.transaction_info(first_transaction, last_transaction,path) except: trans_info=[] for info in trans_info:
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None):
return r
return r or []
def undoable_transactions(self, AUTHENTICATION_PATH=None, first_transaction=None, last_transaction=None):
if defineMacro: self.pushProgram() self.emit("version", TAL_VERSION) self.emit("mode", self.xml and "xml" or "html") todo["defineMacro"] = defineMacro if useMacro: self.pushSlots() self.pushProgram() todo["useMacro"] = useMacro if fillSlot: self.pushProgram() todo["fillSlot"] = fillSlot if defineSlot: self.pushProgram() todo["defineSlot"] = defineSlot
if self.inMacroUse: if fillSlot: self.pushProgram() todo["fillSlot"] = fillSlot self.inMacroUse = 0 else: if fillSlot: raise METALError, ("fill-slot must be within a use-macro", position) if not self.inMacroUse: if defineMacro: self.pushProgram() self.emit("version", TAL_VERSION) self.emit("mode", self.xml and "xml" or "html") todo["defineMacro"] = defineMacro self.inMacroDef = self.inMacroDef + 1 if useMacro: self.pushSlots() self.pushProgram() todo["useMacro"] = useMacro self.inMacroUse = 1 if defineSlot: if not self.inMacroDef: raise METALError, ( "define-slot must be within a define-macro", position) self.pushProgram() todo["defineSlot"] = defineSlot
def emitStartElement(self, name, attrlist, taldict, metaldict, position=(None, None), isend=0): if not taldict and not metaldict: # Handle the simple, common case self.emitStartTag(name, attrlist, isend) self.todoPush({}) if isend: self.emitEndElement(name, isend) return
self.emitStartTag(name, attrlist)
self.emitStartTag(name, list(attrlist))
def emitStartElement(self, name, attrlist, taldict, metaldict, position=(None, None), isend=0): if not taldict and not metaldict: # Handle the simple, common case self.emitStartTag(name, attrlist, isend) self.todoPush({}) if isend: self.emitEndElement(name, isend) return
if not url:
if not url or not self.checkInstallation(REQUEST): REQUEST.set('hide_next', 0)
def tutorialShowLesson(self, id, REQUEST): """ Navigate management frame to a given lesson's screen. """ url=self.lessonURL(id, REQUEST) if not url: return """\
if k is None or k == MV: return 0
def index_object(self, i, obj, threshold=None): """ index and object 'obj' with integer id 'i'""" index = self._index unindex = self._unindex
pdb.set_trace()
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
if hi: setlist = index.items(lo,hi) else: setlist = index.items(lo) for k,set in setlist: if r is None: r = set else: r = r.union(set) except KeyError: pass
if hi: setlist = index.items(lo,hi) else: setlist = index.items(lo) for k, set in setlist: print 'adding set %s to %s' % (tuple(set), id) if r is None: r = set else: r = r.union(set) except KeyError: pass
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
if anyTrue: r=intSet() else: return None
if anyTrue: r=intSet() else: return None print 'UnIndex says there are %s records' % len(r)
def _apply_index(self, request, cid=''): """Apply the index to query parameters given in the argument, request
id='copy%s_of_%s' % (n and n+1 or '', id)
id='copy%s_of_%s' % (n and n+1 or '', orig_id)
def _get_id(ob, id): try: ob=ob.aq_base except: pass n=0 if (len(id) > 8) and (id[8:]=='copy_of_'): n=1 while (hasattr(ob, id)): id='copy%s_of_%s' % (n and n+1 or '', id) n=n+1 return id
if __debug__:
if Z_DEBUG_MODE:
def pt_render(self, source=0, extra_context={}): """Render this Page Template""" if self._v_errors: raise RuntimeError, 'Page Template %s has errors.' % self.id output = StringIO() c = self.pt_getContext() c.update(extra_context) if __debug__: __traceback_info__ = pprint.pformat(c)
def manage_move_objects_up(self, REQUEST, ids=None, delta=None):
def manage_move_objects_up(self, REQUEST, ids=None, delta=1):
def manage_move_objects_up(self, REQUEST, ids=None, delta=None): """ Move specified sub-objects up by delta in container. """ if ids: try: attempt = self.moveObjectsUp(ids, delta) message = '%d item%s moved up.' % ( attempt, ( (attempt!=1) and 's' or '' ) ) except ValueError, errmsg: message = 'Error: %s' % (errmsg) else: message = 'Error: No items were specified!' return self.manage_main(self, REQUEST, skey='position', manage_tabs_message=message)
def manage_move_objects_down(self, REQUEST, ids=None, delta=None):
def manage_move_objects_down(self, REQUEST, ids=None, delta=1):
def manage_move_objects_down(self, REQUEST, ids=None, delta=None): """ Move specified sub-objects down by delta in container. """ if ids: try: attempt = self.moveObjectsDown(ids, delta) message = '%d item%s moved down.' % ( attempt, ( (attempt!=1) and 's' or '' ) ) except ValueError, errmsg: message = 'Error: %s' % (errmsg) else: message = 'Error: No items were specified!' return self.manage_main(self, REQUEST, skey='position', manage_tabs_message=message)
try: sm= response.setMessage except: sm= None
sm = None if response is not None: sm = getattr(response, "setMessage", None)
def publish(request, module_name, after_list, debug=0, # Optimize: call_object=call_object, missing_name=missing_name, dont_publish_class=dont_publish_class, mapply=mapply, ): (bobo_before, bobo_after, object, realm, debug_mode, err_hook, validated_hook, transactions_manager)= get_module_info(module_name) parents=None try: request.processInputs() request_get=request.get response=request.response # First check for "cancel" redirect: cancel='' if request_get('SUBMIT','').strip().lower()=='cancel': cancel=request_get('CANCEL_ACTION','') if cancel: raise 'Redirect', cancel after_list[0]=bobo_after if debug_mode: response.debug_mode=debug_mode if realm and not request.get('REMOTE_USER',None): response.realm=realm if bobo_before is not None: bobo_before() # Get a nice clean path list: path=request_get('PATH_INFO').strip() request['PARENTS']=parents=[object] if transactions_manager: transactions_manager.begin() object=request.traverse(path, validated_hook=validated_hook) if transactions_manager: transactions_manager.recordMetaData(object, request) result=mapply(object, request.args, request, call_object,1, missing_name, dont_publish_class, request, bind=1) if result is not response: response.setBody(result) if transactions_manager: transactions_manager.commit() return response except: if transactions_manager: transactions_manager.abort() # DM: provide nicer error message for FTP try: sm= response.setMessage except: sm= None if sm is not None: from ZServer.medusa.asyncore import compact_traceback cl,val= sys.exc_info()[:2] sm('%s: %s %s' % (getattr(cl,'__name__',cl), val, debug_mode and compact_traceback()[-1] or '')) if err_hook is not None: if parents: parents=parents[0] try: return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) except Retry: # We need to try again.... if not request.supports_retry(): return err_hook(parents, request, sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2], ) newrequest=request.retry() request.close() # Free resources held by the request. try: return publish(newrequest, module_name, after_list, debug) finally: newrequest.close() else: raise
object = object + 1
object += 1
def __iadd__(self, other): return self.__class__(self.value + other)
r"\s*(?:(global|local)\s+)?(%s)\s+(.*)" % NAME_RE, part)
r"(?s)\s*(?:(global|local)\s+)?(%s)\s+(.*)\Z" % NAME_RE, part)
def emitDefines(self, defines, position): for part in splitParts(defines): m = re.match( r"\s*(?:(global|local)\s+)?(%s)\s+(.*)" % NAME_RE, part) if not m: raise TALError("invalid define syntax: " + `part`, position) scope, name, expr = m.group(1, 2, 3) scope = scope or "local" cexpr = self.compileExpression(expr) if scope == "local": self.emit("setLocal", name, cexpr) else: self.emit("setGlobal", name, cexpr)
m = re.match("\s*(%s)\s+(.*)" % NAME_RE, arg)
m = re.match("(?s)\s*(%s)\s+(.*)\Z" % NAME_RE, arg)
def emitRepeat(self, arg): m = re.match("\s*(%s)\s+(.*)" % NAME_RE, arg) if not m: raise TALError("invalid repeat syntax: " + `repeat`) name, expr = m.group(1, 2) cexpr = self.compileExpression(expr) program = self.popProgram() self.emit("loop", name, cexpr, program)
refer to the HTML source for this page.
refer to error log.
def _error_html(self,title,body): # XXX could this try to use standard_error_message somehow? return ("""\
p = aq_parent(aq_inner(self)
p = aq_parent(aq_inner(self))
def getPhysicalPath(self): '''Returns a path (an immutable sequence of strings) that can be used to access this object again later, for example in a copy/paste operation. getPhysicalRoot() and getPhysicalPath() are designed to operate together. ''' path = (self.getId(),) p = aq_parent(aq_inner(self) if p is not None: path = p.getPhysicalPath() + path
try: mtime=os.stat(self.filename)[8] except: mtime=0 if hasattr(self, '_v_program') and mtime == self._v_last_read:
try: mtime = os.path.getmtime(self.filename) except OSError: mtime = 0 if self._v_program is not None and mtime == self._v_last_read:
def _cook_check(self): if self._v_last_read and not DevelopmentMode: return __traceback_info__ = self.filename try: mtime=os.stat(self.filename)[8] except: mtime=0 if hasattr(self, '_v_program') and mtime == self._v_last_read: return self.pt_edit(open(self.filename), None) self._cook() if self._v_errors: LOG('PageTemplateFile', ERROR, 'Error in template', '\n'.join(self._v_errors)) return self._v_last_read = mtime
try: db=self._jar.db()
try: db=self._p_jar.db()
def __bobo_traverse__(self, REQUEST, name): if name[-9:]=='__draft__': return getattr(self, name)
try: db=self._jar.db()
try: db=self._p_jar.db()
def nonempty(self): try: db=self._jar.db() except: # BoboPOS 2 return Globals.VersionBase[self._version].nonempty() else: # ZODB 3 return not db.versionEmpty(self._version)
try: db=self._jar.db()
try: db=self._p_jar.db()
def manage_Save__draft__(self, remark, REQUEST=None): """Make version changes permanent""" try: db=self._jar.db() except: # BoboPOS 2 Globals.VersionBase[self._version].commit(remark) else: # ZODB 3 s=self._version d=self._p_jar.getVersion() if d==s: d='' db.commitVersion(s, d) if REQUEST: REQUEST['RESPONSE'].redirect(REQUEST['URL2']+'/manage_main')
try: db=self._jar.db()
try: db=self._p_jar.db()
def manage_Discard__draft__(self, REQUEST=None): 'Discard changes made during the version' try: db=self._jar.db() except: # BoboPOS 2 Globals.VersionBase[self._version].abort() else: # ZODB 3 db.abortVersion(self._version)
if security.validate(accessed, container, name, value, roles): return 1
if roles is _noroles: if security.validate(accessed, container, name, value): return 1 else: if security.validate(accessed, container, name, value, roles): return 1
def authorize(self, user, accessed, container, name, value, roles): user = getattr(user, 'aq_base', user).__of__(self) newSecurityManager(None, user) security = getSecurityManager() try: try: if security.validate(accessed, container, name, value, roles): return 1 except: noSecurityManager() raise except Unauthorized: pass return 0