面向方面的编程助手
concerns的Python项目详细描述
#关注点
[python](https://www.python.org/)实现
[ruby](https://www.ruby-lang.org/)
[activesupport::关注点](https://api.rubyonrails.org/v5.1/classes/activesupport/concern.html)
行为。
[元类](https://www.python.org/doc/artists/metaclasses/)``初始方法,
正式的“名称空间”:
`` python
`定义初始(cls,name:str,base:tuple,namespace:dict)->;无:
…
```
它是类体的字典表示。
它的上下文将被合并到目标上下文上。< BR> > BR/> DEF反序列化(CLS,数据:STR):
BR/>< BR/>类人物库(NUBDUTPLE): BR/>姓氏:STR
BR/> BR/>类人(个人基础):
关注(SerialMixin)
‘BR/>< BR> > BR>>BR/> StrutKix=真)< BR/>方面是一个映射(例如,字典),它本身将被合并到目标上下文的分解上。
``python
from concerns import concern
声音:str=none):
如果声音:
self.voice=voice
def say(self)->;none:
打印(self.voice)
````
目标类上下文将作为
参数传递给方面,以便在对其进行分解之前进行处理。
``python
from concerns import concern
from collections.abc import mutablemapping
from datetime import datetime
def make_timed(context:mutablemapping)->;none:
“
”可重用方面函数将创建时间添加到对象
“
def set_created_attr(attr:str)->;none:
context[attr]=none
def new(cls,name:str,base:tuple,_dict:dict):
self=super()。\uu new_u(cls,name,base,_dict)
setattr(self,attr)=datetime.now()
return self
上下文[''''u new']=new
context['set_created_attr']=set_created_attr
类寄存器:
关注点(设置时间)
…#更多类属性
set_created_attr('created_at')
````
[python](https://www.python.org/)实现
[ruby](https://www.ruby-lang.org/)
[activesupport::关注点](https://api.rubyonrails.org/v5.1/classes/activesupport/concern.html)
行为。
[元类](https://www.python.org/doc/artists/metaclasses/)``初始方法,
正式的“名称空间”:
`` python
`定义初始(cls,name:str,base:tuple,namespace:dict)->;无:
…
```
它是类体的字典表示。
它的上下文将被合并到目标上下文上。< BR> > BR/> DEF反序列化(CLS,数据:STR):
BR/>< BR/>类人物库(NUBDUTPLE):
BR/> BR/>类人(个人基础):
关注(SerialMixin)
‘BR/>< BR> > BR>>BR/> StrutKix=真)< BR/>方面是一个映射(例如,字典),它本身将被合并到目标上下文的分解上。
``python
from concerns import concern
声音:str=none):
如果声音:
self.voice=voice
def say(self)->;none:
打印(self.voice)
````
目标类上下文将作为
参数传递给方面,以便在对其进行分解之前进行处理。
``python
from concerns import concern
from collections.abc import mutablemapping
from datetime import datetime
def make_timed(context:mutablemapping)->;none:
“
”可重用方面函数将创建时间添加到对象
“
def set_created_attr(attr:str)->;none:
context[attr]=none
def new(cls,name:str,base:tuple,_dict:dict):
self=super()。\uu new_u(cls,name,base,_dict)
setattr(self,attr)=datetime.now()
return self
上下文[''''u new']=new
context['set_created_attr']=set_created_attr
类寄存器:
关注点(设置时间)
…#更多类属性
set_created_attr('created_at')
````