Orderby

2 views
Skip to first unread message

Pynthon

unread,
Apr 25, 2009, 6:16:39 AM4/25/09
to web2py Web Framework
Hello

I searched in the book but I can't find it. Im creating a blog with
the small knowledge I have about W2P. Just for fun and to learn. I
want to order it like this:

3
2
1

and not

1
2
3

The latest posts ion the head :P. How can I do this?

Thanks,
Pynthon

Mladen Milankovic

unread,
Apr 25, 2009, 6:27:52 AM4/25/09
to web...@googlegroups.com
Hi.

I'm assuming you have some query from where you take the posts.
In the select part there's a parameter orderby. To give it to sort it in
reverse order just write the sign ~ in front of the orderby parameter.
example
db(some_query).select(db.table.ALL, orderby = ~db.table.field)


regards
mmlado

Pynthon

unread,
Apr 25, 2009, 6:32:10 AM4/25/09
to web2py Web Framework
Thanks man! Works perfect! Maybe I want this blog for my public site.
But I also want to make an admin panel. How need I to make that? I
know how to work with sessions. But can it also be safe?

Mladen Milankovic

unread,
Apr 25, 2009, 6:45:39 AM4/25/09
to web...@googlegroups.com
Hi.

You can do something with the auth class.
Here some tutorial about it.
http://mdp.cti.depaul.edu/examples/default/tools

You can expose only functions for login/logout. Create a user by hand, through
web2py admin.
Then create controllers/functions that requires authorization.

For the safety... it should be enough safe for a blog. :)
Nothing is safe on the internet, theres always someone who can hack it.
The only question is: is it worth to hack it. :)

regards
mmlado

Pynthon

unread,
Apr 25, 2009, 6:53:13 AM4/25/09
to web2py Web Framework
But I see that there is also with profiles etc.

On Apr 25, 12:45 pm, Mladen Milankovic <mml...@gmail.com> wrote:
> Hi.
>
> You can do something with the auth class.
> Here some tutorial about it.http://mdp.cti.depaul.edu/examples/default/tools

Pynthon

unread,
Apr 25, 2009, 6:54:44 AM4/25/09
to web2py Web Framework
BTW, is there also something like a editor for my blog. Because HTML
gets escaped and when I do enter it does not work :(.

Mladen Milankovic

unread,
Apr 25, 2009, 7:00:03 AM4/25/09
to web...@googlegroups.com
Hi.

Yes there are. If you need more from the authorization you can expose those
too, or all of them if you want to allow registration on the blog.
Usually I work on things where registration isn't good thing, and I need only
login and logout.

If you want all the functions:
def user(): return dict(form = auth())

or some of them:
def login(): return dict(form = auth.login(next=URL(r=request, f="index")))
def logout(): return dict(form = auth.logout(next=URL(r=request, f="login")))
#any other function you need...

regards
mmlado

Pynthon

unread,
Apr 25, 2009, 7:02:42 AM4/25/09
to web2py Web Framework
Hmm my posts were deleted. However, this is with profiles right? I
just want a plain login/logout system :$. And is there also something
like an editor. Because when I type my posts now I can't use enters
because everything is escaped. And the for loop does not work:

{{for post in posts:}}
{{=post.titel}}

{{=post.time}}

{{=post.post}}
{{pass}}

When I do this I get:

Web2Py 2009-04-25 12:19:05 Welcome to my new blog. This blog isn't PHP
but just Web2Py a Python web framework. Its really easy and simple. I
only need a new style without this green stuff. ~ Phant Welcome
2009-04-25 12:10:00 Welcome Hello World! 2009-04-25 12:04:59 For The
Lulz! My Boy 2009-04-25 12:00:53 Hello

Everything is just set together, how can I fix this?

On Apr 25, 12:45 pm, Mladen Milankovic <mml...@gmail.com> wrote:
> Hi.
>
> You can do something with the auth class.
> Here some tutorial about it.http://mdp.cti.depaul.edu/examples/default/tools

Mladen Milankovic

unread,
Apr 25, 2009, 7:03:18 AM4/25/09
to web...@googlegroups.com
Hi.

For the html editor, wouldn't know to recommend.
When you got the post for the blog, just put it into XML() helper. Like:
XML(post) This way it won't be escaped.

regards
mmlado

Mladen Milankovic

unread,
Apr 25, 2009, 7:07:59 AM4/25/09
to web...@googlegroups.com
Hi.

You'll need to add html for formating in the view. You can also add the XML
helper if you want to have html code in the post. Like:

{{for post in posts:}}
<div>
<h1>{{=post.titel}}</h1>

<p>{{=post.time}}</p>

<p>{{=XML(post.post)}}</p>
</div>
{{pass}}

regards
mmlado

Pynthon

unread,
Apr 25, 2009, 7:17:04 AM4/25/09
to web2py Web Framework
Thanks, but I meant more something like the wiki markup language.

mdipierro

unread,
Apr 25, 2009, 10:03:38 AM4/25/09
to web2py Web Framework
from gluon.contrib.markdown import WIKI

{{=WIKI(text)}}

Álvaro Justen [Turicas]

unread,
Apr 26, 2009, 4:05:52 PM4/26/09
to web...@googlegroups.com
On Sat, Apr 25, 2009 at 11:03 AM, mdipierro <mdip...@cs.depaul.edu> wrote:
> from gluon.contrib.markdown import WIKI
>
> {{=WIKI(text)}}

Phynthon (is it your name or nick? :-P),
You can use wiki syntax, but if you want to edit as in a WYSIWYG you
can add a javascript library that do this for you: transform a
textarea in a full-featured text formatter and return HTML code to
you.

See NicEdit: http://www.nicedit.com/
It is very simple and do what you want (if you do not want wiki).

--
Álvaro Justen
Peta5 - Telecomunicações e Software Livre
21 3021-6001 / 9898-0141
http://www.peta5.com.br/

Reply all
Reply to author
Forward
0 new messages