无法评论主帖,所以需要发帖新问题.
我正在尝试从Scotty.NET(评价最高的答案)编写的这个帖子中实现分页解决方案,但面临一个奇怪的问题:
我的自定义代码在此plunker(http://plnkr.co/edit/Mdsy2x)中并解释了该问题.如果我设置$scope.numPerPage
为除"10"之外的任何数字 - 我的总页数会出错.例如,如果我生成450 todo并且设置$scope.numPerPage = 5;
- 我总共得到45页并显示225项,因此除了10之外的任何数字都会给出错误的结果
我是python的新手,并试图为我的第一个应用程序编写测试.简单的app结构:
- app
- tests
__init__.py
- test_main.py
- __init__.py
- main.py
Run Code Online (Sandbox Code Playgroud)
该main.py
包含 main_func
test_main.py:
from main import main_func
def test_check():
assert main_func() is True
Run Code Online (Sandbox Code Playgroud)
如果我pytest
在app
目录中手动运行测试- 得到此错误:
C:\Users\*****\PycharmProjects\checker3>pytest
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: C:\Users\*****\PycharmProjects\app, inifile:
collected 0 items / 1 errors
=================================== ERRORS ====================================
_____________________ ERROR collecting tests/test_main.py _____________________
ImportError while importing test module 'C:\Users\*****\PycharmProjects\app\tests\test_main.py'.
Original error message:
'No module named 'main''
Make sure …
Run Code Online (Sandbox Code Playgroud) 问题很简单,但无法真正找到答案.
如何使用chrome开发人员工具模拟拖放事件?
确定我可以手动拖放文件,但我无法检查DOM中的更改.
我有一个来自API的响应,该响应返回一个枚举值。从API返回的值在请求中表示为字符串。该值是enum
打字稿界面的属性。
问题:
当收到响应时,TS接口将该值存储为字符串(可能就是问题所在),因此我不能将其直接用作enum
。
obj模型:
export interface Condo {
id:number
title:string
latitude:number
longitude:number
city:string
country:string
district:string
address:string
locationType: LocationType
}
export enum LocationType {
CONDO,
MALL,
STATION
}
Run Code Online (Sandbox Code Playgroud)
请求:
getCondoAllByCountry(country_code){
return this.http.get(this.config.apiEndpoint +this.subApiUrl+'/all')
.map(res => <Condo[]>res.json())
.catch((err:Response) => {
return Observable.throw(err.json());
});
}
Run Code Online (Sandbox Code Playgroud)
用法样本:
this.condoService.getCondoAllByCountry(this.userData.country_code).subscribe(data=>{
someFunc(data)
})
............
someFunc(condo_list: Condo[]){
//here is need to know the `locationType` for each object
console.log(typeof condo_list[i].locationType);
console.log(typeof LocationType.CONDO)
switch (condo_list[i].locationType){
case LocationType.CONDO:
console.log('Case - condo')
break;
case LocationType.MALL:
console.log('Case - mall') …
Run Code Online (Sandbox Code Playgroud) 在单个用户执行视图时,是否可以阻止访问视图的所有用户执行视图中的代码?一种单线程视图.
我需要它,因为我pyinstaller
在此视图中生成python可执行文件,并通过配置文件将用户名传递给可执行文件.
例如:
class CliConfig(APIView):
def get(self, request, format=None):
try:
config['DEFAULT']['username'] = request.user
#make a build with pyinstaller
bin_file = open(*generated filepath *, 'rb')
response = Response(FileWrapper(bin_file), content_type='application/octet-stream')
response['Content-Disposition'] = 'attachment; filename="%s"' % '*filename*'
return response
finally:
config['DEFAULT']['username'] = ''
Run Code Online (Sandbox Code Playgroud)
所以,基本上我想要的是生成一个python可执行文件,它将在django rest framwork中设置一个唯一的用户名APIView
.除了通过设置文件传递用户名之外,我没有看到其他方法.如果有办法 - 会赞赏建议.
python 3.6.5
,djangorestframework==3.8.2
,pyinstaller==3.3.1
我的应用程序中有一个案例,我需要使用该对象AccountsDao accountsDao
public class Account {
@Autowired
private AccountsDao accountsDao;
Run Code Online (Sandbox Code Playgroud)
无需将属性添加@Component
到Account
类中(并且无需任何其他方法将其标记为 spring bean)。
app很大,有客观原因Account
不能是Spring Bean,必须手动初始化。
我也知道这是单例,通用结构就可以了。
有没有办法做到这一点?
python ×2
angular ×1
angularjs ×1
django ×1
ionic2 ×1
java ×1
javascript ×1
pagination ×1
pycharm ×1
pyinstaller ×1
pytest ×1
python-3.x ×1
spring ×1
spring-mvc ×1
typescript ×1