o ,WO@sJdZddlmZddlmZddlmZddlmZddlmZddlmZddl m Z dd l m Z dd l m Z dd l mZdd lmZdd lmZddlmZmZddlmZddlmZzddlmZWney}ddZeZZZ Z!eZYnwddl"mZddl"mZddl"m Z ddl"m#Z#e dZ$Gddde%eZ&ddZ'Gddde Z(Gdd d e Z)d!d"Z* # %d@d&d'Z+Gd(d)d)e Z,e'Z- # %dAd*d+Z.Gd,d-d-e(Z/ # $dBd.d/Z0Gd0d1d1e Z1dCd2d3Z2Gd4d5d5e Z3Gd6d7d7e Z4Gd8d9d9e3e4Z5d#d#d#e fd:d;Z6Gdd?Z8d#S)Dz.Component Architecture configuration handlers ConfigurationError)Bool)GlobalInterface) GlobalObject)PythonIdentifier)Tokens)MessageFactory) Interface) implementedBy) providedBy)TextLine)getSiteManager) adaptedBygetName)provideInterface)_BLANK) PermissioncOstd)NzTsecurity proxied components are not supported because zope.security is not availabler)argskwr5/usr/lib/python3/dist-packages/zope/component/zcml.py _no_security$sr)_checkerproxify)protectedFactory)securityAdapterFactoryzopec@s eZdZdS)ComponentConfigurationErrorN)__name__ __module__ __qualname__rrrrr1srcOstt|}||i|dSN)getattrr) methodNamerkwargsmethodrrrhandler4s r(c@sNeZdZeededddZeededddZeededddZd S) IBasicComponentInformationzComponent to usezPython name of the implementation object. This must identify an object in a module using the full dotted name. If specified, the ``factory`` field must be left blank.Ftitle descriptionrequiredrz*Permission required to use this component.FactoryzPython name of a factory which can create the implementation object. This must identify an object in a module using the full dotted name. If specified, the ``component`` field must be left blank.N) r r!r"r_ componentr permissionfactoryrrrrr)8s   r)c@seZdZdZeededdedZeededdd Z eed ed dee d dZ e ed eddd Z eededdd ZeededdddZeededdddZdS)IAdapterDirectivez Register an adapter zAdapter factory/factorieszHA list of factories (usually just one) that create the adapter instance.Tr+r,r- value_type Interface the component providesIThis attribute specifies the interface the adapter instance must provide.Fr*zSpecifications to be adapted.This should be a list of interfaces or classes missing_valuerzEThis adapter is only available, if the principal has this permission.NamezYAdapters can have names. This attribute allows you to specify the name for this adapter.TrustedaIMake the adapter a trusted adapter Trusted adapters have unfettered access to the objects they adapt. If asked to adapt security-proxied objects, then, rather than getting an unproxied adapter of security-proxied objects, you get a security-proxied adapter of unproxied objects. r+r,r-defaultLocatezMake the adapter a locatable adapter Located adapter should be used if a non-public permission is used. N)r r!r"__doc__rr/rr2rprovidesobjectfor_rr1r namertrustedlocaterrrrr3SsV  r3csfdd}d|_|S)NcsD]}||}q|Sr#r)obf factoriesrrr2s z!_rolledUpFactory..factoryrr2)rJr2rrIr_rolledUpFactorys  rLNFc Cs|durt|dkrt|d}|durtdt|}|dur@t|dkr8tt|d}t|dkr8|d}|dur@td|dkrPt|dkrPt|d}|} t| dkr]| d}nt| dkrgtdt| dkrwt|dkrwtdt| }|durt |||}|s|dus|rt ||||}|j d|||ft d |||||j fd |j dtd|fd |r|D]} | dur|j dtd| fd qdSdS) NrzJNo for attribute was provided and can't determine what the factory adapts.Missing 'provides' attributerMzNo factory specified-Can't use multiple factories and multiple foradapterregisterAdapter discriminatorcallabler)lenr TypeErrortuplelistr rrrLrractionr(infor) _contextr2rArCr1rDrErFprJifacerrrrQsj            rQc@seZdZdZeededddZeededddZeeded ddZ e ed ed dee d d Z e ededddZeededdddZeededdddZdS)ISubscriberDirectivez Register a subscriber zSubscriber factoryz1A factory used to create the subscriber instance.Fr*Handlerz&A callable object that handles events.r6r7z5Interfaces or classes that this subscriber depends onr8r9r4rzHThis subscriber is only available, if the principal has this permission.r<aXMake the subscriber a trusted subscriber Trusted subscribers have unfettered access to the objects they adapt. If asked to adapt security-proxied objects, then, rather than getting an unproxied subscriber of security-proxied objects, you get a security-proxied subscriber of unproxied objects. r=r?zMake the subscriber a locatable subscriber Located subscribers should be used if a non-public permission is used. N)r r!r"r@rr/r2r(rrArrBrCrr1rrErFrrrrr_sT  r_c Cs2|dur|dur td|durtd|}n|durtd|dur'td|dur7t|}|dur7td|durAt|||}t|}|sM|dusM|rTt||||}|durg|jdtd||t|jfdn|jdtd|||t|jfd|dur|jdt d |fd|D]}|dur|jdt d |fdqdS) NzNo factory or handler providedz Cannot use handler with provideszCannot use handler with factoryz@You must specify a provided interface when registering a factoryzWNo for attribute was provided and can't determine what the factory (or handler) adapts.registerHandlerrSregisterSubscriptionAdapterrM) rWrrrXrrZ_handlerrr[r) r\rCr2r(rAr1rErFr^rrr subscriber&sf   rdc@s<eZdZdZeededddZeededddZdS) IUtilityDirectivezRegister a utility.zProvided interfacez"Interface provided by the utility.Fr*r;zTName of the registration. This is used by application code when locating a utility.N) r r!r"r@rr/rAr rDrrrrreds recCs|r|rtd|dur*|rtt|}ntt|}t|dkr&|d}ntd|dkr9|r5t|}nt|}|durDt|||d}|jd||ftd||||j ft |d d |jdt d|fd dS) Nz$Can't specify factory and component.rNrrOrM)rAr1utilityregisterUtilityrK)rTrUrrrS) rWrYr r rVrrrZr(r[dictr)r\rAr0r2r1rDrrrrfts4     rfc@s@eZdZdZeedddZeedddZeedddZ dS) IInterfaceDirectivez Define an interface r Tr+r-zInterface typeFr;N) r r!r"r@rr/ interfacetyper rDrrrrris ricCs|jdt|||fddS)NrS)rZr)r\rkrlrDrrrrks  rkc@seZdZdZeededdeeddZe ededd d Z eed ed d d Z eed edd e dZ eededd edZdS)IBasicViewInformationz,This is the basic information for all views.z*Specifications of the objects to be viewedz7This should be a list of interfaces or classes Tr9r4rz&The permission needed to use the view.Fr*Classz2A class that provides attributes used by the view.6Interface that is also allowed if user has permission.a= By default, 'permission' only applies to viewing the view and any possible sub views. By specifying this attribute, you can make the permission also apply to everything described in the supplied interface. Multiple interfaces can be provided, separated by whitespace.zAView attributes that are also allowed if the user has permission.z By default, 'permission' only applies to viewing the view and any possible sub views. By specifying 'allowed_attributes', you can make the permission also apply to the extra attributes on the view object.N)r r!r"r@rr/rrBrCrr1class_rallowed_interfacerallowed_attributesrrrrrms@  rmc@sPeZdZdZeededdedZeededde dZ eed dd Z d S) IBasicResourceInformationz) Basic information for resources zThe name of the resource.z3The name shows up in URLs/paths. For example 'foo'.Tr=z&The interface this component provides.zi A view can provide an interface. This would be used for views that support other views.Fz Request typerjN) r r!r"r@r r/rrDrr rArlrrrrrss$  rsc@s$eZdZdZeeddedZdS)IViewDirectivezRegister a view for a componentr.Fr+r-r5N)r r!r"r@rr/rr2rrrrrts rtc s>|s|r |s td|dur&t||||} Gdddt} | |d| |d<|s,tdt|}|tdkr=d}n%tdkrGtdtdkrWt|dkrWtd fd d }d|_||f}|jd |||ftd |||||jfd|jdt d|fd|dur|D]} | dur|jdt d| fdqdSdS)NzF'permission' required with 'allowed_interface' or 'allowed_attributes'c@s eZdZdZddZddZdS)zview..ProxyViewz#Class to create simple proxy views.cSs||_||_dSr#)r2checker)selfr2rvrrr__init__s z view..ProxyView.__init__cWst|j||jSr#)rr2rv)rwobjectsrrr__call__#sz view..ProxyView.__call__N)r r!r"r@rxrzrrrr ProxyViews r{zNo for interfaces specifiedrNrzNo view factory specifiedrPcs(ddD]}||}qd||S)Nr|r)rGrequestrHrIrrr27s zview..factoryviewrRrSrM) rrrBrXrVr2rZr(r[r) r\r2rlrDrCr1rqrrrArvr{r^rrIrr~ sd         r~c@s8eZdZdZeeddedZeeddedZ dS)IResourceDirectivezRegister a resourceroFruz=View attributes that are also allowed if user has permission.N) r r!r"r@rr/rrqrrrrrrrrVs rc Cs|s|r |s td|dur!t||||}||fdd} || _| }|jd|||ftd||f|||jfd|jdtd|fd|jdtd|fddS)NzDMust use name attribute with allowed_interface or allowed_attributescSst|||Sr#r)r}r2rvrrr proxyResourcexszresource..proxyResourceresourcerRrSrM)rrr2rZr(r[r) r\r2rlrDr1rqrrrArvrrrrrgs<  r)NNNrMFF)NNNNNFF)NNNNrM)NrM)9r@zope.configuration.exceptionsrzope.configuration.fieldsrrrrrzope.i18nmessageidr zope.interfacer r r zope.schemar zope.component._apirzope.component._declarationrrzope.component.interfacerzope.component._compatrzope.security.zcmlr ImportErrorrrrrsecurityzope.component.securityrr/ ValueErrorrr(r)r3rLrQr_rcrdrerfrirkrmrsrtr~rrrrrrs|                   E  AA > $ 3  L