小编Pra*_*har的帖子

如何在一个WPF应用程序中拥有多个窗口?

我是WPF世界的新手,我正在开发一个应用程序,我需要在一个应用程序中拥有多个窗口.与Photoshop一样,当用户点击"新建"按钮时,将打开一个新窗口,旧的现有窗口将在后台显示.但是,工具栏和状态栏保持在顶部,不受影响.我还想添加用户可以使用多个窗口的功能,如果每个窗口都没有最大化.我该如何实现这一目标?如果我在构建问题时有点不清楚,我会道歉.

wpf

7
推荐指数
1
解决办法
8850
查看次数

用户模型的导入错误

我有这段代码在localhost上完美运行,但在GAE上引发了这个模糊的错误:

import_string() failed for 'webapp2_extras.appengine.auth.models.User' . Possible reasons are: - missing __init__.py in a package; - package or module

我的进口声明:

from webapp2_extras import auth
from webapp2_extras import sessions
from webapp2_extras.auth import InvalidAuthIdError   
from webapp2_extras.auth import InvalidPasswordError
Run Code Online (Sandbox Code Playgroud)

auth's用户模型的用法:

user = self.auth.store.user_model.create_user(username, password_raw = password, email = email)
if not user[0]: #returns a tuple with [boolean, user_info]
    return 'Create user error'
else:
    self.set_flash("Thank you for registering. Please login!")
    self.redirect(self.auth_config['login_url'])
Run Code Online (Sandbox Code Playgroud)

完整代码

更新(完整堆栈跟踪)

import_string() failed for 'webapp2_extras.appengine.auth.models.User'. Possible reasons are:

- missing __init__.py …
Run Code Online (Sandbox Code Playgroud)

python google-app-engine

7
推荐指数
1
解决办法
2509
查看次数

使用mod_wsgi记录烧瓶错误

很长一段时间以来,我一直在努力让这项工作得以实现,但我现在真的很有智慧.我已经尝试过在SO和flask文档上找到的所有内容,但我仍然无法使用简单的错误日志,以便我可以调试我的applcation.以下是粘贴的代码 -

# main.py
from flask import Flask
import logging

app = Flask(__name__)
file_handler = logging.FileHandler(filename='/tmp/election_error.log')
file_handler.setLevel(logging.WARNING)
app.logger.addHandler(file_handler)

@app.route('/')
def hello():
   return "hello
   #missing quotes to generate error

if __name__ == "__main__":
   app.run()


#wsgi file
import sys
import logging
sys.path.insert(0, "/var/www/voting_app")
logging.basicConfig(stream=sys.stderr)
from main import app as application


# apache2 conf file
WSGIDaemonProcess voting_app threads=5
WSGIScriptAlias /election /var/www/voting_app/voting_app.wsgi

LogLevel info

<Directory /var/www/voting_app>
        WSGIProcessGroup voting_app
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

请告诉我我哪里出错了.非常感谢.

python logging mod-wsgi

7
推荐指数
2
解决办法
9887
查看次数

使用cURL将数据发布到表单

我正在尝试使用cURL将数据发布到此URL上的表单:

  http://dq.sdc.bsnl.co.in/dq/reversePhone.seam?cid=812363
Run Code Online (Sandbox Code Playgroud)

看到它的来源,表格看起来像

<form id="revPhone" name="revPhone" method="post" action="/bsnl-web/reversePhone.seam;jsessionid=D238FA7A23A89A38C56B808B96F5D212" enctype="application/x-www-form-urlencoded" onkeyup="if (!check2(event)) {return false;};A4J.AJAX.Submit('loader2','revPhone',event,{'eventsQueue':'myqueue','parameters':{'revPhone:j_id16':'revPhone:j_id16'} ,'actionUrl':'/bsnl-web/reversePhone.seam;jsessionid=D238FA7A23A89A38C56B808B96F5D212','requestDelay':5} )">

<input type="hidden" name="revPhone" value="revPhone" />
<input type="hidden" name="revPhone:j_id12" />
<input id="revPhone:firstField" type="text" name="revPhone:firstField" maxlength="8" onkeydown="return removeEnter1(event)" />
Run Code Online (Sandbox Code Playgroud)

代码粘贴在这里:http://hastebin.com/wihunayilu.xml

尝试使用这些值的curl:

curl --data "revPhone:firstField=24988872&revPhone:city=CHENNAI" http://dq.sdc.bsnl.co.in/dq/reversePhone.seam?cid=812363 
Run Code Online (Sandbox Code Playgroud)

我最后再次使用相同的页面作为回复.我如何看到(使用firebug?)传递给帖子表单的参数,以便我可以正确地将请求发送到服务器?

非常感谢

curl

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

jQuery选择器给出不一致的行为

