简体   繁体   English

为什么具有多个继承的DBIx :: Class在更新时失败?

[英]Why does DBIx::Class with multiple inheritance fail on update?

I have a DBIC schema, where all the classes use a common base class, and definition class. 我有一个DBIC架构,其中所有类都使用一个公共基类和定义类。 The base class loads common components, and overrides the update method in order to record changesets in an audit table. 基类加载通用组件,并覆盖update方法,以便将更改集记录在审核表中。 The definition class is a static class generated from the database. 定义类是从数据库生成的静态类。 A typical class header looks something like: 一个典型的类头看起来像:

package Schema::Base;

use base 'DBIx::Class::Core';

sub update {
  my $self = shift;

  # track changes to row

  my $instance = $self->next::method(@_);

  # save changeset to audit table

  return $instance;
}


package Schema::Immutable::User;

use Moose;
use MooseX::NonMoose;
use namespace::autoclean;
extends 'DBIx::Class:Core';

__PACKAGE__->load_components("InflateColumn::DateTime");



package Schema::Mutable::User

use base ('Schema::Base', 'Schema::Immutable::User');

sub update {
  my $self = shift;

  # encrypt password

  return $self->next::method(@_);
}

Everything was working fine until I added and an override to the update in the User class. 在添加和覆盖User类中的更新之前,一切工作正常。 Apparently having the override in the base class, and the User class conflict in some way. 显然在基类中具有重写,并且User类以某种方式发生冲突。 I'm using next::method(@_) to call the next update method, but it always hangs. 我正在使用next :: method(@_)调用下一个更新方法,但它始终挂起。

This is a CGI application. 这是一个CGI应用程序。 So when I hit "save" the browser spins its wheels until I hit escape to cancel the request. 因此,当我点击“保存”时,浏览器旋转轮子,直到我按下“转义”以取消请求。 At this point, my logging picks back up and it shows that all the queries are being executed correctly, and quickly, but it hangs at the end of the User class, and does not progress until I hit escape in the browser. 至此,我的日志记录恢复了,它表明所有查询都在正确,快速地执行,但是它挂在User类的末尾,并且直到我在浏览器中命中转义后才继续进行。

UPDATE: This appears to be an issue with the interaction with catalyst. 更新:这似乎是与催化剂相互作用的问题。 When run by itself this code works correctly. 单独运行时,此代码可以正常工作。 However, when executed from within a catalyst application it fails. 但是,当从催化剂应用程序中执行时,它会失败。

I discovered the root cause of this issue in the application I was debugging. 我在调试的应用程序中发现了此问题的根本原因。 The original author was creating a request parsing object that instantiates a CGI object to parse the incoming request. 原始作者正在创建一个请求解析对象,该对象实例化一个CGI对象来解析传入的请求。 However, this conflicts with catalyst, so the request object spins its wheels until the request from the client ends. 但是,这与催化剂冲突,因此请求对象旋转其轮子,直到来自客户端的请求结束。 Apparently all they needed to get was the url, and the ip from the user so it was easy enough to insert code to do that using the environmental variables without calling CGI. 显然,他们需要获取的只是URL和用户的ip,因此可以很容易地插入代码来使用环境变量来执行此操作,而无需调用CGI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM