clean orhpan GriFS elements.

70 views
Skip to first unread message

aliane abdelouahab

unread,
Sep 24, 2012, 7:13:12 AM9/24/12
to mongodb-user
i got a bug in my application; if i upload TWO products, it's okey
when i delete one of them, but if i upload THREE i got an error from
GridFS telling me that the removed ID dont exists (and this is what i
wanted???)

here is the code:

class VentesHandler(BaseHandler):
@tornado.web.authenticated
def get(self):
user = self.get_secure_cookie("mechtari")
info = tornado.escape.json_decode(user)
email = info["personnel"]["email"]
try:
produits = self.db.users.find({"personnel.email":email},
{"produit_up":1,"_id":0}).distinct("produit_up")
renderer = self.fs
except (errors.AutoReconnect, errors.ConnectionFailure):
self.redirect("/error")
try:
self.render("ventes.html", produits=produits,
renderer=renderer)
except gridfs.errors.NoFile, e:
self.write(str(e))

class Supprimer(BaseHandler):
@tornado.web.authenticated
def post(self):
debut = time.clock()
prod = self.get_arguments("supprime")
produ = prod[0][:]
idd = self.db.users.find_one({"produit_up.spec.id":produ})
["produit_up"][0["avatar"]["photo"]
try:
self.db.users.update({"produit_up.spec.id":produ},
{"$pull":{"produit_up"{"spec.id":produ}}})

self.db.fs.files.remove({"_id":ObjectId('{0}'.format(idd))})
except (errors.AutoReconnect, errors.ConnectionFailure):
self.redirect("/error")
self.redirect("/ventes") # this will redirect to the first code.

and the template:

{% for produit in produits %}
<div class="produit">
<span class="nom">Le nom du produit: {{produit["spec"]["namep"]}}</
span>
{% from bson import ObjectId %}
{% if produit["avatar"]["orientation"]=="portrait" %}
<span><img src="/{{renderer.get(ObjectId(produit["avatar"]
["photo"])).filename}}"height="250px" class="imag">
{% else %}
<span><img src="/{{renderer.get(ObjectId(produit["avatar"]
["photo"])).filename}}"width="250px"class="imag">
{% end %}
<div class="supprimer" >
<form name="supprimer" class="supprimer" method="post" action="/
supprimer">
{% raw xsrf_form_html() %}
<input type="hidden" value="{{produit["spec"]["id"]}}" name="supprime"/
>
<input type="submit" value="SUPPRIMER!"/>
</form>
</div>

as you can see, this two lines:

