;ò ŽŒBCc@sdZdZdklZdklZlZlZlZl Z l Z dk l Z dk lZlZdklZlZlZlZdklZlZdklZd klZlZlZlZd klZd k l Z d k!l"Z"l#Z#l$Z$l%Z%l&Z&d k'Tydk(l)Z)Wn e*j odk(l+Z)nXdk,l-Z-dk.l/Z/lZdk0l1Z1dk2l3Z3e4e5de6dddde7ddddddde8d d!d"d#d$d%d&d'd(d)ƒƒfƒZ9d*e)efd+„ƒYZ:d,e:fd-„ƒYZ;d.„Z<e=e;ƒd/S(0s† I18NLayer. Overlay to provide multilanguage support for all types objects. $Id: I18NLayer.py 12448 2005-09-29 12:03:17Z longsleep $ s$Revision: 1.20 $(s get_request(s aq_acquiresaq_basesaq_innersaq_chains aq_parentsImplicitAcquisitionWrapper(s ObjectManager(s_verifyActionPermissionss_checkPermission(sViewsManagePropertiessListFolderContentssModifyPortalContent(sAddPortalFolderssAddPortalContent(sDefaultDublinCoreImpl(s PermissionssgetSecurityManagersClassSecurityInfos Unauthorized(sCMFCorePermissions(s getToolByName(sLOGsERRORsINFOsPROBLEMsDEBUG(s*(sBaseFolderMixin(s BaseFolder(s _getViewFor(s BadRequests Unauthorized(sI18NContentLayer(s CheckValiditysids allowedTypesrequiredisdefaultsaccessorsContainmentContentTypesmutatorssetContainmentContentTypes vocabularysallowedContentTypeNamesswidgets descriptions@Select the type of documents which this I18NLayer shall contain.sdescription_msgidshelp_containmenttypeslabels contains Types i18n_domains i18nlayers label_msgidslabel_containmenttypesTitleLessBaseFoldercBs tZdZd„Zd„ZRS(sÄ we need a basefolder without title and without extended meta data and the other crap NOTE: this is for at1.2.x .. hopefully implementation will be cleaner in at1.3 and newer cKsdSdS(s we dont have a title sN((sselfskwargs((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysTitleIscKsdS(s we dont have a title N((sselfsvalueskwargs((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pyssetTitleMs(s__name__s __module__s__doc__sTitlessetTitle(((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysTitleLessBaseFolderCs  s I18NLayercBsUtZdZeZdZdZhdd<dd<dd<deif„Z*e id?ƒedd@„Z+e idAƒdB„Z,e idCƒdD„Z-e idEƒdF„Z.e idGƒdH„Z/e idIƒdJ„Z0e idKƒdL„Z1e idMƒdN„Z2e idOƒdP„Z3e idQƒdR„Z4e idSƒdT„Z5e idUƒdV„Z6e idWƒdX„Z7e idYƒdZ„Z8e id[ƒd\„Z9e id]ƒd^„Z:e id_ƒd`„Z;da„Z<e idbƒdc„Z=e iddƒde„Z>e idfƒdg„Z?e idhƒdi„Z@e idjƒdk„ZAe i!e dlƒdm„ZBe i!e dnƒdo„ZCe i!e dpƒgdq„ZDRS(rsh container object which transparently wraps multiple subobjects as language representations isidsviewsnamesViewsactionsstring:${object_url}/views permissionsslanguagelistings Translates-string:${object_url}/i18nlayer_languages_formsvisibleisdefaultfallbacksDefault Fallback Pages/string:${object_url}/i18nlayer_default_fallbacksretrieveContentLayercCs,| o tƒ}nt||d|ƒSdS(s* returns the contentlayer helper instance sverifypermissionN(sREQUESTs get_requestsI18NContentLayersselfsverifypermission(sselfsREQUESTsverifypermission((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysretrieveContentLayerts s"retrieveLanguageContentUnprotectedcCs#|itddƒiddƒSdS(s^ provides a method to get the requested language object without permission checks sverifypermissioniN(sselfsretrieveContentLayersNones getObject(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys"retrieveLanguageContentUnprotected~ssretrieveLanguageContentcCs|i|ƒiƒSdS(s\ public method to get the requested language object including permission checks N(sselfsretrieveContentLayersREQUESTs getObject(sselfsREQUEST((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysretrieveLanguageContent…ssretrieveI18NContentLayerObcCs|SdS(s+ helper to get the i18nlayer object easily N(sself(sselfsREQUEST((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysretrieveI18NContentLayerObŒssretrieveI18NContentLayerURLcCs|iƒSdS(s get the i18nlayers url easily N(sselfs absolute_url(sselfsREQUEST((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysretrieveI18NContentLayerURL’ssretrieveFilteredLanguagescCs|i|ƒiƒSdS(s- returns a mapping of the filtered languages N(sselfsretrieveContentLayersREQUESTsgetFilteredLanguageMap(sselfsREQUEST((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysretrieveFilteredLanguages˜ssretrieveExistingLanguagescCs|i|ƒid|ƒSdS(s& returns a list of existing languages sbothN(sselfsretrieveContentLayersREQUESTsexistingLanguagessboth(sselfsREQUESTsboth((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysretrieveExistingLanguagesžssretrieveAcceptLanguagescCs|i|ƒiƒSdS(s( returns a list of acceptable languages N(sselfsretrieveContentLayersREQUESTs"getLanguagesFromTranslationService(sselfsREQUEST((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysretrieveAcceptLanguages¤scCsrti|||ƒ|idƒodSn|iddƒ\}}t ||ƒi |ƒ ot d|‚ndS(Ns.sbothisThe id "%s" is not allowed.( s ObjectManagers_checkIdsselfsids allow_dups startswithsretrieveExistingLanguagessallowed_languagessallowed_languages_longs CheckValidityschecks BadRequest(sselfsids allow_dupsallowed_languagessallowed_languages_long((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys_checkId©s smapCorecOsÖy|iƒ}Wn t}nX|tj odtt|ƒ|ƒot||ƒ}q­tt|ƒdƒp t |t ƒo|Sq­t |‚nt i |ƒ}|f|}t|ƒot|||ƒSn|SdS(s; maps methods on the given language object sisPrincipiaFolderishN(sselfsretrieveLanguageContentsobsNoneshasattrsaq_basesnamesgetattrsmethods isinstances I18NLayersdefaultsAttributeErrorsinheritedAttributesargsscallablesapplyskw(sselfsnamesdefaultsargsskwsobsmethod((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysmapCore¸s   &   s__call__cOs¦|iƒ}|o ||jot|dƒ}n6|}d}tt|ƒo d}nt||ƒ}tt |ƒddƒot |||i fƒSn|ƒSdS(s* Invokes the default view sviewsdefaultfallbackslanguagelistings isDocTempiN( sselfsretrieveLanguageContentsobs _getViewForsviewsalts_checkPermissionsModifyPortalContentsgetattrsaq_basesapplysREQUEST(sselfsargsskwsobsaltsview((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys__call__Ñs  c KsÎ|iƒ}t|dtƒ}t|ddƒ}|o|ost|dƒ}d|i ƒ|i ƒf}|iddƒiƒod||if}n|ii|ƒd Snt|i||f|ƒSd S( sB redirect to subobject when forcing language urls sportal_languagessforce_language_urlsisviews%s/%ss QUERY_STRINGss%s?%ss redirect viewN(sselfsretrieveLanguageContentsobs getToolByNamesNones language_toolsgetattrs force_redirs _getViewForsviews absolute_urlsgetIdsurlsREQUESTsgetsstrips QUERY_STRINGsRESPONSEsredirectsapplys__call__skw( sselfsREQUESTsRESPONSEskws force_redirsurlsobs language_toolsview((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysviewès s index_htmlc CsU|iƒ}|o%|i} t|dtƒ}t|ddƒ}|o‘d|i ƒ}|i ddƒiƒod||if}n|iidd ƒ|iid d ƒ|iid d ƒ|ii|ƒd Snt| dtƒ}t| dtƒ}|o|o ||jot|i||fhƒSq8nt|i||fhƒSdS(s‹ return content if subobject has index_html method or redirect to subobjects index_html when forcing language urls sportal_languagessforce_language_urlsis%ss QUERY_STRINGss%s?%ss Cache-Controlsno-cachesExpiress-1sPragmasredirect indexs index_htmls__call__N(sselfsretrieveLanguageContentsobs __class__sklasss getToolByNamesNones language_toolsgetattrs force_redirs absolute_urlsurlsREQUESTsgetsstrips QUERY_STRINGsRESPONSEs setHeadersredirectsiscsapplys index_htmls__call__( sselfsREQUESTsRESPONSEs force_redirsurlscsobs language_toolsisklass((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys index_htmlùs(  !sallowedContentTypeNamescCsY|iƒ}t|dƒ}|i|ƒ}y|i|ƒWnnXtd„|ƒSdS(sX returns a tuple with portal types current user can construct inside us s portal_typescCs |iƒS(N(stisgetId(sti((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys&sN( sselfsallowedContentTypessalloweds getToolByNames portal_typess getTypeInfosmyTypesremovesmap(sselfsallowedsmyTypes portal_types((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysallowedContentTypeNamess sContainmentContentTypecCs|ipdSdS(sB returns the configured contenttype of this layer sDocumentN(sselfs_containmentContentType(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysContainmentContentType*ssContainmentMetaTypecCsGy2t|dƒ}|i|iƒƒ}|iƒSWn|iSnXdS(s? returns the configures metatype of this layer s portal_typesN(s getToolByNamesselfs typestools getTypeInfosContainmentContentTypestisMetatypes meta_type(sselfs typestoolsti((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysContainmentMetaType2sssetContainmentContentTypecCs ||_dS(s@ sets the configured contenttype for this layer N(s content_typesselfs_containmentContentType(sselfs content_type((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pyssetContainmentContentType?sssetI18NLayerAttributescCsw| o7tt|ƒ|ƒ o t|‚nt||ƒ}ntt|ƒ o t d‚n|}t |d|ƒdS(so stores required attributes to a given object either to a subobject of myself or to ob s)you are not allowed to modify this objectsi18nContent_languageN( sobshasattrsaq_basesselfsidsAttributeErrorsgetattrs_checkPermissionsModifyPortalContents Unauthorizedslangssetattr(sselfsidsobslang((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pyssetI18NLayerAttributesGs  slistFolderContentscCsPy#|iddfd|d|ƒSWn&tidƒ|d|d|ƒSnXdS(sl map containers helper method we return the language objects contents if its folderish slistFolderContentssdefaultsspecs contentFilterN(sselfsmapCoresspecs contentFilters I18NLayersinheritedAttribute(sselfsspecs contentFilter((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pyslistFolderContentsYs #s contentValuescCsPy#|iddfd|d|ƒSWn&tidƒ|d|d|ƒSnXdS(sl map containers helper method we return the language objects contents if its folderish s contentValuessdefaultsspecsfilterN(sselfsmapCoresspecsfilters I18NLayersinheritedAttribute(sselfsspecsfilter((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys contentValuesbs #s title_or_idcCs,|idƒ}|o|Sn|iƒSdS(s) return the language objects title_or_id stitleN(sselfsmapCorestitlesgetId(sselfstitle((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys title_or_idks sget_sizecCs#y|idƒSWn tSnXdS(sO WebDAV needs this we return the language objects size sget_sizeN(sselfsmapCoresNone(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysget_sizers stagcOs|id||ŽSdS(s map the tag method stagN(sselfsmapCoresargsskw(sselfsargsskw((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pystag}ssgetIconcCs|idd|ƒSdS(s& we display the language objects icon sgetIconsrelative_to_portalN(sselfsmapCoresrelative_to_portal(sselfsrelative_to_portal((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysgetIcon‚ss CookedBodycCs|idd|d|ƒSdS(s- needed to support standard renderable types s CookedBodys stx_levelssetlevelN(sselfsmapCores stx_levelssetlevel(sselfs stx_levelssetlevel((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys CookedBody‡ssTitlecCs|idƒSdS(s dublincore meta data support sTitleN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysTitleŒssCreatorcCs|idƒSdS(s dublincore meta data support sCreatorN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysCreator‘ssSubjectcCs|iddfƒSdS(s dublincore meta data support sSubjectsdefaultN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysSubject–ss PublishercCs|idƒSdS(s dublincore meta data support s PublisherN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys Publisher›ss DescriptioncCs|idƒSdS(s dublincore meta data support s DescriptionN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys Description ss ContributorscCs|idƒSdS(s dublincore meta data support s ContributorsN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys Contributors¥ssDatecCs|idƒSdS(s dublincore meta data support sDateN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysDateªss CreationDatecCs|idƒSdS(s dublincore meta data support s CreationDateN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys CreationDate¯ss EffectiveDatecCs|idƒSdS(s dublincore meta data support s EffectiveDateN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys EffectiveDate´ssExpirationDatecCs|idƒSdS(s dublincore meta data support sExpirationDateN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysExpirationDate¹ssModificationDatecCs|idƒSdS(s dublincore meta data support sModificationDateN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysModificationDate¾ssTypecCs|idƒSdS(s dublincore meta data support sTypeN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysTypeÃssFormatcCs|idƒSdS(s dublincore meta data support sFormatN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysFormatÈss IdentifiercCs|idƒSdS(s dublincore meta data support s IdentifierN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys IdentifierÍssLanguagecCs|iƒiƒSdS(s dublincore meta data support N(sselfsretrieveContentLayersServed(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysLanguageÒssRightscCs|idƒSdS(s dublincore meta data support sRightsN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysRights×scCs y|iƒSWn dSnXdS(s# WebDAV needs this sapplication/unknownN(sselfsFormat(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys content_typeÛs s isEffectivecCs|id|ƒSdS(s publication meta data s isEffectiveN(sselfsmapCoresdate(sselfsdate((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys isEffectiveãsscreatedcCs|idƒSdS(s dublincore meta data support screatedN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pyscreatedèss effectivecCs|idƒSdS(s publication meta data s effectiveN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys effectiveíssexpirescCs|idƒSdS(s publication meta data sexpiresN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysexpiresòssmodifiedcCs|idƒSdS(s meta data support smodifiedN(sselfsmapCore(sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pysmodified÷ss indexObjectcCsdS(s& we dont index i18nlayer into catalog N((sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys indexObjectüss unindexObjectcCsdS(s, as are not indexed we dont have to unindex N((sself((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys unindexObjectss reindexObjectcCsdS(s no indexing of i18nlayers N((sselfsidxs((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys reindexObjects(Es__name__s __module__s__doc__sschemasisPrincipiaFolderishsuse_mimetype_iconssCMFCorePermissionssViewsAddPortalContentsModifyPortalContentsactionssClassSecurityInfossecuritysdeclareObjectPublicsdeclarePrivatesNonesretrieveContentLayers"retrieveLanguageContentUnprotecteds declarePublicsretrieveLanguageContentsretrieveI18NContentLayerObsretrieveI18NContentLayerURLsretrieveFilteredLanguagessretrieveExistingLanguagessretrieveAcceptLanguagess_checkIdsmapCores__call__sviews index_htmlsallowedContentTypeNamessContainmentContentTypesContainmentMetaTypesdeclareProtectedssetContainmentContentTypessetI18NLayerAttributesslistFolderContentss contentValuess title_or_idsget_sizesgetSizestagsgetIcons CookedBodysTitlesCreatorsSubjects Publishers Descriptions ContributorssDates CreationDates EffectiveDatesExpirationDatesModificationDatesTypesFormats IdentifiersLanguagesRightss content_types isEffectivescreateds effectivesexpiressmodifieds indexObjects unindexObjects reindexObject(((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys I18NLayerRsÔ Ÿ                                                                                         cCs`d|ds__doc__s __version__sGlobalss get_requests Acquisitions aq_acquiresaq_basesaq_innersaq_chains aq_parentsImplicitAcquisitionWrappersOFS.ObjectManagers ObjectManagersProducts.CMFCore.utilss_verifyActionPermissionss_checkPermissions#Products.CMFCore.CMFCorePermissionssViewsManagePropertiessListFolderContentssModifyPortalContentsAddPortalFolderssAddPortalContentsProducts.CMFDefault.DublinCoresDefaultDublinCoreImpls AccessControls PermissionssgetSecurityManagersClassSecurityInfos UnauthorizedsProducts.CMFCoresCMFCorePermissionss getToolByNameszLOGsLOGsERRORsINFOsPROBLEMsDEBUGsProducts.Archetypes.publicsProducts.Archetypes.BaseFoldersBaseFolderMixins ImportErrors BaseFoldersProducts.CMFPlone.PloneFolders _getViewFors zExceptionss BadRequests I18NContentsI18NContentLayersutilss CheckValiditysSchemas BaseSchemas StringFieldsNonesSelectionWidgetsschemasTitleLessBaseFolders I18NLayers modify_ftis registerType(&sschemasLOGs aq_acquires aq_parentsaq_chains getToolByNames_verifyActionPermissionss BadRequests_checkPermissionsImplicitAcquisitionWrappers modify_ftisListFolderContentss __version__s Permissionssaq_bases Unauthorizeds ObjectManagersClassSecurityInfosTitleLessBaseFoldersModifyPortalContentsAddPortalContents CheckValiditysERRORsDEBUGsPROBLEMsViewsINFOsBaseFolderMixinsAddPortalFolderssDefaultDublinCoreImplsgetSecurityManagers I18NLayersI18NContentLayersCMFCorePermissionss get_requests _getViewForsManagePropertiessaq_inner((sA/mnt/gmirror/ports/www/zope-i18nlayer/work/I18NLayer/I18NLayer.pys?sJ +    %    ÿº