rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True, output_encoding='utf-8'):
def __init__(self, id, text=None, content_type=None, strict=True, output_encoding='utf-8'):
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True, output_encoding='utf-8'): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = output_encoding
self.pt_edit(text, content_type, True)
self.pt_edit(text, content_type)
def __init__(self, id, text=None, content_type=None, encoding='utf-8', strict=True, output_encoding='utf-8'): self.id = id self.expand = 0 self.ZBindings_edit(self._default_bindings) self.output_encoding = output_encoding
guessed_content_type = guess_type('', text) if guessed_content_type != content_type: raise ValueError('Guessed content-type != passed content-type (%s vs. %s)' % (guessed_content_type, content_type))
def pt_edit(self, text, content_type, keep_output_encoding=False):
print charset
def pt_edit(self, text, content_type, keep_output_encoding=False):
raise ValueError('Unsupported content_type %s' % content_type)
raise ValueError('Unsupported content-type %s' % content_type)
def pt_edit(self, text, content_type, keep_output_encoding=False):
response.setHeader('content-type', '%s; charset=%s' % (self.content_type, self.output_encoding))
response.setHeader('content-type', self.content_type)
def _exec(self, bound_names, args, kw): """Call a Page Template""" if not kw.has_key('args'): kw['args'] = args bound_names['options'] = kw
encoding = sniffEncoding(text)
def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8', submit=None, REQUEST=None, RESPONSE=None): "Add a Page Template with optional file content." filename = '' content_type = 'text/html' if REQUEST and REQUEST.has_key('file'): file = REQUEST['file'] filename = file.filename text = file.read() hea...
encoding = sniffEncoding(text) zpt = ZopePageTemplate(id, text, content_type, encoding, True)
if not isinstance(text, unicode): text = unicode(text, encoding) zpt = ZopePageTemplate(id, text, content_type, output_encoding=encoding)
def manage_addPageTemplate(self, id, title='', text='', encoding='utf-8', submit=None, REQUEST=None, RESPONSE=None): "Add a Page Template with optional file content." filename = '' content_type = 'text/html' if REQUEST and REQUEST.has_key('file'): file = REQUEST['file'] filename = file.filename text = file.read() hea...
'url_quote' function.
'quote' function.
def url_quote(s): """ Convert characters that have special meaning in URLS to HTML character entities using decimal values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_quote' function. """
'url_quote_plus' function.
'quote_plus' function.
def url_quote_plus(s): """ Like url_quote but also replace blank space characters with '+'. This is needed for building query strings in some cases. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_quote_plus' function. """
Convert HTML character entities in strings back to their real values.
Convert HTML %xx character entities into the characters they represent. (Undoes the affects of url_quote). See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'unquote' function. """ def url_unquote_plus(s): """ Like url_unquote but also replace '+' characters with blank spac...
def url_unquote(s): """ Convert HTML character entities in strings back to their real values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote' function. """
'url_unquote' function. """ def url_unquote(s): """ Like url_unquote, but also replace '+' characters with spaces.
'unquote_plus' function.
def url_unquote(s): """ Convert HTML character entities in strings back to their real values. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote' function. """
See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote_plus' function.
def url_unquote(s): """ Like url_unquote, but also replace '+' characters with spaces. See Also "Python 'urllib' module":http://www.python.org/doc/current/lib/module-urllib.html 'url_unquote_plus' function. """
t=[]; a=t.append for s in subs: a(s.getNodeValue()) apply(ST.StructuredTextParagraph.__init__, (self, join(t,'\n\n'), ()), kw)
t=[] a=t.append for s in subs: flatten(s, a) apply(ST.StructuredTextParagraph.__init__, (self, join(t,'\n\n'), ()), kw)
def __init__(self, subs, **kw): t=[]; a=t.append for s in subs: a(s.getNodeValue()) apply(ST.StructuredTextParagraph.__init__, (self, join(t,'\n\n'), ()), kw)
'getContentType', '__call__', '')),
'getContentType', '')),
def manage_addFile(self,id,file='',title='',precondition='', content_type='', REQUEST=None): """Add a new File object. Creates a new File object 'id' with the contents of 'file'""" id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) self=self...
'getContentType', '__call__', '')),
'getContentType', '')),
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id=str(id) title=str(title) content_type=str(content_type) precondition=str(precondition) id, title = cookId(id, title, file) se...
main()
unittest.main(defaultTest='test_suite')
def test_suite(): return unittest.makeSuite(HTMLTests, 'check')
"""IMplement a contents view by redirecting to the true view
"""Implement a contents view by redirecting to the true view
def manage_main(trueself, self, REQUEST, update_menu=0): """IMplement a contents view by redirecting to the true view """ d = update_menu and '/manage_main?update_menu=1' or '/manage_main' REQUEST['RESPONSE'].redirect(self.DestinationURL()+d)
mm = TemplateDict() mm._push(var) mm._push({'_ob': ob}) return mm['_ob']
return render(ob)
def __call__(self, econtext): base = self._base path = list(self._path) # Copy! contexts = econtext.contexts var = contexts['var'] # Expand dynamic path parts from right to left. for i, varname in self._dynparts: val = var[varname] if type(val) is type(''): path[i] = val else: # If the value isn't a string, assume it's...
prop=' <n:%s%s>%s</n:%s>' % (name, attrs, xml_escape(value), name)
if hasattr(self,"dav__"+name): prop=' <n:%s%s>%s</n:%s>' % (name, attrs, value, name) else: prop=' <n:%s%s>%s</n:%s>' % (name, attrs, xml_escape(value), name)
def dav__allprop(self, propstat=propstat, join=string.join): # DAV helper method - return one or more propstat elements # indicating property names and values for all properties. result=[] for item in self._propertyMap(): name, type=item['id'], item.get('type','string') value=self.getProperty(name) if type=='tokens': v...
if REQUEST is not None: return self.manage_main(self,REQUEST)
if REQUEST is not None: try: url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url)
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id, title = cookId(id, title, file) self=self.this() self._setObject(id, Image(id,title,'',content_type, precondition)) if Global...
"""Principia object for *Images*, can be GIF, PNG or JPEG. Has the same methods as File objects. Images also have a string representation that renders an HTML 'IMG' tag.
"""Image objects can be GIF, PNG or JPEG and have the same methods as File objects. Images also have a string representation that renders an HTML 'IMG' tag.
def manage_addImage(self, id, file, title='', precondition='', content_type='', REQUEST=None): """ Add a new Image object. Creates a new Image object 'id' with the contents of 'file'. """ id, title = cookId(id, title, file) self=self.this() self._setObject(id, Image(id,title,'',content_type, precondition)) if Global...
self.index = self._index_factory(self.getLexicon())
self.index = self._index_factory(aq_base(self.getLexicon()))
def __init__(self, id, extra=None, caller=None, index_factory=None, field_name=None, lexicon_id=None): self.id = id
print tag, self.nsdict
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) print tag, self.nsdict if tag not in EMPTY_HTML_TAGS: self.tagstack.append(tag) else: self.pop_xmlns() print "<", tag, self.nsdict self.gen.emitStartTag(tag, attrs)
print "<", tag, self.nsdict
def finish_starttag(self, tag, attrs): self.scan_xmlns(attrs) print tag, self.nsdict if tag not in EMPTY_HTML_TAGS: self.tagstack.append(tag) else: self.pop_xmlns() print "<", tag, self.nsdict self.gen.emitStartTag(tag, attrs)
print "<", tag, self.nsdict
def finish_endtag(self, tag): if tag not in EMPTY_HTML_TAGS: if not tag: tag = self.tagstack.pop() else: assert tag in self.tagstack while self.tagstack[-1] != tag: self.finish_endtag(None) self.tagstack.pop() self.pop_xmlns() print "<", tag, self.nsdict self.gen.emitEndTag(tag)
obj=obj._getCopy(self)
def pasteFromClipboard(self,clip_id='',clip_data='',REQUEST=None): """ """
if hasattr(ob, '__call__'): return 1 else: return isinstance(ob, types.ClassType)
return hasattr(ob, '__call__') or isinstance(ob, types.ClassType)
def safe_callable(ob): # Works with ExtensionClasses and Acquisition. if hasattr(ob, '__class__'): if hasattr(ob, '__call__'): return 1 else: return isinstance(ob, types.ClassType) else: return callable(ob)
if index%4000 == 0: index = randid()
if index % 4000 == 0: index = randint(-2000000000, 2000000000)
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
index=randid()
index = randint(-2000000000, 2000000000)
def catalogObject(self, object, uid, threshold=None,idxs=[]): """ Adds an object to the Catalog by iteratively applying it all indexes.
% (fields[i], self._names[i], _index))
% (fields[i], self._names[i], index))
def __getitem__(self,index):
def _delOb(self, id, value):
def _delOb(self, id):
def _delOb(self, id, value): delattr(self, id) pc=self.aq_inner.aq_parent.aq_parent._zclass_propertysheets_class delattr(pc,id) pc.__propset_attrs__=tuple(map(lambda o: o[0], self._objects)) rclass(pc)
CatalogAwareInterface=Interface(CatalogAware)
def reindex_all(obj=None): """
if 'Anonymous' in roles: return 1
if 'Anonymous' in object_roles: return 1
def allowed(self, object, object_roles=None): """Check whether the user has access to object, assuming that object.__roles__ is the given roles.""" if object_roles is None or 'Anonymous' in object_roles: return 1 usr_roles=self.getRolesInContext(object) for role in object_roles: if role in usr_roles: # The user apparen...
if 'Shared' in roles:
if 'Shared' in object_roles:
def allowed(self, object, object_roles=None): """Check whether the user has access to object, assuming that object.__roles__ is the given roles.""" if object_roles is None or 'Anonymous' in object_roles: return 1 usr_roles=self.getRolesInContext(object) for role in object_roles: if role in usr_roles: # The user apparen...
roles=self._shared_roles(object) if roles is None or 'Anonymous' in roles: return 1 while 'Shared' in roles: roles.remove('Shared') return self.allowed(object,roles)
object_roles=self._shared_roles(object) if object_roles is None or 'Anonymous' in object_roles: return 1 while 'Shared' in object_roles: object_roles.remove('Shared') return self.allowed(object,object_roles)
def allowed(self, object, object_roles=None): """Check whether the user has access to object, assuming that object.__roles__ is the given roles.""" if object_roles is None or 'Anonymous' in object_roles: return 1 usr_roles=self.getRolesInContext(object) for role in object_roles: if role in usr_roles: # The user apparen...
return self.manage_main(self, REQUEST, cb_dataValid=1)
REQUEST['__cp'] = cp return self.manage_main(REQUEST)
def manage_cutObjects(self, ids=None, REQUEST=None): """Put a reference to the objects named in ids in the clip board""" if ids is None and REQUEST is not None: return eNoItemsSpecified elif ids is None: raise ValueError, 'ids must be specified'
return self.manage_main(self, REQUEST, cb_dataValid=1)
REQUEST['__cp'] = cp return self.manage_main(REQUEST)
def manage_copyObjects(self, ids=None, REQUEST=None, RESPONSE=None): """Put a reference to the objects named in ids in the clip board""" if ids is None and REQUEST is not None: return eNoItemsSpecified elif ids is None: raise ValueError, 'ids must be specified'
if v: v="CHECKET"
if v: v="CHECKED"
def _booleanInput(self,n,t,v):
'boolean': _booleanInput,
def _textInput(self,n,t,v): return ('<TEXTAREA NAME="%s" ROWS="10" COLS="50">%s</TEXTAREA>'
d=j(j(CUSTOMER_HOME,'var'),'gadfly')
d=j(j(INSTANCE_HOME,'var'),'gadfly')
def manage_addZGadflyConnection( self, id, title, connection, check=None, REQUEST=None): " " return getDA().manage_addZGadflyConnection( self, id, title, connection, check, REQUEST)
errend = find(text, '-->')
errend = text.find('-->')
def write(self, text): assert type(text) is type('') if text[:len(self._error_start)] == self._error_start: errend = find(text, '-->') if errend >= 0: text = text[errend + 4:] if self._text != text: self._text = text self._cook()
if not exists(path_join(package_dir, '__init__.py')): continue
if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.pyc')): continue
def install_products(): # Install a list of products into the basic folder class, so # that all folders know about top-level objects, aka products path_join=os.path.join product_dir=path_join(SOFTWARE_HOME,'lib/python/Products') isdir=os.path.isdir exists=os.path.exists DictType=type({}) meta_types=list(Folder.Folder...
env['PATH_TRANSLATED']= os.path.normpath( os.path.join(os.getcwd(), env['PATH_INFO']))
env['PATH_TRANSLATED']= posixpath.normpath( posixpath.join(os.getcwd(), env['PATH_INFO']))
def get_env(self, req): env = self._ENV.copy() (path, params, query, fragment) = req.split_uri() if params: path = path + params # undo medusa bug while path and path[0] == '/': path = path[1:] if '%' in path: path = unquote(path) if query: # ZPublisher doesn't want the leading '?' query = query[1:] env['PATH_INFO']= '...
s = open(fn).read()
s = open(fn).read().strip()
def _prep_version_data(): global _version_string, _zope_version if _version_string is None: v = sys.version_info pyver = "python %d.%d.%d, %s" % (v[0], v[1], v[2], sys.platform) cfg = getConfiguration() fn = os.path.join(cfg.softwarehome, 'version.txt') expr = re.compile( r'(?P<product>[A-Za-z0-9]+) +(?P<major>[0-9]+)'...
doc, localName = self.engine.findMacroDocument(macroName) if not doc: macro = self.macros[localName] else: macroDict = macroIndexer(doc) if not macroDict.has_key(localName): print "Macro", macroName, "not found" return macroNode = macroDict[localName] macro, dummy = TALCompiler(macroNode)()
macro = self.engine.evaluateMacro(macroName)
def do_useMacro(self, macroName, compiledSlots): doc, localName = self.engine.findMacroDocument(macroName) if not doc: # Local macro macro = self.macros[localName] else: # External macro macroDict = macroIndexer(doc) if not macroDict.has_key(localName): print "Macro", macroName, "not found" return macroNode = macroDict...
<select name="<!--
<select name="%(id)s">
def _edit_widget_for_type(self, t, id, p): if t in ('int', 'long', 'float', 'date', 'string'): if t=='string': q=' html_quote' else: q='' return (''' <input name="%s:%s" size="35" value="<!--#var %s%s-->">''' % (id, t, id, q) ) if t=='boolean': return (''' <input type="checkbox" name="%s:boolean" size="35" <!--#if %s--...
working directory. This is the default if no options are specified.
working directory.
def main(args): usage_msg="""Usage: python testrunner.py options 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. options: -a Run all tests found in all subdirectories of the curre...
self._delObject(id)
def manage_renameObject(self, id, new_id, REQUEST=None): """Rename a particular sub-object""" try: self._checkId(new_id) except: raise CopyError, MessageDialog( title='Invalid Id', message=sys.exc_info()[1], action ='manage_main') ob=self._getOb(id) if not ob.cb_isMoveable(): raise CopyError, eNotSupported % id self._v...
key = self.getBrowserIdManager().getToken(create=0) if key: if self._hasSessionDataObject(key): return 1
return not not self.getSessionData(create=0)
def hasSessionData(self): """ """ key = self.getBrowserIdManager().getToken(create=0) if key: if self._hasSessionDataObject(key): return 1
$Id: Publish.py,v 1.8 1996/07/18 14:59:54 jfulton Exp $"""
$Id: Publish.py,v 1.9 1996/07/23 19:59:29 jfulton Exp $"""
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
__version__='$Revision: 1.8 $'[11:-2]
__version__='$Revision: 1.9 $'[11:-2]
def taste(spam): "a favorable reviewer" return spam,'yum yum, I like ' + spam
except TypeError:
except (TypeError,AttributeError):
def publish(self, module_name, published='web_objects',
try: transaction=get_transaction() transaction.begin() except: transaction=None
def function_with_empty_signature(): pass
def flatten_field(v,converter):
def flatten_field(v,converter=None):
def flatten_field(v,converter): if type(v) is types.ListType: if len(v) > 1: return map(flatten_field,v) v=v[0] try: if v.file: v=v.file else: v=v.value except: pass if converter: v=converter(v) return v
if b[-1]=='/': b=b[:-1]
while b and b[-1]=='/': b=b[:-1]
def __init__(self,
if p >= 0: self.base=b[:p+1] else: self.base=''
if p >= 0: b=b[:p+1] else: b='' while b and b[0]=='/': b=b[1:] try: server_url= string.strip(self.environ['SERVER_URL' ]) except: server_url='http://'+string.strip(self.environ['SERVER_NAME']) self.base="%s/%s" % (server_url,b)
def __init__(self,
+RoleManager.manage_options
def add(self, id, title='', smtp_host=None, localhost='localhost', smtp_port=25, timeout=1.0, REQUEST=None): ' add a MailHost into the system ' id=str(id) title=str(title) if smtp_host is not None: smtp_host=str(smtp_host) if type(smtp_port) is not type(1): smtp_port=string.atoi(smtp_port) i=MailHost() #cr...
if not string.strip(part): break raise TALError("invalid z:define syntax: " + `part`)
raise TALError("invalid define syntax: " + `part`)
def emitDefines(self, defines): for part in splitParts(defines): m = re.match( r"\s*(?:(global|local)\s+)?(%s)\s+(.*)" % NAME_RE, part) if not m: if not string.strip(part): break # extra space after semi raise TALError("invalid z:define syntax: " + `part`) scope, name, expr = m.group(1, 2, 3) scope = scope or "local" c...
raise TALError("invalid z:repeat syntax: " + `repeat`)
raise TALError("invalid repeat syntax: " + `repeat`)
def emitRepeat(self, arg): m = re.match("\s*(%s)\s+(.*)" % NAME_RE, arg) if not m: raise TALError("invalid z:repeat syntax: " + `repeat`) name, expr = m.group(1, 2) cexpr = self.compileExpression(expr) program = self.popProgram() self.emit("loop", name, cexpr, program)
raise TALError("Bad syntax in z:insert/z:replace: " + `arg`)
raise TALError("Bad syntax in insert/replace: " + `arg`)
def emitSubstitution(self, arg, attrDict={}): key, expr = parseSubstitution(arg) if not key: raise TALError("Bad syntax in z:insert/z:replace: " + `arg`) cexpr = self.compileExpression(expr) program = self.popProgram() if key == "text": self.emit("insertText", cexpr, program) else: assert key == "structure" self.emit("...
<<<<<<< Application.py examples_path = os.path.join(Globals.INSTANCE_HOME, 'import', 'Examples.zexp') =======
def initialize(app): # Initialize the application # Initialize the cache: app.Control_Panel.initialize_cache() # The following items marked b/c are backward compatibility hacks # which make sure that expected system objects are added to the # bobobase. This is required because the bobobase in use may pre- # date the ...
>>>>>>> 1.176.2.2
def initialize(app): # Initialize the application # Initialize the cache: app.Control_Panel.initialize_cache() # The following items marked b/c are backward compatibility hacks # which make sure that expected system objects are added to the # bobobase. This is required because the bobobase in use may pre- # date the ...
else: del attr.__roles__
else: try: del attr.__roles__ except: pass
def delRoles(self, roles):
self.obj =obj
if hasattr(obj, 'aq_self'): obj=obj.aq_self self.obj=obj
def __init__(self,name,data,obj):
def marshal_long(n,f): return ('%s:long=%s' % (n,f))[:-1]
def marshal_long(n,f): value = '%s:long=%s' % (n, f) if value[-1] == 'L': value = value[:-1] return value
def marshal_long(n,f): return ('%s:long=%s' % (n,f))[:-1]
if hasattr(o, 'isPrincipiaFolderish') and \
if hasattr(aq_base(o), 'isPrincipiaFolderish') and \
def tpValues(self): # Return a list of subobjects, used by tree tag. r=[] if hasattr(aq_base(self), 'tree_ids'): tree_ids=self.tree_ids try: tree_ids=list(tree_ids) except TypeError: pass if hasattr(tree_ids, 'sort'): tree_ids.sort() for id in tree_ids: if hasattr(self, id): r.append(self._getOb(id)) else: obj_ids=se...
files=self.objectItems()
files = list(self.objectItems())
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
if f[1].meta_type == "Folder":
if hasattr(aq_base(f[1]), 'isPrincipiaFolderish') and f[1].isPrincipiaFolderish:
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
else: all_files.append(f)
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
files = list(files)
def manage_FTPlist(self, REQUEST): """Directory listing for FTP. """ out=()
lst =[] for name,child in obj.objectItems(): if child.meta_type=="Folder": lst.extend(findChildren(child,dirname+ obj.id + '/'))
lst = [] for name, child in obj.objectItems(): if hasattr(aq_base(child), 'isPrincipiaFolderish') and child.isPrincipiaFolderish: lst.extend(findChildren(child, dirname + obj.id + '/'))
def findChildren(obj,dirname=''): """ recursive walk through the object hierarchy to find all children of an object (ajung) """ lst =[] for name,child in obj.objectItems(): if child.meta_type=="Folder": lst.extend(findChildren(child,dirname+ obj.id + '/')) else: lst.append( (dirname + obj.id + "/" + name,child) ) ret...
elif name=='secure': cookie = '%s; Secure' % cookie
elif name=='secure' and v: cookie = '%s; Secure' % cookie
def _cookie_list(self): cookie_list=[] for name, attrs in self.cookies.items():
entry = (permission_name, tuple(names), tuple(roles))
entry = (permission_name, tuple(names), tuple(roles.keys()))
def apply(self, classobj): """Apply security information to the given class object.""" dict = classobj.__dict__
self.emit("startTag", node.nodeName, getAttributeList(node))
self.emit("startTag", node.nodeName, self.getFullAttrList(node))
def emitStartTag(self, node): self.emit("startTag", node.nodeName, getAttributeList(node))
self.emit("startEndTag", node.nodeName, getAttributeList(node))
self.emit("startEndTag", node.nodeName, self.getFullAttrList(node))
def emitStartEndTag(self, node): self.emit("startEndTag", node.nodeName, getAttributeList(node))
return
else: self.expandElement(node) self.popNS() def expandElement(self, node):
def visitElement(self, node): if not node.hasAttributes(): self.emitElement(node) return macroName = node.getAttributeNS(ZOPE_METAL_NS, "use-macro") if macroName: slotDict = slotIndexer(node) compiledSlots = {} if slotDict: # Compile the slots for slotName, slotNode in slotDict.items(): self.pushProgram() self.visitEle...
c = ctxt.vars
def testVariables(self): '''Test variables''' ctxt = self.getContext() c = ctxt.vars ctxt.beginScope() ctxt.setLocal('v1', 1) ctxt.setLocal('v2', 2)
self._old = __builtins__.__dict__.get('INSTANCE_HOME') __builtins__.INSTANCE_HOME = os.path.split(
self._old = builtinsdict.get('INSTANCE_HOME') builtinsdict['INSTANCE_HOME'] = os.path.split(
def setUp(self): self._old = __builtins__.__dict__.get('INSTANCE_HOME') __builtins__.INSTANCE_HOME = os.path.split( Products.ExternalMethod.tests.__file__)[0]
del __builtins__.INSTANCE_HOME
del builtinsdict['INSTANCE_HOME']
def tearDown(self): if self._old is None: del __builtins__.INSTANCE_HOME else: __builtins__.INSTANCE_HOME = self._old
__builtins__.INSTANCE_HOME = self._old
builtinsdict['INSTANCE_HOME'] = self._old
def tearDown(self): if self._old is None: del __builtins__.INSTANCE_HOME else: __builtins__.INSTANCE_HOME = self._old
if not hasattr(fs,'list'): form['BODY']=other['BODY']=fs.value
if not hasattr(fs,'list') or fs.list is None: form['BODY']=other['BODY']=fs.value
def __init__(self,
from DocumentTemplate import HTML, String
from DocumentTemplate.DT_HTML import HTML, String
def read_file(name): f = open(os.path.join(here, name), 'rb') res = f.read() f.close() return res
if v is not None: v(self.namespace,inst,key,r)
if v is not None: v(inst,inst,key,r,self.namespace)
def __getitem__(self,key):
r=1
def careful_mul(env, *factors): s=None r=1 for factor in factors: try: l=len(factor) s=1 except: l=factor if s and (l*r) > 1000: raise TypeError, 'Illegal sequence repeat' r=r*factor return r
except: l=factor if s and (l*r) > 1000: raise TypeError, 'Illegal sequence repeat'
except TypeError: c=c*factor if s and c > 1000: raise TypeError, \ 'Illegal sequence repeat (too many repetitions: %d)' % c
def careful_mul(env, *factors): s=None r=1 for factor in factors: try: l=len(factor) s=1 except: l=factor if s and (l*r) > 1000: raise TypeError, 'Illegal sequence repeat' r=r*factor return r
def dav__propstat(self, name, propstat=propstat, propdesc=propdesc,
def dav__propstat(self, name, result, propstat=propstat, propdesc=propdesc, join=string.join): xml_id=self.xml_namespace() propdict=self._propdict() if not propdict.has_key(name): prop='<n:%s xmlns:n="%s"/>\n' % (name, xml_id) code='404 Not Found' if not result.has_key(code): result[code]=[prop] else: result[code].ap...
def dav__propstat(self, name, propstat=propstat, propdesc=propdesc, join=string.join): # DAV helper method - return a propstat element indicating # property name and value for the requested property. xml_id=self.xml_namespace() propdict=self._propdict() if not propdict.has_key(name): prop=' <n:%s/>' % name error=propd...
if parent is None: return fields return fields.__of__(parent)
return fields
def __getitem__(self,index): if index==self._index: return self._row parent=self._parent fields=self._class(self._data[index], parent) self._index=index self._row=fields if parent is None: return fields return fields.__of__(parent)
type = "var"
type = "path"
def evaluate(self, expression): m = re.match(r"(?s)(%s):(.*)\Z" % NAME_RE, expression) if m: type, expr = m.group(1, 2) else: type = "var" expr = expression if type == "str": return expr if type == "local": return self.locals[string.strip(expr)] if type == "global": return self.globals[string.strip(expr)] if type == "v...
if type == "str":
if type in ("string", "str"):
def evaluate(self, expression): m = re.match(r"(?s)(%s):(.*)\Z" % NAME_RE, expression) if m: type, expr = m.group(1, 2) else: type = "var" expr = expression if type == "str": return expr if type == "local": return self.locals[string.strip(expr)] if type == "global": return self.globals[string.strip(expr)] if type == "v...
if type == "local": return self.locals[string.strip(expr)] if type == "global": return self.globals[string.strip(expr)] if type == "var":
if type in ("path", "var", "global", "local"):
def evaluate(self, expression): m = re.match(r"(?s)(%s):(.*)\Z" % NAME_RE, expression) if m: type, expr = m.group(1, 2) else: type = "var" expr = expression if type == "str": return expr if type == "local": return self.locals[string.strip(expr)] if type == "global": return self.globals[string.strip(expr)] if type == "v...
return self.globals[expr]
raise TALESError("unknown variable: %s", expr) if type == "not": v = self.evaluate(expr) return not v if type == "exists": return self.locals.has_key(expr) or self.globals.has_key(expr)
def evaluate(self, expression): m = re.match(r"(?s)(%s):(.*)\Z" % NAME_RE, expression) if m: type, expr = m.group(1, 2) else: type = "var" expr = expression if type == "str": return expr if type == "local": return self.locals[string.strip(expr)] if type == "global": return self.globals[string.strip(expr)] if type == "v...
return eval(expr, self.globals, self.locals)
try: return eval(expr, self.globals, self.locals) except: t, v, tb = info = sys.exc_info() raise TALESError("evaluation error in %s" % `expr`, info=sys.exc_info())
def evaluate(self, expression): m = re.match(r"(?s)(%s):(.*)\Z" % NAME_RE, expression) if m: type, expr = m.group(1, 2) else: type = "var" expr = expression if type == "str": return expr if type == "local": return self.locals[string.strip(expr)] if type == "global": return self.globals[string.strip(expr)] if type == "v...
sdc = root['folder'] = OFS.Folder.Folder()
sdc = root['folder'] = Folder()
def _getMountRoot(self, root): sdc = root.get('folder', None) if sdc is None: sdc = root['folder'] = OFS.Folder.Folder() self._populate(sdc, root)
_v_rcs=None _v_rst=None
def db_size(self): if Globals.DatabaseVersion=='2': s=os.stat(self.db_name())[6] else: s=self._p_jar.db().getSize() if s >= 1048576.0: return '%.1fM' % (s/1048576.0) return '%.1fK' % (s/1024.0)
self._v_rcs=self.refdict() self._v_rst=DateTime()
global _v_rcs global _v_rst _v_rcs=self.refdict() _v_rst=DateTime()
def rcsnapshot(self): self._v_rcs=self.refdict() self._v_rst=DateTime()
return self._v_rst
return _v_rst
def rcdate(self): return self._v_rst
if self._v_rcs is None:
if _v_rcs is None:
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()
rc=self._v_rcs
rc=_v_rcs
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()
meta_type='', CreateFactory=0, REQUEST=None):
meta_type='', CreateAFactory=0, REQUEST=None):
def manage_addZClass(self, id, title='', baseclasses=[], meta_type='', CreateFactory=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...