diff --git a/VERSION b/VERSION index f48bb347..d01a7ab5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-08-17 23:11:58) dev +Version 2.00.0 (2012-08-18 00:10:33) dev diff --git a/gluon/contrib/markmin/markmin2html.py b/gluon/contrib/markmin/markmin2html.py index 5c700984..21d25964 100755 --- a/gluon/contrib/markmin/markmin2html.py +++ b/gluon/contrib/markmin/markmin2html.py @@ -510,7 +510,7 @@ META = '\x06' LINK = '\x07' DISABLED_META = '\x08' LATEX = '' -regex_URL=re.compile(r'@\{(?P\w+)/(?P.+?)\}') +regex_URL=re.compile(r'@\{(?P\w+)/(?P.*?)\}') regex_env=re.compile(r'@\{(?P[\w\-\.]+?)(\:(?P.*?))?\}') regex_expand_meta = re.compile('('+META+'|'+DISABLED_META+')') regex_dd=re.compile(r'\$\$(?P.*?)\$\$') @@ -797,22 +797,11 @@ def render(text, text = str(text or '') text = regex_backslash.sub(lambda m: m.group(1).translate(ttab_in), text) - if environment: - def u2(match, environment=environment): - f = environment.get(match.group('a'), match.group(0)) - if callable(f): - try: - f = f(match.group('b')) - except Exception, e: - f = 'ERROR: %s' % e - return str(f) - text = regex_env.sub(u2, text) - if URL is not None: # this is experimental @{function/args} # turns into a digitally signed URL def u1(match,URL=URL): - f,args = match.group('f','args') + f,args = match.group('f','args') return URL(f,args=args.split('/'), scheme=True, host=True) text = regex_URL.sub(u1,text) @@ -1265,8 +1254,21 @@ def render(text, if beg and end: return '
%s
' % (cls, id, escape(code[1:-1])) return '%s' % (cls, id, escape(code[beg:end])) + text = regex_expand_meta.sub(expand_meta, text) text = text.translate(ttab_out) + + if environment: + def u2(match, environment=environment): + f = environment.get(match.group('a'), match.group(0)) + if callable(f): + try: + f = f(match.group('b')) + except Exception, e: + f = 'ERROR: %s' % e + return str(f) + text = regex_env.sub(u2, text) + return text def markmin2html(text, extra={}, allowed={}, sep='p', diff --git a/gluon/storage.py b/gluon/storage.py index 7d45a98d..c2d467fc 100644 --- a/gluon/storage.py +++ b/gluon/storage.py @@ -83,6 +83,8 @@ class Storage(object): setattr(self,key,value) def __delitem__(self,key): delattr(self,key) + def __nonzero__(self): + return len(self.__dict__)>0 def pop(self,key,default=None): if key in self: default = getattr(self,key) diff --git a/gluon/tools.py b/gluon/tools.py index 2e0c39bd..d46799d6 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -2435,7 +2435,6 @@ class Auth(object): [, onvalidation=DEFAULT [, onaccept=DEFAULT [, log=DEFAULT]]]]) """ - table_user = self.settings.table_user request = current.request response = current.response @@ -2468,7 +2467,7 @@ class Auth(object): separator=self.settings.label_separator ) if captcha: - addrow(form, captcha.label, captcha, captcha.comment, self.settings.formstyle,'captcha__row') + addrow(form, captcha.label, captcha, captcha.comment, self.settings.formstyle,'captcha__row') if form.accepts(request, session, formname='reset_password', dbio=False, onvalidation=onvalidation, @@ -4459,9 +4458,19 @@ class Wiki(object): def markmin_render(self,page): return MARKMIN(page.body,url=True,environment=self.env, autolinks=lambda link: expand_one(link,{})).xml() + @staticmethod + def component(text): + """ + In wiki docs allows @{component:controller/function/args} + which renders as a LOAD(..., ajax=True) + """ + items = text.split('/') + controller, function, args = items[0], items[1], items[2:] + return LOAD(controller, function, args=args, ajax=True).xml() def __init__(self,auth,env=None,automenu=True,render='markmin', manage_permissions=False,force_prefix=''): self.env = env or {} + self.env['component'] = Wiki.component if render == 'markmin': render=self.markmin_render self.auth = auth self.automenu = automenu