[web2py] Re: Rendering 'raw' HTML for AngularJS with Web2py

2013-01-29 Thread Dirk Krause
and it works.

links that helped:
http://jsfiddle.net/Bvc62/3/
http://stackoverflow.com/questions/12923521/angular-js-custom-delimiter


This would be your view



  
  Angular demo
  
//<![CDATA[ 

var myApp = angular.module('myApp', [], function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});

function MyCtrl($scope) {
$scope.name = 'Superhero';
}
//]]>  




  
Hello, [[name]]






Am Dienstag, 29. Januar 2013 21:10:04 UTC+1 schrieb Dirk Krause:
>
> I have to apologize for my stupid question.
>
> Of course web2py *does* deliver raw html. But AngularJS uses the same 
> brackets convention as web2py - that's what caused the conflict (I should 
> write a book: 'The Art of Reading Error Messages' ... *facepalm*)
>
> There seems to be a workaround, since you can change the markup in angular 
> according to this:
>
> http://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags
>
> I'll try this next.
>
> Am Dienstag, 29. Januar 2013 17:12:30 UTC+1 schrieb Dirk Krause:
>>
>> Hi,
>>
>> I am trying to use web2py to manage a database and display the resulting 
>> JSON in AngularJS.  To render an angular compatible view I need to pass raw 
>> html in a view (for example the html needs to start with '' 
>> and so forth). Of course I could place the files in the static folder, but 
>> then I can't protect the files via @auth.requires_login() etc.
>>
>> What would be the best way to achieve that?
>>
>> Thank you,
>>   Dirk
>>
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Rendering 'raw' HTML for AngularJS with Web2py

2013-01-29 Thread Dirk Krause
I have to apologize for my stupid question.

Of course web2py *does* deliver raw html. But AngularJS uses the same 
brackets convention as web2py - that's what caused the conflict (I should 
write a book: 'The Art of Reading Error Messages' ... *facepalm*)

There seems to be a workaround, since you can change the markup in angular 
according to this:
http://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags

I'll try this next.

Am Dienstag, 29. Januar 2013 17:12:30 UTC+1 schrieb Dirk Krause:
>
> Hi,
>
> I am trying to use web2py to manage a database and display the resulting 
> JSON in AngularJS.  To render an angular compatible view I need to pass raw 
> html in a view (for example the html needs to start with '' 
> and so forth). Of course I could place the files in the static folder, but 
> then I can't protect the files via @auth.requires_login() etc.
>
> What would be the best way to achieve that?
>
> Thank you,
>   Dirk
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Rendering 'raw' HTML for AngularJS with Web2py

2013-01-29 Thread Dirk Krause
Hi,

I am trying to use web2py to manage a database and display the resulting 
JSON in AngularJS.  To render an angular compatible view I need to pass raw 
html in a view (for example the html needs to start with '' 
and so forth). Of course I could place the files in the static folder, but 
then I can't protect the files via @auth.requires_login() etc.

What would be the best way to achieve that?

Thank you,
  Dirk

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How do I use web2py to make a simple GUI?

2013-01-25 Thread Dirk Krause
my two cents:
as long as you don't need web services (and you don't if I understood you 
correctly) you are probably better off with a JavaScript framework without 
a server component (i.e. without web2py).

The AngularJS framework is one of many frameworks that come with good 
documentation. I'd recommend digging into these examples, if you want to go 
this way:
http://rabidgadfly.com/2012/12/angularjs-simple-calculator/
The example there also works on mobile devices.
Also: http://docs.angularjs.org/tutorial/


