Modify

Ticket #168 (closed defect: invalid)

Opened 4 years ago

Last modified 4 years ago

Appengine query models

Reported by: martinhoarantes@… Owned by: xi
Priority: highest Component: pyyaml
Severity: normal Keywords: pyyaml, appengine, models, bigtable
Cc:

Description

Hi, I´m using Google Appengine, language Python. I´d like to know how to query a model.

I´m using this code, but the output is miserable:

class GerarYAML(webapp.RequestHandler):
    def post(self):
        user = users.get_current_user() 
        if user: 
            formacaos = models.Formacao().all()
            experiencias = models.Experiencia().all()
            investigacaos = models.Investigacao().all() 
            distribuicaos = models.Distribuicao().all()
            
            docentes = models.Docente.all()
            docentes.filter('user =', users.get_current_user())
            
            for docente in docentes:
                for formacao in formacaos:
                    for experiencia in experiencias:
                        for investigacao in investigacaos:
                            for distribuicao in distribuicaos:
                                formacao.docente = docente.key()
    
                                'Nome: %s' % (docente.nome)
                                'Apelido: %s' % (docente.apelido)
                                'Unidade: %s' % (docente.unidade)
                                'Categoria: %s' % (docente.categoria)
                                'Regime: %s' % (docente.regime)
                                  
                                'Formacao: %s' % (formacao.formAno)
                                'Grau de Formacao: %s' % (formacao.formGrau)
                                'Area de Formacao: %s' % (formacao.formArea)
                                'Instituicao Academica: %s' % (formacao.formInstituicao)
                                'Classificacao Final: %s' % (formacao.formClassificacao)
                        
                                yaml.dump(docente, sys.stdout)
                                yaml.dump(formacao, sys.stdout)  
                                yaml.dump(experiencia, sys.stdout)
                                yaml.dump(investigacao, sys.stdout)
                                yaml.dump(distribuicao, sys.stdout)  
    
    
                                self.response.headers['Content-Type'] = 'application/yaml'
                                self.response.headers['Content-Disposition'] = 'filename = my.yaml'

Can someone point out, how can i solve this issue?

I´d like to download a file automatically when user submit a button with .yaml format and more or less formatted.

Attachments

Change History

comment:1 Changed 4 years ago by xi

  • Status changed from new to closed
  • Resolution set to invalid

I'm afraid I can't help you unless you could provide more details. What kind of output you expected and actually got? Note that I'm not familiar with Appengine.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.