任何人都可以解释以下行为吗?

var ctx = $('#myCanvas').getContext("2d");      //doesnt work 
var ctx = $('#myCanvas')[0].getContext("2d");   //works
canvasWidth = $('#myCanvas').width();           //works
canvasHeight = $('#myCanvas').height();         //works
canvasWidth = $('#myCanvas')[0].width();        //doesnt work
canvasHeight = $('#myCanvas')[0].height();      //doesnt work
Run Code Online (Sandbox Code Playgroud)

jquery canvas

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

无法批量分配受保护的属性

我的features文件看这个:

Given there are the following users:
    | email              | password | admin |
    | admin@ticketee.com | password | true  |
Run Code Online (Sandbox Code Playgroud)

并且我的user模型没有声明admin属性attr_accessible以防止批量分配.因此,我已对user_steps.rb文件进行了更改以解决此问题.

Given /^there are the following users:$/ do |table|
  table.hashes.each do |attributes|
   unconfirmed = attributes.delete("unconfirmed") == "true"
   @user = User.create!(attributes)
   @user.update_attribute("admin", attributes["admin"] == "true")
   @user.confirm! unless unconfirmed
 end
end
Run Code Online (Sandbox Code Playgroud)

现在这应该按照书中的说法--Rails3在行动.我也检查了他们在线仓库的代码.用黄瓜运行它会产生以下错误:

Can't mass-assign protected attributes: admin (ActiveModel::MassAssignmentSecurity::Error)
  ./features/step_definitions/user_steps.rb:4:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/user_steps.rb:2:in `each'
  ./features/step_definitions/user_steps.rb:2:in `/^there are the …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails cucumber

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

用 python 编写更好的递归深度优先搜索

我正在尝试用 python 构建一个图形库(以及标准图形算法)。我尝试过实现 DFS,这就是它的样子

def DFS(gr, s, path):
    """ Depth first search 
    Returns a list of nodes "findable" from s """
    if s in path: return False
    path.append(s)
    for each in gr.neighbors(s):
        if each not in path:
            DFS(gr, each, path)
Run Code Online (Sandbox Code Playgroud)

这工作正常,但我对它的使用方式不满意。例如目前你需要这样做

 path = []
 DFS(mygraph, "s", path)
 print path
Run Code Online (Sandbox Code Playgroud)

相反,我希望以这种方式使用 DFS

path = DFS(mygraph, "s")
print path
Run Code Online (Sandbox Code Playgroud)

对于递归 DFS,我无法想出像上面那样工作的实现。有人可以给我一些关于如何实现这一目标的指示吗?

python

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

从O(logn)中的python heapq删除

我有一个像这样的堆(python,heapq模块) -

>>> h = []
>>> heappush(h, (5, 'write code'))
>>> heappush(h, (7, 'release product'))
>>> heappush(h, (1, 'write spec'))
>>> heappush(h, (3, 'create tests'))
Run Code Online (Sandbox Code Playgroud)

如何在O(logn)中将具有项值的元组作为"create tests"删除并保留堆属性?

这是我能想到的(不是O(logn))

for i in range(len(h)):
   if h[i][1] == "create tests":
      h[i], h[-1] = h[-1], h[i]
      popped = h.pop()
      heapq.heapify(h)
      break
Run Code Online (Sandbox Code Playgroud)

python

4
推荐指数
3
解决办法
5632
查看次数

使用端口443连接到Heroku

我是一名大学生,除了44,443之外的所有港口都被封锁了.我可以通过连接到github

Host github.com                                                                                    
  Hostname ssh.github.com
  Port 443
Run Code Online (Sandbox Code Playgroud)

git push heroku master 给我这个错误:

ssh: connect to host heroku.com port 22: Connection refused
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

我已经尝试过在这里发布的解决方案,但我仍然没有工作.有没有办法可以连接到heroku部署我的网站?

非常感谢

ssh heroku

4
推荐指数
2
解决办法
3282
查看次数

登录python + mod_wsgi应用程序

我在apache服务器上部署了一个python flask应用程序.这是我的abc.conf档案:

WSGIDaemonProcess voting_app threads=5
WSGIScriptAlias /election /var/www/voting_app/voting.wsgi

LogLevel info
ErrorLog "/var/www/voting_app/error.log"
CustomLog "/var/www/voting_app/access.log" combined

<Directory /var/www/voting_app>
    WSGIProcessGroup voting_app
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

为了检查调试,我在我的应用程序中出现了语法错误.在重新启动服务器时,我收到500服务器错误但我无法在任何地方看到错误的详细信息.我检查了我添加的两个文件作为日志 - 它们完全是空白的.日志文件也是如此/var/log/apache2.我在这里错过了什么?

python mod-wsgi

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