Am Mittwoch, 23. Januar 2013 22:27:22 UTC+1 schrieb Kaare Mikkelsen:
>
> Hi, the answer to this question may well be that I should leave web2py 
> alone and use something else, so I had better start explaining what I'm 
> trying to do. I'm sorry if my post comes across as long-winded, feel free 
> to skip to the question at the bottom:
>
> I want to make a small app for a special, quite simple, calculation that I 
> do fairly often. I thought it would be a good exercise to learn how to make 
> this as a web-application (rather than digging into how to make apps for my 
> smartphone OS) that I could use through the browser on my phone. I'm 
> reasonably comfortable with programming, and getting better at python 
> (though I must say I'm still more comfortable with Matlab and c++). So, 
> really, first I just need to make input fields, a "go"-button, and 
> preferably learn how to accommodate different display sizes. Later, 
> naturally, there is a range of features that could be fun to tackle.
>
> But, when reading the online book, it seems the focus is on very different 
> things, with much more advanced functionality than what I need. Somehow I 
> feel there should be a bit more detail between "hello world" and making my 
> own wiki. I have read the "Overview" thoroughly, and bits and pieces of the 
> rest.
>
> I found web2py from googling how to use python to build a web application, 
> which lead me to django, which lead to comparisons of web2py and django, 
> leading me to think that this was the more beginner-friendly tool.
>
> QUESTION:
> Is there a place where I can learn about making input forms (animating the 
> buttons, defining what happens when they're clicked etc.), either from 
> scratch or a general class? I have no experience with html, but of course I 
> am expecting to have to get familiar with that as well. Are these simple 
> objects things one should be comfortable with before tackling advanced 
> tools such as web2py? (if so, how?)
>
> I hope the above wasn't too long, and that someone can point me in the 
> right direction :)
>

-- 





[web2py] Re: MARKMIN line break

2012-11-29 Thread Dirk Krause
I learned from my editor that there is a huge difference between a 
paragraph and a line break. This also documented on a different thread here 
- people writing texts need both.


Am Donnerstag, 29. November 2012 17:51:45 UTC+1 schrieb Massimo Di Pierro:
>
> Why do you want the newline at all? If you have \n\n in your text, it will 
> be used to brak  You can just add space after  with css.
>
> On Thursday, 29 November 2012 10:27:12 UTC-6, Dirk Krause wrote:
>>
>> I see, and thank you. Now we already have a database full of text without 
>> the 'newline' tag and I have two options:
>> (1) traverse through the database and applying foresaid regex to all text 
>> fields or
>> (2) hack the regex somewhere into the code.
>>
>> I just tried (2) and it seems to be working; I applied this:
>> {{=MARKMIN(re.sub(r'([^\n])\n([^\n])', r'\1[[NEWLINE]]\n\2', theText))}}
>> and it seems to be working.
>>
>> So that's ok now, but when I do a CSV export it's not in so I my guess is 
>> I need to change the MARKMIN renderer itself, right?
>>
>>
>> Am Donnerstag, 29. November 2012 16:27:19 UTC+1 schrieb Massimo Di Pierro:
>>>
>>> The idea was to insert explicit newlines inside tags like H1, H2, etc.
>>>
>>> On Thursday, 29 November 2012 08:52:24 UTC-6, Dirk Krause wrote:
>>>>
>>>> ok, thank you.
>>>>
>>>> I am only wondering why there is a special tag '[[NEWLINE]] when there 
>>>> is already a one-to-one token for it - the single page break itself.
>>>> This can be parsed with
>>>> re.sub(r'([^\n])\n([^\n])', r'\1[[NEWLINE]]\n\2', s)
>>>> (full example here: http://pythonfiddle.com/replace-single-line-break )
>>>>
>>>> Where would I put this regular expression best to avoid the newline tag 
>>>> for the editor?
>>>>
>>>> Thanks again.
>>>>
>>>> Am Donnerstag, 29. November 2012 13:13:54 UTC+1 schrieb villas:
>>>>>
>>>>> Use this:
>>>>>
>>>>> [[NEWLINE]]
>>>>>
>>>>> On Thursday, November 29, 2012 11:04:56 AM UTC, Dirk Krause wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> sorry if this was answered elsewhere but I couldn't find it:
>>>>>> I found no consistent answer how to add single line breaks ('') 
>>>>>> as opposed to paragraphs ('') into MARKMIN.
>>>>>>
>>>>>> This is what I found so far:
>>>>>> (1) the 'purest' Markdown doesn't allow line breaks at all (found in 
>>>>>> stackoverflow)
>>>>>> (2) there is a common practice to add two or more spaces at the end 
>>>>>> of the line to inject a  (see http://goo.gl/iEGU).
>>>>>> (3) then there is github flavored markdown (
>>>>>> http://github.github.com/github-flavored-markdown/ ) which simply 
>>>>>> adds this to the renderer.
>>>>>>
>>>>>> Obviously the MARKMIN renderer doesn't support (3). From some forum 
>>>>>> posts I thought it would support (2) but it doesn't (I checked on 
>>>>>> version 2.0.9).
>>>>>>
>>>>>> What is the best practice to achieve single line breaks?
>>>>>>
>>>>>> Thanks,
>>>>>>   Dirk
>>>>>>
>>>>>>
>>>>>>

-- 





[web2py] Re: web2py on Heroku

2012-11-29 Thread Dirk Krause
Sure. I could take what you wrote down there, test it on Heroku, verify 
that nothing was forgotten, beef it up a little bit and put it - where? A 
pull request on Github? Is the documentation a git?


Am Donnerstag, 29. November 2012 17:52:22 UTC+1 schrieb Massimo Di Pierro:
>
> Can you help with that documentation?
>
> On Thursday, 29 November 2012 10:35:44 UTC-6, Dirk Krause wrote:
>>
>> From my attempts to get apps running on Heroku (a few experiments with 
>> nodejs) people expect to create and edit the requirements and the procfile 
>> anyways. The procedure is also described in Herokus 
>> Tutorials<https://devcenter.heroku.com/articles/python>, 
>> so one needs to understand the concept anyways. No need to ship that would 
>> be my 2 cents, rather document it (like you already did here).
>>
>> Am Donnerstag, 29. November 2012 16:41:45 UTC+1 schrieb Massimo Di Pierro:
>>>
>>> FYI (from web2py-developers)
>>>
>>>
>>> Hello everybody,
>>>
>>> At PyCon Argentina I met Craig Kerstiens from Heroku. He explained to me 
>>> how heroku works and we were able to make web2py work on heroku.
>>>
>>> This is still experimental and I will continue tweak it but you may want 
>>> to give it a try and share your suggestions for improvement:
>>>
>>>
>>> HOWTO:
>>>
>>> 1) get a heroku account and SDK (it is all free)
>>>
>>> 2) download web2py from google code (not from github because you do not 
>>> want the .git folder)
>>>
>>>hg clone https://massimo.dipie...@code.google.com/p/web2py/
>>>
>>>cd web2py
>>>
>>> 3) install your web2py apps
>>>
>>> 4) in each app, replace
>>>
>>>db=DAL(…)
>>>
>>> with
>>>
>>>from gluon.contrib.heroku import get_db 
>>> 
>>>
>>>db = get_db() 
>>>
>>> 5) from inside the web2py folder do (this create a git repo, if you have 
>>> one, delete it):
>>>
>>>scripts/setup-web2py-heroku.sh
>>>
>>> Now should have your apps running on heroku with postgresql.
>>>
>>> caveats:
>>>
>>> get_db()  gives you a postgresql connection on heroku and stores 
>>> sessions, migrations , and uploads in postgres (one db for all apps). When 
>>> running locally uses a heroku.test.sqlite database (one for each app). I 
>>> will post instructions so that each app gets its own database. Tickets 
>>> still go in file system and will be accessible via admin interface but 
>>> every 24hrs the file system is wiped out and tickets are lost.
>>>
>>> Admin is not in readonly mode but any change you do via admin will be 
>>> lost when the system is reset (every 24 hrs). So you should assume it is 
>>> readonly.
>>>
>>> Appadmin works fine.
>>>
>>> Is the DAL(…) -> get_db() replacement too much to ask to the users? We 
>>> could do it automatically under the hood once we detect heroku. What do you 
>>> think? Using get_db gives more flexibility for tweaking, specifically when 
>>> multiple databases are present.
>>>
>>> There are two files that need to be created (done by 
>>> setup-web2py-heroku.sh): requirements.txt and Procfile. We could ship them 
>>> with web2py but people need to be able to configure them anyway. Should we 
>>> ship them or let users create them?
>>>
>>> This should be even easier. People should be able to simply git commit 
>>> apps (with get_db) and pip install web2py. I do not know how to do it 
>>> because I do not understand distutil and git well enough yet. Perhaps 
>>> people should be able to git pull apps directly from the admin running on 
>>> heroku.
>>>
>>>
>>> Massimo
>>>
>>

-- 





Re: [web2py] dashboard using bootstrap

2012-11-29 Thread Dirk Krause
Check http://d3js.org/ and http://raphaeljs.com/

Also there is http://paperjs.org/ and esp http://processingjs.org/

There is a good overview here:
http://coding.smashingmagazine.com/2012/02/22/web-drawing-throwdown-paper-processing-raphael/

Am Donnerstag, 29. November 2012 17:24:43 UTC+1 schrieb Richard:
>
> http://www.highcharts.com/
>
> Is pretty nice!
>
> Do you know something similar that is open source?
>
> Richard
>
> On Thu, Nov 29, 2012 at 4:58 AM, Manuele Pesenti 
> 
> > wrote:
>
>> highcharts
>
>
>

-- 





[web2py] Re: web2py on Heroku

2012-11-29 Thread Dirk Krause
>From my attempts to get apps running on Heroku (a few experiments with 
nodejs) people expect to create and edit the requirements and the procfile 
anyways. The procedure is also described in Herokus 
Tutorials, 
so one needs to understand the concept anyways. No need to ship that would 
be my 2 cents, rather document it (like you already did here).

Am Donnerstag, 29. November 2012 16:41:45 UTC+1 schrieb Massimo Di Pierro:
>
> FYI (from web2py-developers)
>
>
> Hello everybody,
>
> At PyCon Argentina I met Craig Kerstiens from Heroku. He explained to me 
> how heroku works and we were able to make web2py work on heroku.
>
> This is still experimental and I will continue tweak it but you may want 
> to give it a try and share your suggestions for improvement:
>
>
> HOWTO:
>
> 1) get a heroku account and SDK (it is all free)
>
> 2) download web2py from google code (not from github because you do not 
> want the .git folder)
>
>hg clone https://massimo.dipie...@code.google.com/p/web2py/
>
>cd web2py
>
> 3) install your web2py apps
>
> 4) in each app, replace
>
>db=DAL(…)
>
> with
>
>from gluon.contrib.heroku import get_db 
> 
>
>db = get_db() 
>
> 5) from inside the web2py folder do (this create a git repo, if you have 
> one, delete it):
>
>scripts/setup-web2py-heroku.sh
>
> Now should have your apps running on heroku with postgresql.
>
> caveats:
>
> get_db()  gives you a postgresql connection on heroku and stores sessions, 
> migrations , and uploads in postgres (one db for all apps). When running 
> locally uses a heroku.test.sqlite database (one for each app). I will post 
> instructions so that each app gets its own database. Tickets still go in 
> file system and will be accessible via admin interface but every 24hrs the 
> file system is wiped out and tickets are lost.
>
> Admin is not in readonly mode but any change you do via admin will be lost 
> when the system is reset (every 24 hrs). So you should assume it is 
> readonly.
>
> Appadmin works fine.
>
> Is the DAL(…) -> get_db() replacement too much to ask to the users? We 
> could do it automatically under the hood once we detect heroku. What do you 
> think? Using get_db gives more flexibility for tweaking, specifically when 
> multiple databases are present.
>
> There are two files that need to be created (done by 
> setup-web2py-heroku.sh): requirements.txt and Procfile. We could ship them 
> with web2py but people need to be able to configure them anyway. Should we 
> ship them or let users create them?
>
> This should be even easier. People should be able to simply git commit 
> apps (with get_db) and pip install web2py. I do not know how to do it 
> because I do not understand distutil and git well enough yet. Perhaps 
> people should be able to git pull apps directly from the admin running on 
> heroku.
>
>
> Massimo
>

