[web2py] Re: Implementing tornado chat server with web2py

2012-01-05 Thread Red Arrow
for chatting, usually use XMPP like Gtalk or facebook chat. If
choosing between gevent or tornado, gevent can handle better than
tornado.
http://nichol.as/benchmark-of-python-web-servers

On 5 Tháng Giêng, 09:01, Khalil KHAMLICHI 
wrote:
> looks like websockets dont work any more with the couple chrome/tornado =>
> error : Unexpected response code: 426
> attached image from dev. tools in chrome.
>
>  websocket_error_in_newVersion_of_chrome.png
> 21KXemTải xuống


Re: [web2py] Re: Logging in web2py

2012-01-05 Thread Joseph Jude
I'm using this logging module with logging.conf. It works fine in 
controllers & models. How to make it work in modules?

Regards,
Joseph


[web2py] Re: crud update with writeable=readable=False

2012-01-05 Thread Anthony
On Thursday, January 5, 2012 10:45:31 PM UTC-5, lucas wrote:
>
> yes, perfect and that makes perfect sense. 
>
> hey anthony, what is the setting to email the mail.settings.login when 
> a user's registration is pending.  meaning when a new user registers, 
> how do we setup web2py to email us so that we can erase pending under 
> the registration key?
>

Maybe something like:

auth.settings.register_onaccept = lambda form: 
mail.send(to=['ad...@yoursite.com'],
subject='Registration pending',
message='New user (id = %s) waiting for approval' % form.vars.id)

Note, that will introduce a slight delay for the user because it may take a 
second or two to send the email. An alternative is to queue the email for a 
background 
task: 
http://web2py.com/books/default/chapter/29/8#Sending-messages-using-a-background-task.

Anthony





[web2py] Re: crud update with writeable=readable=False

2012-01-05 Thread lucas
yes, perfect and that makes perfect sense.

hey anthony, what is the setting to email the mail.settings.login when
a user's registration is pending.  meaning when a new user registers,
how do we setup web2py to email us so that we can erase pending under
the registration key?

thanx again and web2py is really great.  i am learning it and loving
it.  lucas


[web2py] Re: Packaging web2py + application

2012-01-05 Thread LightDot
Is Python 2.7 a must? There are python 2.6 RPMs available from EPEL 
repository. They install parallel to the existing python 2.4 and thus 
avoids breaking yum and other applications that rely on stock python 2.4.

Python 2.7 could be packaged in a similar way, but by using this existing 
packages from EPEL (Fedora project), you'd avoid maintaining a custom set 
of python RPMs.

Packaging web2py and your application shouldn't be a problem. Making web2py 
RPMs is very straightforward and I've been doing it for a while for an 
internal web2py project of ours.

If you decide to go this route yourself, I'd recommend reading Fedora's 
packaging how-to's, as they seem to be quite complete and applicable to 
CentOS/SL/RHEL with very minor modifications. Than just have a look at some 
simpler existing .spec files and go from there, it's not as hard as it 
might look.


Re: [web2py] Re: Is there an example? RPC between applications

2012-01-05 Thread Bruce Wade
Thanks for the reply, I have already read that section prior to sending my
email :D

I am still unclear. I know how to handle the login when in a web browser.
However when using the RPC server I just get the following response:

send: 'POST /api/default/call/jsonrpc HTTP/1.1\r\nHost:
127.0.0.1:8000\r\nAccept-Encoding:
gzip\r\nUser-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)\r\nContent-Type:
application/json\r\nContent-Length: 62\r\n\r\n'
send: '{"params": [1, 2], "id": 6641919632256610108, "method": "add"}'
reply: 'HTTP/1.1 303 SEE OTHER\r\n'
header: Set-Cookie:
 session_id_api=127.0.0.1-b7adcc1a-ae18-4010-a20c-12e37d3e0c55; Path=/
header: Content-Type: text/html; charset=UTF-8
header: Location: /api/default/user/login?_next=/api/default/call/jsonrpc
header: Date: Thu, 05 Jan 2012 20:51:49 GMT
header: Server: Rocket 1.2.4 Python/2.7.2+
header: Content-Length: 99
header: Connection: keep-alive
Traceback (most recent call last):
  File "", line 1, in 
  File "gluon/contrib/simplejsonrpc.py", line 106, in 
return lambda *args: self.call(attr, *args)
  File "gluon/contrib/simplejsonrpc.py", line 121, in call
verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1312, in single_request
response.msg,
xmlrpclib.ProtocolError: 


On Thu, Jan 5, 2012 at 2:43 PM, Alan Etkin  wrote:

> On services and authentication there is a section in the book that
> gives an example, as posted by Anthony in another thread:
>
> http://web2py.com/books/default/chapter/29/10?search=services+and+authentication#Services-and-Authentication
>
> Thread on similar topic:
>
> http://groups.google.com/group/web2py/browse_thread/thread/fa1ada23498e2b30/34bd1ef34aadd230?lnk=gst&q=Authentication+using+xmlrpc#34bd1ef34aadd230
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Is there an example? RPC between applications

2012-01-05 Thread Alan Etkin
On services and authentication there is a section in the book that
gives an example, as posted by Anthony in another thread:
http://web2py.com/books/default/chapter/29/10?search=services+and+authentication#Services-and-Authentication

Thread on similar topic:
http://groups.google.com/group/web2py/browse_thread/thread/fa1ada23498e2b30/34bd1ef34aadd230?lnk=gst&q=Authentication+using+xmlrpc#34bd1ef34aadd230


Re: [web2py] Re: global functions in models

