我的观察者中有2人正在观察同一sales_order_shipment_save_before事件.ModuleA是我创造的那个,然后我创造了ModuleB
现在只有ModuleB观察者被召唤而不是ModuleA.
请让我知道如何解决这个问题,并且两位观察员都会被召集.
ModuleA
<?xml version="1.0"?>
<config>
<global>
<models>
<shipmentsave>
<class>My_Shipmentsave_Model</class>
</shipmentsave>
</models>
</global>
<adminhtml>
<events>
<sales_order_shipment_save_before>
<observers>
<shipmentsave>
<type>singleton</type>
<class>shipmentsave/observer</class>
<method>salesOrderShipmentSaveBefore</method>
</shipmentsave>
</observers>
</sales_order_shipment_save_before>
</events>
</adminhtml>
</config>
Run Code Online (Sandbox Code Playgroud)
Observer.php
<?php
class My_Shipmentsave_Model_Observer
{
public function salesOrderShipmentSaveBefore(Varien_Event_Observer $observer)
{
$shipment = $observer->getEvent()->getShipment();
return;
}
}
Run Code Online (Sandbox Code Playgroud)
ModuleB
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Bshipment>
<version>0.1.0</version>
</My_Bshipment>
</modules>
<admin>
<routers>
<bshipment>
<use>admin</use>
<args>
<module>My_Bshipment</module>
<frontName>bshipment</frontName>
</args>
</bshipment>
</routers>
</admin>
<adminhtml>
<events>
<sales_order_shipment_save_before>
<observers>
<shipmentsave>
<type>singleton</type> …Run Code Online (Sandbox Code Playgroud) 我在查找JavaScript代码中的错误时遇到了问题.它告诉我发生了运行时错误:Expected ')'
这是代码:
<xsl:for-each select="./projects/project">
<script LANGUAGE='Javascript'>
x = 0;
if(x == 0) {
document.write("<td style="background-color:#76787A" ><xsl:value-of select="weight"/></td>")
}
else
{
document.write("<td><xsl:value-of select="weight"/></td>")
}
</script>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
你怎么看?
在尝试回答这个问题时,我想建议使用enable_if+ disable_if来基于类型是(或不是)多态的事实来允许方法的重载.
所以我创建了一个小测试文件:
template <class T>
void* address_of(T* p,
boost::enable_if< boost::is_polymorphic<T> >* dummy = 0)
{ return dynamic_cast<void*>(p); }
template <class T>
void* address_of(T* p,
boost::disable_if< boost::is_polymorphic<T> >* dummy = 0)
{ return static_cast<void*>(p); }
struct N { int x; };
int main(int argc, char* argv[])
{
N n;
std::cout << address_of(&n) << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这看起来很温顺.
然而gcc(3.4 ...)扼杀了这个:
test.cpp:在函数中
int main(int, char**):
test.cpp:29:错误:调用重载address_of(N*)是不明确的
test.cpp:17:注意:候选者是:void* address_of(T*, boost::enable_if<boost::is_polymorphic<T>, void>*)[有T = …
使用psycopg2 cursor对象考虑Python中的以下代码(为清楚起见,更改或省略了一些列名称):
filename='data.csv'
file_columns=('id', 'node_id', 'segment_id', 'elevated',
'approximation', 'the_geom', 'azimuth')
self._cur.copy_from(file=open(filename),
table=self.new_table_name, columns=file_columns)
Run Code Online (Sandbox Code Playgroud)
\COPYbash工作速度非常快,即使对于大型(~1,000,000行)文件也是如此.这段代码超5000行,但data.csv超过10,000 行时,程序完全冻结.
任何想法\解决方案?
亚当
我知道每种编程语言都有一定的指导和风格.我的问题是关于我编写代码的两种语言,这种语言不是很受欢迎或记录在案.
我知道这个话题非常广泛,每个人都有自己独特的做事方式.我想要的是听到某些风格的优点,缺点.
为了探索这个问题,假设您正在编写自己的编程语言,基于您过去的经验,最好的方法是什么?
请记住,可能会有基于特定语言的起伏,所以请考虑这种语言是否无关紧要.我仍然很喜欢编程,所以我想养成使代码可读且易于理解的最佳习惯.
有很多话题需要讨论,我可以通过基础知识运行:
全局变量
它们应该以_开头并全部大写吗?
局部变量
它们应该以_结尾并始终是小写的吗?
变量名称
如果我定义的是员工的小时工资,那么它应该是EmployeeHourlyWage,Employee_Hourly_Wage吗?
变量类型
如果你在名称中包含变量的类型,例如,如果我定义$ Hours并且它已经存储了一个整数,我应该将它命名为$ Hour_INT,以便我知道它何时引用它是什么类型?谁知道,我可能有$ Hours_FLOAT
Curly Brackets括号
是否应该与自己排列这样的词,或者什么?哪一项最好,首选,最具可读性?
IF ($Test) {
//code
} ELSE {
//code
}
IF ($Test)
{
//code
} ELSE {
//code
}
IF ($Test)
{
//code
}
ELSE
{
//code
}
Run Code Online (Sandbox Code Playgroud)
对齐
我不断排列变量和它们的值,所以我知道哪里去了哪里.这是不好的做法:
// Assuming GUI(TOP, LEFT, HEIGHT, WIDTH)
GUI( 23 , 44 , 245 , 2323 )
GUI( 232 , 4332 , 22 , 6576 )
GUI( 21 , 4 , 1 …Run Code Online (Sandbox Code Playgroud) 我已经使用Core Data实现了一个小概念验证应用程序,通过文本字段接受用户的一些对象属性值,并且由于此处和iPhone Core Data Recipes应用程序中的信息,它们都运行良好.但我现在需要向用户显示对象验证错误,我找不到推荐的处理方法.Recipe应用程序中的代码只记录错误并说"用代码替换此实现以适当地处理错误".十分感谢.
我敢肯定有很多方法来解释,分析和验证错误信息发送给用户,但我想知道的是,如果有一些最佳做法或有人实施了,我可以遵循一个模式,众说纷纭.验证码[newObject valdiateForInsert&error];应该放在哪里?在NSManagedObject子类中?在处理屏幕的UIViewController中,是否允许添加对象?也许在app范围内的ValidationController?
所有验证错误都在NSError的用户信息,这是各种NSValidation键和值的NSDictionary的返回.有没有一种很好的方法可以将此错误信息转换为对用户有帮助的内容?例如,我的核心数据模型中有一条规则,某个属性只能是3个字符.如果在保存或更新一个对象,我得到验证错误的过程中,我需要解析出NSError用户信息,并找到值的NSValidationErrorKey(属性的名称)时,NSValidationErrorValue(导致错误的对象的值)和NSValidationErrorPredicate(违反的规则,在这种情况下返回length <= 3.
有没有可以传回给用户一个良好的,普遍接受的收集和这个数据改写(munging)弄成的呢?目前,我正在拉NSError信息为字符串,然后通过一系列针对我验证每个属性的条件语句的下降,它是如此丑陋,我还挺想,当我看着它想吐.必须有一种更好,更清晰的方式来使用Core Data验证错误并将可读版本传递给用户.
在我的Windows中,我有一个TextBox,我喜欢从另一个线程更新(文本属性).这样做时,我得到InvalidOperationException(参见标题).我在谷歌发现了不同的链接解释这一点,但我似乎仍然无法使它工作.
我试过的是这个:
Window1代码:
private static Window1 _myWindow;
private MessageQueueTemplate _messageQueueTemplate;
private const string LocalTemplateName = "LocalExamSessionAccessCodeMessageQueueTemplate";
private const string RemoteTemplateName = "RemoteExamSessionAccessCodeMessageQueueTemplate";
...
public Window1()
{
InitializeComponent();
_myWindow = this;
}
public static Window1 MyWindow
{
get
{
return _myWindow;
}
}
public void LogText(string text)
{
informationTextBox.Text += text + Environment.NewLine;
}
...
Run Code Online (Sandbox Code Playgroud)
在另一个类(实际上是一个spring.NET Listener适配器,监听某个队列,在另一个线程中启动).
var thread = new Thread(
new ThreadStart(
delegate()
{
Window1.MyWindow.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
Window1.MyWindow.LogText(text);
}
));
}
));
Run Code Online (Sandbox Code Playgroud)
它不会引发错误,但在窗口1的LogText法文本没有被触发,因此文本没有更新.
所以基本上,我想从另一个线程中运行的另一个类更新这个TextBox组件.
我想用Maven执行Linux shell命令.这是我尝试过的:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>hostname</executable>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我在尝试查看localhost中的页面时遇到此错误.网站以前工作过.代码文件未预编译.我已经清理了asp.net临时文件夹,并为WSroot和Temporary ASP.NET Files文件夹的IIS_IUSRS帐户授予了完全控制权限,但没有更改.
尝试执行时,我也遇到了Access Denied错误
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i
Run Code Online (Sandbox Code Playgroud)
描述:编译服务此请求所需的资源时发生错误.请查看以下特定错误详细信息并相应地修改源代码.
编译器错误消息: BC2000:编译器初始化意外失败:0x80070005
来源错误: [没有相关的源代码行]
源文件: vbc:致命 线: 0
详细的编译器输出:
c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework64\v3.5\vbc.exe" /t:library /utf8output /R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Design\2.0.0.0__b03f5f7f11d50a3a\System.Design.dll" /R:"C:\Windows\assembly\GAC_64\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\assembly\GAC_64\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\edc6d145\6ccb6f45\assembly\dl3\5a446507\0042bc76_16cec701\Intelligencia.UrlRewriter.DLL" /R:"C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\Windows\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /out:"C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\edc6d145\6ccb6f45\App_SubCode_vb.8xqaf3z2.dll" /D:DEBUG=1 /debug+ /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls,System.Web.Configuration,System.Data,System.Data.OleDb,System.Globalization /warnaserror- /optionInfer+ "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\edc6d145\6ccb6f45\App_SubCode_vb.8xqaf3z2.0.vb" "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\edc6d145\6ccb6f45\App_SubCode_vb.8xqaf3z2.1.vb"
Microsoft (R) Visual Basic Compiler version 9.0.30729.715
Copyright (c) Microsoft Corporation. All rights reserved.
vbc : Fatal error BC2000 : compiler initialization failed unexpectedly: …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我必须实现原生相机活动,我必须启动相机并拍照.
详细地说,我的应用程序包含,One TextView(在顶部)显示活动名称和一个按钮(在底部)和屏幕的中间区域,应该查看相机预览..当用户单击该按钮时,应单击快照并将其显示在另一个活动的Imageview中.
我知道使用以下方法:
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult( intent, 0 );
Run Code Online (Sandbox Code Playgroud)
但是如果我使用这种方法则不会显示我的textview和按钮视图.
(请注意:我正在使用Android SDK 1.5和HTC Hero)
请通过任何文章,网站或pdf的建议来帮助我.
thanx,paresh
android android-camera android-camera-intent android-capture