首页 \ 问答 \ VO类应该包含域逻辑吗?(Should VO classes contains the domain logic?)

VO类应该包含域逻辑吗?(Should VO classes contains the domain logic?)

我一直在阅读这个关于DAO和VO类的网站,以便与PHP和MVC一起使用。 http://www.sitecrafting.com/blog/php-patterns-part-ii/

我想知道应该在哪里放置域逻辑。 (仅处理对象数据,算法等的方法)

它应该在VO课程吗? 或者我应该为域逻辑类创建另一个包?

它与DB无关,所以我认为它不会放在DAO类上。 谢谢。


I have been reading this site about the DAO and VO classes to work with PHP and MVC. http://www.sitecrafting.com/blog/php-patterns-part-ii/

And i was wondering where should it be placed the domain logic. (methods to deal only with the object data, algoritms etc.)

Should it be at the VO classes? Or i should create another package for the domain logic classes?

It is not related with the DB so i assume it won't be placed on the DAO classes. Thanks.


原文:https://stackoverflow.com/questions/11578112
更新时间:2021-09-22 20:09

最满意答案

使用\来逃避'char

Operation.objects.exclude(field__icontains="\'foobar\'")

在python中:

>>> a = "\'hi\'"
>>> print a
'hi'

use the \ to escape the ' char

Operation.objects.exclude(field__icontains="\'foobar\'")

in python:

>>> a = "\'hi\'"
>>> print a
'hi'

相关问答

更多
  • 你可以使用__in : A.objects.filter(b__in=bs) 或者你可以避免创建bs查询集,并直接在你的查询中关联关系: A.objects.filter(b__bcondition=bvalue) You can use __in: A.objects.filter(b__in=bs) or you can avoid creating the bs queryset at all, and follow the relation directly in your query: A. ...
  • 不要在全局范围内初始化查询。 将None绑定到名称,然后编写一个函数,首先检查值是否为None ,如果是,则生成数据,然后返回值。 Don't initialize queries in a global scope. Bind None to the name, then write a function that first checks if the value is None and if so generates the data, and then returns the value.
  • 此票证讨论了此行为: https : //code.djangoproject.com/ticket/9006 只需使用order_by查询。 发生这种情况是因为如果您未指定显式排序,则数据库引擎可以自由返回任何合适的行。 所以我猜它只是从它的缓存中选择一个。 This ticket discusses this behavior: https://code.djangoproject.com/ticket/9006 Just use order_by query. This happens because ...
  • 不确定这是否是最好的方法,但它确实有效。 如果有人发布了更好的答案,我会接受他们的。 class OtherModel(models.Model) ... class MyModelManager(models.Manager): def get_queryset(self): self.model.list_other_model = OtherModel.objects.all() return super(MyModelManager, self).g ...
  • 这种事情非常棘手。 我实际上会在视图中完成所有工作,在那里修改查询集并将其传递给模板。 rank = 1 previous = None entries = list(entries) previous = entries[0] previous.rank = 1 for i, entry in enumerate(entries[1:]): if entry.value != previous.value: rank = i + 2 entry.rank = str ...
  • 编辑您的ContactForm class ContactForm(ModelForm): contatto_choice = forms.ModelChoiceField(queryset=Choice.objects.all()) class Meta: model = Contatto fields = ['contatto_choice', 'phone_number','email','text'] 你不需要其他形式 Edit Your C ...
  • 您的问题实际上并不清楚您的实际期望,但无论如何,这里有一些提示: 首先,模型实例(假设它们是相同模型的实例)比较它们的主键值,该键值也用作字典和集合的哈希值,因此如果要比较基础数据库记录,则不应使用模型实例,但将原始数据库值视为元组或列表的列表。 您可以使用(或) Queryset.values_list()或Queryset.values()来获得这些内容 - 不要忘记list()它们,以便您真正获得list而不是查询集。 这将我们带到了第二个重要的地方:虽然将自己呈现为列表类(在它们支持len() ,迭 ...
  • 如果执行以下命令,将揭示神秘感 ./manage.py sqlmigrate myapp 0001 请注意使用您的应用名称(我认为是bfm )替换myapp ,并使用创建Comment模型的实际迁移替换0001。 生成的sql将显示实际表是使用place_id int而不是place Place创建的,因为RDBMS对模型一无所知,模型只在应用程序级别。 django orm的工作是从RDBMS获取数据并将它们转换为模型实例。 这就是为什么你总是在每个Comment实例中获得一个place成员,并且该pl ...
  • 使用\来逃避'char Operation.objects.exclude(field__icontains="\'foobar\'") 在python中: >>> a = "\'hi\'" >>> print a 'hi' use the \ to escape the ' char Operation.objects.exclude(field__icontains="\'foobar\'") in python: >>> a = "\'hi\'" >>> print a 'hi'
  • 查询集中没有高级group_by 。 它用于aggregate和annotate调用,但它不适用于您。 有一个低级API,根本没有记录。 您可以获得内部查询说明: queryset = ... #whatever query you'd want to group by query = queryset.query 然后你可以通过添加一个你想要分组的字段来改变group_by成员 - 这是一个列表: query.group_by.append('a_field') 但: 你必须认真地知道你在做什么。 这 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。