2012-01-05 Thread Tsvi Mostovicz
I managed to find the culprit. The function before it had a mismatched
parentheses. So it would continue reading this function and fail on
compilation. Thanks for all your replies.  The append works, although
if this is a new user and no list has been defined yet it won't. So I
check if it returns None, set the list to [] and then have the append
statement.
I thought all the vars would be initialized by default so a list type
would return [] if it wasn't set in the form.

Another thing I learned is the fact that the function must receive one
argument (form).

Thanks again for the wonderful support.

Sent from my phone

On 5 בינו 2012, at 00:17, Alan Etkin  wrote:

> And if the auth_user field is of type list:, seems that even it
> is ok to do simply:
>
> auth.user.mylistfield.append(object)
>
> without explicit db query or update
>
> On 4 ene, 18:42, Alan Etkin  wrote:
>> If you are doing post-registration process, you might want to use
>> auth.settings.register_onaccept:
>>
>> register_onaccept is a list of functions or a single function or
>> lambda that receive a form argument
>>
>> form.vars.id contains the id of the new auth_user record.
>>
>> For appending to a sequence stored in an auth_user record field, maybe
>> it would be better to get the auth_user record field first with a db
>> query, modify it and finally update the db record.
>>
>> On 4 ene, 11:54, tsvim  wrote:
>>
>>> Hi all,
>>
>>> I'm trying to use the callbacks for auth.settings.register_onvalidation.
>>> I first put the function in controllers, when I discovered it should be in
>>> models as the settings are there.
>>> Now I have them in models, but I get a invalid syntax error on the last
>>> line:
>>
>>> def register_new_table_token():
>>> auth.user.last_opened = session.table_token
>>> auth.add_membership(auth.add_group(session.table_token),auth.user.id)
>>> auth.user.my_budgets.append(session.table_token)
>>> return
>>
>>> This happens both when I have pass instead of return or I don't enter a
>>> return statement.
>>
>>> Please help,
>>
>>> Thanks,
>>
>>> Tsvi
>>
>>


[web2py] Re: define_table - how to do this correctly (best practice?)

2012-01-05 Thread lyn2py
What you say is true, however for argument's sake, how could I achieve
the above with the 4th table?

