I use mongoengine and when I call a class mongoengine give me error
for example when I use : Site.objects()
I get this
TypeError: id must be an instance of (str, unicode, ObjectId), not <type 'dict'>
and it's my class definition :
class Site(db.Document):
siteURL = db.URLField('''required = True''')
name = db.StringField(required = True)
pages = db.ListField(ReferenceField(Page))
siteId = db.IntField(required = True , unique = True )
views = db.IntField(required = True , default = 0)
visitors = db.IntField(required = True , default = 0)
stat_by_hour = LimitedListField(EmbeddedDocumentField(HourStat))
weekday_stat = db.ListField(EmbeddedDocumentField(WeekdayStat))
os = db.ListField(ReferenceField(OS))
countries = db.ListField(ReferenceField(Country))
cities = db.ListField(ReferenceField(City))
browsers = db.ListField(ReferenceField(Browser))
resolutions = db.ListField(ReferenceField(Resolution))
mostVisitedDays = db.SortedListField(EmbeddedDocumentField(MostVisitedDay) , ordering="visitors")
Related
I am trying to automate my shipping process using the Python fedex module. I am using developer test credentials. The code to create my shipment can be seen here:
import fedex
from fedex.services.ship_service import FedexProcessShipmentRequest, FedexDeleteShipmentRequest
from fedex.config import FedexConfig
CONFIG_OBJ = FedexConfig(key='******',
password= '*****',
account_number='***',
meter_number='***',
use_test_server=True)
shipment = FedexProcessShipmentRequest(CONFIG_OBJ)
shipment = FedexProcessShipmentRequest(CONFIG_OBJ)
shipment.RequestedShipment.DropoffType = 'REGULAR_PICKUP'
shipment.RequestedShipment.ServiceType = 'FEDEX_GROUND'
shipment.RequestedShipment.PackagingType = 'YOUR_PACKAGING'
shipment.RequestedShipment.Shipper.Contact.PersonName = 'Sender Name'
shipment.RequestedShipment.Shipper.Contact.PhoneNumber = '9012638716'
shipment.RequestedShipment.Shipper.Address.StreetLines = ['Address Line 1']
shipment.RequestedShipment.Shipper.Address.City = 'Detroit'
shipment.RequestedShipment.Shipper.Address.StateOrProvinceCode = 'Mi'
shipment.RequestedShipment.Shipper.Address.PostalCode = '48127'
shipment.RequestedShipment.Shipper.Address.CountryCode = 'US'
shipment.RequestedShipment.Recipient.Contact.PersonName = 'Recipient Name'
shipment.RequestedShipment.Recipient.Contact.PhoneNumber = '9012637906'
shipment.RequestedShipment.Recipient.Address.StreetLines = ['Address Line 1']
shipment.RequestedShipment.Recipient.Address.City = 'Detroit'
shipment.RequestedShipment.Recipient.Address.StateOrProvinceCode = 'Mi'
shipment.RequestedShipment.Recipient.Address.PostalCode = '48127'
shipment.RequestedShipment.Recipient.Address.CountryCode = 'US'
shipment.RequestedShipment.EdtRequestType = 'NONE'
shipment.RequestedShipment.ShippingChargesPayment.Payor.ResponsibleParty.AccountNumber \
= CONFIG_OBJ.account_number
shipment.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
shipment.RequestedShipment.LabelSpecification.LabelFormatType = 'COMMON2D'
shipment.RequestedShipment.LabelSpecification.ImageType = 'PNG'
shipment.RequestedShipment.LabelSpecification.LabelStockType = 'PAPER_7X4.75'
shipment.RequestedShipment.LabelSpecification.LabelPrintingOrientation = 'BOTTOM_EDGE_OF_TEXT_FIRST'
The code executes without problem and outputs the following JSON:
(reply){
HighestSeverity = "SUCCESS"
Notifications[] =
(Notification){
Severity = "SUCCESS"
Source = "ship"
Code = "0000"
Message = "Success"
LocalizedMessage = "Success"
},
Version =
(VersionId){
ServiceId = "ship"
Major = 23
Intermediate = 0
Minor = 0
}
JobId = "aac513eb0455f072033104594"
CompletedShipmentDetail =
(CompletedShipmentDetail){
UsDomestic = True
CarrierCode = "FDXG"
MasterTrackingId =
(TrackingId){
TrackingIdType = "FEDEX"
TrackingNumber = "794608334864"
}
ServiceTypeDescription = "FXG"
ServiceDescription =
(ServiceDescription){
ServiceType = "FEDEX_GROUND"
Code = "92"
Names[] =
....
I would like to show the physical shipping label that the following subsection of the output points to:
Label =
(ShippingDocument){
Type = "OUTBOUND_LABEL"
ShippingDocumentDisposition = "RETURNED"
ImageType = "PNG"
Resolution = 200
CopiesToPrint = 1
Parts[] =
(ShippingDocumentPart){
DocumentPartSequenceNumber = 1
Image = "iVBORw0KGgoAAAANSUhEUgAABXgAAAO2AQAAAAB6QsJkAA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412vd5P1uhPvp787rnfrf57vAqu39/fL+Xw3mc8J7xeN8vtvh+uf/vx3x/l6F/Oir6LeeO/vd5P7+5h3wuT9l8P1+qe7T+/74c2fLyHcvYEwthefvtn9jy+aPu34tz+fxIbiPbg+fNkr73I02s1Go9ge38x2/2fd+ANx7LE//c83YB3+YO7bXyLYE6/cx/AaXsNreA2v4TW8htfwGl7Da3gNr+E1vIbX8Bpew2t4Da/hNbyG1/AaXsNreA2v4TW8htfwGl7Da3gNr+E1vIbX8Bpew2t4Da/hNbyG1/AaXsNreA2v4TW8htfwGl7Da3gNr+E1vIbX8Bpew2t4Da/hNbyG1/AaXsNreA2v4TW8htfwGl7Da3gNr+E1vIbX8Bpew2t4Da/hNbyG1/AaXsNreA2v4TW8hlf18/8BREqCrGpwnF0AAAAASUVORK5CYII="
},
}
However, I am unsure how to do this. Can anybody offer me any guidance?
Thank you!
I have went through other answers but none of them seems to answer this question , I have cloned sandman2 which does not have column filter and column searchable option in admin dashboard , below is the ModelView
from flask_admin.contrib.sqla import ModelView
class CustomAdminView(ModelView): # pylint: disable=no-init
"""Define custom templates for each view."""
list_template = 'list.html'
create_template = 'create.html'
edit_template = 'edit.html'
column_display_pk = True
ModelView.can_export = True
ModelView.can_delete = False
ModelView.can_view_details = True
ModelView.can_set_page_size = True
ModelView.can_create = False
ModelView.page_size = 500
And I am calling this in app.py
def register_model(cls, admin=None):
"""Register *cls* to be included in the API service
:param cls: Class deriving from :class:`sandman2.models.Model`
"""
cls.__url__ = '/{}'.format(cls.__name__.lower())
service_class = type(
cls.__name__ + 'Service',
(Service,),
{
'__model__': cls,
})
# inspect primary key
cols = list(cls().__table__.primary_key.columns)
# composite keys not supported (yet)
primary_key_type = 'string'
if len(cols) == 1:
col_type = cols[0].type
# types defined at http://flask.pocoo.org/docs/0.10/api/#url-route-registrations
if isinstance(col_type, sqltypes.String):
primary_key_type = 'string'
elif isinstance(col_type, sqltypes.Integer):
primary_key_type = 'int'
elif isinstance(col_type, sqltypes.Numeric):
primary_key_type = 'float'
# registration
register_service(service_class, primary_key_type)
if admin is not None:
columns = (c.name for c in (list(cls().__table__.columns)) if not c.primary_key)
cv = CustomAdminView(cls, db.session)
cv.column_filters = columns
cv.column_searchable_list = list(columns)
admin.add_view(cv)
Still no luck , no filter option on the admin neither the filter option.
I'm trying override a str method in Person() class:
'''class Person(object):
def __init__(self, Nose = None, Neck = None, RShoulder = None, RElbow = None, RWrist = None, LShoulder = None, LElbow = None, LWrist = None, MidHip = None, RHip = None, RKnee = None, RAnkle = None, LHip = None, LKnee = None, LAnkle = None, REye = None, LEye = None, REar = None, LEar = None, LBigToe = None, LSmallToe = None, LHeel = None, RBigToe = None, RSmallToe = None, RHeel = None):
self.Nose = Nose
self.Neck = Neck
self.RShoulder = RShoulder
self.RElbow = RElbow
self.RWrist = RWrist
self.LShoulder = LShoulder
self.LElbow = LElbow
self.LWrist = LWrist
self.MidHip = MidHip
self.RHip = RHip
self.RKnee = RKnee
self.RAnkle = RAnkle
self.LHip = LHip
self.LKnee = LKnee
self.LAnkle = LAnkle
self.REye = REye
self.LEye = LEye
self.REar = REar
self.LEar = LEar
self.LBigToe = LBigToe
self.LSmallToe = LSmallToe
self.LHeel = LHeel
self.RBigToe = RBigToe
self.RSmallToe = RSmallToe
self.RHeel = RHeel
def __str__(self):
return 'Nose = %s\nNeck = \n%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s'%(self.Nose,self.Neck,self.RShoulder,self.RElbow,self.RWrist,self.LShoulder,self.LElbow,self.LWrist,self.MidHip,self.RHip,self.RKnee,self.RAnkle,self.LHip,self.LKnee,self.LAnkle,self.REye,self.LEye,self.REar,self.LEar,self.LBigToe,self.LSmallToe,self.LHeel,self.RBigToe,self.RSmallToe,self.RHeel)'''
And I want to find more elegant way to return a string which will look like that:
Nose = something
Neck = something
...
...
...
Question: elegant way to return a string which will look like ...
You can use the built-in vars function to get the __dict__ of the class variable and format it using .format(... and .join(....
Reference:
vars([object])
Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.
.format(value[, format_spec])
Convert a value to a “formatted” representation, as controlled by a standard formatting syntax that is used by most built-in types: Format Specification Mini-Language.
<str>.join(iterable)
Return a string which is the concatenation of the strings in iterable.
class Person:
def __init__(self, **kwargs):
self.Nose = kwargs.get('Nose', None)
self.Neck = kwargs.get('Neck', None)
self.RShoulder = kwargs.get('RShoulder', None)
def __str__(self):
return '\n'.join(('{} = {}'
.format(k, v) for k, v in vars(self).items()))
p = Person(Nose=1, Neck=1)
print(p)
Output:
Nose = 1
Neck = 1
RShoulder = None
Tested with Python: 3.6
I want to use a checkbox to control the ratio multiplied in slider function.
First I try to change the variable directly, but failed.
Then I try to change the dragCommand, but also failed.
How can I control it?
import pymel.core as pm
import math
myRatio = math.sqrt(2) * 0.5
def myPolyBevel(*args):
# called by convert
def convertOn(*args):
#myRatio = math.sqrt(2) * 0.5
myOffsetSlider.dragCommand = myOffsetOn
def convertOff(*args):
#myRatio = 1.0
myOffsetSlider.dragCommand = myOffsetOff
# called by offset
def myOffsetOn(*args):
temp = pm.floatSliderGrp( myOffsetSlider, query = True, value = True ) * myRatio
pm.setAttr( myBevel.name()+".offset", temp )
def myOffsetOff(*args):
temp = pm.floatSliderGrp( myOffsetSlider, query = True, value = True )
pm.setAttr( myBevel.name()+".offset", temp )
# main
if pm.selected():
# add Bevel
newBevel = pm.polyBevel3( pm.selected(), offset = 0.1 * myRatio, segments = 2, smoothingAngle = 30, chamfer = 1 )
myBevel = newBevel[0]
# UI
bevelWindow = pm.window(title = 'Bevel')
bevelLayout = pm.columnLayout()
myConvert = pm.checkBoxGrp( numberOfCheckBoxes = 1, label = '', label1 = 'Convert', value1 = 1, onCommand = convertOn, offCommand = convertOff )
myOffsetSlider = pm.floatSliderGrp( label='Offset', field = True,
minValue = 0.0, maxValue = 5.0,
fieldMinValue = 0.0, fieldMaxValue = 100.0,
value = 0.1, step = 0.001,
dragCommand = myOffsetOn, changeCommand = myOffsetOn )
pm.showWindow()
# Main
mainWindow = pm.window(title = 'Star')
mainLayout = pm.gridLayout( cellWidthHeight = (40,40), numberOfColumns = 5 )
bevelButton = pm.button( label = 'Bevel', command = myPolyBevel)
pm.showWindow()
You may have to not nest all this command, it makes it harder (or use some Class method)
use partial to pass args :
Maya Python - Using data from UI
here a useful post you can refer, check theodor and my answers on the topic (we often answer this question )
my models:
class Mod(models.model)
name = models.CharField(max_length = 255)
co_x = models.DecimalField(max_digits = 11, decimal_places = 8)
co_y = models.DecimalField(max_digits = 11, decimal_places = 8)
my views:
def closedPoint(request):
location_name = str(request.POST.get("lo", default=""))
nokta_x = int(float(request.POST.get("x"))
nokta_y = int(float(request.POST.get("y"))
poi = Point(nokta_x, nokta_y, srid = 900913)
sk = Mod()
poi_s = Point(sk.co_x, co_y, srid = 900913)
resut_poi = Mod.objects.filter(poi_s__distance_lte = (poi, D(km = 7))).filter(name__in = location_name)
here i want to deduct closest point in 7 km but it gives "Invalid parameters given for Point initialization
Ok, so it's now clear your error message comes from initializing a Point class with None.
That is your first critical problem.
Judging by the error message, my guess is that poi_s is initialized with None, None as Mod() is an unsaved instance with no values and those are the invalid parameters.
sk = Mod() # unsaved Mod instance with no defaults
poi_s = Point(sk.co_x, co_y, srid = 900913)
# sk.co_x is None
Your second problem that will appear after fixing the above is querying a model with an invalid lookup type (specific to PointField, __distance) which accepts a tuple. How to solve that, I don't know.
You would have to look at how GeoDjango translates that tuple into a DB lookup.