Commit 7a9f9e16 authored by Hanno Schlichting's avatar Hanno Schlichting

Deal with a couple more func_code/func_defaults vs. double under code/defaults

parent f1a9a52e
......@@ -36,12 +36,14 @@ class HTML(DocumentTemplate.HTML,Persistence.Persistent,):
class ClassicHTMLFile(DocumentTemplate.HTMLFile,MethodObject.Method,):
"Persistent HTML Document Templates read from files"
class func_code: pass
func_code=func_code()
func_code.co_varnames='trueself', 'self', 'REQUEST'
func_code.co_argcount=3
_need__name__=1
_v_last_read=0
class func_code:
pass
func_code = __code__ = func_code()
func_code.co_varnames = 'trueself', 'self', 'REQUEST'
func_code.co_argcount = 3
_need__name__ = 1
_v_last_read = 0
def __init__(self, name, _prefix=None, **kw):
if _prefix is None:
......@@ -92,8 +94,8 @@ from ComputedAttribute import ComputedAttribute
class DTMLFile(Bindings, Explicit, ClassicHTMLFile):
"HTMLFile with bindings and support for __render_with_namespace__"
func_code = None
func_defaults = None
func_code = __code__ = None
func_defaults = __defaults__ = None
_need__name__=1
_Bindings_ns_class = TemplateDict
......
......@@ -51,8 +51,8 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
meta_type = 'Page Template (File)'
func_defaults = None
func_code = FuncCode((), 0)
func_defaults = __defaults__ = None
func_code = __code__ = FuncCode((), 0)
_v_last_read = 0
# needed by AccessControl.class_init.InitializeClass
......
......@@ -75,8 +75,8 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
meta_type = 'Page Template'
output_encoding = 'utf-8' # provide default for old instances
func_defaults = None
func_code = FuncCode((), 0)
func_defaults = __defaults__ = None
func_code = __code__ = FuncCode((), 0)
_default_bindings = {'name_subpath': 'traverse_subpath'}
_default_content_fn = os.path.join(package_home(globals()),
......
......@@ -38,8 +38,8 @@ class Script(SimpleItem, BindingsUI):
security = ClassSecurityInfo()
index_html = None
func_defaults=()
func_code=None
func_defaults = __defaults__ = ()
func_code = __code__ = None
_Bindings_ns_class = TemplateDict
......
......@@ -15,27 +15,32 @@
This provides support for simulating function signatures
"""
class FuncCode:
def __init__(self, varnames, argcount):
self.co_varnames=varnames
self.co_argcount=argcount
self.co_varnames = varnames
self.co_argcount = argcount
def __cmp__(self, other):
if other is None: return 1
try: return cmp((self.co_argcount, self.co_varnames),
if other is None:
return 1
try:
return cmp((self.co_argcount, self.co_varnames),
(other.co_argcount, other.co_varnames))
except: return 1
except Exception:
return 1
# This is meant to be imported directly into a class.
def _setFuncSignature(self, defaults=None, varnames=(), argcount=-1):
# Simplify calls.
if argcount < 0 and varnames:
argcount = len(varnames)
# Generate a change only if we have to.
if self.func_defaults != defaults:
self.func_defaults = defaults
self.func_defaults = self.__defaults__ = defaults
code = FuncCode(varnames, argcount)
if self.func_code != code:
self.func_code = code
self.func_code = self.__code__ = code
......@@ -63,7 +63,7 @@ class Function:
headers['Host']=urlparse(url)[1]
self.func_name=url[url.rfind('/')+1:]
self.__dict__['__name__']=self.func_name
self.func_defaults=()
self.func_defaults = self.__defaults__ = ()
self.args=arguments
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment