mardi 26 mai 2015

Django BD error

Hi guys i´m using Django 1.7 and mysql to create an application and I´m receiving this error

ValueError at /Cannot create form field for 'radiotipo_idradiotipo' yet, because its related model u'Radioinfo' has not been loaded yet

I don´t know what is this. this error happenes on my forms.py, here´s the code: forms.py

from django import forms
from models import Node, Datasource, Radio, Radiotipo, Snapshot, Tag, Taginfo, Valores

class NodeForm(forms.ModelForm):
    class Meta:
        model = Node

class DatasourceForm(forms.ModelForm):
    class Meta:
        model = Datasource
class RadiotipoForm(forms.ModelForm):
    class Meta:
        model = Radiotipo
class SnapshotForm(forms.ModelForm):
    class Meta:
        model = Snapshot
class TagForm(forms.ModelForm):
    class Meta:
        model = Tag
class TaginfoForm(forms.ModelForm):
    class Meta:
        model = Taginfo
class ValoresForm(forms.ModelForm):
    class Meta:
        model = Valores
class RadioForm(forms.ModelForm):
    class Meta:
        model = Radio

and here is my models.py

class Datasource(models.Model):

    objects = GChartsManager()

    idestacao_meteo = models.IntegerField(db_column='idDATASOURCE', primary_key=True, editable=False)  # Field name made lowercase.
    nome_estacao = models.CharField(db_column='NAME', max_length=45)  # Field name made lowercase.
    fabricante = models.CharField(db_column='MANUFACTURER', max_length=45, blank=True)  # Field name made lowercase.
    modelo = models.CharField(db_column='MODEL', max_length=45, blank=True)  # Field name made lowercase.
    node_idnode = models.ForeignKey('Node', db_column='site_idSITE', blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'datasource'


class Node(models.Model):

    objects = GChartsManager()

    idnode = models.IntegerField(db_column='idSITE', primary_key=True, editable=False)  # Field name made lowercase.
    nome = models.CharField(db_column='NAME', max_length=45)  # Field name made lowercase.
    informacoes = models.CharField(db_column='DESCRIPTION', max_length=45, blank=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'site'

class Radio(models.Model):

    objects = GChartsManager()

    idradio = models.IntegerField(db_column='idRADIO', primary_key=True, editable=False)
    endreal = models.CharField(db_column='ENDREAL', max_length=64, blank=True)  # Field name made lowercase.
    radiotipo_idradiotipo = models.ForeignKey('Radioinfo', db_column='radioInfo_idRADIOINFO')  # Field name made lowercase.
    datasource_idestacao_meteo = models.ForeignKey(Datasource, db_column='datasource_idDATASOURCE', blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'radio'

class Radiotipo(models.Model):

    objects = GChartsManager()

    idradiotipo = models.IntegerField(db_column='idRADIOINFO', primary_key=True, editable=False)  # Field name made lowercase.
    nome = models.CharField(db_column='NAME', max_length=45)
    descricao = models.CharField(db_column='DESCRIPTION', max_length=300, blank=True)

    class Meta:
        managed = False
        db_table = 'radioinfo'

class Snapshot(models.Model):

    objects = GChartsManager()

    idsnap = models.IntegerField(db_column='idSNAP', primary_key=True, editable=False)  # Field name made lowercase.
    valor = models.FloatField(db_column='VALUE', blank=True, null=True)  # Field name made lowercase.
    snapshot = models.DateTimeField(db_column='SNAPSHOT', blank=True, null=True)  # Field name made lowercase.
    tag_idtag = models.ForeignKey('Tag', db_column='tag_idTAG')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'snapshot'

class Tag(models.Model):

    objects = GChartsManager()

    idtag = models.IntegerField(db_column='idTAG', primary_key=True, editable=False)  # Field name made lowercase.
    desvio = models.FloatField(db_column='DEVIATION', blank=True, null=True)  # Field name made lowercase.
    tempo_max = models.IntegerField(db_column='TIME_MAX', blank=True, null=True)  # Field name made lowercase.
    conv_rate = models.IntegerField(db_column='CONV_RATE', blank=True, null=True)  # Field name made lowercase.
    taginfo_idtaginfo1 = models.ForeignKey('Taginfo', db_column='tagInfo_idTAGINFO')  # Field name made lowercase.
    datasource_idestacao_meteo = models.ForeignKey(Datasource, db_column='datasource_idDATASOURCE', blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'tag'

class Taginfo(models.Model):

    objects = GChartsManager()

    idtaginfo = models.IntegerField(db_column='idTAGINFO', primary_key=True, editable=False)  # Field name made lowercase.
    nome = models.CharField(db_column='NAME', max_length=45)  # Field name made lowercase.
    descricao = models.CharField(db_column='DESCRIPTION', max_length=255, blank=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'taginfo'

class Valores(models.Model):

    objects = GChartsManager()

    idvalores = models.IntegerField(db_column='idVALUES', primary_key=True, editable=False)  # Field name made lowercase.
    valor = models.FloatField(db_column='VALUE')  # Field name made lowercase.
    datahora = models.DateTimeField(db_column='DATETIME')  # Field name made lowercase.
    tag_idtag = models.ForeignKey(Tag, db_column='tag_idTAG')  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'values'

Thanks for helping.




How do I discover the variables being passed to a server by a form using POST?

Is there a tool on Unix or Mac to peek the query a web page form is doing using POST?

I want to know which variables are being passed by the form to the server.

The idea is to use these variables to automate the queries.




How to download all PDF files from a website using wget but every link is a database query

This is the search form

http://ift.tt/1esEVde

Fill Pesquisa livre field with something like rio

Every link you will see, if clicked, will lead to a page that contains a PDF file.

My problem is that this page is a form that is querying a database.

Is that possible to use wget with a URL that is a query get all PDFs that the result pages contain? how?

I have tried this command and it is failing

wget -r -A pdf http://ift.tt/1RluMgv

thanks.




Relational Model Created from JSON is Creating extra Collections

I've been scouring the web for a week and I'm stuck.

I'm creating a Backbone Relational model as follows:

SearchPage = Backbone.RelationalModel.extend({
  urlRoot: '/api/search',

  parse: function(response) {
    return {
      query: response.GSP.Q,
      param: response.GSP.PARAM,
      total: response.GSP.RES.M,
      result: response.GSP.RES.R,
      filter: response.GSP.RES.PARM.PMT.PV
    };
  },

  relations: [
    {
      type: Backbone.HasMany,
      key: 'result',
      relatedModel: 'Result',
      collectionType: 'ResultCollection',
      reverseRelation: {
        key: 'resultOf'
      }
    },
    {
      type: Backbone.HasMany,
      key: 'filter',
      relatedModel: 'Filter',
      collectionType: 'FilterCollection',
      reverseRelation: {
        key: 'filterOf'
      }
    },
    {
      type: Backbone.HasMany,
      key: 'param',
      relatedModel: 'Param',
      collectionType: 'ParamCollection',
      reverseRelation: {
        key: 'paramOf'
      }
    },
  ]
});

The creation from the JSON is working fine. All of the models and collections are being created perfectly fine, but I'm all seeing an extra Collection being created for each of the attributes that are being made into collections.

See the following grabbed from the Backbone inspector:

  • Collection 0: Backbone.Collection {length: 0, models: (...), _byId: Object, url: (...), trigger: function…}
  • Collection 1: Backbone.Collection {length: 10, models: (...), _byId: Object, url: (...), trigger: function…}
  • Collection 2: child {length: 10, models: (...), _byId: Object, url: (...), trigger: function…}
  • Collection 3: Backbone.Collection {length: 84, models: (...), _byId: Object, url: (...), trigger: function…}
  • Collection 4: child {length: 84, models: (...), _byId: Object, url: (...), trigger: function…}
  • Collection 5: Backbone.Collection {length: 15, models: (...), _byId: Object, url: (...), trigger: function…}
  • Collection 6: child {length: 15, models: (...), _byId: Object, url: (...), trigger: function…}

There is no duplication of Models going on, so I'm a bit confused. The only thing I can think is that the child collections are a part of the attributes in the SearchPage Model?

Is there a way to prevent these extra collections from being created or are they a necessary part of the Model?

I guess some context for why I'm using such a big relational model is that the api only serves the information from one single URL and it's one giant blob of information that I parse into this model.

Thanks in advance for your help!




Create an efficient webcrawler(java), which has three parts. ServerCrawler, IndexServer and ClientCrawler as follows

  1. The ServerCrawler will start with a list of URLs (seed list)

  2. When a ClientCrawler connects to the ServerCrawler, the ServerCrawler will send the oldest 10 urls in the list to the client.

  3. The ClientCrawler will download the pages of these urls and send them to IndexServer.

  4. The ClientCrawler will find all urls in the downloaded pages and then it will send them to the ServerCrawler which will add them to the list.

  5. The client will send “more” to receive more URLs to be crawler or “close” to close connection.

  6. ServerCrawler, and IndexServer must be multithreaded.

  7. ServerCrawler to ClinetCrawler must use TCP connection

  8. ClientCrawler to IndexServer must use UDP connection




Convert svg to word processor readable vector graphics on a webpage

I have a webpage that produces svg. I would like the user to be able to include those graphics in their word processors (Libre Office, MS Office, etc.) documents. Unfortunately, those word processors do not (MS Office) or only rudimentary (Libre Office) support svg natively. So I would like to let the user download an automatically converted file (eps or emf, etc.).

I have no clue how to achive this while this seems like an obvious problem for anyone producing vector graphics on the web. Inkscape produces nice eps files from svg. But the user would have to install and manually convert files. Imagemagick only supports conversion to rasterized images which would loose the appeal of vector images for print.




how to use Rserve usage with PHP

I have to run a script from php getting the data from a from

here is my script

library(pathview)

pv.out <- pathview(gene.data = gene.d,gene.idtype = geneid,cpd.data = cpd.d,cpd.idtype=cpdid,pathway.id = pathway,species = species,out.suffix = suffix,kegg.native = kegg,sign.pos =pos,same.layer = layer,keys.align = align,split.group = split,expand.node = expand,multi.state=multistate,match.data = matchd ,node.sum=nsum,key.pos = kpos,cpd.lab.offset= offset,limit = list(gene = glmt, cpd = clmt), bins = list(gene = gbins, cpd= cbins),low = list(gene = glow, cpd = clow),mid = list(gene = gmid, cpd = cmid), high = list(gene = ghigh, cpd =chigh),discrete = list(gene = gdisc, cpd = cdisc))

save.image("workenv.Rdata")

write.table(pv.out$plot.data.gene,file=paste(paste(paste("genedata.",species,sep=""),pathway,sep=""),".txt",sep=""),quote = FALSE) write.table(pv.out$plot.data.cpd,file=paste(paste(paste("cpddata.",species,sep=""),pathway,sep=""),".txt",sep=""),quote = FALSE)