appy.gen: refactoring due to De-Plonization.

This commit is contained in:
Gaetan Delannay 2011-12-05 10:52:18 +01:00
parent 6733f4c7dc
commit d934f49a99
31 changed files with 1220 additions and 1325 deletions

33
gen/templates/Class.py Normal file
View file

@ -0,0 +1,33 @@
<!codeHeader!>
from OFS.SimpleItem import SimpleItem
from OFS.Folder import Folder
from appy.gen.utils import createObject
from AccessControl import ClassSecurityInfo
import Products.<!applicationName!>.config as cfg
from appy.gen.plone25.mixins import BaseMixin
from appy.gen.plone25.mixins.ToolMixin import ToolMixin
from wrappers import <!genClassName!>_Wrapper as Wrapper
def manage_add<!genClassName!>(self, id, title='', REQUEST=None):
'''Creates instances of this class.'''
createObject(self, id, '<!genClassName!>', '<!applicationName!>')
if REQUEST is not None: return self.manage_main(self, REQUEST)
class <!genClassName!>(<!parents!>):
'''<!classDoc!>'''
security = ClassSecurityInfo()
meta_type = '<!genClassName!>'
portal_type = '<!genClassName!>'
allowed_content_types = ()
filter_content_types = 0
global_allow = 1
icon = "ui/<!icon!>"
wrapperClass = Wrapper
config = cfg
def do(self):
'''BaseMixin.do can't be traversed by Zope if this class is the tool.
So here, we redefine this method.'''
return BaseMixin.do(self)
for elem in dir(<!baseMixin!>):
if not elem.startswith('__'): security.declarePublic(elem)
<!methods!>

View file

