Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion clean orhpan GriFS elements.
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
aliane abdelouahab  
View profile  
 More options Sep 24 2012, 8:59 am
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Mon, 24 Sep 2012 05:58:46 -0700 (PDT)
Local: Mon, Sep 24 2012 8:58 am
Subject: Re: clean orhpan GriFS elements.
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...

> On Mon, Sep 24, 2012 at 7:13 AM, aliane abdelouahab

> <alabdeloua...@gmail.com> wrote:
> > 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-...

> > --
> > You received this message because you are subscribed to the Google
> > Groups "mongodb-user" group.
> > To post to this group, send email to mongodb-user@googlegroups.com
> > To unsubscribe from this group, send email to
> > mongodb-user+unsubscribe@googlegroups.com
> > See also the IRC channel -- freenode.net#mongodb


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.