3131 'LocalTestApi'
3232]
3333KW_CONTROLLER_RESOURCE = 'Controller'
34+ KW_SCHEDULER_RESOURCE = 'Scheduler'
3435KW_SERVICE_RESOURCE = 'Service'
3536KW_CLIENT_RESOURCE = 'Client'
3637KW_REPOSITORY_RESOURCE = 'Repository'
4243 KW_CONTROLLER_RESOURCE : [
4344 'ActuatorHealthController'
4445 ],
46+ KW_SCHEDULER_RESOURCE : [],
4547 KW_SERVICE_RESOURCE : [
4648 'ActuatorHealthService'
4749 ],
@@ -209,8 +211,9 @@ def getResourceFinalName(resourceInstance, resourceName=None) :
209211 if not resourceName :
210212 resourceName = resourceInstance .__class__ .__name__
211213 for resourceType in KW_RESOURCE_LIST :
212- if resourceType in resourceName :
214+ if resourceName . endswith ( resourceType ) :
213215 resourceName = resourceName .replace (resourceType , c .NOTHING )
216+ print (f'{ resourceName [0 ].lower ()} { resourceName [1 :]} ' )
214217 return f'{ resourceName [0 ].lower ()} { resourceName [1 :]} '
215218
216219@Function
@@ -229,7 +232,8 @@ def setResource(apiInstance, resourceInstance, resourceName=None) :
229232@Function
230233def bindResource (apiInstance ,resourceInstance ) :
231234 validateFlaskApi (apiInstance )
232- setResource (getattr (apiInstance .resource , getResourceType (resourceInstance ).lower ()), resourceInstance )
235+ validateResourceInstance (resourceInstance )
236+ setResource (ReflectionHelper .getAttributeOrMethod (apiInstance .resource , getResourceType (resourceInstance ).lower ()), resourceInstance )
233237
234238@Function
235239def validateArgs (args , requestClass , method ) :
@@ -344,43 +348,6 @@ def innerResourceInstanceMethod(*args,**kwargs) :
344348 return innerResourceInstanceMethod
345349 return innerMethodWrapper
346350
347- @Function
348- def Service () :
349- def Wrapper (OuterClass , * args , ** kwargs ):
350- log .debug (Service ,f'''wrapping { OuterClass .__name__ } ''' )
351- class InnerClass (OuterClass ):
352- def __init__ (self ,* args ,** kwargs ):
353- log .debug (OuterClass ,f'in { InnerClass .__name__ } .__init__(*{ args } ,**{ kwargs } )' )
354- OuterClass .__init__ (self ,* args ,** kwargs )
355- apiInstance = getApi ()
356- self .globals = apiInstance .globals
357- self .service = apiInstance .resource .service
358- self .client = apiInstance .resource .client
359- self .repository = apiInstance .resource .repository
360- self .validator = apiInstance .resource .validator
361- self .mapper = apiInstance .resource .mapper
362- self .helper = apiInstance .resource .helper
363- self .converter = apiInstance .resource .converter
364- ReflectionHelper .overrideSignatures (InnerClass , OuterClass )
365- return InnerClass
366- return Wrapper
367-
368- @Function
369- def ServiceMethod (requestClass = None ):
370- def innerMethodWrapper (resourceInstanceMethod ,* args ,** kwargs ) :
371- log .debug (ServiceMethod ,f'''wrapping { resourceInstanceMethod .__name__ } ''' )
372- def innerResourceInstanceMethod (* args ,** kwargs ) :
373- resourceInstance = args [0 ]
374- try :
375- validateArgs (args ,requestClass ,innerResourceInstanceMethod )
376- methodReturn = resourceInstanceMethod (* args ,** kwargs )
377- except Exception as exception :
378- raiseGlobalException (exception , resourceInstance , resourceInstanceMethod )
379- return methodReturn
380- ReflectionHelper .overrideSignatures (innerResourceInstanceMethod , resourceInstanceMethod )
381- return innerResourceInstanceMethod
382- return innerMethodWrapper
383-
384351@Function
385352def Client () :
386353 def Wrapper (OuterClass , * args , ** kwargs ):
@@ -645,4 +612,8 @@ def validateFlaskApi(instance) :
645612 apiClassName = flask_restful .Api .__name__
646613 moduleName = flask_restful .__name__
647614 if not apiClassName == getClassName (instance ) and apiClassName == getQualitativeName (instance ) and moduleName == getModuleName (instance ) :
648- raise Exception (f'Globals can only be added to a "flask_restful.Api" instance. Not to { apiInstance } ' )
615+ raise Exception (f'Invalid "flask_restful.Api" instance. { apiInstance } is not an Api instance' )
616+
617+ def validateResourceInstance (resourceInstance ) :
618+ if ObjectHelper .isNone (resourceInstance ) :
619+ raise Exception (f'Resource cannot be None' )
0 commit comments