コード例 #1
0
ファイル: mount_service.py プロジェクト: unimusic/bisqueUCSB
    def delete_mount_path(self, store_name, path, delete_resource=True, **kw):
        """ Delete an store element and all below it

        :param path: A string (url) of the path
        :type  path: str
        """

        value = None
        if len(path) and path[-1] == 'value':
            value = path.pop()
        if len(path) == 0:
            return False
        q = self._load_mount_path(store_name, path)
        if q is None:
            log.debug("Cannot find %s in %s", path, store_name)
            return False
        log.debug("delete from %s of %s = %s", store_name, path,
                  etree.tostring(q))
        #if  q.tag != 'link':
        #    return False
        data_service.del_resource(q,
                                  check_acl=False,
                                  check_blob=False,
                                  check_references=False)
        if delete_resource and value is not None:
            data_service.del_resource(q.get('value'))
        return True
コード例 #2
0
 def delete(self, duri, **kw):
     # remove all member
     log.info ("dataset: delete members of %s to " , duri)
     dataset = data_service.get_resource(duri, view='full')
     members = dataset.xpath('./value')
     data_service.del_resource(dataset)
     return self.iterate (operation='delete', dataset=dataset, members=members, **kw)
コード例 #3
0
ファイル: service.py プロジェクト: satish1901/bisque-dev
    def delete_user(self, uniq):
        """
            Deletes user

            @param uniq - resource uniq for the user

        """
        # Remove the user from the system for most purposes, but
        # leave the id for statistics purposes.
        bquser = DBSession.query(BQUser).filter(
            BQUser.resource_uniq == uniq).first()
        if bquser:
            log.debug("ADMIN: Deleting user: %s", str(bquser))
            user = DBSession.query(User).filter(
                User.user_name == bquser.resource_name).first()
            log.debug("Renaming internal user %s", str(user))

            if user:
                DBSession.delete(user)
                # delete the access permission
                for p in DBSession.query(TaggableAcl).filter_by(
                        user_id=bquser.id):
                    log.debug("KILL ACL %s", str(p))
                    DBSession.delete(p)
                self.deleteimages(bquser.resource_name, will_redirect=False)
                #DBSession.delete(bquser)

                #transaction.commit()
            data_service.del_resource(bquser)
            return '<resource>Delete User</resource>'

        abort(400)
コード例 #4
0
 def delete_links(self, resource):
     'Delete link nodes   for a resource'
     log.debug ("delete_links %s", resource.get ('resource_uniq'))
     # Delete the reference in the store
     links = data_service.query ('link', parent=False, value = resource.get ('resource_uniq'), cache=False)
     for link in links:
         log.debug ("delete_blob: delete link %s", link.get('uri'))
         data_service.del_resource(link, check_acl=False, check_blob=False, check_references=False)
コード例 #5
0
    def remove(self, path, delete_blob=True, user=None, **kwargs):
        ' Delete a resource identified by path  '
        log.info("delete() called %s", path)
        if user is not None and identity.is_admin():
            identity.current.set_current_user(user)

        resource = data_service.query("file|image",
                                      resource_value=path,
                                      wpublic='1',
                                      cache=False)
        for child in resource:
            data_service.del_resource(child)
        return etree.tostring(resource)
コード例 #6
0
    def action(self, member, action, tagdoc, **kw):
        """Modify the tags of the member
        @param member: the memeber of the dataset
        @param action: a string :append, delete, edit_value, edit_name, change_name
        @poarag tagdoc
        """
        member = member.text
        if isinstance(tagdoc, basestring):
            tagdoc = etree.XML(tagdoc)

        log.debug ('TagEdit (%s) %s with %s' % (action, member, etree.tostring(tagdoc)))
        # These update operation should be done in the database
        # However, I don't want to think about it now
        # so here's the brute-force way
        if action=="append":
            resource = data_service.get_resource(member, view='short')
            resource.append(tagdoc)
            data_service.update(resource)
        elif action=='delete':
            resource = data_service.get_resource(member, view='full')
            for tag in tagdoc.xpath('./tag'):
                resource_tags = resource.xpath('./tag[@name="%s"]' % tag.get('name'))
                for killtag in resource_tags:
                    data_service.del_resource(killtag.get('uri'))
        elif action=='edit_value':
            resource = data_service.get_resource(member, view='full')
            for tag in tagdoc.xpath('./tag'):
                resource_tags = resource.xpath('./tag[@name="%s"]' % tag.get('name'))
                for mtag in resource_tags:
                    mtag.set('value', tag.get('value'))
            data_service.update(resource)
        elif action=='edit_name':
            resource = data_service.get_resource(member, view='full')
            for tag in tagdoc.xpath('./tag'):
                resource_tags = resource.xpath('./tag[@value="%s"]' % tag.get('value'))
                for mtag in resource_tags:
                    mtag.set('name', tag.get('name'))
            data_service.update(resource)
        elif action=='change_name':
            resource = data_service.get_resource(member, view='full')
            for tag in tagdoc.xpath('./tag'):
                resource_tags = resource.xpath('./tag[@name="%s"]' % tag.get('name'))
                for mtag in resource_tags:
                    mtag.set('name', tag.get('value'))
            data_service.update(resource)

        return None
コード例 #7
0
 def action(self, member, **kw):
     log.debug ('Delete action %s' % member)
     data_service.del_resource (member.text)
     return None
コード例 #8
0
ファイル: admin.py プロジェクト: satish1901/bisque-dev
    def run(self):

        load_config(self.options.config)
        from lxml import etree
        from tg import config, session, request
        from bq import data_service
        from bq.core.identity import set_admin_mode
        import transaction
        load_bisque_services()

        prefs = config_path('preferences.xml')

        set_admin_mode(True)
        if self.args[0].startswith('init'):
            x = data_service.query('system')
            if len(x):
                if self.options.force:
                    print("deleting current system object")
                    data_service.del_resource(x[0])
                else:
                    print("NO ACTION: System object initialized at %s " %
                          etree.tostring(x[0]))
                    sys.exit(1)

            if os.path.exists(prefs):
                if self.options.force:
                    print("deleting %s" % prefs)
                    os.remove(prefs)
                else:
                    print('NO ACTION: %s exists.. cannot init' % prefs)
                    sys.exit(1)

            system = etree.parse(
                defaults_path('preferences.xml.default')).getroot()
            for el in system.getiterator(tag=etree.Element):
                el.set('permission', 'published')
            system = data_service.new_resource(system, view='deep')
        elif self.args[0].startswith('read'):
            system = data_service.query('system', view='deep')
            if len(system):
                system = system[0]
            else:
                system = None
        else:
            if not os.path.exists(prefs):
                print "Need %s" % prefs
                return
            system = etree.parse(prefs).getroot()
            # Esnure all elements are published
            for el in system.getiterator(tag=etree.Element):
                el.set('permission', 'published')
            # Read system object
            uri = system.get('uri')
            print 'system = %s' % etree.tostring(system)

            system = data_service.update_resource(new_resource=system,
                                                  resource=uri,
                                                  view='deep')
            print etree.tostring(system)
        transaction.commit()
        if system is not None:
            with open(prefs, 'w') as f:
                f.write(etree.tostring(system, pretty_print=True))
                print "Wrote %s" % prefs