From e3b7f5364ff8be78447bbaeb471c70e3e5c026a0 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Thu, 31 May 2012 17:29:06 +0200 Subject: [PATCH] [gen] CSS improvements; bugfix: parsing now works even if encoding is declared at the beginning of the Python file; a default layout for Boolean fields, including a description, is now available in Boolean.dLayouts. --- gen/__init__.py | 4 +++- gen/generator.py | 5 +++++ gen/ui/appy.css | 7 ++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gen/__init__.py b/gen/__init__.py index 90af26d..3883594 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -1443,6 +1443,7 @@ class String(Type): return self.getCaptchaChallenge({})['text'] class Boolean(Type): + def __init__(self, validator=None, multiplicity=(0,1), index=None, default=None, optional=False, editDefault=False, show=True, page='main', group=None, layouts = None, move=0, indexed=False, @@ -1458,8 +1459,9 @@ class Boolean(Type): label) self.pythonType = bool + dLayouts = {'view': 'lf', 'edit': Table('flrv;=d', width=None)} def getDefaultLayouts(self): - return {'view': 'l;f!-', 'edit': Table('f;lrv;=', width=None)} + return {'view': 'lf', 'edit': Table('f;lrv;=', width=None)} def getValue(self, obj): '''Never returns "None". Returns always "True" or "False", even if diff --git a/gen/generator.py b/gen/generator.py index e310029..8a92fc4 100644 --- a/gen/generator.py +++ b/gen/generator.py @@ -79,10 +79,15 @@ class AstClass: class Ast: '''Python AST.''' classPattern = (symbol.stmt, symbol.compound_stmt, symbol.classdef) + utf8prologue = '# -*- coding: utf-8 -*-' def __init__(self, pyFile): f = file(pyFile) fContent = f.read() f.close() + # For some unknown reason, when an UTF-8 encoding is declared, parsing + # does not work. + if fContent.startswith(self.utf8prologue): + fContent = fContent[len(self.utf8prologue):] fContent = fContent.replace('\r', '') ast = parser.suite(fContent).totuple() # Get all the classes defined within this module. diff --git a/gen/ui/appy.css b/gen/ui/appy.css index 4257a4c..77ef526 100644 --- a/gen/ui/appy.css +++ b/gen/ui/appy.css @@ -59,9 +59,10 @@ img { border: 0; vertical-align: middle} .buttons { margin-left: 4px;} .fakeButton { border: 1px solid #D7DEE4; background-color: #fde8e0; padding: 0px 8px 2px; font: italic 92% Helvetica,Arial,sans-serif} -.message { color: #fd9c03; position: absolute; top: -55px; left: 100px; - width: 700px; border: 1px black dashed; padding: 2px 6px; - background-color: #f4f5f6} +.message { position: absolute; top: -40px; left: 150px; font-size: 90%; + width: 600px; border: 1px #F0C36D solid; padding: 6px 16px; + background-color: #F9EDBE; text-align: center; + border-radius: 2px 2px 2px 2px; box-shadow: 0 2px 4px #A9A9A9;} .discreet { font-size: 90%; } .portlet { width: 150px; border-right: 1px solid #5F7983;} .portletContent { margin: 9px; }