我目前正在构建一个带有rails后端的iPhone应用程序.我在iphone上使用facebook的单点登录(SSO),并且在客户端上的身份验证效果非常好.我在rails上使用devise作为后端.
注意我已经在iOS应用程序中咨询过Facebook身份验证,该应用程序也已经访问了安全的Web服务
我看到设计有一个叫做token_authenticable的东西,它本质上是该线程的第5步中描述的"票证".这是我看到的当前流程
这很简单.但是,我有几个问题:
大家好我想用mongodb使用django的内置身份验证.我在网上看过,他们并不是真正的稳定和可靠的解决方案.
有谁有mongodb粉丝可以指出我如何通过最小的黑客实现这一目标?那太好了.
我有以下型号:
class Look(Base):
__tablename__ = "looks"
id = Column(Integer, primary_key=True)
url = Column(String, nullable=False, unique=True)
class Similarity(Base):
__tablename__ = 'similarities'
__table_args__ = (UniqueConstraint('look_id_small', 'look_id_big'),)
id = Column(Integer, primary_key=True)
look_id_small = Column(Integer, ForeignKey('looks.id'), nullable=False)
look_id_big = Column(Integer, ForeignKey('looks.id'), nullable=False)
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时:
try:
with session.begin_nested():
similarity = Similarity()
similarity.look_id_small, similarity.look_id_big = look_id1, look_id2
session.add(similarity)
session.commit()
except Exception, e:
logging.error(e)
print "look_id1: %s, look_id2: %s" % (look_id1, look_id2)
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
2013-01-19 04:55:42,974 ERROR Foreign key associated with column 'similarities.look_id_small' could not find table 'looks' with …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
session = scoped_session(sessionmaker(autocommit=False, autoflush=True, bind=engine))
Base = declarative_base()
Base.query = session.query_property()
class CommonBase(object):
created_at = Column(DateTime, default=datetime.datetime.now)
updated_at = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
class Look(Base, CommonBase):
__tablename__ = "looks"
id = Column(Integer, primary_key=True)
def __init__(self):
print "__init__ is run"
Base.__init__(self)
self.feedback = None
def set_feedback(self, feedback):
"""Status can either be 1 for liked, 0 no response, or -1 disliked.
"""
assert feedback in [1, 0, -1]
self.feedback = feedback
def get_feedback(self):
return self.feedback
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Traceback (most recent call last):
File …Run Code Online (Sandbox Code Playgroud) 我使用与此类似的东西实现了twitter认证:https://github.com/plataformatec/devise/wiki/OmniAuth :-Overview
我的问题是,由于twitter没有向您提供用户的电子邮件,您如何将用户引导回以下流程:
设计几乎照顾#3和#4.我应该如何构建代码以允许#2转换为#3和#4?
谢谢!
我有这个订单表格,允许我的用户创建订单.订单由多个元组组成(producetype, quantity).Producetype应该以<select>表单形式呈现,而数量只能是输入.应该动态添加producetype的选择,因为这可能会改变.目前,我用裸HTML编写了这个

我想使用WTForm,因为WTForm真的简化了我的代码.但是,我无法这样做:
码:
class OrderEntryForm(Form):
quantity = IntegerField('Quantity',
[validators.Required(), validators.NumberRange(min=1)])
# we will be dynamically adding choices
producetype = SelectField('Produce',
[validators.Required()],
choices=[])
class OrderForm(Form):
name = TextField('Crop', [validators.Length(min=3, max=60)])
due_date = DateField('Due Date', [validators.required()])
order_entries = FieldList(FormField(OrderEntryForm))
Run Code Online (Sandbox Code Playgroud)
我有以下问题:
order_entriesOrderForm 的字段中?order = { name:hello, due_date:2014-06-18, order_entries:[ {producetype_id: 1, quantity: 2}, {producetype_id: 3, quantity: 4}] }怎么能用OrderForm正确的OrderEntryForm价值填充我?我的代码可以在这里找到:https://gist.github.com/vicngtor/f8c8f0519dbd6b3b6110
我一直在玩Restkit大约一天,它的复杂性让我感到疯狂.
我在iOS上寻找一个简单,维护良好,安静的客户端,可以与我用rails编写的web服务器进行通信.我只需要以下内容:轻松调用CREATE/UPDATE/DELETE,灵活地检查响应代码以及响应体(我依靠响应体来为我的对象设置某些与服务器相关的ID)
不幸的是,Resty并不"真的支持ARC,所以它现在不在我的领域之内.
有什么建议?
这是我的database.py
engine = create_engine('sqlite:///:memory:', echo=True)
session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine))
Base = declarative_base()
Base.query = session.query_property()
def init_db():
# import all modules here that might define models so that
# they will be registered properly on the metadata. Otherwise
# you will have to import them first before calling init_db()
import models
Base.metadata.create_all(engine)
Run Code Online (Sandbox Code Playgroud)
这是我的backend.py
from flask import Flask, session, g, request, render_template
from database import init_db, session
from models import *
app = Flask(__name__)
app.debug = True
app.config.from_object(__name__)
# Serve …Run Code Online (Sandbox Code Playgroud) 我现在在Heroku上使用Flask,并且希望能够将错误记录到文件中(通过FileHandler)。
我认为heroku并没有正式支持。
在heroku的日志记录页面上,有一些有关syslog和drain的信息,设置起来似乎很复杂。
我想要快速简便的东西。有什么建议吗?
我最近卸载了postgresql并通过pip安装了pyscopg2.
我知道libcrypto和libssl涉及一些技巧
目前我将它们符号链接到:
$ ls -lah libssl.*
-rwxr-xr-x 1 root wheel 402K Aug 28 11:06 libssl.0.9.7.dylib
-rwxr-xr-x 1 root wheel 589K Aug 28 11:06 libssl.0.9.8.dylib
lrwxr-xr-x 1 root wheel 55B Nov 29 23:38 libssl.1.0.0.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libssl.1.0.0.dylib
lrwxr-xr-x 1 root wheel 55B Nov 30 02:25 libssl.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libssl.1.0.0.dylib
/usr/lib
$ ls -lah libcrypto.*
-rwxr-xr-x 1 root wheel 2.1M Aug 28 11:06 libcrypto.0.9.7.dylib
-rwxr-xr-x 1 root wheel 2.6M Aug 28 11:06 libcrypto.0.9.8.dylib
-r-xr-xr-x 1 root wheel 1.6M Oct 31 22:12 libcrypto.1.0.0.dylib
lrwxr-xr-x …Run Code Online (Sandbox Code Playgroud)