In my situation, the 3 tables have different fields (but I didn't have
access to the file so I simply made them the same in the example here.

Thanks.

On Jan 6, 1:24 am, Andrew  wrote:
> I think this is more of a data modeling question than web2py.
> I would have one table called "content" with an extra column
> "content_type" .  You could define queries over the top if you just
> want one ofthe three.
>
> Your M:M table logically joins to "content".  You sort of have three
> subtype tables, but they are identical in structure so there is no
> reason to separate,
>
> On Jan 6, 5:22 am, lyn2py  wrote:
>
>
>
>
>
>
>
> > I have tables with individual properties,
>
> > db.define_table('article',
> >   Field('title', 'string', length=255,required=True),
> >   Field('description', 'text',required=True),
> > )
> > db.define_table('post',
> >   Field('title', 'string', length=255,required=True),
> >   Field('description', 'text',required=True),
> > )
> > db.define_table('page',
> >   Field('title', 'string', length=255,required=True),
> >   Field('description', 'text',required=True),
> > )
>
> > And I have a table with many-to-many relationship (with different
> > tables):
>
> > db.define_table('action',
> >   Field('user_id','reference
> > auth_user',default=auth.user_id,required=True),
>
> > Field('action','string',requires=IS_IN_SET(('fav','subscribe','report','fol 
> > low')),required=True),
> >   Field('table',requires=???,required=True),
> >   Field('table_id','integer',default=???,required=True),
> > )
>
> > My questions:
> > 1.. The field, "table" is actually one of the tables, article/post/
> > page. Is the only correct way to use
> > requires=IS_IN_SET(('article','post','page')) ?
>
> > 2.. "table_id" is actually dependent on the "table" selected. what
> > should I put for "default=???"
>
> > 3.. Can I set a different set of IS_IN_SET for "action" field,
> > depending on the "table" field chosen?
>
> > 4.. Finally, if the above is the wrong approach, how should I do it
> > correctly (best practice?)
>
> > Thanks!


[web2py] Re: Movuca - The Social CMS - Need Testers and Contributors

2012-01-05 Thread Alan Etkin
The WYSIWYG editor works smooth, altough i didn't used all of its
functions. I also like the multi-tab upload facility. It all looks
really good with Firefox 3.6.24

Martin Mulone is also developing Instant Press for web2py, with
similar features i think.

On 5 ene, 07:36, Bruno Rocha  wrote:
> Hi,
>
> I am developing a Social CMS, I was very inspired by vikuit.com but I made
> some conceptual improvements on what I think is a Social CMS.
>
> This is a simple system based in Articles, Content Types, Themes, Users,
> Activities etc...
>
> The code is in github[1] and you have to note that I am trying a different
> approach which is very un-web2pythonic and it is already under tests.
>
> The demo page is alive[2] Please help me test it! register, login, create
> articles, like, dislike, favorite, comment etc...
>
> If you have suggestions or ideas please let me know!
>
> * this will be released as Creative Commons Share-a-like-attribution license
>
> I need opinions, testers and contributors.
>
> [1]https://github.com/rochacbruno/Movuca(repo)
> [2]http://labs.blouweb.com/movuca (DEMO)
>
> * if you want to install it, just run setup/install to load system fixtures
> * you need web2py trunk
> * you need PIL
> * not sure if runs on GAE
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]


[web2py] Re: default_application showing full url

2012-01-05 Thread Anthony
That's probably because default_controller defaults to 'default', and 
default_function defaults to 'index' -- you might get the full URL if you 
explicitly set those to None in your router (haven't tried it).

Anthony

On Thursday, January 5, 2012 3:53:11 PM UTC-5, Leopold wrote:
>
> Hi all, 
>
> I have an application "myapp" which I want to make it the default app 
> when I navigate to the base domain (let's say "localhost" for now). By 
> adding: 
> default_application = 'myapp', 
> to the routers BASE dict in routes.py I am able to do that, however it 
> shortens the resulting url from "localhost/myapp/default/index" to 
> just "localhost". 
>
> I read that if I still want the complete url to be displayed by the 
> browser I should add: 
> applications = None, 
> to the same dict, however it doesn't work, it still shows the short 
> form of the url (displaying myapp as it should). 
>
> Here's the dict I added in routes.py: 
>
> routers = dict( 
>
> # base router 
> BASE = dict( 
> default_application = 'calidad', 
> applications = None, 
> ), 
> ) 
>
> I hit Reload routes and even close and start web2py again but still 
> the application name gets removed. 
> Any help? 
> Thanks.



[web2py] default_application showing full url

2012-01-05 Thread Leopold
Hi all,

I have an application "myapp" which I want to make it the default app
when I navigate to the base domain (let's say "localhost" for now). By
adding:
default_application = 'myapp',
to the routers BASE dict in routes.py I am able to do that, however it
shortens the resulting url from "localhost/myapp/default/index" to
just "localhost".

I read that if I still want the complete url to be displayed by the
browser I should add:
applications = None,
to the same dict, however it doesn't work, it still shows the short
form of the url (displaying myapp as it should).

Here's the dict I added in routes.py:

routers = dict(

# base router
BASE = dict(
default_application = 'calidad',
applications = None,
),
)

I hit Reload routes and even close and start web2py again but still
the application name gets removed.
Any help?
Thanks.


[web2py] Re: crud update with writeable=readable=False

2012-01-05 Thread Anthony
On Thursday, January 5, 2012 3:34:54 PM UTC-5, lucas wrote:
>
> yes, thank you anthony.  the first one didn't work because in my db.py 
> model file, the creation of the auth_user table is before the 
> auth_permission table, so it blows the program.


Right, sorry. You could simply move it to right after all the auth tables 
are defined in db.py (but still use the same logic).

Anthony 


[web2py] Re: crud update with writeable=readable=False

2012-01-05 Thread lucas
yes, thank you anthony.  the first one didn't work because in my db.py
model file, the creation of the auth_user table is before the
auth_permission table, so it blows the program.

but the second suggestion of changing the writable attribute to True
in the code worked great.  thank you so much.  lucas


[web2py] Re: Cookbook online ?

2012-01-05 Thread Omi Chiba
OK, I will consider purchasing one.

On Jan 4, 9:55 pm, Massimo Di Pierro 
wrote:
> I believe they will sell it in PDF. They have copyright. I have no
> saying on the matter.
>
> On Jan 4, 9:50 am, Omi Chiba  wrote:
>
>
>
>
>
>
>
> > Great work !!
> > Will it be available online somewhere ?
>
> >http://www.packtpub.com/web2py-application-development-recipes-to-mas...


[web2py] Re: crud update with writeable=readable=False

2012-01-05 Thread Anthony
The readable and writeable attributes of a field can be set conditionally 
(e.g., depending on request parameters or user authorization) or changed at 
any point in your code, so you could do:

db.define_table('auth_user', ...,
Field('approved', writeable = auth.has_membership('admin') and True or 
False))

Or in the action that generates the form to be used by the admin user:

db.auth_user.approved.writeable = True
form = SQLFORM(db.auth_user, ...)

Anthony

On Thursday, January 5, 2012 2:26:54 PM UTC-5, lucas wrote:
>
> hello one and all, 
>
> i have a field under a custom auth_user called "approved".  it is 
> writeable and readable False so that the users can not see or edit 
> this field under the register form. 
>
> but, i am also generating a form of the table where i want to be able 
> to edit the "approved" field as the admin of the site.  so i can see 
> two possible ways of doing it.  i can make the "approved" field 
> writeable and remove it from the auto registration form somehow before 
> it is sent from the server.  or, leave the field writeable False, and 
> then create the crud.update for the admin and then add this field 
> manually to the crud object after it is created so that the admin can 
> edit the field. 
>
> please advise me into which of the two scenarios is best and exactly 
> how to do it.  thank you in advance and have a great day.  lucas



[web2py] Re: crud update with writeable=readable=False

2012-01-05 Thread Alan Etkin
One way is to configure this attribute in the custom form action:

db.auth_user..readable = True

Other actions will use the readable and writable values defined at the
model.

On 5 ene, 16:26, lucas  wrote:
> hello one and all,
>
> i have a field under a custom auth_user called "approved".  it is
> writeable and readable False so that the users can not see or edit
> this field under the register form.
>
> but, i am also generating a form of the table where i want to be able
> to edit the "approved" field as the admin of the site.  so i can see
> two possible ways of doing it.  i can make the "approved" field
> writeable and remove it from the auto registration form somehow before
> it is sent from the server.  or, leave the field writeable False, and
> then create the crud.update for the admin and then add this field
> manually to the crud object after it is created so that the admin can
> edit the field.
>
> please advise me into which of the two scenarios is best and exactly
> how to do it.  thank you in advance and have a great day.  lucas


[web2py] crud update with writeable=readable=False

2012-01-05 Thread lucas
hello one and all,

i have a field under a custom auth_user called "approved".  it is
writeable and readable False so that the users can not see or edit
this field under the register form.

but, i am also generating a form of the table where i want to be able
to edit the "approved" field as the admin of the site.  so i can see
two possible ways of doing it.  i can make the "approved" field
writeable and remove it from the auto registration form somehow before
it is sent from the server.  or, leave the field writeable False, and
then create the crud.update for the admin and then add this field
manually to the crud object after it is created so that the admin can
edit the field.

please advise me into which of the two scenarios is best and exactly
how to do it.  thank you in advance and have a great day.  lucas


[web2py] Blog mention of Web2py

2012-01-05 Thread mikech
http://pyrseas.wordpress.com/2011/12/19/design-notes-on-database-application-development/
 


Re: [web2py] Packaging web2py + application

2012-01-05 Thread Ross Peoples
StaticPython looks pretty cool, but there are two issues I see with this:

First, my target platform is 64-bit. StaticPython is only 32-bit.
Second, the RPM is a requirement. In the future, we may create a yum repo 
for the application for updates and things like that, so we have to use RPM 
from the beginning.


[web2py] Is there an example? RPC between applications

2012-01-05 Thread Bruce Wade
"The XMLRPC client can also be implemented inside a web2py action, so that
one action can talk to another web2py application (even within the same
installation) using XMLRPC." Is there an example of how to properly do this?

The situation is:
1) We have multiple applications in the same installation which share a
single database and also have their own database for their unique
application. The shared database I would like to create an application that
provides RPC access to handle all the data related operations.
2) We are developing an android based application that will also need to
access the shared database via RPC. This means we need the ability to
handle logging into the system so the RPC knows which data to return based
on the logged in user.

Current I have an api application that has all the models created for the
database now I am working on creating the RPC api.

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Packaging web2py + application

2012-01-05 Thread Angelo Compagnucci
I can suggest you http://code.google.com/p/pts-mini-gpl/wiki/StaticPython

It's a statically compiled version (and runtime) of python, you can drop it
in web2py folder and write a script that starts

./python web2py.py 

In this way you have not to fight with rpm packing (I made several packeges
for opensuse ...), you can yust zip your application. This bynary works
well on all linux x86 x86-68 archs and it's not influenced by the
distribution you are running.

Angelo

2012/1/5 Ross Peoples 

> Hello everyone,
>
> I want to make an RPM package for my application that primarily targets
> CentOS. I am working with version 5, which only has Python 2.4. I would
> like to create an RPM that packages Python 2.7, web2py, and my application.
> Does anyone have any experience with doing anything like this? I'm a
> developer, not a packager, so this is all new to me.
>
> Any help would be greatly appreciated. Thanks,
>
> Ross
>



-- 
Profile: http://it.linkedin.com/in/compagnucciangelo


[web2py] Packaging web2py + application

2012-01-05 Thread Ross Peoples
Hello everyone,

I want to make an RPM package for my application that primarily targets 
CentOS. I am working with version 5, which only has Python 2.4. I would 
like to create an RPM that packages Python 2.7, web2py, and my application. 
Does anyone have any experience with doing anything like this? I'm a 
developer, not a packager, so this is all new to me.

Any help would be greatly appreciated. Thanks,

Ross


[web2py] Re: dropbox python api

2012-01-05 Thread Joseph Jude
If anyone is interested, you can look into the code for dropbox connection 
here:

http://goo.gl/QYT2y

This is my default.py. Look at dropbox_connect  and process_dropbox.

Question: How can I automate this with cron? When I do it, it stops with 
the redirect.

Thank you,
Joseph


Re: [web2py] How to do that: Verifying email account ownership

2012-01-05 Thread thstart
I mean a separate functionality from auth. Like the user is
posting a list of email addresses in a text box and my app
gets them and sends verification email messages to these
accounts. Once the user clicks the links to go to my app
and my app to mark this email verified and store it in 
a users' separate database


[web2py] Re: define_table - how to do this correctly (best practice?)

2012-01-05 Thread Andrew

I think this is more of a data modeling question than web2py.
I would have one table called "content" with an extra column
"content_type" .  You could define queries over the top if you just
want one ofthe three.

Your M:M table logically joins to "content".  You sort of have three
subtype tables, but they are identical in structure so there is no
reason to separate,

On Jan 6, 5:22 am, lyn2py  wrote:
> I have tables with individual properties,
>
> db.define_table('article',
>   Field('title', 'string', length=255,required=True),
>   Field('description', 'text',required=True),
> )
> db.define_table('post',
>   Field('title', 'string', length=255,required=True),
>   Field('description', 'text',required=True),
> )
> db.define_table('page',
>   Field('title', 'string', length=255,required=True),
>   Field('description', 'text',required=True),
> )
>
> And I have a table with many-to-many relationship (with different
> tables):
>
> db.define_table('action',
>   Field('user_id','reference
> auth_user',default=auth.user_id,required=True),
>
> Field('action','string',requires=IS_IN_SET(('fav','subscribe','report','fol 
> low')),required=True),
>   Field('table',requires=???,required=True),
>   Field('table_id','integer',default=???,required=True),
> )
>
> My questions:
> 1.. The field, "table" is actually one of the tables, article/post/
> page. Is the only correct way to use
> requires=IS_IN_SET(('article','post','page')) ?
>
> 2.. "table_id" is actually dependent on the "table" selected. what
> should I put for "default=???"
>
> 3.. Can I set a different set of IS_IN_SET for "action" field,
> depending on the "table" field chosen?
>
> 4.. Finally, if the above is the wrong approach, how should I do it
> correctly (best practice?)
>
> Thanks!


Re: [web2py] How to do that: Verifying email account ownership

2012-01-05 Thread Nik Go
Do you mean a registered user's email address? It's included in web2py,
just enable it. Check out
http://web2py.com/book/default/chapter/09#Mail-and-Auth



On Friday, January 6, 2012, thstart wrote:

> Verifying email account ownership - I am brainstorming for the best way to
> know email address is owned by an user.
>
> Something like that - a user enters email address, my app
> generates a code and sends an email message with a link with this
> code, the user clicks and comes to my app which thus verifies he
> is the owner of the email account.
>
> Similar to reset password.
>
> How is the easiest wat to do that with web2py?
>


[web2py] How to do that: Verifying email account ownership

2012-01-05 Thread thstart
Verifying email account ownership - I am brainstorming for the best way to 
know email address is owned by an user.

Something like that - a user enters email address, my app
generates a code and sends an email message with a link with this
code, the user clicks and comes to my app which thus verifies he 
is the owner of the email account.

Similar to reset password. 

How is the easiest wat to do that with web2py?


[web2py] define_table - how to do this correctly (best practice?)

2012-01-05 Thread lyn2py
I have tables with individual properties,

db.define_table('article',
  Field('title', 'string', length=255,required=True),
  Field('description', 'text',required=True),
)
db.define_table('post',
  Field('title', 'string', length=255,required=True),
  Field('description', 'text',required=True),
)
db.define_table('page',
  Field('title', 'string', length=255,required=True),
  Field('description', 'text',required=True),
)

And I have a table with many-to-many relationship (with different
tables):

db.define_table('action',
  Field('user_id','reference
auth_user',default=auth.user_id,required=True),
 
Field('action','string',requires=IS_IN_SET(('fav','subscribe','report','follow')),required=True),
  Field('table',requires=???,required=True),
  Field('table_id','integer',default=???,required=True),
)

My questions:
1.. The field, "table" is actually one of the tables, article/post/
page. Is the only correct way to use
requires=IS_IN_SET(('article','post','page')) ?

2.. "table_id" is actually dependent on the "table" selected. what
should I put for "default=???"

3.. Can I set a different set of IS_IN_SET for "action" field,
depending on the "table" field chosen?

4.. Finally, if the above is the wrong approach, how should I do it
correctly (best practice?)

Thanks!




[web2py] Re: How do Global Variables Work?

2012-01-05 Thread Anthony
On Thursday, January 5, 2012 10:14:45 AM UTC-5, Peter O wrote:
>
> http://web2py.com/books/default/chapter/29/5?search=globals%28%29


The globals being accessed in the above linked example (which is actually 
the 'welcome' app layout.html) are defined either in models or in another 
(included) view, not in a controller.
 

> I see. Am I right that View doesn't see the global variables (in 
> Controller), but the parent View sees the variables in View as global 
> variables?
>

It depends. An extended view sees variables defined in an extending view if 
(a) the variables are defined in the extending view before the {{extend}} 
directive, or (b) the variables are referenced in the extended view after 
the point where the extending view has been included. The sidebar example 
in 'welcome' linked above works via (a). Note that /default/index.html in 
'welcome' starts with:

{{left_sidebar_enabled,right_sidebar_enabled=False,True}}
{{extend 'layout.html'}}

By defining left_sidebar_enabled and right_sidebar_enabled before extending 
layout.html, those variables are defined before any of the layout.html code 
is executed, so they are available anywhere in layout.html (including 
within any other views included within layout.html). When executing a view, 
web2py first pieces together the entire page, with all extends and 
includes, and then it executes the Python code to generate the HTML.
 

> Then, what causes the difference between Example 1 and 2? What's the 
> relationship between the 'environment' and the 'context' in response? How 
> do I access the 'environment' explicitly in the Controller?
>

In your second example, you have:

response.render('default/test.html', globals()) 

Passing globals() to response.render() adds all the globals to the 
environment in which the view is rendered (actually, most of the objects in 
globals() are already in the view environment, so you are only really 
adding any new globals created in the controller). Your first example would 
be equivalent to:

response.render('default/test.html', dict()) 

which is simply equivalent to:

response.render('default/test.html') 

In that case, the view environment includes all the globals defined in the 
models (as well as the web2py framework globals), but you haven't added any 
variables generated in the controller to the view environment.

Anthony


Re: [web2py] Re: Selecting Latest Thread for a specific category

2012-01-05 Thread Andrew Evans
Hey ty that helped enough to solve my problem


db((db.forum_post.category == db.category.id) & (db.category.id ==
forums.id)).select(db.forum_post.ALL,
orderby=~db.forum_post.id, limitby=(0,1))

the "forums" value is a loop through the categories :-)

*cheers

ty very much for your help



On Wed, Jan 4, 2012 at 8:38 PM, Anthony  wrote:

> Do you have a particular category to select from? If so, you need to add
> that condition to your query. Assuming some_id is the id of the category
> you want:
>
> db((db.forum_post.category == db.category.id) & (db.category.id ==
> some_id)).select(db.**foru**m_post.ALL, orderby=~db.forum_post.id
> , limitby=(0,1))
>
> Or are you trying to do something else?
>
> Anthony
>
>
> On Wednesday, January 4, 2012 9:04:01 PM UTC-5, Andrew wrote:
>
>> Hi no its not on GAE
>>
>> I do get the last post but its for the last category posted in here is a
>> link you can see :-)
>>
>> http://www.fireflywra.com/**forum 
>>
>> *cheers
>>
>>
>> On Wed, Jan 4, 2012 at 5:10 PM, Anthony  wrote:
>>
>>> What do you get with that query? Is this on GAE (on GAE, I don't think
>>> the id's are necessarily in order)?
>>>
>>>
>>> On Wednesday, January 4, 2012 6:20:36 PM UTC-5, Andrew wrote:

 In some forum code, I am trying to select the latest thread specific
 to a forum category. But I am unsure how to do this

 Any ideas are greatly appreciated

 This is the code I tried with

 {{last_posts = db(db.forum_post.category ==
 db.category.id).select(db.**foru**m_post.ALL, orderby=~db.forum_post.id,

 limitby=(0,1))}}
>>>
>>>
>>


[web2py] Re: How do Global Variables Work?

2012-01-05 Thread Massimo Di Pierro
The list of global variables defined in models and passed to the
controllers are also passed to the view (for example the views see db,
request, session, etc. globals variables defined in controllers are
not passes to the view unless done explicitely.

On Jan 5, 8:03 am, Peter O  wrote:
> Hihi,
>
> I am baffled by what I see between Example 1 and 2.
>
> It may be a good case to improve my understanding of the run-time
> environment of web2py.
>
> Thanks in advance for any comments.
>
> VIEW: (test.html)
>
>   
> {{=globals().get('t1', False)}}
>   
>
> CONTROLLER:
>
> == Example 1 ==
>
> def test():
>     global t1
>     t1 = True
>     return dict() # the browser show 'False'. I was expecting 'True'
>
> == Example 2 ==
>
> def test():
>     global t1
>     t1 = True
>
>     response.render('default/test.html', globals() ) #the return is
> discarded
>
>     return dict() # the browser show 'True'. I was expecting the same
> result as Example 1.


[web2py] Re: MARKMIN clarification

2012-01-05 Thread Massimo Di Pierro
Please log it. I will fix it asap but log it so I do not forget.

On Jan 5, 8:30 am, lyn2py  wrote:
> Should I log an issue for this? Or might it already be fixed?
>
> On Jan 2, 10:25 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > I agree with you something is wrong... and needs fixing.
>
> > On Jan 2, 7:26 am, lyn2py  wrote:
>
> > > I double-checked... there are no extra spaces after the dashes.
>
> > > I tried on a new post, this is the produced HTML:
> > > here's some blockquote:
> > > this is a message
> > > for first parathis is a message
> > > for second parathis is a message
> > > for third para
> > > here's some blockquote:
> > > --
> > > this is a message
> > > for first parathis is a message
> > > for second parathis is a message
> > > for third para
> > > --
>
> > > Thanks!
>
> > > On Jan 2, 1:01 pm, Massimo Di Pierro 
> > > wrote:
>
> > > > This could be a bug. It is possible you have extra spaces after some
> > > > of the ?
>
> > > > On Jan 1, 5:59 pm, lyn2py  wrote:
>
> > > > > MARKMIN blockquote: I can't have 2 blockquotes in a single message?
>
> > > > > This is the text I used, and only the one on top was generated as a
> > > > > blockquote. The one below was like the rest of the body.
>
> > > > > here's some blockquote:
> > > > > --
> > > > > this is a message
> > > > > for first para
>
> > > > > this is a message
> > > > > for second para
>
> > > > > this is a message
> > > > > for third para
> > > > > --
>
> > > > > here's a second blockquote (not rendered properly):
> > > > > --
> > > > > this is a message
> > > > > for first para
>
> > > > > this is a message
> > > > > for second para
>
> > > > > this is a message
> > > > > for third para
> > > > > --
>
> > > > > If I add more blockquotes, the last one always doesn't render
> > > > > properly.
>
> > > > > Is this a bug?
>
> > > > > On Dec 31 2011, 12:22 am, Massimo Di Pierro
>
> > > > >  wrote:
> > > > > > Two new lines in markmin translate into an end of paragraph in 
> > > > > > html, a
> > > > > > single new line is interpreted as a continuation of the same
> > > > > > paragraph.
>
> > > > > > On Dec 30, 1:51 am, lyn2py  wrote:
>
> > > > > > > Does MARKMIN have issues with processing newlines?
> > > > > > > Because I can't use formatting here, everything looks like the 
> > > > > > > same
> > > > > > > text, but in MARKMIN the formatting is ok, only the newlines is 
> > > > > > > not
> > > > > > > ok.
>
> > > > > > > (1) I noticed that newlines don't convert to  in MARKMIN, 
> > > > > > > which is
> > > > > > > strange.
>
> > > > > > > Example:
> > > > > > > I write this
> > > > > > > in two lines
>
> > > > > > > MARKMIN processes it as: I write thisin two lines
>
> > > > > > > But 2 newlines automatically converts to a paragraph (which is
> > > > > > > correct).
>
> > > > > > > (2) Also, when using verbatim ``
>
> > > > > > > Example:
> > > > > > > ``I write this``
>
> > > > > > > ``in two paragraphs``
>
> > > > > > > MARKMIN: I write thisin two paragraphs
>
> > > > > > > (3) Using a mix of verbatim/italics/bold
>
> > > > > > > Example:
> > > > > > > ``an edit as usual``
>
> > > > > > > ``another``
>
> > > > > > > ''one or the other''
> > > > > > > **could be bolded**
>
> > > > > > > MARKMIN:
> > > > > > > an edit as usualanother
>
> > > > > > > one or the other could be bolded
>
> > > > > > > Notice the inconsistency in processing newlines (and spaces).
> > > > > > > Is this correct behavior of MARKMIN?


[web2py] Re: How do Global Variables Work?

2012-01-05 Thread Peter O
http://web2py.com/books/default/chapter/29/5?search=globals%28%29

I see. Am I right that View doesn't see the global variables (in 
Controller), but the parent View sees the variables in View as global 
variables?

Then, what causes the difference between Example 1 and 2? What's the 
relationship between the 'environment' and the 'context' in response? How 
do I access the 'environment' explicitly in the Controller?



Re: [web2py] How do Global Variables Work?

2012-01-05 Thread Anthony

>
> However, what's the purpose of global variables? I thought this conflicts 
> with one of the examples in the Introduction chapter.
>

Which example? 


[web2py] Re: How do Global Variables Work?

2012-01-05 Thread Anthony
See http://web2py.com/books/default/chapter/29/4#Workflow:

"The view sees every variable defined in the models as well as those in the 
dictionary returned by the action, but does not see global variables 
defined in the controller."

web2py builds an environment and runs the models in that environment (which 
may then add objects to it). It then creates a copy of the environment 
before running the controller, and after running the controller, it adds 
the items returned in the dictionary by the controller to the 
pre-controller copy of the environment, which is where the view is 
executed. You can see this 
here: http://code.google.com/p/web2py/source/browse/gluon/main.py#200

Anthony

On Thursday, January 5, 2012 9:03:03 AM UTC-5, Peter O wrote:
>
> Hihi,
>
> I am baffled by what I see between Example 1 and 2.
>
> It may be a good case to improve my understanding of the run-time 
> environment of web2py.
>
> Thanks in advance for any comments.
>
> VIEW: (test.html)
>
>   
> {{=globals().get('t1', False)}}
>   
>
> CONTROLLER:
>
> == Example 1 ==
>
> def test():
> global t1
> t1 = True
> return dict() # the browser show 'False'. I was expecting 'True'
>
> == Example 2 ==
>
> def test():
> global t1
> t1 = True
>
> response.render('default/test.html', globals() ) #the return is 
> discarded
>
> return dict() # the browser show 'True'. I was expecting the same 
> result as Example 1.
>
>
>
>
>
>

Re: [web2py] How do Global Variables Work?

2012-01-05 Thread Peter O
I understand explicitly passing the variable will do the work.

However, what's the purpose of global variables? I thought this conflicts 
with one of the examples in the Introduction chapter.

Secondly, I don't understand the different results between Example 1 and 2. 
Something deeper is happening here, I feel.


[web2py] Re: Need to update the twitter book example?

2012-01-05 Thread Alan Etkin
Sorry for the late post. The admin twitter issue should be fixed in
trunk.

http://code.google.com/p/web2py/issues/detail?id=577

On 21 dic 2011, 22:19, lyn2py  wrote:
> Not sure if you have noticed, but the web2py admin tweets are also not
> showing up since 1.99.3
>
> On Dec 21, 1:34 pm, Anthony  wrote:
>
> > Yeah, I had an app using the old method -- looks like Twitter recently
> > dropped support for that method. I guess we should update the book.
>
> > On Tuesday, December 20, 2011 6:25:19 PM UTC-5,AlanEtkinwrote:
>
> > > It seems that the get tweets example from the book (14.12) is not
> > > working anymore:
>
> > > When requesting from the browser's address field this location:
>
> > >http://twitter.com/username?format=json
>
> > > The output is an html page
>
> > > I had to change the address to the twitter rest api search command:
>
> > > Here is the related documentation
> > >https://dev.twitter.com/docs/api/1/get/search
>
> > > Does the current book example works for anybody?
>
>


[web2py] Re: MARKMIN clarification

2012-01-05 Thread lyn2py
Should I log an issue for this? Or might it already be fixed?

On Jan 2, 10:25 pm, Massimo Di Pierro 
wrote:
> I agree with you something is wrong... and needs fixing.
>
> On Jan 2, 7:26 am, lyn2py  wrote:
>
>
>
>
>
>
>
> > I double-checked... there are no extra spaces after the dashes.
>
> > I tried on a new post, this is the produced HTML:
> > here's some blockquote:
> > this is a message
> > for first parathis is a message
> > for second parathis is a message
> > for third para
> > here's some blockquote:
> > --
> > this is a message
> > for first parathis is a message
> > for second parathis is a message
> > for third para
> > --
>
> > Thanks!
>
> > On Jan 2, 1:01 pm, Massimo Di Pierro 
> > wrote:
>
> > > This could be a bug. It is possible you have extra spaces after some
> > > of the ?
>
> > > On Jan 1, 5:59 pm, lyn2py  wrote:
>
> > > > MARKMIN blockquote: I can't have 2 blockquotes in a single message?
>
> > > > This is the text I used, and only the one on top was generated as a
> > > > blockquote. The one below was like the rest of the body.
>
> > > > here's some blockquote:
> > > > --
> > > > this is a message
> > > > for first para
>
> > > > this is a message
> > > > for second para
>
> > > > this is a message
> > > > for third para
> > > > --
>
> > > > here's a second blockquote (not rendered properly):
> > > > --
> > > > this is a message
> > > > for first para
>
> > > > this is a message
> > > > for second para
>
> > > > this is a message
> > > > for third para
> > > > --
>
> > > > If I add more blockquotes, the last one always doesn't render
> > > > properly.
>
> > > > Is this a bug?
>
> > > > On Dec 31 2011, 12:22 am, Massimo Di Pierro
>
> > > >  wrote:
> > > > > Two new lines in markmin translate into an end of paragraph in html, a
> > > > > single new line is interpreted as a continuation of the same
> > > > > paragraph.
>
> > > > > On Dec 30, 1:51 am, lyn2py  wrote:
>
> > > > > > Does MARKMIN have issues with processing newlines?
> > > > > > Because I can't use formatting here, everything looks like the same
> > > > > > text, but in MARKMIN the formatting is ok, only the newlines is not
> > > > > > ok.
>
> > > > > > (1) I noticed that newlines don't convert to  in MARKMIN, which 
> > > > > > is
> > > > > > strange.
>
> > > > > > Example:
> > > > > > I write this
> > > > > > in two lines
>
> > > > > > MARKMIN processes it as: I write thisin two lines
>
> > > > > > But 2 newlines automatically converts to a paragraph (which is
> > > > > > correct).
>
> > > > > > (2) Also, when using verbatim ``
>
> > > > > > Example:
> > > > > > ``I write this``
>
> > > > > > ``in two paragraphs``
>
> > > > > > MARKMIN: I write thisin two paragraphs
>
> > > > > > (3) Using a mix of verbatim/italics/bold
>
> > > > > > Example:
> > > > > > ``an edit as usual``
>
> > > > > > ``another``
>
> > > > > > ''one or the other''
> > > > > > **could be bolded**
>
> > > > > > MARKMIN:
> > > > > > an edit as usualanother
>
> > > > > > one or the other could be bolded
>
> > > > > > Notice the inconsistency in processing newlines (and spaces).
> > > > > > Is this correct behavior of MARKMIN?


Re: [web2py] How do Global Variables Work?

2012-01-05 Thread Bruno Rocha
you need to pass it

return dict(t1=t1)

or

return locals()

http://zerp.ly/rochacbruno
Em 05/01/2012 12:03, "Peter O"  escreveu:

> Hihi,
>
> I am baffled by what I see between Example 1 and 2.
>
> It may be a good case to improve my understanding of the run-time
> environment of web2py.
>
> Thanks in advance for any comments.
>
> VIEW: (test.html)
>
>   
> {{=globals().get('t1', False)}}
>   
>
> CONTROLLER:
>
> == Example 1 ==
>
> def test():
> global t1
> t1 = True
> return dict() # the browser show 'False'. I was expecting 'True'
>
> == Example 2 ==
>
> def test():
> global t1
> t1 = True
>
> response.render('default/test.html', globals() ) #the return is
> discarded
>
> return dict() # the browser show 'True'. I was expecting the same
> result as Example 1.
>
>
>
>
>
>


[web2py] How do Global Variables Work?

2012-01-05 Thread Peter O
Hihi,

I am baffled by what I see between Example 1 and 2.

It may be a good case to improve my understanding of the run-time 
environment of web2py.

Thanks in advance for any comments.

VIEW: (test.html)

  
{{=globals().get('t1', False)}}
  

CONTROLLER:

== Example 1 ==

def test():
global t1
t1 = True
return dict() # the browser show 'False'. I was expecting 'True'

== Example 2 ==

def test():
global t1
t1 = True

response.render('default/test.html', globals() ) #the return is 
discarded

return dict() # the browser show 'True'. I was expecting the same 
result as Example 1.







Re: [web2py] Re: utf-8 and pyfpdf

2012-01-05 Thread Martin Weissenboeck
Thank you.
I had to change the following lines:

1247   table = TABLE( _border="0", _align="center", _width="50%, *rows")

1305   table = TABLE(   _border="1", _align="center", _width="100%",
*[head,foot, body])

2012/1/4 Christopher Steel 

> French and English pdf examples (and some others if you dig a bit)
>
> http://code.google.com/p/uc-pdf/downloads/list
>


Re: [web2py] Re: Movuca - The Social CMS - Need Testers and Contributors

2012-01-05 Thread Martín Mulone
nice bruno, what does it mean movuca?

2012/1/5 Bruno Rocha 

> On Thu, Jan 5, 2012 at 9:27 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Looks really slick
>
>
>
> This is the "basic" theme, I am working on two more themes. One based in
> Foundation and another in twitter bootstrap. It is all modular so its easy
> to create new themes.
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>


-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] Re: Movuca - The Social CMS - Need Testers and Contributors

2012-01-05 Thread Bruno Rocha
On Thu, Jan 5, 2012 at 9:27 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Looks really slick



This is the "basic" theme, I am working on two more themes. One based in
Foundation and another in twitter bootstrap. It is all modular so its easy
to create new themes.

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: Movuca - The Social CMS - Need Testers and Contributors

2012-01-05 Thread Massimo Di Pierro
Looks really slick.



On Jan 5, 4:36 am, Bruno Rocha  wrote:
> Hi,
>
> I am developing a Social CMS, I was very inspired by vikuit.com but I made
> some conceptual improvements on what I think is a Social CMS.
>
> This is a simple system based in Articles, Content Types, Themes, Users,
> Activities etc...
>
> The code is in github[1] and you have to note that I am trying a different
> approach which is very un-web2pythonic and it is already under tests.
>
> The demo page is alive[2] Please help me test it! register, login, create
> articles, like, dislike, favorite, comment etc...
>
> If you have suggestions or ideas please let me know!
>
> * this will be released as Creative Commons Share-a-like-attribution license
>
> I need opinions, testers and contributors.
>
> [1]https://github.com/rochacbruno/Movuca(repo)
> [2]http://labs.blouweb.com/movuca (DEMO)
>
> * if you want to install it, just run setup/install to load system fixtures
> * you need web2py trunk
> * you need PIL
> * not sure if runs on GAE
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]


[web2py] Movuca - The Social CMS - Need Testers and Contributors

2012-01-05 Thread Bruno Rocha
Hi,

I am developing a Social CMS, I was very inspired by vikuit.com but I made
some conceptual improvements on what I think is a Social CMS.

This is a simple system based in Articles, Content Types, Themes, Users,
Activities etc...

The code is in github[1] and you have to note that I am trying a different
approach which is very un-web2pythonic and it is already under tests.

The demo page is alive[2] Please help me test it! register, login, create
articles, like, dislike, favorite, comment etc...

If you have suggestions or ideas please let me know!

* this will be released as Creative Commons Share-a-like-attribution license

I need opinions, testers and contributors.

[1] https://github.com/rochacbruno/Movuca (repo)
[2] http://labs.blouweb.com/movuca  (DEMO)

* if you want to install it, just run setup/install to load system fixtures
* you need web2py trunk
* you need PIL
* not sure if runs on GAE

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: How to create pdfs using markmin2pdf with Windows 7

2012-01-05 Thread stefaan

> I am not sure if miktex includes pdflatex. I only used it on linux but
> it should be easy to define it after miktex is installed.

MiKTeX *does* indeed contain pdflatex.