Not tested, but maybe something like:
from gluon.dal import Rows, Row
def rowsWithoutDB():
auth=HTTPBasicAuth('username', 'password')
r = requests.get("http://myURL/projects.xml", auth=auth)
projects = BeautifulStoneSoup(r.content)
records = [Row(dict(redmine=str(project.contents[3].text)))
for project in projects.findAll('project')]
rows = Rows(colnames=['redmine'], records=records)
return dict(rows=rows)
Anthony
On Sunday, October 20, 2013 1:38:34 PM UTC-4, JaapP wrote:
>
> Hi All,
>
> i've been struggling and googling this problem for may hours, hope someone
> can give me a hint:
>
> i'm trying to create a ROWS object from data i receive from an external
> webservice.
>
> I do not have a corresponding table in the database, and would like to do
> something like this:
>
> *NOT WORKING CODE:*
>
> def rowsWithoutDB():
> auth=HTTPBasicAuth('username', 'password')
> r = requests.get("http://myURL/projects.xml", auth=auth)
> projects = BeautifulStoneSoup(r.content)
>
> rows = Rows()
> rows.colnames = ['controle.redmine']
> for project in projects.findAll('project'):
> pid = str(project.contents[3].text)
> rows.append({'controle':{'redmine':pid}})
> return dict(rows=rows)
>
> But, this does not do the trick.
>
> If i inspect a rows object generated with a db().select() i see that all
> records are of type ROW
> The above example results gives the records a dict type.
>
> I found a similar question (
> https://groups.google.com/forum/#!msg/web2py/CS-beWsQ9KY/iSy8VEUhH5EJ )
> but this was only partially answered.
>
> I hope somebody can help!
>
> Thanks,
>
> Jaap
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.