小编Mar*_* M.的帖子

Visual Studio 2015社区中的ES6/ES7支持

我听说VS 2015支持新的js语法但是当我在这个IDE中打开一个使用aurelia.js编写的项目时,intellisense会抱怨很多很多东西,例如.

export class UpperValueConverter {
  toView(value){
    return value && value.toUpperCase();
  }
}
Run Code Online (Sandbox Code Playgroud)

我安装了WebEssentials 2015.似乎仍然没有任何工作...可能一个重要的信息是我目前的VS安装是一个新的,所以我没有弄乱任何设置.

ecmascript-6 visual-studio-2015 aurelia ecmascript-7

24
推荐指数
2
解决办法
3万
查看次数

在ember.js中从组件发送动作到路由

这是路线:

import Ember from 'ember';

export default Ember.Route.extend({
    actions: {
        closeModal: function () {
            alert('asdf');
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

组件js代码:

import Ember from 'ember';

export default Ember.Component.extend({
    actions: {
        closeModal: function () {
            this.sendAction('closeModal');
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我想做的是(如代码所暗示的那样;))从组件到路由发送一个动作,以便路由可以对其进行操作.但是上面的代码不起作用 - 组件正确处理动作,但是sendAction它内部的调用方法没有做任何事情.

编辑:

我解决了这个问题:

this._controller.send('closeModal');在组件的动作方法中,然而这个解决方案并不满足我.Ember的作者说在ember 2.0中将删除控制器,因此在我的代码中我不想对它们进行任何引用.建议?

javascript ember.js

19
推荐指数
1
解决办法
9762
查看次数

Django ORM和锁定表

我的问题如下:

我有一个汽车经销商A和一个名为的db表sold_cars.当汽车正在出售时,我在此表中创建了条目.

Table有一个名为的整数列order_no.它应该是经销商销售的汽车中独一无二的.

因此,如果经销商A出售汽车a, b and c,那么这一栏应该是1, 2, 3.我必须使用这个列,而不是主键,因为我不想在我的数字中有任何漏洞 - 经销商A和B(可能会在以后添加)应该有订单号1,2,3,而不是A :1,3,5和B:2,4,6.所以...我为给定的经销商选择最后一个最大的order_no,将其增加1并保存.

问题是两个人在同一毫秒内从经销商A购买了汽车,两个订单都获得了相同的订单号.有什么建议?我正在考虑在事务块中关闭此进程,并锁定此表直到事务完成,但无法找到有关如何执行此操作的任何信息.

django orm locking

18
推荐指数
4
解决办法
1万
查看次数

如何修复"复数形式可能是危险的"django错误?

我不明白.如果我将Accept-Language标题设置为除"en"(de,pl,es)之外的任何内容,或者甚至是不存在的内容(如xxs),则应用程序不会吐出此错误,但是当我将其设置为"恩".它只发生在Windows(最新的gettext工具)上.这是堆栈跟踪:

Traceback (most recent call last):
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\core\han
dlers\exception.py", line 39, in inner
    response = get_response(request)
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\core\han
dlers\base.py", line 244, in _legacy_get_response
    response = middleware_method(request)
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\middlewa
re\locale.py", line 29, in process_request
    translation.activate(language)
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\utils\tr
anslation\__init__.py", line 161, in activate
    return _trans.activate(language)
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\utils\tr
anslation\trans_real.py", line 238, in activate
    _active.value = translation(language)
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\utils\tr
anslation\trans_real.py", line 227, in translation
    _translations[language] = DjangoTranslation(language)
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\utils\tr
anslation\trans_real.py", line 129, in __init__
    self._add_installed_apps_translations()
  File "E:\projekty\python\myapp_api\_env\lib\site-packages\django\utils\tr
anslation\trans_real.py", line 176, in _add_installed_apps_translations …
Run Code Online (Sandbox Code Playgroud)

python django translation

10
推荐指数
1
解决办法
1348
查看次数

在Angular2应用程序中找不到名称模块

我正在使用angular-cli来运行我的打字机动力angular2应用程序.我有这样的AppComponent定义:

import { Component } from '@angular/core';
import { ServersListComponent } from './servers-list/servers-list.component';

@Component({
    moduleId: module.id,
    selector: 'app',
    templateUrl: 'app.component.html',
    styleUrls: ['app.component.css'],
    directives: []
})
export class AppComponent {

}
Run Code Online (Sandbox Code Playgroud)

angular-cli无法编译此文件,因为它会在行中提出此问题主题中提到的错误moduleId: module.id.

我的tsconfig.json文件定义如下:

{
    "compileOnSave": false,
    "compilerOptions": {
        "declaration": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "mapRoot": "",
        "module": "commonjs",
        "moduleResolution": "node",
        "noEmitOnError": true,
        "noImplicitAny": false,
        "outDir": "../dist/",
        "rootDir": ".",
        "sourceMap": true,
        "target": "es5",
        "inlineSources": true
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}
Run Code Online (Sandbox Code Playgroud)

javascript angular

8
推荐指数
1
解决办法
3705
查看次数

从基类中的派生类获取属性

如何从基类中的派生类获取属性?

基类:

public abstract class BaseModel {
    protected static readonly Dictionary<string, Func<BaseModel, object>>
            _propertyGetters = typeof(BaseModel).GetProperties().Where(p => _getValidations(p).Length != 0).ToDictionary(p => p.Name, p => _getValueGetter(p));
}
Run Code Online (Sandbox Code Playgroud)

派生类:

public class ServerItem : BaseModel, IDataErrorInfo {
    [Required(ErrorMessage = "Field name is required.")]
    public string Name { get; set; }
}

public class OtherServerItem : BaseModel, IDataErrorInfo {
    [Required(ErrorMessage = "Field name is required.")]
    public string OtherName { get; set; }

    [Required(ErrorMessage = "Field SomethingThatIsOnlyHereis required.")]
    public string SomethingThatIsOnlyHere{ get; set; }
} …
Run Code Online (Sandbox Code Playgroud)

c# oop reflection

6
推荐指数
3
解决办法
2万
查看次数

Specflow 覆盖原始异常堆栈跟踪

你们中有人知道可以关闭标题中提到的行为的解决方法吗?每次我在测试步骤中做错事时,异常都会如下所示:

Test method 
FunctionalTests.Features.Parties.PartyAddingFeature.FeatureTitle threw exception: 
TechTalk.SpecFlow.BindingException: Error calling binding method 'FunctionalTests:FunctionalTests.Steps.PartiesSteps.GivenLegacyPartyUpsertedIntegrationEventCameInWithData(String, Table)': Object of type 'System.String' cannot be converted to type 'System.Int32'.
    at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) in D:\a\1\s\TechTalk.SpecFlow\Bindings\BindingInvoker.cs:line 69
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 395
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 316
   at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep() in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 132
   at FunctionalTests.Features.Parties.PartyAddingFeature.ScenarioCleanup()
   at FunctionalTests.Features.Parties.PartyAddingFeature.FeatureTitle() in C:\Project\test\Services\FunctionalTests\Features\Parties\PartyAdding.feature:line 25
Run Code Online (Sandbox Code Playgroud)

c# functional-testing specflow

6
推荐指数
1
解决办法
1750
查看次数

绑定到Model或ViewModel

我使用MVVM模式创建了一个项目(或者我认为;)).为了简化我的案例:

型号:

public class Model {
    public string Name { get; set; }
    public bool IsDefective { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

ViewModel - 扩展MvvmLight ViewModelBase:

public class ViewModel : ViewModelBase {
    private ObservableCollection<Model> models;
    public ObservableCollection<Model> Models {
        get {
            if (_models== null) {
                _models= new ObservableCollection<Models>();
            }

            return _models;
        }
        set {
            RaisePropertyChanged("Models");

            _models= value;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

查看 - 我正在显示文本框列表:

<TextBlock Text="{Binding Name}">
    <TextBlock.Style>
        <Style TargetType="{x:Type TextBlock}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=.IsDefective}" Value="True">
                    <Setter Property="Foreground" Value="Red" /> …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm

5
推荐指数
1
解决办法
8807
查看次数

带有图例的字段集右上角的位置图标

我在使以下布局在所有浏览器中看起来都相同时遇到问题:

.wrapper {
  margin-top: 100px;
  position: relative;
  height: 400px;
  width: 400px;
  border: 1px solid black;
}

.icon {
  position: absolute;
  width: 40;
  height: 40px;
  border: 1px solid black;
  background-color: white;
  top: -20px;
  right: 10px;
}
Run Code Online (Sandbox Code Playgroud)
<fieldset class="wrapper">
  <legend>Legendary!</legend>
  <div class="icon">icon</div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

问题是当legend元素存在时,div.icon在firefox上向下拉几个像素,在chrome上向上拉几个像素.当我删除legend元素时,它工作正常,但我不能这样做.关于如何让它在任何地方看起来都一样的想法?

html css

5
推荐指数
1
解决办法
1492
查看次数

如何在gunicorn服务器下为生产配置Django日志记录?

我已经设置了以下日志记录配置:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters': {
        'verbose': {
            'format': '%(asctime)s %(levelname)s [%(name)s:%(lineno)s] %(module)s %(process)d %(thread)d %(message)s'
        }
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'stream': sys.stdout,
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'gunicorn.errors': {
            'level': 'INFO',
            'handlers': ['console'],
            'propagate': True,
        },
    }
}
Run Code Online (Sandbox Code Playgroud)

它似乎根本没有作用。当该标志DEBUG设置True为时,我可以在控制台中看到一些错误。但是,将其设置为时False,我不能。因此,尽管DEBUG以一种方式或其他方式设置了标志,如何将错误记录到控制台?

django logging gunicorn

5
推荐指数
1
解决办法
4069
查看次数