-- 





[web2py] Re: MARKMIN line break

2012-11-29 Thread Dirk Krause
I see, and thank you. Now we already have a database full of text without 
the 'newline' tag and I have two options:
(1) traverse through the database and applying foresaid regex to all text 
fields or
(2) hack the regex somewhere into the code.

I just tried (2) and it seems to be working; I applied this:
{{=MARKMIN(re.sub(r'([^\n])\n([^\n])', r'\1[[NEWLINE]]\n\2', theText))}}
and it seems to be working.

So that's ok now, but when I do a CSV export it's not in so I my guess is I 
need to change the MARKMIN renderer itself, right?


Am Donnerstag, 29. November 2012 16:27:19 UTC+1 schrieb Massimo Di Pierro:
>
> The idea was to insert explicit newlines inside tags like H1, H2, etc.
>
> On Thursday, 29 November 2012 08:52:24 UTC-6, Dirk Krause wrote:
>>
>> ok, thank you.
>>
>> I am only wondering why there is a special tag '[[NEWLINE]] when there is 
>> already a one-to-one token for it - the single page break itself.
>> This can be parsed with
>> re.sub(r'([^\n])\n([^\n])', r'\1[[NEWLINE]]\n\2', s)
>> (full example here: http://pythonfiddle.com/replace-single-line-break )
>>
>> Where would I put this regular expression best to avoid the newline tag 
>> for the editor?
>>
>> Thanks again.
>>
>> Am Donnerstag, 29. November 2012 13:13:54 UTC+1 schrieb villas:
>>>
>>> Use this:
>>>
>>> [[NEWLINE]]
>>>
>>> On Thursday, November 29, 2012 11:04:56 AM UTC, Dirk Krause wrote:
>>>>
>>>> Hi,
>>>>
>>>> sorry if this was answered elsewhere but I couldn't find it:
>>>> I found no consistent answer how to add single line breaks ('') 
>>>> as opposed to paragraphs ('') into MARKMIN.
>>>>
>>>> This is what I found so far:
>>>> (1) the 'purest' Markdown doesn't allow line breaks at all (found in 
>>>> stackoverflow)
>>>> (2) there is a common practice to add two or more spaces at the end of 
>>>> the line to inject a  (see http://goo.gl/iEGU).
>>>> (3) then there is github flavored markdown (
>>>> http://github.github.com/github-flavored-markdown/ ) which simply adds 
>>>> this to the renderer.
>>>>
>>>> Obviously the MARKMIN renderer doesn't support (3). From some forum 
>>>> posts I thought it would support (2) but it doesn't (I checked on 
>>>> version 2.0.9).
>>>>
>>>> What is the best practice to achieve single line breaks?
>>>>
>>>> Thanks,
>>>>   Dirk
>>>>
>>>>
>>>>

-- 





[web2py] Re: MARKMIN line break

2012-11-29 Thread Dirk Krause
ok, thank you.

I am only wondering why there is a special tag '[[NEWLINE]] when there is 
already a one-to-one token for it - the single page break itself.
This can be parsed with
re.sub(r'([^\n])\n([^\n])', r'\1[[NEWLINE]]\n\2', s)
(full example here: http://pythonfiddle.com/replace-single-line-break )

Where would I put this regular expression best to avoid the newline tag for 
the editor?

Thanks again.

Am Donnerstag, 29. November 2012 13:13:54 UTC+1 schrieb villas:
>
> Use this:
>
> [[NEWLINE]]
>
> On Thursday, November 29, 2012 11:04:56 AM UTC, Dirk Krause wrote:
>>
>> Hi,
>>
>> sorry if this was answered elsewhere but I couldn't find it:
>> I found no consistent answer how to add single line breaks ('') as 
>> opposed to paragraphs ('') into MARKMIN.
>>
>> This is what I found so far:
>> (1) the 'purest' Markdown doesn't allow line breaks at all (found in 
>> stackoverflow)
>> (2) there is a common practice to add two or more spaces at the end of 
>> the line to inject a  (see http://goo.gl/iEGU).
>> (3) then there is github flavored markdown (
>> http://github.github.com/github-flavored-markdown/ ) which simply adds 
>> this to the renderer.
>>
>> Obviously the MARKMIN renderer doesn't support (3). From some forum posts 
>> I thought it would support (2) but it doesn't (I checked on version 2.0.9).
>>
>> What is the best practice to achieve single line breaks?
>>
>> Thanks,
>>   Dirk
>>
>>
>>

-- 





[web2py] MARKMIN line break

2012-11-29 Thread Dirk Krause
Hi,

sorry if this was answered elsewhere but I couldn't find it:
I found no consistent answer how to add single line breaks ('') as 
opposed to paragraphs ('') into MARKMIN.

This is what I found so far:
(1) the 'purest' Markdown doesn't allow line breaks at all (found in 
stackoverflow)
(2) there is a common practice to add two or more spaces at the end of the 
line to inject a  (see http://goo.gl/iEGU).
(3) then there is github flavored markdown 
(http://github.github.com/github-flavored-markdown/ ) which simply adds 
this to the renderer.

Obviously the MARKMIN renderer doesn't support (3). From some forum posts I 
thought it would support (2) but it doesn't (I checked on version 2.0.9).

What is the best practice to achieve single line breaks?

Thanks,
  Dirk


-- 





[web2py] Form upload with cURL

2012-09-13 Thread Dirk Krause
Hi,

I finally figured out to do a file upload via curl (may be obvious to 
everybody else, but not to me ...) so here we go:

I followed the 'manual file upload' example over at web2pyslices (thanks, 
Yarin!):
  http://www.web2pyslices.com/slice/show/1504/manual-uploads

Just for clarity I changed the table name and the field names to 't_*' and 
'f_*' (which I consider a best practice).
I added this to the model ...
db.define_table('t_image',
Field('f_title'),
Field('f_file', 'upload'),
format = '%(title)s')

... and this to the controller ...
@auth.requires_login()
def index():
image_form = FORM(
INPUT(_name='image_title',_type='text'),
INPUT(_name='image_file',_type='file')
)

if image_form.accepts(request.vars,formname='image_form'):

image = db.t_image.f_file.store(image_form.vars.image_file.file, 
image_form.vars.image_file.filename)
id = 
db.t_image.insert(f_file=image,f_title=image_form.vars.image_title)

images = db().select(db.t_image.ALL)

return dict(images=images)
... and this to the view.

{{extend "layout.html"}}
 






 

{{for image in images:}}



{{=image.f_title}}


[Download]


{{pass}}



The applications name was 'upload' so the corresponding cURL call would be:
curl --user user:pass --form "image_title=some name" --form 
"_formname=image_form" --form "image_file=@test.png" --form Submit=OK http:
//127.0.0.1:8000/upload/default/index
(with user:pass being substituted with a valid username/password 
combination and test.png sitting in the same directory)

I hope this saves somebody some time.

This doesn't work for the SQLFORM.smartgrid forms unfortunately since they 
sport a '_formkey' parameter which changes every time you call the form. 
 If someone knows a solution to this, I'd be happy to learn it.

-- 





[web2py] Re: grid/smartgrid field editability

2012-08-31 Thread Dirk Krause
That was it - thx a bunch!

Am Freitag, 31. August 2012 11:28:34 UTC+2 schrieb Niphlod:
>
> the "default" way of setting db.table.field.writable = False should work...
>
> Il giorno venerdì 31 agosto 2012 11:26:16 UTC+2, Dirk Krause ha scritto:
>>
>> Is there an (easy) way to disable the editability of distinct fields in a 
>> grid/smartgrid?
>>
>> I'd like to create a view for an editor (being able to edit all fields), 
>> and an approver (being able to just view all fields, and change only one 
>> field like a checkbox).
>>
>> Thanks, Dirk
>>
>

-- 





[web2py] grid/smartgrid field editability

2012-08-31 Thread Dirk Krause
Is there an (easy) way to disable the editability of distinct fields in a 
grid/smartgrid?

I'd like to create a view for an editor (being able to edit all fields), 
and an approver (being able to just view all fields, and change only one 
field like a checkbox).

Thanks, Dirk

-- 





[web2py] Re: web2py 2.0 almost done

2012-08-07 Thread Dirk Krause
If you want the trunk (i.e. the latest version) I assume it's best that you 
do a 
git clone https://github.com/web2py/web2py/
and work from there.
Every once and a while you will want to do a
git pull
to receive the latest version.



Am Dienstag, 7. August 2012 18:03:24 UTC+2 schrieb Luc Chase:
>
> Where is the Ver. 2.0 system? Is it at  
> http://www.web2py.com/examples/static/nightly/web2py_src.zip   ?
>
>
>
>
> On Tuesday, 7 August 2012 05:33:48 UTC+1, Massimo Di Pierro wrote:
>>
>> Web2py 2.0 is almost done. 
>> Please try the nightly build.
>> Let us know if it breaks anything.
>>
>> massimo
>>
>

-- 





[web2py] Re: web2py 2.0 almost done

2012-08-07 Thread Dirk Krause
Sry if this is a dumb question: am I supposed to post possible bugs here or 
file an issue on google code?

Am Dienstag, 7. August 2012 06:33:48 UTC+2 schrieb Massimo Di Pierro:
>
> Web2py 2.0 is almost done. 
> Please try the nightly build.
> Let us know if it breaks anything.
>
> massimo
>

-- 





Re: [web2py] Re: web2py hangs while creating the mysql tables

2012-08-07 Thread Dirk Krause
I finally understand why the app wizard prefixes every table with 't_' and 
every field with 'f_'.  Probably a good practice anyway.

Am Dienstag, 7. August 2012 17:03:44 UTC+2 schrieb Yarin:
>
> Change the name of in your Field('long') field in maps table - it's a 
> reserved keyword in MySQL and will cause it to hang.
>
> On Tuesday, August 7, 2012 10:57:07 AM UTC-4, Aurelijus Useckas wrote:
>>
>> Here it is:
>>
>> db.define_table('tag',
>> Field('tag', notnull=True, unique=True),
>> format='%(tag)s')
>>
>> db.define_table('city',
>> Field('name', notnull=True, unique=True),
>> format='%(name)s')
>> 
>> db.define_table('maps',
>> Field('name'),
>> Field('last_name'),
>> Field('long'),
>> Field('lat'))
>> 
>> 
>> db.define_table('asoc',
>> Field('name', label='Pavadinimas', unique=True),
>> Field('City', 'list:reference city', label='Miestas'),
>> Field('address', label='Adresas'),
>> Field('www'),
>> Field('tel'),
>> Field('fax'),
>> Field('email'),
>> Field('President', label='Asociacijos prezidentas'),
>> Field('CEO', label='Asociacijos generalinis'),
>> Field('CEO_tel', label='Generalinio tel.'),
>> Field('CEO_email', label='Generalinio email'),
>> Field('CEO_mob', label='Generalinio mobilus'),
>> Field('Pres_tel', label='Prezidento tel.'),
>> Field('Pres_email', label='Prezidento email'),
>> Field('Pres_mob', label='Prezidento mobilus'),
>> Field('submited_at', 'datetime', default=request.now, writable=False, 
>> readable=False),
>> Field('updated_at', 'datetime', default=request.now, 
>> update=request.now, writable=False, readable=False),
>> Field('submited_by', db.auth_user, default=auth.user_id, 
>> writable=False, readable=False),
>> Field('updated_by', db.auth_user, update=auth.user_id, 
>> writable=False, readable=False),
>> format='%(name)s')
>>
>> db.asoc.email.requires=IS_EMPTY_OR(IS_EMAIL())
>> db.asoc.CEO_email.requires=IS_EMPTY_OR(IS_EMAIL())
>> db.asoc.Pres_email.requires=IS_EMPTY_OR(IS_EMAIL())
>> db.asoc.name.requires=IS_NOT_EMPTY()
>>
>> db.define_table('countries',
>> Field('Country', notnull=True, unique=True),
>> Field('latitude', readable=True, writable=False),
>> Field('longitude', readable=True, writable=False),
>> format = '%(Country)s'
>> )
>>
>> def horizontal_checkboxes(f,v):
>> horizontal_widget = SQLFORM.widgets.checkboxes.widget(f,v,cols=4)
>> return locals()
>>
>> db.define_table('company',
>> Field('title', label='Pavadinimas', unique=True),
>> Field('CEO', label='Generalinis dir.'),
>> Field('code', 'integer', label='Įmonės kodas',unique=True, 
>> default=None),
>> Field('revenue', 'integer', label='Metinė apyvarta (mln.)'),
>> Field('workers', 'integer', label='Darbuotojų skaičius'),
>> # Field('logo', 'upload', label='Įmonės logo'),
>> Field('produce_tag', 'list:reference tag', label='Produkcija', 
>> default=None),
>> Field('produce', label='Produkcija (smulkiau)'),
>> Field('Email', default=None, notnull=False),
>> Field('Tel'),
>> Field('Fax'),
>> Field('www'),
>> Field('City', 'list:reference city', label='Miestas'),
>> Field('address', label='Adresas'),
>> Field('extra_contacts', 'boolean', label='Pridėti kontakt. duomenų'),
>> Field('extra_contacts_2', 'boolean', label='Pridėti kontakt. 
>> duomenų'),
>> Field('name_1', label='Vardas'),
>> Field('pareigos_1', label='Pareigos'),
>> Field('tel_1', label='Papildomas tel.'),
>> Field('email_1', label='Papildomas el. paštas'),
>> Field('name_2', label='Vardas'),
>> Field('pareigos_2', label='Pareigos'),
>> Field('tel_2', label='Papildomas tel.'),
>> Field('email_2', label='Papildomas el. paštas'),
>> Field('Association',  db.asoc, label='Priklauso asociacijai'),
>> Field('other', 'text', label='Papildoma info'),
>> Field('submited_at', 'datetime', default=request.now, writable=False, 
>> readable=False),
>> Field('submited_by', db.auth_user, default=auth.user_id, 
>> writable=False, readable=False),
>> Field('updated_at', 'datetime', update=request.now, writable=False, 
>> readable=False),
>> Field('updated_by', db.auth_user, update=auth.user_id, 
>> writable=False, readable=False),
>> Field('exports_wants_to', 'list:reference countries', label='Domina 
>> šalys'),
>> Field('exports_to', 'list:reference countries', label='Eksportuoja 
>> į', required=False),
>> Field('imports_from', 'list:reference countries', label='Importuoja 
>> iš', required=False),
>> format = '%(title)s')
>>
>> from plugin_multiselect_widget import (
>> hmultiselect_widget, vmultiselect_widget,
>> rhmultiselect_widget, rvmultiselect_widget,
>> )
>>
>> db.company.exports_to.widget = hmultiselect_widget
>> db.company.imports_from.widget = hmultiselect_widget
>> db.company.exports_wants_to.widget = hmultiselect_widget
>> 
>> db.company

[web2py] RESTful services with curl and/or python

2012-08-02 Thread Dirk Krause
Hi,

I tried to pull together the different sources for restful services, 
including various hints in this group and of course the excellent web2py 
documentation. If this is the wrong place or info, feel free to move or 
delete it.

Here's how you create a restful web2py application in under 2 minutes:
- create a wizard application called 'RT'
- add a table named 'entries' and add a field 'entry wiki'
- finish the wizard with all the default values
- register a user 'user' with password 'pass'
now you have an application with 10 random entries.

The next two step are required due to a bug that I filed before 
(http://goo.gl/CPO0G)
- go to the design page of the app and change the table name from 
't_entries' to 'entries'
  in db_wizard.py (4 times) and in default.py (1 time)
- check that the application is still working. you notice that the table 
now is empty since we changed
  the name of the table.
- Add a couple of entries.

- now add the RESTful services to the controller as described in 
http://goo.gl/iITNd ('parse_as_rest') 
  or here: http://goo.gl/ltfa2

@request.restful()
def api():
response.view = 'generic.'+request.extension
def GET(*args,**vars):
patterns = 'auto'
parser = db.parse_as_rest(patterns,args,vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status,parser.error)
def POST(table_name,**vars):
return db[table_name].validate_and_insert(**vars)
def PUT(table_name,record_id,**vars):
return db(db[table_name]._id==record_id).update(**vars)
def DELETE(table_name,record_id):
return db(db[table_name]._id==record_id).delete()
return locals()


- In the browser:
  you get all entries with
  http://127.0.0.1:8000/RT/default/api/entries.json

  you get the just the second entry with
  http://127.0.0.1:8000/RT/default/api/entries/id/2.json

  you get all auto-generated patterns with
  http://127.0.0.1:8000/RT/default/api/patterns.json

That's as far as we get with GET in a browser.

To make things more realistic, we add basic user authentication and try 
some POSTs with curl.
- Add 
auth.settings.allow_basic_login = True
@auth.requires_login()

  above @request.restful. Authentification now is mandatory for the REST 
interface.

- get the first entry
  curl --user user:pass 
http://127.0.0.1:8000/RT/default/api/entries/id/1.json

- post a new entry
  curl --user user:pass -d "f_entry=something" 
http://127.0.0.1:8000/RT/default/api/entries.json

- delete the first entry
  curl -X DELETE --user user:pass 
http://127.0.0.1:8000/RT/default/api/entries/1.json


Same thing from python:

import requests
from requests.auth import HTTPBasicAuth 
payload = {'f_entry': 'somevalue'}
auth=HTTPBasicAuth('user', 'pass')
r = requests.post("http://127.0.0.1:8000/RT/default/api/entries.json";, data=
payload, auth=auth)
r = requests.delete("http://127.0.0.1:8000/RT/default/api/entries/1.json",data
=payload, auth=auth)

-- 





[web2py] Markmin patch with nested lists

2012-07-31 Thread Dirk Krause
Hi,

I am trying to apply this patch:
http://code.google.com/p/web2py/issues/attachmentText?id=524&aid=5240002000&name=markmin_nested_list.diff&token=kjJqRhq0Kmpw7px0Idciodnzvyo%3A1343665747008
(IIRC Massimo posted this somewhere here.)

I successfully patched it to the markmin2html.py file, but I don't see any 
changes. Do I need to restart something to see the changes working?

Thanks,
Dirk

--