self.db.users.update({"produit_up.spec.id":produ}, {"$pull":
{"produit_up{"spec.id":produ}}})
self.db.fs.files.remove({"_id":ObjectId('{0}'.format(idd))})

the first one deletes the object, the second one clean its picture
from GridFS, but if there is more than one, it will make an error, for
example if i delete the object with
ObjectId('5060384f3a5f3a09488f7384') then i get an error when i'll be
redirected:

no file in gridfs collection
Collection(Database(Connection('localhost', 27017), u'essog'),
u'fs.files') with _id ObjectId('5060384f3a5f3a09488f7384')

and here is the link to stackoverflow (formatted):

http://stackoverflow.com/questions/12563503/how-to-delete-an-element-with-its-attached-file-in-gridfs

Bernie Hackett

unread,
Sep 24, 2012, 8:22:25 AM9/24/12
to mongod...@googlegroups.com
> self.db.fs.files.remove({"_id":ObjectId('{0}'.format(idd))})

You need to use the GridFS API for this. All you are doing is removing
the file metadata, not the chunks of binary data. The picture is not
actually being removed.

http://api.mongodb.org/python/current/api/gridfs/index.html#gridfs.GridFS.delete
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb

aliane abdelouahab

unread,
Sep 24, 2012, 8:58:46 AM9/24/12
to mongodb-user
still get the error even using :
self.fs.delete(ObjectId('{0}'.format(idd)))

On 24 sep, 13:22, Bernie Hackett <ber...@10gen.com> wrote:
> > self.db.fs.files.remove({"_id":ObjectId('{0}'.format(idd))})
>
> You need to use the GridFS API for this. All you are doing is removing
> the file metadata, not the chunks of binary data. The picture is not
> actually being removed.
>
> http://api.mongodb.org/python/current/api/gridfs/index.html#gridfs.Gr...
> >http://stackoverflow.com/questions/12563503/how-to-delete-an-element-...

aliane abdelouahab

unread,
Sep 24, 2012, 10:51:09 AM9/24/12
to mongodb-user
any clue?

Bernie Hackett

unread,
Sep 24, 2012, 11:07:02 AM9/24/12
to mongod...@googlegroups.com
Are you sure you haven't already deleted that _id in some other thread
or previous operation?

aliane abdelouahab

unread,
Sep 24, 2012, 11:11:31 AM9/24/12
to mongodb-user
no, the only place i've deleted it is before calling the page where i
got a refreshed list of products.
without deleting the gridfs file, or with two product (so the refresh
will show only one product) it works well.

aliane abdelouahab

unread,
Sep 24, 2012, 5:11:06 PM9/24/12
to mongodb-user
still dont get the error! any help?

aliane abdelouahab

unread,
Sep 25, 2012, 7:18:37 AM9/25/12
to mongodb-user
any ideas? is it a mongodb bug? (dont flush the GridFS?)

A. Jesse Jiryu Davis

unread,
Sep 25, 2012, 11:11:13 AM9/25/12
to mongod...@googlegroups.com
No, it's not a MongoDB bug. It seems that you have successfully deleted a file from GridFS, but you haven't deleted the file's id from users and hence whenever your template tries to do a "get" on that file it gets the  "no file in gridfs collection" error. I don't think this line is doing what you want it to:

self.db.users.update({"produit_up.spec.id":produ}, {"$pull":{"produit_up"{"spec.id":produ}}})

It has a syntax error, you need another ":". Once you've fixed that, verify that the "$pull" is really removing the reference to the GridFS file from the users collection. If you delete the file from GridFS, but you don't delete its id from "users", then you'll continue to try to get the file whenever you render your template, and that causes the error.

aliane abdelouahab

unread,
Sep 25, 2012, 11:41:22 AM9/25/12
to mongodb-user
i've removed the code where it deletes the picture from GridFS, and it
worked and updates, and when making in console list(db.users.find())
it gived me everytime one pulled item.
by the way, if i try to delete the picture, then the page of that user
will be not accessible, everytime i access it, it claims the objectId
of that picture, and to repair it i must remove of its product
produit_up to make it blank, then i can access.
i'll check deeper with your solution and see
thank you again :)

On 25 sep, 16:11, "A. Jesse Jiryu Davis" <je...@10gen.com> wrote:
> No, it's not a MongoDB bug. It seems that you have successfully deleted a
> file from GridFS, but you haven't deleted the file's id from users and
> hence whenever your template tries to do a "get" on that file it gets
> the  "no file in gridfs collection" error. I don't think this line is doing
> what you want it to:
>
> self.db.users.update({"produit_up.spec.id":produ}, {"$pull":{"produit_up"{"
> spec.id":produ}}})
>
> It has a syntax error, you need another ":". Once you've fixed that, verify
> that the "$pull" is really removing the *reference* to the GridFS file from

aliane abdelouahab

unread,
Sep 25, 2012, 5:17:39 PM9/25/12
to mongodb-user
still getting the error;
using fs.list() dont show the file, and fs.exists() return False.

and i got the real problem (but still not the solution); it seems that
it's because of iterating in the template (this is why i did not get
the error while using two files, because the new redirected link will
have only one file which will not cause problems), so here is how the
problem occurs: it's like a stack: ONLY REMOVING FROM THE TOP IS
ALLOWED (the last added item by default)! so it seems that it's a
problem from templated on how do i iterate over the database!

A. Jesse Jiryu Davis

unread,
Sep 26, 2012, 9:21:43 AM9/26/12
to mongod...@googlegroups.com
I'm having trouble understanding you. Can you please post,

1. An example 'user' document before you execute '$pull'
2. The '$pull' statement
3. The example 'user' document after you execute the '$pull'

aliane abdelouahab

unread,
Sep 26, 2012, 10:02:07 AM9/26/12
to mongodb-user
here is the user without products.

[{u'_id': ObjectId('5061fab93a5f3a09f4be0e21'),
u'adresse': {u'commune': u'Azazga',
u'coord': [36.743954, 4.365041],
u'site': u'http://eddar.dz',
u'wilaya': u'15'},
u'avatar': {u'avatar': ObjectId('5061fab93a5f3a09f4be0e1f'),
u'avctype': u'image/jpeg',
u'orientation': u'paysage'},
u'personnel': {u'daten': u'1984-01-01',
u'email': u'abdelou...@yahoo.fr',
u'nom': u'aliane',
u'password': u'$pbkdf2-hashed password',
u'prenom': u'abdelouahab',
u'pseudo': u'alucaard',
u'sexe': u'Homme',
u'statut': u'particulier',
u'tel': u'0775744482'},
u'produit_up': []}]

the $pull operation:

idd = self.db.users.find_one({"produit_up.spec.id":produ})
["produit_up"][0]["avatar"]["photo"]
self.db.users.update({"produit_up.spec.id":produ}, {"$pull":
{"produit_up":{"spec.id":produ}}})

and with product:

Out[1]:
[{u'_id': ObjectId('5061fab93a5f3a09f4be0e21'),
u'adresse': {u'commune': u'Azazga',
u'coord': [36.743954, 4.365041],
u'site': u'http://eddar.dz',
u'wilaya': u'15'},
u'avatar': {u'avatar': ObjectId('5061fab93a5f3a09f4be0e1f'),
u'avctype': u'image/jpeg',
u'orientation': u'paysage'},
u'personnel': {u'daten': u'1983-10-19',
u'email': u'abdelou...@yahoo.fr',
u'nom': u'aliane',
u'password': u'$pbkdf2-hashed password',
u'prenom': u'abdelouahab',
u'pseudo': u'alucaard',
u'sexe': u'Homme',
u'statut': u'particulier',
u'tel': u'0775744482'},
u'produit_up': [{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'portrait',
u'photo': ObjectId('506309923a5f3a0e147de2d5')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'portable solide, tr\xe8s bon \xe9tat',
u'id': u'alucaard13486677947',
u'namep': u'nokia 3310',
u'nombre': 1,
u'prix': 1000,
u'tags': [u'portable', u'3310', u'solide'],
u'vendu': False}}]}]

A. Jesse Jiryu Davis

unread,
Sep 26, 2012, 11:17:34 AM9/26/12
to mongod...@googlegroups.com
Thanks, and what's the output of this?:

self.db.users.find({"personnel.email":email}, {"produit_up":1,"_id":0}).distinct("produit_up")

Does it include any value for 'avatar' that refer to GridFS files you've deleted?


On Wednesday, September 26, 2012 10:02:18 AM UTC-4, aliane abdelouahab wrote:
here is the user without products.

[{u'_id': ObjectId('5061fab93a5f3a09f4be0e21'),
  u'adresse': {u'commune': u'Azazga',
   u'coord': [36.743954, 4.365041],
   u'site': u'http://eddar.dz',
   u'wilaya': u'15'},
  u'avatar': {u'avatar': ObjectId('5061fab93a5f3a09f4be0e1f'),
   u'avctype': u'image/jpeg',
   u'orientation': u'paysage'},
  u'personnel': {u'daten': u'1984-01-01',
   u'email': u'abdelo...@yahoo.fr',
   u'nom': u'aliane',
   u'password': u'$pbkdf2-hashed password',
   u'prenom': u'abdelouahab',
   u'pseudo': u'alucaard',
   u'sexe': u'Homme',
   u'statut': u'particulier',
   u'tel': u'0775744482'},
  u'produit_up': []}]

the $pull operation:

idd = self.db.users.find_one({"produit_up.spec.id":produ})
["produit_up"][0]["avatar"]["photo"]
self.db.users.update({"produit_up.spec.id":produ}, {"$pull":
{"produit_up":{"spec.id":produ}}})

and with product:

Out[1]:
[{u'_id': ObjectId('5061fab93a5f3a09f4be0e21'),
  u'adresse': {u'commune': u'Azazga',
   u'coord': [36.743954, 4.365041],
   u'site': u'http://eddar.dz',
   u'wilaya': u'15'},
  u'avatar': {u'avatar': ObjectId('5061fab93a5f3a09f4be0e1f'),
   u'avctype': u'image/jpeg',
   u'orientation': u'paysage'},
  u'personnel': {u'daten': u'1983-10-19',
   u'email': u'abdelo...@yahoo.fr',

aliane abdelouahab

unread,
Sep 26, 2012, 11:49:44 AM9/26/12
to mongodb-user
here is with one product:

empty:

db.users.find({"personnel.email":"abdelou...@yahoo.fr"},
{"produit_up":1,"_id":0}).distinct("produit_up")
Out[1]: []
fs.list()
Out[1]: [u'134859845728-nopic.jpg'] # this is a picture that i've
uploaded if a user dont put its avatar, this will be attributed to his
avatar.

and after placing 3 products:

db.users.find({"personnel.email":"abdelou...@yahoo.fr"},
{"produit_up":1,"_id":0}).distinct("produit_up")
Out[1]:
[{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'portrait',
u'photo': ObjectId('5063230f3a5f3a07b8f39786')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'test',
u'id': u'alucaard134867431957',
u'namep': u'iphone 3gs',
u'nombre': 1,
u'prix': 1,
u'tags': [u'test', u'test', u'test'],
u'vendu': False}},
{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'portrait',
u'photo': ObjectId('506322e73a5f3a07b8f39782')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'test',
u'id': u'alucaard134867427954',
u'namep': u'nokia 3310',
u'nombre': 1,
u'prix': 1,
u'tags': [u'test', u'test', u'test'],
u'vendu': False}},
{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'paysage',
u'photo': ObjectId('506322fc3a5f3a07b8f39784')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'test',
u'id': u'alucaard134867430036',
u'namep': u'peugeot 206',
u'nombre': 1,
u'prix': 1,
u'tags': [u'test', u'test', u'test'],
u'vendu': False}},
{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'portrait',
u'photo': ObjectId('506323273a5f3a07b8f39788')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'test',
u'id': u'alucaard134867434318',
u'namep': u'samsung e250',
u'nombre': 1,
u'prix': 1,
u'tags': [u'test', u'test', u'test'],
u'vendu': False}}]

and after removing the middle one (and getting the error):

the operation is done in:

self.db.users.update({"produit_up.spec.id":produ}, {"$pull":
{"produit_up":{"spec.id":produ}}})
self.fs.delete(ObjectId('{0}'.format(idd)))

and the returned hidden form to get the id :

idd = 506322e73a5f3a07b8f39782 # so the _id is
ObjectId("506322e73a5f3a07b8f39782")

and then the error:

no file in gridfs collection
Collection(Database(Connection('localhost', 27017), u'essog'),
u'fs.files') with _id ObjectId('506322e73a5f3a07b8f39782')

and then the operation to see the products:

db.users.find({"personnel.email":"abdelou...@yahoo.fr"},
{"produit_up":1,"_id":0}).distinct("produit_up")
Out[1]:
[{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'portrait',
u'photo': ObjectId('5063230f3a5f3a07b8f39786')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'test',
u'id': u'alucaard134867431957',
u'namep': u'iphone 3gs',
u'nombre': 1,
u'prix': 1,
u'tags': [u'test', u'test', u'test'],
u'vendu': False}},
{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'portrait',
u'photo': ObjectId('506322e73a5f3a07b8f39782')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'test',
u'id': u'alucaard134867427954',
u'namep': u'nokia 3310',
u'nombre': 1,
u'prix': 1,
u'tags': [u'test', u'test', u'test'],
u'vendu': False}},
{u'avatar': {u'avctype': u'image/jpeg',
u'orientation': u'portrait',
u'photo': ObjectId('506323273a5f3a07b8f39788')},
u'spec': {u'abus': 0,
u'date': u'2012-09-26',
u'description': u'test',
u'id': u'alucaard134867434318',
u'namep': u'samsung e250',
u'nombre': 1,
u'prix': 1,
u'tags': [u'test', u'test', u'test'],
u'vendu': False}}]

and here is wht i've found i was trying to make those tests:

in order to clean the console in Aptana Studio, i've hit the button
refresh python execution to free the console (and this has to re-
execute the code) and this action i did it when i've 3 product to try
to delete one and get 2 product and the bug, and guess what: then i've
deleted the product, it worked! so here my guess: the stream is still
there holding the ObjectId in the RAM, so when i refresh, it will be
deleted, just a guess...

aliane abdelouahab

unread,
Sep 26, 2012, 5:33:58 PM9/26/12
to mongodb-user
it's exactly what is expected! the elements are not removed from
Tornado, but from console they're removed! bizarre!
here is the code:
i've added the line:

print
str(self.db.users.find({"personnel.pseudo":"alucaard"}).distinct("produit_up"))

and here is what i got before deleting:


[{u'spec': {u'description': u'vend nokia 3310 du top', u'tags':
[u'nokia', u'portable', u'solide'], u'vendu': False, u'prix': 1000,
u'abus': 0, u'namep': u'nokia 3310', u'date': u'2012-09-25',
u'nombre': 1, u'id': u'alucaard134859865997'}, u'avatar': {u'photo':
ObjectId('5061fb833a5f3a09f4be0e22'), u'avctype': u'image/jpeg',
u'orientation': u'portrait'}}, {u'spec': {u'description': u'iphone
foooooooort', u'tags': [u'iphone', u'apple', u'3g'], u'vendu': False,
u'prix': 20000, u'abus': 0, u'namep': u'iphone 3gs', u'date':
u'2012-09-25', u'nombre': 1, u'id': u'alucaard134859872247'},
u'avatar': {u'photo': ObjectId('5061fbc23a5f3a09f4be0e24'),
u'avctype': u'image/jpeg', u'orientation': u'portrait'}}, {u'spec':
{u'description': u'bajoooooooot', u'tags': [u'206', u'hdi',
u'peugeot'], u'vendu': False, u'prix': 500000, u'abus': 0, u'namep':
u'peugeot 206', u'date': u'2012-09-25', u'nombre': 1, u'id':
u'alucaard134859875565'}, u'avatar': {u'photo':
ObjectId('5061fbe33a5f3a09f4be0e26'), u'avctype': u'image/jpeg',
u'orientation': u'paysage'}}]

[I 120926 21:49:55 web:1465] 200 GET /ventes (::1) 15.00ms
[I 120926 21:49:55 web:1465] 304 GET /static/css/profil.css?v=f0bf8 (::
1) 17.00ms
[I 120926 21:49:55 web:1465] 304 GET /134859872247-apple-iphone-3-
gs.jpg (::1) 7.00ms
[I 120926 21:49:55 web:1465] 304 GET /134859865997-nokia.jpg (::1)
6.00ms
[I 120926 21:49:56 web:1465] 304 GET /134859875565-peugeot.jpg (::1)
11.00ms
[I 120926 21:49:56 web:1465] 304 GET /static/js/jquery.js?v=e1efb (::
1) 0.00ms
[I 120926 21:49:56 web:1465] 304 GET /static/js/jquery.alerts.js?
v=ef703 (::1) 0.00ms

[I 120926 21:50:13 web:1465] 302 POST /supprimer (::1) 12.00ms

#this is when deleting

[{u'spec': {u'description': u'vend nokia 3310 du top', u'tags':
[u'nokia', u'portable', u'solide'], u'vendu': False, u'prix': 1000,
u'abus': 0, u'namep': u'nokia 3310', u'date': u'2012-09-25',
u'nombre': 1, u'id': u'alucaard134859865997'}, u'avatar': {u'photo':
ObjectId('5061fb833a5f3a09f4be0e22'), u'avctype': u'image/jpeg',
u'orientation': u'portrait'}}, {u'spec': {u'description':
u'bajoooooooot', u'tags': [u'206', u'hdi', u'peugeot'], u'vendu':
False, u'prix': 500000, u'abus': 0, u'namep': u'peugeot 206', u'date':
u'2012-09-25', u'nombre': 1, u'id': u'alucaard134859875565'},
u'avatar': {u'photo': ObjectId('5061fbe33a5f3a09f4be0e26'),
u'avctype': u'image/jpeg', u'orientation': u'paysage'}}]

[{u'spec': {u'description': u'vend nokia 3310 du top', u'tags':
[u'nokia', u'portable', u'solide'], u'vendu': False, u'prix': 1000,
u'abus': 0, u'namep': u'nokia 3310', u'date': u'2012-09-25',
u'nombre': 1, u'id': u'alucaard134859865997'}, u'avatar': {u'photo':
ObjectId('5061fb833a5f3a09f4be0e22'), u'avctype': u'image/jpeg',
u'orientation': u'portrait'}}, {u'spec': {u'description':
u'bajoooooooot', u'tags': [u'206', u'hdi', u'peugeot'], u'vendu':
False, u'prix': 500000, u'abus': 0, u'namep': u'peugeot 206', u'date':
u'2012-09-25', u'nombre': 1, u'id': u'alucaard134859875565'},
u'avatar': {u'photo': ObjectId('5061fbe33a5f3a09f4be0e26'),
u'avctype': u'image/jpeg', u'orientation': u'paysage'}}]

the product has not been removed!

and here is the code:

class VentesHandler(BaseHandler):
@tornado.web.authenticated
def get(self):
user = self.get_secure_cookie("mechtari")
info = tornado.escape.json_decode(user)
email = info["personnel"]["email"]
try:
produits = self.db.users.find({"personnel.email":email},
{"produit_up":1, "_id":0}).distinct("produit_up")
renderer = self.fs
print
str(self.db.users.find({"personnel.pseudo":"alucaard"}).distinct("produit_up"))
except (errors.AutoReconnect, errors.ConnectionFailure):
self.redirect("/error")
try:
self.render("ventes.html", produits=produits,
renderer=renderer)
except gridfs.errors.NoFile, e:
self.write(str(e))

class Supprimer(BaseHandler):
@tornado.web.authenticated
def post(self):
prod = self.get_arguments("supprime")
produ = prod[0][:]
idd = self.db.users.find_one({"produit_up.spec.id":produ})
["produit_up"][0]["avatar"]["photo"]
try:
self.db.users.update({"produit_up.spec.id":produ},
{"$pull":{"produit_up":{"spec.id":produ}}})
self.fs.delete(ObjectId('{0}'.format(idd)))
print
str(self.db.users.find({"personnel.pseudo":"alucaard"}).distinct("produit_up"))

aliane abdelouahab

unread,
Sep 28, 2012, 10:03:51 AM9/28/12
to mongodb-user
any clue?

On 26 sep, 16:17, "A. Jesse Jiryu Davis" <je...@10gen.com> wrote:
> Thanks, and what's the output of this?:
>
> self.db.users.find({"personnel.email":email}, {"produit_up":1,"_id":0}).distinct("produit_up")
>
> Does it include any value for 'avatar' that refer to GridFS files you've
> deleted?
>
> On Wednesday, September 26, 2012 10:02:18 AM UTC-4, aliane abdelouahab
> wrote:
>
>
>
>
>
>
>
>
>
> > here is the user without products.
>
> > [{u'_id': ObjectId('5061fab93a5f3a09f4be0e21'),
> >   u'adresse': {u'commune': u'Azazga',
> >    u'coord': [36.743954, 4.365041],
> >    u'site': u'http://eddar.dz',
> >    u'wilaya': u'15'},
> >   u'avatar': {u'avatar': ObjectId('5061fab93a5f3a09f4be0e1f'),
> >    u'avctype': u'image/jpeg',
> >    u'orientation': u'paysage'},
> >   u'personnel': {u'daten': u'1984-01-01',
> >    u'email': u'abdelo...@yahoo.fr <javascript:>',
> >    u'nom': u'aliane',
> >    u'password': u'$pbkdf2-hashed password',
> >    u'prenom': u'abdelouahab',
> >    u'pseudo': u'alucaard',
> >    u'sexe': u'Homme',
> >    u'statut': u'particulier',
> >    u'tel': u'0775744482'},
> >   u'produit_up': []}]
>
> > the $pull operation:
>
> > idd = self.db.users.find_one({"produit_up.spec.id":produ})
> > ["produit_up"][0]["avatar"]["photo"]
> > self.db.users.update({"produit_up.spec.id":produ}, {"$pull":
> > {"produit_up":{"spec.id":produ}}})
>
> > and with product:
>
> > Out[1]:
> > [{u'_id': ObjectId('5061fab93a5f3a09f4be0e21'),
> >   u'adresse': {u'commune': u'Azazga',
> >    u'coord': [36.743954, 4.365041],
> >    u'site': u'http://eddar.dz',
> >    u'wilaya': u'15'},
> >   u'avatar': {u'avatar': ObjectId('5061fab93a5f3a09f4be0e1f'),
> >    u'avctype': u'image/jpeg',
> >    u'orientation': u'paysage'},
> >   u'personnel': {u'daten': u'1983-10-19',
> >    u'email': u'abdelo...@yahoo.fr <javascript:>',
Reply all
Reply to author
Forward
0 new messages