我以前从未见过这种情况,谷歌似乎在这里没有提供太多帮助,如果标题含糊,则表示歉意,不确定该怎么称呼。
我正在从ext.db迁移到ndb,并且我模型中的某些逻辑使用了ext.db的 <div class="container">
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="image1.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="metalcard.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="image3.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
函数。 migration doc将我带到此SO question,这告诉我可以将.container {
margin: 0 auto;
max-width: 1200px;
padding: 0 1rem;
display: inline-block;
}
.card-container{
width: 25%; /* Adjust the target width*/
}
.flip-container {
position: relative;
perspective: 1000px;
}
/* flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
transform: rotateY(180deg);
}
.flip-container, .front, {
width: 100%;
height: 170px;
}
.flip-container,.back {
height: 190px;
width: 100%;
}
.flipper {
transition: 0.9s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
background: rgba(0,0,0,0.05);
z-index: 2;
/* for firefox 31 */
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.back {
background: #00ccff;
transform: rotateY(180deg);
}
等默认属性设置为is_saved()
,并设置一些post / get挂钩将其更改为{ {1}},我将获得相同的功能。
所以,我有一个健身模型:
is_saved
我的代码库中的其他逻辑最终导致保存(或False
)该实体,最终我保存了该实体的True
变量:
class Workout(ndb.Expando):
..properties..
is_saved = False
def __init__(self, parent=None, **kwds):
self._summary = None
self._description = None
self._snapshots = kwds.get('_snapshots')
self._action = kwds.get('_action')
self._record_id = kwds.get('_record_id')
self._packageNumber = None
super(Workout, self).__init__(parent=None, **kwds)
@classmethod
def _post_get_hook(cls, key, future):
obj = future.get_result()
if obj is not None:
# test needed because post_get_hook is called even if get() fails!
obj.is_saved = True
def _post_put_hook(self, future):
logging.info(future)
self.is_saved = True
太好了,put()
是workout
,逻辑有效。
>>> workout
Workout(key=Key('Workout', 5132107961597952), calories=2.0, creation_date=datetime.datetime(2018, 8, 24, 18, 23, 0, 769000), distance=1.0, elapsedSeconds=21600, is_deleted=False, is_saved=True)
好吧,如果我自己设置:
is_saved
好吧,这违背了所有逻辑和理由。也许是物体?
True
好吧,对象没有问题。我不知道这是怎么了。