@ -0,0 +1,90 @@
#importedElem { color: grey; font-style: italic; }
.appyPod { float:right; }
.appyFocus { color: #900101; }
.appyChanges th {
font-style: italic;
background-color: transparent;
border: 0 none transparent;
padding: 0.1em 0.1em 0.1em 0.1em;
}
.appyChanges td {
padding: 0.1em 0.2em 0.1em 0.2em !important;
border-top: 1px dashed #8CACBB !important;
border-right: 0 none transparent !important;
border-left: 0 none transparent !important;
border-bottom: 0 none transparent !important;
}
/* Tooltip */
a.tooltip span {
display:none;
padding:2px 3px;
margin-top: 25px;
}
a.rtip span { margin-left:3px; }
a.ltip span { margin-left:-150px }
a.tooltip:hover span {
display: inline;
position: absolute;
border: 1px solid grey;
background-color: white;
color: #dd;
}
/* Table styles */
fieldset {
line-height: 1em;
border: 2px solid #8CACBB;
margin: 0.5em 0em 0.5em 0em;
padding: 0 0.7em 0.5em;
}
.noPadding {
padding-right: 0em !important;
padding-left: 0em !important;
padding-top: 0em !important;
padding-bottom: 0em !important;
}
.appyButton {
background: &dtml-globalBackgroundColor; url(&dtml-portal_url;/linkOpaque.gif) 5px 1px no-repeat;
cursor: pointer;
font-size: &dtml-fontSmallSize;;
padding: 1px 1px 1px 12px;
text-transform: &dtml-textTransform;;
/* overflow: visible; IE produces ugly results with this */
}
.fakeButton {
background: #ffd5c0 url(&dtml-portal_url;/ui/fakeTransition.gif) 5px 1px no-repeat;
padding: 3px 4px 3px 12px;
}
/* Portlet elements */
.portletHeader {
text-transform: none;
padding: 1px 0.5em;
}
.portletSearch {
padding: 0 0 0 0.6em;
font-style: normal;
font-size: 95%;
}
.portletGroup {
font-variant: small-caps;
font-weight: bold;
font-style: normal;
}
.portletGroupItem { padding-left: 0.8em; font-style: italic; }
.portletMenu { margin-bottom: 0.4em; }
/* image-right, but without border */
.image-right {
border:0px solid Black;
clear:both;
float:right;
margin:0.5em;
}

38
gen/templates/__init__.py Normal file
View file

@ -0,0 +1,38 @@
<!codeHeader!>
# Test coverage-related stuff --------------------------------------------------
import sys
from appy.gen.plone25.mixins.TestMixin import TestMixin
covFolder = TestMixin.getCovFolder()
# The previous method checks in sys.argv whether Zope was lauched for performing
# coverage tests or not.
cov = None # The main Coverage instance as created by the coverage program.
totalNumberOfTests = <!totalNumberOfTests!>
numberOfExecutedTests = 0
if covFolder:
try:
import coverage
from coverage import coverage
cov = coverage()
cov.start()
except ImportError:
print 'COVERAGE KO! The "coverage" program is not installed. You can ' \
'download it from http://nedbatchelder.com/code/coverage.' \
'\nHit <enter> to execute the test suite without coverage.'
sys.stdin.readline()
def countTest():
global numberOfExecutedTests
numberOfExecutedTests += 1
# ------------------------------------------------------------------------------
import config
from appy.gen.plone25.installer import ZopeInstaller
# Zope-level installation of the generated product. ----------------------------
def initialize(context):
<!imports!>
# I need to do those imports here; else, types and add permissions will not
# be registered.
classes = [<!classes!>]
ZopeInstaller(context, config, classes).install()
# ------------------------------------------------------------------------------

51
gen/templates/config.py Normal file
View file

@ -0,0 +1,51 @@
<!codeHeader!>
import os, os.path, sys, copy
import appy.gen
import wrappers
<!imports!>
# The following imports are here for allowing mixin classes to access those
# elements without being statically dependent on Plone/Zope packages. Indeed,
# every Archetype instance has a method "getProductConfig" that returns this
# module.
from persistent.list import PersistentList
from zExceptions import BadRequest
from ZPublisher.HTTPRequest import BaseRequest
from OFS.Image import File
from ZPublisher.HTTPRequest import FileUpload
from AccessControl import getSecurityManager
from AccessControl.PermissionRole import rolesForPermissionOn
from DateTime import DateTime
from Products.ExternalMethod.ExternalMethod import ExternalMethod
from Products.Transience.Transience import TransientObjectContainer
import appy.gen
import logging
logger = logging.getLogger('<!applicationName!>')
# Some global variables --------------------------------------------------------
PROJECTNAME = '<!applicationName!>'
diskFolder = os.path.dirname(<!applicationName!>.__file__)
defaultAddRoles = [<!defaultAddRoles!>]
ADD_CONTENT_PERMISSIONS = {
<!addPermissions!>}
# Applications classes, in various formats
rootClasses = [<!rootClasses!>]
appClasses = [<!appClasses!>]
appClassNames = [<!appClassNames!>]
allClassNames = [<!allClassNames!>]
# In the following dict, we store, for every Appy class, the ordered list of
# appy types (included inherited ones).
attributes = {<!attributes!>}
# Application roles
applicationRoles = [<!roles!>]
applicationGlobalRoles = [<!gRoles!>]
grantableRoles = [<!grRoles!>]
# Configuration options
languages = [<!languages!>]
languageSelector = <!languageSelector!>
sourceLanguage = '<!sourceLanguage!>'
# ------------------------------------------------------------------------------

View file

@ -0,0 +1,6 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:five="http://namespaces.zope.org/five"
i18n_domain="<!applicationName!>">
<!deprecated!>
</configure>

27
gen/templates/testAll.py Normal file
View file

@ -0,0 +1,27 @@
<!codeHeader!>
from unittest import TestSuite
from Testing import ZopeTestCase
from Testing.ZopeTestCase import ZopeDocTestSuite
from Products.PloneTestCase import PloneTestCase
from appy.gen.plone25.mixins.TestMixin import TestMixin, beforeTest, afterTest
<!imports!>
# Initialize Zope & Plone test systems -----------------------------------------
ZopeTestCase.installProduct('PloneLanguageTool')
ZopeTestCase.installProduct('<!applicationName!>')
PloneTestCase.setupPloneSite(products=['PloneLanguageTool',
'<!applicationName!>'])
class Test(PloneTestCase.PloneTestCase, TestMixin):
'''Base test class for <!applicationName!> test cases.'''
# Data needed for defining the tests -------------------------------------------
data = {'test_class': Test, 'setUp': beforeTest, 'tearDown': afterTest,
'globs': {'appName': '<!applicationName!>'}}
modulesWithTests = [<!modulesWithTests!>]
# ------------------------------------------------------------------------------
def test_suite():
return TestSuite([ZopeDocTestSuite(m, **data) for m in modulesWithTests])
# ------------------------------------------------------------------------------

19
gen/templates/wrappers.py Normal file
View file

@ -0,0 +1,19 @@
# ------------------------------------------------------------------------------
from appy.gen import *
Grp = Group # Avoid name clashes with the Group class below and appy.gen.Group
from appy.gen.plone25.wrappers import AbstractWrapper
from appy.gen.plone25.wrappers.ToolWrapper import ToolWrapper as WTool
from appy.gen.plone25.wrappers.UserWrapper import UserWrapper as WUser
from appy.gen.plone25.wrappers.GroupWrapper import GroupWrapper as WGroup
from appy.gen.plone25.wrappers.TranslationWrapper import TranslationWrapper as WT
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
tfw = {"edit":"f","cell":"f","view":"f"} # Layout for Translation fields
<!imports!>
<!User!>
<!Group!>
<!Translation!>
<!Tool!>
<!wrappers!>
# ------------------------------------------------------------------------------