[web2py] Re: Why URL(..., scheme=True, ...) is implemented differently than request.is_https?

2019-07-23 Thread Ray (a.k.a. Iceberg)
Thanks Anthony for the suggestion! I created a PR just now. 
https://github.com/web2py/web2py/pull/2233

Was wondering which place would be easier to draw the maintainers' 
attention, an issue/PR on github.com/web2py/web2py or a new post in this 
group/forum. :-)

Regards,
Ray

On Wednesday, July 17, 2019 at 2:44:53 PM UTC-7, Anthony wrote:
>
> Feel free to submit a pull request. Or just set scheme='https' if you know 
> it is HTTPS.
>
> Anthony
>
> On Tuesday, July 16, 2019 at 4:31:06 AM UTC-4, Ray (a.k.a. Iceberg) wrote:
>>
>> Hi there,
>>
>> I tend to use
>>
>> URL(..., scheme=True, ...)
>>
>> in my apps to generate an absolute URL, as documented here 
>> <http://web2py.com/books/default/chapter/29/04/the-core#Absolute-urls>.
>>
>> However, one of my app which has been deployed behind Apache wsgi with 
>> https, I noticed that the generated absolute URLs still use non-secure 
>> "http://...";.
>>
>> It is said that there can be some special situation that the wsgi 
>> setting would be inaccurate 
>> <https://stackoverflow.com/questions/43906350/djangos-request-meta-getwsgi-url-scheme-returns-http-instead-of-https>.
>>  
>> However my question here for web2py is, why URL(..., scheme=True, ...) 
>> is implemented to depend on wsgi_url_scheme ONLY 
>> <https://github.com/web2py/web2py/blob/R-2.18.3/gluon/rewrite.py#L207>, 
>> while the is_https is more sophisticated 
>> <https://github.com/web2py/web2py/blob/R-2.18.3/gluon/main.py#L366-L367>? 
>> And, why does URL(..., scheme=True, ...) NOT depend on the more 
>> sophisticated is_https instead?
>>
>> Regards,
>> Ray
>>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/01602063-ca30-4117-b8c7-bea4d102988b%40googlegroups.com.


[web2py] Re: Why URL(..., scheme=True, ...) is implemented differently than request.is_https?

2019-07-17 Thread Ray (a.k.a. Iceberg)
The problem is NOT about how to setup apache to redirect http to https. I 
am already doing that. But, in fact, it was such a redirection, combining 
with the unfortunate fact that web2py's URL(..., scheme=True) still 
generating "http://..."; links, causing my RESTful API to malfunction. Who 
would know an http PUT request would lost its http body after a 
redirection? Nonetheless, in my previous post, I already narrowed down to 
the root cause, and asked: why URL(..., scheme=True) is currently 
implemented as detecting wsgi_url_scheme env var, rather than simply 
relying on the more sophisicated request.is_https?

Regards,
Ray

On Tuesday, July 16, 2019 at 2:18:45 PM UTC-7, Paco Bernal wrote:
>
> You can always redirect apache from http to https

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e6a3c5f0-2076-4182-a95c-26c212fe56e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Why URL(..., scheme=True, ...) is implemented differently than request.is_https?

2019-07-16 Thread Ray (a.k.a. Iceberg)
Hi there,

I tend to use

URL(..., scheme=True, ...)

in my apps to generate an absolute URL, as documented here 
.

However, one of my app which has been deployed behind Apache wsgi with 
https, I noticed that the generated absolute URLs still use non-secure 
"http://...";.

It is said that there can be some special situation that the wsgi setting 
would be inaccurate 
.
 
However my question here for web2py is, why URL(..., scheme=True, ...) is 
implemented to depend on wsgi_url_scheme ONLY 
, 
while the is_https is more sophisticated 
? 
And, why does URL(..., scheme=True, ...) NOT depend on the more 
sophisticated is_https instead?

Regards,
Ray

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/274b4a55-3600-4b8b-ae86-c0dfd62e40bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: record representation format that refer to another table and that table is refer to another table

2019-04-24 Thread Ray (a.k.a. Iceberg)
I know I'm late to the party, but I have to write to thank Anthony for 
sharing such a wonderful trick!

One more thing, I happen to also discover that we do not have to use 
lambda. The following form is less verbose, more intuitive.

db.define_table('room',
Field('room_no'),
Field('category', 'list:string'),
Field('status', 'list:string'),
Field('branch', 'reference branch'),
format='%(branch.address) %(room_no)s')

Thanks everyone, especially Massimo for building such an amazingly flexible 
web2py!

Regards,
Ray

On Saturday, March 23, 2013 at 6:48:59 AM UTC-7, Anthony wrote:
>
> Oh, yeah, even better, you can make the "format" attribute a function (it 
> takes a record of its own table) -- so:
>
> db.define_table('room',
> Field('room_no'),
> Field('category', 'list:string'),
> Field('status', 'list:string'),
> Field('branch', 'reference branch'),
> format=lambda r: '%s %s' % (r.branch.address, r.room_no))
>
> Anthony
>
> On Saturday, March 23, 2013 1:41:38 AM UTC-4, 黄祥 wrote:
>>
>> just curious, is it possible to add the format function in the table room?
>>
>>
>>
>>
>>

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


[web2py] FYI: A tutorial on how to customize export in SQLFORM.grid

2018-04-01 Thread Ray (a.k.a. Iceberg)
Stumbled upon this blog post "Export in web2py's SQLFORM.grid 
" by Prasad Muley. It provides 
concrete example on how to customize an exporter TO REMOVE THE TABLE PREFIX 
IN CSV HEADER LINE. That is easier to digest than the standard web2py 
book's one-liner 

 
"(exporters) are all defined in gluon/sqlhtml.py. Take a look at those for 
creating your own exporter.".

Hope that helps! Enjoy!

Regards,
Ray


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


[web2py] What happened to the on-screen time picker widget?

2017-12-24 Thread Ray (a.k.a. Iceberg)
Hi there,

I have been using web2py several years ago and I'm picking it up again 
recently. (Actually, web2py never left me. It is like riding a bike, once 
you learn you never forget! And that's largely due to Massimo's committment 
to keep web2py backward-compatible.)

OK let's cut to the chase. I remember back then we had 3 on-screen pickers 
for "time", "date", "datetime", respectively. Today when I add a time field 
to my existing app, there is no time selector widget pops up on my page. At 
first I thought its absense was caused by my (incorrectly?) customized 
layouts but, after some time-consuming investigation, I realize that the 
recent web2py simply does not ship with an on-screen time picker widget 
anymore, but chooses to filter invalid keyboard input instead.

I can probably deal with the status quo, but may I ask why that previous 
time picker widget is gone? I thought the previous one worked better with 
touch screen.

Happy Christmas!

Regards,
Ray

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


Re: [web2py] Re: A bug in _after_insert callback's document (book)? And more.

2015-04-23 Thread Ray (a.k.a. Iceberg)


On Wednesday, April 22, 2015 at 6:56:13 AM UTC-7, Anthony wrote:
>
> It is a different story when building a RESTful API. There would be no 
>> rendering behavior before form submission, and normally I use state-less 
>> HTTP basic auth and then purposely turn off session feature. Unless I force 
>> my api callers to do HTTP POST first, to yet another dedicated "token" api, 
>> which will issue the token and also store it into some backend storage 
>> (such as a DB or central key-value service), blah blah. But this sounds not 
>> "lightweight" at all.
>>
> You could have the client generate its own unique token with each request 
> (e.g., a UUID or timestamp) and cache that on the server for some period of 
> time -- if another request comes in with the same token, then ignore the 
> request and return an appropriate message (perhaps indicating whether a 
> previous request was successful, in case the client didn't receive the 
> success message from an earlier attempt).
>
> Thanks Anthony. That is a very creative idea indeed! I would try to go one 
step further, to let the server to calculate a hash based on request.path 
AND request.vars AND http header date field, so that it would become a 
universal double-submission protection, WITHOUT needing to change the 
client side at all. After all, semantics is important in RESTful api, and 
such UUID is typically not in original api parameters. Of course, all these 
are based on an assumption that there should never be a need to create 2 
fully identical records in one table.

PS: I may not try it anytime soon, because I gonna enable the unique=True 
(and manually create the unique index for my auth_user table) anyway, and 
then I got the protection, for free. Still thanks a lot!

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


[web2py] Re: A bug in _after_insert callback's document (book)? And more.

2015-04-17 Thread Ray (a.k.a. Iceberg)


On Friday, April 17, 2015 at 6:35:09 AM UTC-7, Anthony wrote:
>
> 2. Even without above snippet, in our context I would say a rare 
 500-response-but-it-would-be-gone-if-you-simply-retry is (arguably?) still 
 better than, silently creating duplicated user accounts which clearly 
 violates the universal expectation of such a fundamental db scheme 
 assumption.

>>>
>>> This doesn't seem to be a likely problem -- two different users would 
>>> have to be trying to register with the same username/email within 
>>> milliseconds of each other. On the other hand, I suppose this would make 
>>> the 500 response in such a case equally rare (assuming we set unique=True 
>>> in the table definition).
>>>
>>> Well, in my case, the delay was caused by sending email, so it is 
>> definitely not "milliseconds of each other". It takes some 2 or 3 seconds, 
>> maybe even longer. And during this period, it is not that another user 
>> would try to register with same username/email, it is somehow the same user 
>> request would (seemingly?) be resent (by the user's app or by my reverse 
>> proxy apache or by a wsgi middleware or whatever, which I don't know yet).
>>
>
> Got it, but that sounds like a bug to be fixed. It shouldn't be possible 
> to re-submit the standard registration form twice because the _formkey 
> token prevents duplicate submissions. Are you using a different method for 
> submitting registration data?
>

It is because I am providing a RESTFUL api for the app to call. That is why 
I (have to?) bypass all the good things in the default form-based 
infrastructure such as double submit prevention. Sad but true.
 

>  
>
>> Although I agree with your earlier suggestion to re-engineer the email 
>> sending part to a separated queue, which is a good idea indeed, but as a 
>> more general topic, I still think it would be good to have web2py to define 
>> unique=True for username and/or email in auth_user table by default. 
>> Personally I am willing to trade a rare (0.01%?) chance of a user-scary 500 
>> error ticket for the 100% guarantee of no duplication in auth_user table. 
>> Don't you think so?
>>
>
> Sounds reasonable. Maybe submit an issue and/or bring it up on the 
> developers list.
>
>
OK. See https://github.com/web2py/web2py/issues/921

By the way, thank you Anthony for your follow-up info in another post about 
the manually setup unique=True workaround.

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


[web2py] Re: A bug in _after_insert callback's document (book)? And more.

2015-04-16 Thread Ray (a.k.a. Iceberg)


On Thursday, April 16, 2015 at 11:55:02 AM UTC-7, Anthony wrote:
>
> 1. To address your concern about "an attempted duplicate entry will end 
>> up raising an exception and returning a 500 response unless you catch and 
>> handle the error.", we could probably add something like this snippet at 
>> the (nearly) end of the "if form.accepts(...)" branch inside that 
>> register() in tools.py:
>>
>> try:
>> db.commit()
>> except Exception as e:
>> db.rollback()
>> response.flash = "Something is wrong. %s" % e  # It is better 
>> than nothing
>>
>
> We don't want to do explicit commits like this because that will commit 
> any previous operations as well, which means those operations would not be 
> rolled back in case there is a subsequent error (i.e., this violates the 
> principle that each request should be wrapped in a single transaction).
>

OK, good point on explicit commits. Now I agree not to add that snippet 
into tools.py. But then, see below.
 

>
> 2. Even without above snippet, in our context I would say a rare 
>> 500-response-but-it-would-be-gone-if-you-simply-retry is (arguably?) still 
>> better than, silently creating duplicated user accounts which clearly 
>> violates the universal expectation of such a fundamental db scheme 
>> assumption.
>>
>
> This doesn't seem to be a likely problem -- two different users would have 
> to be trying to register with the same username/email within milliseconds 
> of each other. On the other hand, I suppose this would make the 500 
> response in such a case equally rare (assuming we set unique=True in the 
> table definition).
>
> Well, in my case, the delay was caused by sending email, so it is 
definitely not "milliseconds of each other". It takes some 2 or 3 seconds, 
maybe even longer. And during this period, it is not that another user 
would try to register with same username/email, it is somehow the same user 
request would (seemingly?) be resent (by the user's app or by my reverse 
proxy apache or by a wsgi middleware or whatever, which I don't know yet). 
As a result, I saw duplication actually happening in my db every now and 
then. FYI: Their creation time stamp vary among 1 to 3 seconds.

Although I agree with your earlier suggestion to re-engineer the email 
sending part to a separated queue, which is a good idea indeed, but as a 
more general topic, I still think it would be good to have web2py to define 
unique=True for username and/or email in auth_user table by default. 
Personally I am willing to trade a rare (0.01%?) chance of a user-scary 500 
error ticket for the 100% guarantee of no duplication in auth_user table. 
Don't you think so?

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


[web2py] Re: A bug in _after_insert callback's document (book)? And more.

2015-04-16 Thread Ray (a.k.a. Iceberg)


On Thursday, April 16, 2015 at 7:01:22 AM UTC-7, Anthony wrote:
>
> A followup question. The reason I need my clumsy 
 customized_email_verification() in the first place, is because I seemingly 
 have to do db.commit() BEFORE the time consuming email sending job. 
 Otherwise I saw some randomly duplicated records in my auth_user table. I 
 don't know the exact reason but my guess is, the tools.py's 
 define_tables() 
 uses IS_NOT_IN_DB() validators which only work in web2py level, but does 
 NOT define any "unique=True" in the DB level. Is this considered as a 
 defect?

>>>
>>> It's not a defect, just something you have to handle properly in your 
>>> code. You can separately set the unique=True argument when creating the 
>>> model, and that will be enforced by the database, 
>>>
>>
>> I know I can always define my OTHER tables properly. But now we are 
>> talking about the web2py built-in auth_user table. Do I have to redefine 
>> them in my models/db.py EVERY TIME I start a new project? That doesn't 
>> sound right. Is there any reason we don't want to do that inside 
>> gluon/tools.py?
>>
>
> I think you should be able to set the "unique" attribute of individual 
> fields after the table has been defined, so you shouldn't need to re-define 
> the entire table. I don't think we want to set that attribute in tools.py 
> because we would then need a mechanism for catching database errors that 
> might be generated.
>
> Anthony
>

Thanks for your hint, Anthony. I did not realize that I can set that 
"unique" attribute after db.define_tables(). Will definitely try to do that 
in my projects.

That said, I still believe this should be a default behavior for an 
out-of-box web2py app. Reasons below.

1. To address your concern about "an attempted duplicate entry will end up 
raising an exception and returning a 500 response unless you catch and 
handle the error.", we could probably add something like this snippet at 
the (nearly) end of the "if form.accepts(...)" branch inside that 
register() in tools.py:

try:
db.commit()
except Exception as e:
db.rollback()
response.flash = "Something is wrong. %s" % e  # It is better than 
nothing

2. Even without above snippet, in our context I would say a rare 
500-response-but-it-would-be-gone-if-you-simply-retry is (arguably?) still 
better than, silently creating duplicated user accounts which clearly 
violates the universal expectation of such a fundamental db scheme 
assumption.

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


[web2py] Re: A bug in _after_insert callback's document (book)? And more.

2015-04-15 Thread Ray (a.k.a. Iceberg)


On Wednesday, April 15, 2015 at 5:11:22 PM UTC-7, Anthony wrote:
>
> However, I believe (at least in web2py 2.9.12) the first parameter in 
>> _after_insert() is NOT a dict, but a Row object. Because, my web2py app 
>> uses the following code in db.py, trying to send out a validation email to 
>> new registrated user:
>>
>> def customized_email_verification(row, row_id):
>>>
>> db(db.auth_user.id==row_id).update(registration_key="a random 
>>> string")  # I need this because my users are not registered from web UI 
>>
>> db.commit()  # commit BEFORE the time consuming email action, 
>>> otherwise a parallel requests could cause duplicated record in DB?!
>>
>> auth.settings.mailer.send(to=row["email"], subject="Hi", 
>> *message=customized_message 
>>> % row*)
>>> db.auth_user._after_insert.append(customized_email_verification)
>>
>>
>> and it ends up with a very confusing error as:
>>
>> TypeError: format requires a mapping
>>
>>
>> Finally I located that line and changed it into:
>>
>> ... customized_message % row.as_dict()
>>
>>
>> and then it works.
>>
>> So I am asking for your confirmation and suggest to fix the book 
>> accordingly.
>>
>
> Yes, the first argument is a Row object, so we should probably update the 
> book. However, your error is odd because you can generally use a Row object 
> in that way without explicitly converting it to a dictionary. What is the 
> content of customized_message and the Row object when this error is 
> generated?
>

Thanks for the hint, Anthony. You are right, normally "Welcome 
%(first_name)s" % row will just work.

In my case, it looks like the error also has some something to do with the 
i18n, although I did not really use the translation feature. This is the 
last part of the error trace.

  File "C:\REPO\web2py\applications\v1\models\db.py", line 134, in 
email_verification
message=auth.messages.verify_email % row  # .as_dict()
  File "C:\REPO\web2py\gluon\tools.py", line 468, in send
elif message.strip().startswith('",)

No wonder. Now we can use the following line to demonstrate the problem.

>>> "Welcome %(first_name)s, pls click %(link)s" % ("whatever string",)
TypeError: format requires a mapping

I did not further investigate what goes wrong inside the languages.py.


 
>
>> A followup question. The reason I need my clumsy 
>> customized_email_verification() in the first place, is because I seemingly 
>> have to do db.commit() BEFORE the time consuming email sending job. 
>> Otherwise I saw some randomly duplicated records in my auth_user table. I 
>> don't know the exact reason but my guess is, the tools.py's define_tables() 
>> uses IS_NOT_IN_DB() validators which only work in web2py level, but does 
>> NOT define any "unique=True" in the DB level. Is this considered as a 
>> defect?
>>
>
> It's not a defect, just something you have to handle properly in your 
> code. You can separately set the unique=True argument when creating the 
> model, and that will be enforced by the database, 
>

I know I can always define my OTHER tables properly. But now we are talking 
about the web2py built-in auth_user table. Do I have to redefine them in my 
models/db.py EVERY TIME I start a new project? That doesn't sound right. Is 
there any reason we don't want to do that inside gluon/tools.py?

 

> but your problem then is that an attempted duplicate entry will end up 
> raising an exception and returning a 500 response unless you catch and 
> handle the error.
>

I can do this part.
 

>
>
>> Anthony
>

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


[web2py] A bug in _after_insert callback's document (book)? And more.

2015-04-15 Thread Ray (a.k.a. Iceberg)
Hi folks,

The book describes DAL's _after_insert() callback 

 
as:

The caveat is that depending on the functionality, the callback has 
> different signature.
> This is best explained via some examples.
> >>> db.define_table('person',Field('name'))
> >>> def pprint(*args): print args
> >>> db.person._before_insert.append(lambda f: pprint(f))
> >>> db.person._after_insert.append(lambda f,id: pprint(f,id))   # WRONG 
> SIGNATURE?
> >>> db.person._before_update.append(lambda s,f: pprint(s,f))
> >>> db.person._after_update.append(lambda s,f: pprint(s,f))
> >>> db.person._before_delete.append(lambda s: pprint(s))
> >>> db.person._after_delete.append(lambda s: pprint(s))
> Here f is a dict of fields passed to insert or update, id is the id of 
> the newly inserted record, s is the Set object used for update or delete.
> >>> db.person.insert(name='John')
> ({'name': 'John'},)
> ({'name': 'John'}, 1)# WRONG EXAMPLE?


However, I believe (at least in web2py 2.9.12) the first parameter in 
_after_insert() is NOT a dict, but a Row object. Because, my web2py app 
uses the following code in db.py, trying to send out a validation email to 
new registrated user:

def customized_email_verification(row, row_id):
>
db(db.auth_user.id==row_id).update(registration_key="a random string") 
>  # I need this because my users are not registered from web UI 

db.commit()  # commit BEFORE the time consuming email action, otherwise 
> a parallel requests could cause duplicated record in DB?!

auth.settings.mailer.send(to=row["email"], subject="Hi", 
*message=customized_message 
> % row*)
> db.auth_user._after_insert.append(customized_email_verification)


and it ends up with a very confusing error as:

TypeError: format requires a mapping


Finally I located that line and changed it into:

... customized_message % row.as_dict()


and then it works.

So I am asking for your confirmation and suggest to fix the book 
accordingly.


A followup question. The reason I need my clumsy 
customized_email_verification() in the first place, is because I seemingly 
have to do db.commit() BEFORE the time consuming email sending job. 
Otherwise I saw some randomly duplicated records in my auth_user table. I 
don't know the exact reason but my guess is, the tools.py's define_tables() 
uses IS_NOT_IN_DB() validators which only work in web2py level, but does 
NOT define any "unique=True" in the DB level. Is this considered as a 
defect? Think about this sequence.

Now: the first user creation request is validated but by default not yet 
committed, and now sending email which will likely take 2 seconds
Now + 1 second: Somehow the client could resent same request. This request 
also passes validation, because there is no duplication in DB so far.
Now + 2 second: The email for request #1 has been sent. And record #1 is 
committed into DB.
Now + 3 second: The email for request #2 has been sent. And duplicated 
record #2 is committed into DB.

How can I improve such pattern? Thanks!

Regards,
Ray

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


[web2py] VARCHAR or NVARCHAR?

2015-04-14 Thread Ray (a.k.a. Iceberg)
Hi there,

Long story short, I am now working in a project with web2py trying to 
connect to a MSSQL database. My team tends to use the connect string as 
"mssql4://..." to take the advantage of the (latest and greatest?) 
MSSQL4Adapter, however we also notice from the dal source code mssql.py 
that, MSSQL4Adapter defines "string" as "VARCHAR", while an older 
MSSQL2Adapter defines "string" as "*N*VARCHAR".

It seems there is some other opinion in favor of "NVARCHAR" 

 for 
internationalization reason. But then why the web2py MSSQL4dapter chooses 
"VARCHAR" instead of "NVARCHAR"? Any insight?

Thanks in advance!

Regards,
Ray

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


[web2py] Re: Shouldn't request.is_local be false when a web2py behind apache being accessed by remote client?

2014-08-19 Thread Ray (a.k.a. Iceberg)
Suggest to put this 2 lines into the scaffold app's model.py:

# Uncomment following line if you deploy your web2py behind a proxy
# request.is_local = False

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


Re: [web2py] Re: web2py app as proxy... but how?

2014-08-19 Thread Ray (a.k.a. Iceberg)
Streaming the output or not does not make much difference here, because 
your source code is designed to read ALL input first. That causes the 
response feeling slow. Not to mention this approach won't work at all when 
dealing with large content.

A better way is to read a small amount of data and then relay it to the 
output. This is real streaming.


Regards,
Ray

On Tuesday, August 19, 2014 1:16:02 AM UTC-7, Niphlod wrote:
>
> not really, except that it's not streamed.
>
> On Tuesday, August 19, 2014 10:12:55 AM UTC+2, Manuele wrote:
>>
>> Il 19/08/14 09:27, Niphlod ha scritto: 
>> > from cStringIO import StringIO 
>> > def whateveryoumaycall(): 
>> > content = fetch_the_resource() 
>> > f = StringIO() 
>> > f.write(content) 
>> > f.seek(0) 
>> > #set the correct headers, such as 
>> > response.headers['Content-Type'] = 'blablabla' 
>> > response.headers['Content-Length'] = 31298312098312 
>> > . 
>> > return response.stream(content, ) 
>> ok more or less is what I'm doing... is there any advcantage by 
>> returning response.stream(content, ) instead of returning text as 
>> I'm doing now? 
>>
>> Thanks 
>>
>> M. 
>>
>

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


[web2py] Re: Shouldn't request.is_local be false when a web2py behind apache being accessed by remote client?

2014-08-19 Thread Ray (a.k.a. Iceberg)

On Monday, August 18, 2014 8:16:36 PM UTC-7, Ray (a.k.a. Iceberg) wrote:
>
> Hi web2py big family,
>
> I thought I had been using web2py for long enough but, still got stumbled 
> by this little issue. :-)
>
> I setup web2py behind apache (using the default setup script on 
> webfaction.com, if that matters). My site works, except the 
> request.is_local is always True. Here comes some of my request attributes:
>
>  
> env:
> remote_addr:
> 127.0.0.1
>
> http_x_forwarded_for:
> 70.184.77.217
>
>
> client:
> 70.184.77.217
>
>
>
> local_hosts:
>  (it contains no 70.184.77.217)
>
>
>
>
>
>
>
> is_local:
> True
>
>
> Checking the source code, it reads:
>
> is_local = env.remote_addr in local_hosts
>
> So it gives me a "True".
>
> But shouldn't we change it into "is_loca = client in local_hosts" so that 
> it would be False in this situation?
>
>
> Thanks in advance
>
>
>
FYI: Meanwhile, I use a quick workaround as to define a models/onsite.py 
containing only one line "request.is_local = False". 

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


[web2py] Shouldn't request.is_local be false when a web2py behind apache being accessed by remote client?

2014-08-18 Thread Ray (a.k.a. Iceberg)
Hi web2py big family,

I thought I had been using web2py for long enough but, still got stumbled 
by this little issue. :-)

I setup web2py behind apache (using the default setup script on 
webfaction.com, if that matters). My site works, except the 
request.is_local is always True. Here comes some of my request attributes:

 
env:
remote_addr:
127.0.0.1

http_x_forwarded_for:
70.184.77.217


client:
70.184.77.217



local_hosts:
 (it contains no 70.184.77.217)

is_local:
True


Checking the source code, it reads:

is_local = env.remote_addr in local_hosts

So it gives me a "True".

But shouldn't we change it into "is_loca = client in local_hosts" so that 
it would be False in this situation?


Thanks in advance




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


[web2py] Re: What is the purpose of auth.settings.login_userfield?

2014-04-06 Thread Ray (a.k.a. Iceberg)


On Sunday, April 6, 2014 12:03:59 AM UTC-7, Ray (a.k.a. Iceberg) wrote:
>
> Just want to double confirm.
>
> 1. I found many following lines in tools.py:
>
> userfield = self.settings.login_userfield or 'username' \
> if 'username' in table_user.fields else 'email'
>
> it means:
>
> if 'username' in table_user.fields:
> userfield = self.settings.login_userfield or 'username'
> else:
> userfield = 'email
>
>
> 2. If we used a slightly different source code like this:
>
> userfield = self.settings.login_userfield or ('username'
> if 'username' in table_user.fields else 'email')
>
> it means something quite different:
>
> if self.settings.login_userfield:  # if user explicitly define the 
> login_userfield
> userfield = self.settings.login_userfield  # then use it 
> unconditionally
> else:   # otherwise automatically determine one
> userfield = 'username' if 'username' in table_user.fields else 
> 'email'
>
>
> So, to double confirm, what is the design purpose of 
> auth.settings.login_userfield? If it is #1, I recommend to use a pair of 
> brackets to avoid misunderstanding.
>
> userfield = (self.settings.login_userfield or 'username'
> ) if 'username' in table_user.fields else 'email'
>
>
Well, now I believe the #2 purpose is the design intention, based on this 
section in Auth.register():

table_user = self.table_user()
if self.settings.login_userfield:
username = self.settings.login_userfield
elif 'username' in table_user.fields:
username = 'username'
else:
username = 'email'

In this case, I believe #1 is a bug and need to be fixed. 

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


[web2py] What is the purpose of auth.settings.login_userfield?

2014-04-06 Thread Ray (a.k.a. Iceberg)
I found many following lines in tools.py:

userfield = self.settings.login_userfield or 'username' \
if 'username' in table_user.fields else 'email'

Should it be this instead?

userfield = self.settings.login_userfield or ('username'
if 'username' in table_user.fields else 'email')

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


[web2py] Re: Can not run web2py_no_console.exe. Version 2.8.2 on win 7 x 64

2014-01-17 Thread Ray (a.k.a. Iceberg)


On Sunday, December 15, 2013 10:00:19 AM UTC-7, Rob Paire wrote:
>
> Hello all,
>  I am having same problem running on Windows server 2003 32bit. When I 
> launch web2py.exe the following dialog error appears: 
>
> *Title: Error Entry Point Not Found*
>
> *Description: The procedure entry point wcscpy_s could not be located in 
> the dynamic link library msvcrt.dll*
>
> Clicking OK returns control to the web2py executable which fails with the 
> following console message:
>
> C:\web2py>web2py
> Traceback (most recent call last):
>   File "", line 6, in 
>   File "__main__.py", line 128, in 
>   File "__main__web2py__.py", line 18, in 
>   File "/home/mdipierro/make_web2py/web2py/gluon/__init__.py", line 15, in 
>  le>
>   File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 19, in 
>  e>
>   File "/home/mdipierro/make_web2py/web2py/gluon/xmlrpc.py", line 10, in 
>  >
>   File "SimpleXMLRPCServer.py", line 102, in 
>   File "xmlrpclib.py", line 144, in 
>   File "httplib.py", line 79, in 
>   File "mimetools.py", line 6, in 
>   File "tempfile.py", line 35, in 
>   File "random.py", line 879, in 
>   File "random.py", line 97, in __init__
>   File "random.py", line 111, in seed
> WindowsError: [Error -2146893795] Provider DLL failed to initialize 
> correctly
>
> I reverted back to 2.7.4 for the time being.
>
>  
Same problem here.  I guess that *msvcrt.dll* thing is because the 
web2py282 windows builder is running on a different Windows platform than 
before.
Now I have to roll back.

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


[web2py] Suggestion: Add IS_LOWER() to auth_user.email.requires list

2013-09-15 Thread Ray (a.k.a. Iceberg)
Hi there,

I just add IS_LOWER() to the beginning of auth_user.email.requires list, 
this way all input email address even with UPPERCASE will be stored as 
lower case in db. I think this should be the default behavior, so I write 
this suggestion.

Regards,
Ray

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


[web2py] Re: Why change underline to hyphen in url patterns of parse_as_rest()?

2013-09-03 Thread Ray (a.k.a. Iceberg)
On Monday, July 1, 2013 10:47:16 PM UTC+8, Ray (a.k.a. Iceberg) wrote:
>
> On Monday, July 1, 2013 7:30:51 PM UTC+8, Ray (a.k.a. Iceberg) wrote:
>>
>> Hi folks,
>>
>> I just noticed that, the auto patterns generated by dal.py's 
>> parse_as_rest() are using hyphen to replace underline. This way if I have:
>>
>> db.define_table("my_table",
>> Field("my_field"),
>> )
>>
>> it will show up in auto patterns as a url like 
>> "http://.../my-table/my-field";.
>>
>> However this brings some inconvenience when I am writing other pieces of 
>> program to access this patterns.
>>
>> So the question is, why dal.py's parse_as_rest() intentionally change all 
>> underlines into hyphens? I don't think SEO consideration matters in an api. 
>> So why?
>>
>> Thanks in advance.
>>
>> Regards,
>> Ray
>>
>
> Actually I am working on a generic rest api. I end up with several 
> unnecessary lines of "...replace('-', '_')", in order to counteract the 
> undesirable "underline to hyphen" behavior, came from dal.py's 
> parse_as_rest() auto pattern. Yet I am still curious to know, why design a 
> "underline to hyphen" behavior in parse_as_rest() auto pattern?
>
> Regards,
> Ray
>

I got bitten by the same problem, again. So, in short, my table looks like 
this:

   db.define_table("my_table",
Field("my_field"),
)

Why the auto patterns generated by parse_as_rest() ends up as something 
like this (notice the hyphen)?

"/my*-*table/id/{my_table.id}",
"/my*-*table/id/{my_table.id}/:field",

and I prefer this (notice the underline):

"/my*_*table/id/{my_table.id}",
"/my*_*table/id/{my_table.id}/:field",

Any thoughts?
 

-- 

--- 
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: IS web2py good for largescale

2013-08-04 Thread Ray (a.k.a. Iceberg)
Looks like using a memcache (which using finite memory) is the only way to 
go in this case?

On Monday, August 5, 2013 6:42:09 AM UTC+8, Massimo Di Pierro wrote:
>
> If the query depends on user input than yes.
> select(cache=(...)) uses the SQL QUERY as key. If it is possible for the 
> QUERY that you are caching to always be different because depends on user 
> this input you have a memory leak. Actually more than that. You have a DoS 
> vulnerability because a user can keep making queries thus exploiting the 
> leak easily.
>
> You should only cache selects that do not depend on use input.
>
>
> On Sunday, 4 August 2013 16:55:08 UTC-5, Loïc wrote:
>>
>> Thank you Anthony.
>>
>> Maybe I missed a point in the book, but does memory leak with cache.ram 
>> also applies to select caching?
>> For example when you do 
>>
>> rows = db(query).select(cache=(cache.ram,3600),cacheable=True)
>>
>> Is there any way to specify the key, or to empty the cache after some 
>> time?
>> What is the "correct" way to do?
>>
>>
>> Thank you
>>
>>

-- 

--- 
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.




Re: [web2py] Re: Fail to recognize json payload in a content-type: application/json POST request

2013-08-01 Thread Ray (a.k.a. Iceberg)


On Thursday, August 1, 2013 11:38:17 PM UTC+8, Jonathan Lundell wrote:
>
> On 1 Aug 2013, at 7:25 AM, "Ray (a.k.a. Iceberg)" 
> > 
> wrote:
>
> Thanks for trying to help Niphlod. More details so far.
>
> Strangely, that problem does NOT exist when I test with 
> http://web2py.com/examples/simple_examples/status
>
> So I compare the output page between mine and the one from web2py.com, 
> then I found something.
>
> On my server's output, there are only TWO appearances of 
> "application/json", one in request.env.content_type and another in 
> request.wsgi.environ.CONTENT_TYPE.
>
> On web2py.com's output, there are FOUR appearances of "application/json", 
> they are request.env.content_type, request.env.http_content_type, 
> request.wsgi.environ.CONTENT_TYPE, and 
> request.wsgi.environ.HTTP_CONTENT_TYPE.
>
> And turns out line 343 of parse_get_post_vars() uses only 
> "http_content_type" to trigger the json support.
> http://code.google.com/p/web2py/source/browse/gluon/main.py
>
> No wonder the symptom. So the next question is, what makes the 
> request.env.http_content_type missing in my case? Is it somehow because my 
> apache sits behind an nginx (a webfaction convention) so the request.is_local 
> is always True (which is not the case of web2py.com)?
>
> Or, shall we simply change that line 343 of gluon/main.py into this:
>
> 
>
> is_json = (env.get('http_content_type', '')
> or env.get('content_type', '')
> )[:16] == 'application/json'
>
>
> Thoughts?
>
>
> The specs associated with the Content-Type header are a little 
> complicated. WSGI inherits them from CGI. 
>
> The general idea is that (if the protocol is http), the environ members 
> beginning with http_ were supplied by the client. Headers not starting with 
> http_ are supplied by the server (possibly based on client headers).
>
> The bottom line: the server is required to provide content_type if the 
> client supplies one (otherwise it's optional); it is *not* required to 
> supply the client header http_content_type.
>
> GGI/1.1: http://ken.coar.org/cgi/draft-coar-cgi-v11-03.txt
>
> 6.1.3. CONTENT_TYPE
> ...
>Servers MUST provide this metavariable to scripts if a
>"Content-Type" field was present in the original request
>header. If the server receives a request with an attached
>entity but no "Content-Type" header field, it MAY attempt to
>determine the correct datatype, or it MAY omit this
>metavariable when communicating the request information to the
>script.
>
> 6.1.5. Protocol-Specific Metavariables
> ...
>Metavariables with names beginning with "HTTP_" contain values
>from the request header, if the scheme used was HTTP. Each
>HTTP header field name is converted to upper case, has all
>occurrences of "-" replaced with "_", and has "HTTP_"
>prepended to form the metavariable name.
> ...
>Servers are not required to create metavariables for all the
>request header fields that they receive. In particular, they
>MAY decline to make available any header fields carrying
>authentication information, such as "Authorization", or which
>are available to the script via other metavariables, such as
>"Content-Length" and "Content-Type".
>
> Rocket, for example, complies:
>
> if 'HTTP_CONTENT_TYPE' in environ:
> environ['CONTENT_TYPE'] = environ['HTTP_CONTENT_TYPE']
>
>
> So, if anything, web2py should be looking at content_type only; it's a 
> mistake to look at http_content_type only, and (by spec) unnecessary to 
> look at http_content_type at all.
>
> If we're really worried about spec-breaking servers, we could repeat the 
> Rocket logic (above) early on incoming requests (and the same for 
> content_length, which has similar rules).
>


Sounds convincing! So it is a bug need to be fixed. Let's see how Massimo 
or others say.

-- 

--- 
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: Fail to recognize json payload in a content-type: application/json POST request

2013-08-01 Thread Ray (a.k.a. Iceberg)
Thanks for trying to help Niphlod. More details so far.

Strangely, that problem does NOT exist when I test with 
http://web2py.com/examples/simple_examples/status

So I compare the output page between mine and the one from web2py.com, then 
I found something.

On my server's output, there are only TWO appearances of 
"application/json", one in request.env.content_type and another in 
request.wsgi.environ.CONTENT_TYPE.

On web2py.com's output, there are FOUR appearances of "application/json", 
they are request.env.content_type, request.env.http_content_type, 
request.wsgi.environ.CONTENT_TYPE, and 
request.wsgi.environ.HTTP_CONTENT_TYPE.

And turns out line 343 of parse_get_post_vars() uses only 
"http_content_type" to trigger the json support. 
http://code.google.com/p/web2py/source/browse/gluon/main.py

No wonder the symptom. So the next question is, what makes the 
request.env.http_content_type missing in my case? Is it somehow because my 
apache sits behind an nginx (a webfaction convention) so the 
request.is_local is always True (which is not the case of web2py.com)?

Or, shall we simply change that line 343 of gluon/main.py into this:



is_json = (env.get('http_content_type', '')
or env.get('content_type', '')
)[:16] == 'application/json'


Thoughts?

On Thursday, August 1, 2013 5:49:24 PM UTC+8, Niphlod wrote:
>
> I really can't reproduce it. Can you log somewhere within the 
> parse_get_post_vars function what happens ?
>
> On Thursday, August 1, 2013 8:53:09 AM UTC+2, Ray (a.k.a. Iceberg) wrote:
>>
>> To whom it may concern:
>>
>> I tried posting vars in json format, with content-type: application/json 
>> header, to my web2py application.
>>
>> When the above test is run on my laptop, i.e. requests are sent directly 
>> to web2py's rocket web server, recent web2py (the 2.5.1-stable) can 
>> successfully decode the payload into request.vars, as expected as mentioned 
>> in https://groups.google.com/d/msg/web2py/9YdxVpuJlA8/ek0zJae5U9YJ
>>
>> But when I deploy my application to my production server, the same web2py 
>> 2.5.1-stable can not recognize the payload and the request.vars are always 
>> empty. How come?
>>
>> My production server is running a web2py (was 2.4.6, and then manually 
>> overwritten by those files in 2.5.1's web2py_src.zip), behind apache's 
>> mod_wsgi, (which itself is behind a global nginx, but that architecture is 
>> a webfaction convention which I think is not relevent).
>>
>> Below is the request full content:
>>
>> *POST /examples/simple_examples/status/foo/bar.json HTTP/1.1*content-type: 
>> application/jsonHost: example.comContent-Length:14user-agent: fake
>> Connection:Keep-Alive
>>
>>
>> {"foo": "bar"}
>>
>>
>> And below is part of the web2py response, showing the request content. You 
>> can see web2py got the correct content type header, but still fail to decode 
>> the json payload in request.
>>
>> env:
>>
>>
>>
>>
>>
>>
>> content_length:
>> 14
>> content_type:
>> application/json
>> http_connection:
>> close
>> http_forwarded_request_uri:
>> /examples/simple_examples/status/foo/bar.json
>> http_host:
>> sandbox..com
>> http_http_x_forwarded_proto:
>> http
>> http_https:
>> off
>> http_user_agent:
>> fake
>> http_x_forwarded_for:
>> 107.23.xxx.xxx
>> http_x_forwarded_host:
>> sandbox..com
>> http_x_forwarded_proto:
>> http
>> http_x_forwarded_server:
>> sandbox..com
>> http_x_forwarded_ssl:
>> off
>>
>>
>> post_vars:
>>
>> vars:
>>
>> wsgi:
>> environ:
>> CONTENT_LENGTH:
>> 14
>> CONTENT_TYPE:
>> application/json
>>
>>
>>
>>
>>
>>

-- 

--- 
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] POSTing application/json request to web2py

2013-07-31 Thread Ray (a.k.a. Iceberg)
To whom it may concern:

I tried posting vars in json format, with content-type: application/json 
header, to my web2py application.

When the above test is run on my laptop, i.e. requests are sent directly to 
web2py's rocket web server, recent web2py (the 2.5.1-stable) can 
successfully decode the payload into request.vars, as expected as mentioned 
in https://groups.google.com/d/msg/web2py/9YdxVpuJlA8/ek0zJae5U9YJ

But when I deploy my application to my production server, the same web2py 
2.5.1-stable can not recognize the payload and the request.vars are always 
empty. How come?

My production server is running a web2py (was 2.4.6, and then manually 
overwritten by those files in 2.5.1's web2py_src.zip), behind apache's 
mod_wsgi, (which itself is behind a global nginx, but that architecture is 
a webfaction convention which I think is not relevent).

Below is the request full content:

*POST /examples/simple_examples/status/foo/bar.json HTTP/1.1*content-type: 
application/jsonHost: example.comContent-Length:14user-agent: fake
Connection:Keep-Alive


{"foo": "bar"}


And below is part of the web2py response, showing the request content. You can 
see web2py got the correct content type header, but still fail to decode the 
json payload in request.

env:






content_length:
14
content_type:
application/json
http_connection:
close
http_forwarded_request_uri:
/examples/simple_examples/status/foo/bar.json
http_host:
sandbox..com
http_http_x_forwarded_proto:
http
http_https:
off
http_user_agent:
fake
http_x_forwarded_for:
107.23.xxx.xxx
http_x_forwarded_host:
sandbox..com
http_x_forwarded_proto:
http
http_x_forwarded_server:
sandbox..com
http_x_forwarded_ssl:
off


post_vars:

vars:

wsgi:
environ:
CONTENT_LENGTH:
14
CONTENT_TYPE:
application/json





-- 

--- 
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: IOS, Json, Web2py.

2013-07-25 Thread Ray (a.k.a. Iceberg)


On Friday, July 26, 2013 12:45:58 AM UTC+8, Ray (a.k.a. Iceberg) wrote:
>
>
>
> On Tuesday, June 11, 2013 5:14:42 AM UTC+8, Niphlod wrote:
>>
>> ps: recent web2py releases should parse application/json POSTs 
>> transparently, no need to request.body.read() anymore it goes all in 
>> request.vars and request.post_vars as usual.
>>
>>
> Sorry to chime in an old thread, but which "recent version" of web2py 
> supports application/json in, oops, POST? Is there any chance that web2py 
> also support request Content-Type=application/json in PUT?
>

Forget previous post please. I just tried and found out http PUT is also 
supported in latest web2py 2.5.1 

-- 

--- 
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: IOS, Json, Web2py.

2013-07-25 Thread Ray (a.k.a. Iceberg)


On Tuesday, June 11, 2013 5:14:42 AM UTC+8, Niphlod wrote:
>
> ps: recent web2py releases should parse application/json POSTs 
> transparently, no need to request.body.read() anymore it goes all in 
> request.vars and request.post_vars as usual.
>
>
Sorry to chime in an old thread, but which "recent version" of web2py 
supports application/json in, oops, POST? Is there any chance that web2py 
also support request Content-Type=application/json in PUT?

-- 

--- 
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: Why change underline to hyphen in url patterns of parse_as_rest()?

2013-07-01 Thread Ray (a.k.a. Iceberg)
On Monday, July 1, 2013 7:30:51 PM UTC+8, Ray (a.k.a. Iceberg) wrote:
>
> Hi folks,
>
> I just noticed that, the auto patterns generated by dal.py's 
> parse_as_rest() are using hyphen to replace underline. This way if I have:
>
> db.define_table("my_table",
> Field("my_field"),
> )
>
> it will show up in auto patterns as a url like 
> "http://.../my-table/my-field";.
>
> However this brings some inconvenience when I am writing other pieces of 
> program to access this patterns.
>
> So the question is, why dal.py's parse_as_rest() intentionally change all 
> underlines into hyphens? I don't think SEO consideration matters in an api. 
> So why?
>
> Thanks in advance.
>
> Regards,
> Ray
>

Actually I am working on a generic rest api. I end up with several 
unnecessary lines of "...replace('-', '_')", in order to counteract the 
undesirable "underline to hyphen" behavior, came from dal.py's 
parse_as_rest() auto pattern. Yet I am still curious to know, why design a 
"underline to hyphen" behavior in parse_as_rest() auto pattern?

Regards,
Ray

-- 

--- 
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] Why change underline to hyphen in url patterns of parse_as_rest()?

2013-07-01 Thread Ray (a.k.a. Iceberg)
Hi folks,

I just noticed that, the auto patterns generated by dal.py's 
parse_as_rest() are using hyphen to replace underline. This way if I have:

db.define_table("my_table",
Field("my_field"),
)

it will show up in auto patterns as a url like 
"http://.../my-table/my-field";.

However this brings some inconvenience when I am writing other pieces of 
program to access this patterns.

So the question is, why dal.py's parse_as_rest() intentionally change all 
underlines into hyphens? I don't think SEO consideration matters in an api. 
So why?

Thanks in advance.

Regards,
Ray

-- 

--- 
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: Bug report: username as "space inside" is incorrectly accepted

2013-06-29 Thread Ray (a.k.a. Iceberg)
Thanks for prompt response. Issue is created. 
http://code.google.com/p/web2py/issues/detail?id=1568

On Sunday, June 30, 2013 12:17:12 AM UTC+8, Massimo Di Pierro wrote:
>
> Please do and I will take care of this asap.
>
> On Saturday, 29 June 2013 10:07:57 UTC-5, Ray (a.k.a. Iceberg) wrote:
>>
>> Hi folks,
>>
>> First of all, I think white space is generally not acceptable as part of 
>> username. But right now web2py accepts username such as "space inside".
>>
>> Actually, web2py defines the username validator like this:
>>
>> [IS_MATCH('[\w\.\-]+'), ...]
>>
>> so space is presumably not an intention.
>>
>>
>> The fix is:
>>
>> [IS_MATCH('[\w\.\-]+', strict=True, error_message='Only allow 
>> a-zA-Z0-9_-.'), ...]
>>
>>
>> Do I need to write an issue to google code issue tracker?
>>
>

-- 

--- 
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] Bug report: username as "space inside" is incorrectly accepted

2013-06-29 Thread Ray (a.k.a. Iceberg)
Hi folks,

First of all, I think white space is generally not acceptable as part of 
username. But right now web2py accepts username such as "space inside".

Actually, web2py defines the username validator like this:

[IS_MATCH('[\w\.\-]+'), ...]

so space is presumably not an intention.


The fix is:

[IS_MATCH('[\w\.\-]+', strict=True, error_message='Only allow 
a-zA-Z0-9_-.'), ...]


Do I need to write an issue to google code issue tracker?

-- 

--- 
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.




Re: [web2py] validate_and_insert() doesn't work for absent field

2013-06-27 Thread Ray (a.k.a. Iceberg)
On Thursday, June 27, 2013 8:52:14 PM UTC+8, Anthony wrote:
>
> On Thursday, June 27, 2013 8:39:23 AM UTC-4, Ray (a.k.a. Iceberg) wrote:
>
>> Thanks for trying to help. But sorry I don't understand how your theory 
>> can explain why the 2nd case in my example works and 3rd case didn't.
>>
>
> The second case is equivalent to a form including both fields but the user 
> leaving the bar input empty. The third case is equivalent to excluding the 
> bar field from the form altogether (e.g., by setting its writable attribute 
> to False) -- in that case, it is not validated. Note, you can also set 
> required=True if you want the DAL to require a value for a given field -- 
> that works independently of the validators (and you can set notnull=True in 
> order to have the database raise an error when no value is inserted).
>
> Anthony
>

That makes sense. Thanks. And then it raises another concern: when in the 
normal form situation, is it possible a user forges an http post without 
several field, in order to bypass the IS_NOT_EMPTY() or whatever validator? 
Is this a security vulnerability?

-- 

--- 
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.




Re: [web2py] validate_and_insert() doesn't work for absent field

2013-06-27 Thread Ray (a.k.a. Iceberg)
Thanks for trying to help. But sorry I don't understand how your theory can 
explain why the 2nd case in my example works and 3rd case didn't.

On Thursday, June 27, 2013 7:45:48 PM UTC+8, viniciusban wrote:
>
> I think this is expected, because the field.requires property exists 
> to be executed in forms and validate_and_insert() only simulates this 
> behaviour. 
>
> On Thu, Jun 27, 2013 at 7:30 AM, Ray (a.k.a. Iceberg) 
> > 
> wrote: 
> > Hi community, 
> > 
> > I'm working with web2py, again. :-) 
> > 
> > It took me hours today to realize validate_and_insert(field1=value1, 
> > field3=value3, ...) only works for the fields appears, but not for those 
> > absent. Is this a expected behavior or is it considered a bug? 
> > 
> > See example. 
> > 
> > # -*- coding: utf-8 -*- 
> > db.define_table('my_table', 
> > Field('foo', requires=IS_NOT_EMPTY()), 
> > Field('bar', requires=IS_NOT_EMPTY()), 
> > ) 
> > 
> > def index(): 
> > # r = db.my_table.validate_and_insert(foo='hello', bar='world')  # 
> Pass. 
> > Of course 
> > 
> > # r = db.my_table.validate_and_insert(foo='hello', bar=None)  # 
> Refused. 
> > As expected. 
> > 
> > r = db.my_table.validate_and_insert(foo='hello')  # This one got 
> > PASSED?! 
> > 
> > if r.id: 
> > return {'message': 'Created #%d' % r.id} 
> > else: 
> > return {'message': 'err: %s' % r.errors} 
> > 
> > 
> > Problem can be reproduced on web2py 2.4.6 and 1.99.4 
> > 
> > Thanks in advance. 
> > 
> > -- 
> > 
> > --- 
> > 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+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 

--- 
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] validate_and_insert() doesn't work for absent field

2013-06-27 Thread Ray (a.k.a. Iceberg)
Hi community,

I'm working with web2py, again. :-)

It took me hours today to realize validate_and_insert(field1=value1, 
field3=value3, ...) only works for the fields appears, but not for those 
absent. Is this a expected behavior or is it considered a bug?

See example.

# -*- coding: utf-8 -*-
db.define_table('my_table',
Field('foo', requires=IS_NOT_EMPTY()),
Field('bar', requires=IS_NOT_EMPTY()),
)

def index():
# r = db.my_table.validate_and_insert(foo='hello', bar='world')  # 
Pass. Of course

# r = db.my_table.validate_and_insert(foo='hello', bar=None)  # 
Refused. As expected.

r = db.my_table.validate_and_insert(foo='hello')  # This one got 
PASSED?!

if r.id:
return {'message': 'Created #%d' % r.id}
else:
return {'message': 'err: %s' % r.errors}


Problem can be reproduced on web2py 2.4.6 and 1.99.4

Thanks in advance.

-- 

--- 
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.




Re: [web2py] Restful authentication and CORS

2013-05-27 Thread Ray (a.k.a. Iceberg)
Hi Alec,

On Tuesday, July 17, 2012 1:03:04 AM UTC+8, Alec Taylor wrote:
>
> On Tue, Jul 17, 2012 at 2:20 AM, David Marko > 
> wrote:
> > +1 from me having this. Btw. On client side i'm using AngularJS and 
> Trigger.io (instead of PhoneGap)
>
> I've been looking around, and will have one of the following setups:
>
>- *AngularJS * with 
> *BarristerRPC
>* 
>- *BackboneJS * with 
> *Backbone.Rpc
>*
>- *JQuery mobile*  with 
> *jquery-jsonrpc*(or plain 
> JSON.stringify)
>
> All within a *PhoneGap * (*Apache 
> Cordova
> *) app using the* Facebook connect 
> plugin
> * for authentication (for graceful downgrade from Facebook mobile 
> appto Facebook 
> website auth ).
>
> I should have a PoC  on 
> August 2 with a full backend written in web2py and two frontends (one in 
> web2py views; the other in one of the above frameworks).
>
> Subsequently I'll release it under a full open-source license onto 
> Bitbucket. I'll post to the web2py list with link + slides when the repo is 
> live 
>

Sorry for late response. I am a web2py veteran who dives into restful world 
only recently. Do you have any finding to share about the restful 
authentication in web2py? Thanks in advance!

Regards,
Ray

-- 

--- 
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.




Re: [web2py] proper way to mobile and desktop 'skins'

2012-11-10 Thread Ray (a.k.a. Iceberg)
Hi there,

I just come across this old post. I solve this problem in a slightly 
different way. With all the same *.mobile views ready, I just explicitly 
use ".mobile" extension name as my visiting url, such as 
http://.../app/controller/action.mobile, therefore I don't need those "if 
is_mobile" code snippet in my every controller functions.

Hope that helps.

Regards,
Ray


On Tuesday, June 28, 2011 4:21:26 PM UTC+8, demetrio wrote:
>
> Sorry, i sent the message incomplete:
>
> Hi!
>
> I'm using jQueryMobile to make the "mobile skin", and the way that i do
> is this:
>
> if is_mobile and request.extension == "html" :
> #Its mobile 
> response.view = "%s/%s.%s" % (request.controller,
> request.function, "mobile")
> if not os.path.exists(os.path.join(request.folder, 'views',
> request.controller, request.function+".mobile")):
> response.view = '%s.%s' % ("generic", "mobile") 
>
>
> The 'request.extension == "html"' condition is because if you
> use .load, .json extensions or so, it can crash
>
> With this code, you only have to make ".mobile" extensions of your
> views:
>
> for example if you have:
>
> layout.html
> generic.html
> controller/funct1.hmtl
> controller/funct2.html
>
> You only have to make the views:
>
> layout.mobile
> generic.mobile
> controller/funct1.mobile
> controller/funct2.mobile
>
> If you keep your editor's syntax highlighting maybe you can change
> ".mobile" extension with ".mobile.html" (editing the code that i pasted
> at the begginig too, to make this change work)
>
> I hope this solution will be useful
>
> El lun, 27-06-2011 a las 16:28 -0700, Luis Goncalves escribió:
> > Hello!
> > 
> > I need to customize my views so that they look good on a computer
> > screen and on a smart phone.
> > 
> > One way to do so, It think, is to have separate layout definitions and
> > then do something like:
> > 
> > {{if session.platform == 'mobile':}}
> > {{extend 'mobile-layout.html}}
> > {{else:}}
> > {{extend 'desktop-layout.html'}}
> > {{pass}}
> > 
> > This does not seem to be working -  I get lots of syntax errors (can't
> > even figure out where they are!)
> > 
> > Is this approach wrong?   Is it possible to have a conditional
> > "extend" ?
> > 
> > Is there a smarter/better way to make the view rendering platform
> > dependent?
> > 
> > Thanks,
> > Luis.
>
>
>

-- 





[web2py] Re: Suggestion about using jqmobile in web2py

2012-05-16 Thread Ray (a.k.a. Iceberg)
Further discussion is moved to  
http://groups.google.com/group/web2py-developers/browse_frm/thread/ab1f23e39dcd3c9d
 

Thanks for attention.

Regards,
Ray

On Tuesday, May 15, 2012 10:15:10 PM UTC+8, Anthony wrote:
>
> Meanwhile, shall we keep the discussion about how to utilize that 
>> layout_jqm.html (no matter where it locates)? I am using two experimental 
>> callers as below:
>>
>> cat myapp/views/generic.mobi
>> {{extend 'layout_jqm.html'}}
>> {{response.headers['Content-Type'] = 'text/html'}}
>> # the rest is same as generic.html
>>
>> cat myapp/controllers/default.py
>> if request.user_agent().is_mobile or request.user_agent().is_tablet:
>> response.view = 'generic.mobi'
>> # the rest is same as the out-of-box welcome/controllers/default.py
>>
>> These minimal effort makes my app works smooth for both desktop and 
>> mobile. So far so good. Do you think they should go into scaffold too?
>>
>
> We might consider including that code commented out, but I don't think the 
> "welcome" app should use jQuery Mobile by default (it should probably also 
> allow the user to opt out of the mobile site and get to the desktop site if 
> preferred). Note, we already have a mobile-friendly "responsive" layout 
> (including a mobile menu).
>
> Anthony
>


[web2py] Re: Suggestion about using jqmobile in web2py

2012-05-14 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

Thanks for telling me such undocumented trick to use other app's layout 
file. However I still think a built-in layout_jqm.html for scaffold app is 
cleaner than cross-app reference. Anyway, see my latest layout_jqm.html 
sample in ticket 797  http://code.google.com/p/web2py/issues/detail?id=797 

Meanwhile, shall we keep the discussion about how to utilize that 
layout_jqm.html (no matter where it locates)? I am using two experimental 
callers as below:

cat myapp/views/generic.mobi
{{extend 'layout_jqm.html'}}
{{response.headers['Content-Type'] = 'text/html'}}
# the rest is same as generic.html

cat myapp/controllers/default.py
if request.user_agent().is_mobile or request.user_agent().is_tablet:
response.view = 'generic.mobi'
# the rest is same as the out-of-box welcome/controllers/default.py

These minimal effort makes my app works smooth for both desktop and mobile. 
So far so good. Do you think they should go into scaffold too?

Regards,
Ray

On Tuesday, May 15, 2012 2:06:11 AM UTC+8, Massimo Di Pierro wrote:
>
> Please open a ticket about this. I do not think this belongs to the 
> welcome app but, if we can use it in admin (instead of the current mobile 
> admin also based on jquery mobile) then you will be able to do:
>
> {{extend '../../admin/views/jqm_layout.html'}}
>
> On Monday, 14 May 2012 04:30:23 UTC-5, Ray (a.k.a. Iceberg) wrote:
>>
>> Hi there,
>>
>> 1. I am working at my first mobile website recently. At first I spent 
>> (quite) some time to know and download the hard-to-find 
>> web2py.plugin.jqmobile.w2p, then I realize the main resource I need is just 
>> its views/plugin_jqmobile/layout.html, so it comes to an idea. Why not just 
>> pack that tiny layout file inside the default scaffold app as 
>> views/jqm_layout.html? (Attached in this post)
>>
>> 2. And then it is so easy to use it. Just {{extend "jqm_layout.html"}} 
>> instead of {{extend "layout.html"}} in your view files. I will also suggest 
>> one step further. Change the first line of generic.html from:
>>
>> {{extend "layout.html"}}
>>
>> to:
>>
>> {{extend response.layout or "layout.html"}}
>>
>> This way developers can easily switch into two (or even more) layouts on 
>> demand by defining a proper response.layout, yet still backward compatible.
>>
>> Will this go into trunk?
>>
>> Regards,
>> Ray
>>
>

[web2py] Re: Can/should {{super}} works even without a parent block?

2012-05-14 Thread Ray (a.k.a. Iceberg)
The point here is that the web2py out-of-box layout.html and the 
web2py.plugin.jqmobile.w2p layout contain different set of blocks.

Sure I can change one of that manually. But wouldn't it be better if 
{{super}} can simply work no matter the parent block exists or not? That 
way I can even take out a block via layout.html later, without having to 
adjust all other controller-specific views accordingly.

Regards,
Ray

On Tuesday, May 15, 2012 12:39:56 AM UTC+8, Anthony wrote:
>
> Can't you put an empty version of that block in your jQuery Mobile layout 
> as well?
>
> Anthony
>
> On Monday, May 14, 2012 11:56:45 AM UTC-4, Ray (a.k.a. Iceberg) wrote:
>>
>> Guess you mean {{try:}}{{super}}{{except: pass}}
>>
>> Unfortunately it fails too.
>>
>> So a fix is a must?
>>
>> Regards,
>> Ray
>>
>>

[web2py] Re: Can/should {{super}} works even without a parent block?

2012-05-14 Thread Ray (a.k.a. Iceberg)
Guess you mean {{try:}}{{super}}{{except: pass}}

Unfortunately it fails too.

So a fix is a must?

Regards,
Ray

On Monday, May 14, 2012 11:50:45 PM UTC+8, Ross Peoples wrote:
>
> Correction, that should be:
> {{try:}}{{super}}{{catch:pass}}
>
>
>
> On Monday, May 14, 2012 11:45:37 AM UTC-4, Ross Peoples wrote:
>>
>> While not the prettiest solution, you can always use 
>> {{try:}}{{super}}{{catch}} in views. I know that sounds like a bandaid, but 
>> I think an exception is the desired behavior here. Otherwise, returning an 
>> empty string would make troubleshooting difficult if you accidentally 
>> mistyped the name of the block and the block keeps showing up as empty.
>
>

[web2py] Can/should {{super}} works even without a parent block?

2012-05-14 Thread Ray (a.k.a. Iceberg)
Hi,

There is a {{super}} syntax to bring the parent block. Fine. (See its doc 
here. http://web2py.com/books/default/chapter/29/5#Blocks-in-views )

But if using {{block undefined_block}}{{super}}{{end}} will generate error 
ticket. This brings trouble if I am switching different layouts for some 
reason (in my case, I am switching between layout.html and jqm_layout.html)

So, can/should {{super}} works even without a parent block? Let's say it 
just generate an empty string in such situation?

Regards,
Ray


[web2py] Re: Suggestion about using jqmobile in web2py

2012-05-14 Thread Ray (a.k.a. Iceberg)
On Monday, May 14, 2012 8:56:41 PM UTC+8, Anthony wrote:
>
> On Monday, May 14, 2012 8:41:59 AM UTC-4, Massimo Di Pierro wrote:
>>
>> I would like to see the implementation. I am pretty sure this will break 
>> the bytecode compilation of apps.
>>
>
> {{extend response.layout or "layout.html"}}
>
> Yes -- to compile, the view to extend has to be known at compile time, but 
> the value of response.layout is dynamically set at run time.
>
> Anthony 
>

Thanks for pointing out this, gentlemen. I seldom compile my app before so 
I don't know that behavior. Grrr.

1. But at least we can ship the views/jqm_layout.html (see my first post) 
with welcome scaffold app. Ok?

2. And then I will personally add an extra views/jqm_generic.html like this:

{{extend "jqm_layout.html"}}
.. # others are same as views/generic.html

after that, all my mobile pages just need to use response.view = 
'jqm_generic.html'. What do you think about that?

2.1 I even tried a views/generic.mobi like this:

{{extend "jqm_layout.html"}}{{response.headers['Content-Type'] = 
'text/html'}}
.. # others are same as views/generic.html 

It works too, however I am afraid crud logic will not work for pages whose 
extension are other than .html and .load

Ideas?

Regards,
Ray


[web2py] Suggestion about using jqmobile in web2py

2012-05-14 Thread Ray (a.k.a. Iceberg)
Hi there,

1. I am working at my first mobile website recently. At first I spent 
(quite) some time to know and download the hard-to-find 
web2py.plugin.jqmobile.w2p, then I realize the main resource I need is just 
its views/plugin_jqmobile/layout.html, so it comes to an idea. Why not just 
pack that tiny layout file inside the default scaffold app as 
views/jqm_layout.html? (Attached in this post)

2. And then it is so easy to use it. Just {{extend "jqm_layout.html"}} 
instead of {{extend "layout.html"}} in your view files. I will also suggest 
one step further. Change the first line of generic.html from:

{{extend "layout.html"}}

to:

{{extend response.layout or "layout.html"}}

This way developers can easily switch into two (or even more) layouts on 
demand by defining a proper response.layout, yet still backward compatible.

Will this go into trunk?

Regards,
Ray
Title: {{=response.title or request.application}}


  

  
  
  
  
  



  
	{{=response.title}}
	{{block header}}
	{{if not auth.user:}}
	Login
	{{else:}}
	Logout
	{{pass}}
	{{=T("Home")}}
	{{end}}
  
  
	{{if response.flash:}}{{=response.flash}}{{pass}}
	{{if response.menu:}}
	
	  {{=T("Main Menu")}}
	  {{for _ in response.menu:}}
	  {{=_[0]}}
	  {{pass}}
	
	{{pass}}
	{{include}}
  
  
	{{block footer}}
	powered by web2py - @2011
	{{end}}
  





  



[web2py] Re: Slow queries or how to determine if cache is working?

2012-02-25 Thread Ray (a.k.a. Iceberg)
You only apply cache to your last query. You might need to cache the
other two queries to gain full cache boost.
Besides, you can add some profiling checkpoint inside your code to
know which part is time consuming.

Regards,
Ray

On Feb 25, 3:53 pm, pbreit  wrote:
> I'm struggling to figure out if caching is working. I insert a list of
> categories on pages where I show a bunch of items for sale. First, I only
> have 400 items in the DB and it takes quite a bit longer than I would
> expect to display the first time. Second, I am trying to cache the query
> and it doesn't appear to speed up at all. Does this mean my problem might
> be elsewhere? Is there any way to tell that caching is working?
>
> Here is my page:http://pricetack.com/items
>
> The component (I've tried cache.disk as well):
>
> def item_groupings():
>     seller = db(db.auth_user.name==request.vars.seller).select().first()
>     if seller:
>         groupings = db((db.item.status=='active') &
>             (db.item.seller==seller) &
>             (db.item.grouping!='test')).select(db.item.grouping,
>                 orderby=db.item.grouping, distinct=True)
>     else:
>         groupings = db((db.item.status=='active') &
>             (db.item.grouping!='test')).select(db.item.grouping,
>                 orderby=db.item.grouping, distinct=True, cache=(cache.ram,
> 360))
>     return dict(groupings=groupings)
>
> Maybe I should try to generate the HTML in the controller?


[web2py] Re: Minor optimize: skip superfish when possible

2011-12-28 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

I just noticed that my second patch is derived from an old revision of
web2py skeleton app. It might not be directly patched the latest
trunk.

Anyway, this is what it tries to solve, and you can digest it and do
it again in the latest trunk.

1. Wrap all those "{{=MENU(...)}} ...
jQuery('ul.sf-menu')superfish(); ... " inside the {{if
response.menu:}}...{{pass}} too

2. Add a long-lost parameter as: {{=MENU(..., li_active='current')}}

3. and then add a css snippet to make active menu distinguishing:
li.current {background:white; /* #BDD2FF; */}

Regards,
Ray

On Dec 27, 1:29 am, "Ray (a.k.a. Iceberg)"  wrote:
> My fault. There should be one more modification.
>
> diff -r 04673c0ce6ab views/layout.html
> --- a/views/layout.html Tue Dec 27 01:29:01 2011 +0800
> +++ b/views/layout.html Tue Dec 27 01:29:17 2011 +0800
> @@ -39,8 +39,10 @@
>
>      {{#--  require CSS and JS files for this page (read info in
> base.css) --}}
>      {{response.files.append(URL('static','css/base.css'))}}
> -    {{response.files.append(URL('static','css/superfish.css'))}}
> -    {{response.files.append(URL('static','js/superfish.js'))}}
> +    {{if response.menu:}}
> +        {{response.files.append(URL('static','css/superfish.css'))}}
> +        {{response.files.append(URL('static','js/superfish.js'))}}
> +        {{pass}}
>      {{#-- include web2py specific js code (jquery, calendar, form
> stuff) --}}
>      {{include 'web2py_ajax.html'}}
>
> @@ -88,13 +90,14 @@
>
>         
>           {{block statusbar}} 
> -         {{#-- superfish menu --}}
> -      li.current {background:white; /* #BDD2FF; */}
> -      {{=MENU(response.menu,_class='sf-menu',li_active='current')}}
> -         
> -           jQuery(document).ready(function(){
> -           jQuery('ul.sf-menu').superfish();});
> -         
> +         {{if response.menu:}}{{#-- superfish menu --}}
> +          

[web2py] Re: Minor optimize: skip superfish when possible

2011-12-26 Thread Ray (a.k.a. Iceberg)
My fault. There should be one more modification.

diff -r 04673c0ce6ab views/layout.html
--- a/views/layout.html Tue Dec 27 01:29:01 2011 +0800
+++ b/views/layout.html Tue Dec 27 01:29:17 2011 +0800
@@ -39,8 +39,10 @@

 {{#--  require CSS and JS files for this page (read info in
base.css) --}}
 {{response.files.append(URL('static','css/base.css'))}}
-{{response.files.append(URL('static','css/superfish.css'))}}
-{{response.files.append(URL('static','js/superfish.js'))}}
+{{if response.menu:}}
+{{response.files.append(URL('static','css/superfish.css'))}}
+{{response.files.append(URL('static','js/superfish.js'))}}
+{{pass}}
 {{#-- include web2py specific js code (jquery, calendar, form
stuff) --}}
 {{include 'web2py_ajax.html'}}

@@ -88,13 +90,14 @@


  {{block statusbar}} 
- {{#-- superfish menu --}}
-  li.current {background:white; /* #BDD2FF; */}
-  {{=MENU(response.menu,_class='sf-menu',li_active='current')}}
- 
-   jQuery(document).ready(function(){
-   jQuery('ul.sf-menu').superfish();});
- 
+ {{if response.menu:}}{{#-- superfish menu --}}
+  li.current {background:white; /* #BDD2FF; */}
+  {{=MENU(response.menu,_class='sf-
menu',li_active='current')}}
+ 
+   jQuery(document).ready(function(){
+   jQuery('ul.sf-menu').superfish();});
+     
+  {{pass}}
  
  {{end}}


On Dec 27, 12:31 am, Massimo Di Pierro 
wrote:
> good idea. In trunk!
>
> On Dec 26, 9:32 am, "Ray (a.k.a. Iceberg)"  wrote:
>
>
>
>
>
>
>
> > Hey folks,
>
> > I just use this little trick in my app, to reduce two unnecessary http
> > requests when menus are not needed.
>
> > I think the optimization is reasonable. And people can always manually
> > re-enable superfish by response.files.extend([...]). So, my proposal
> > is to put this into the default welcome (scaffold) app. Shall we?
>
> > diff -r 483ebd275b49 views/layout.html
> > --- a/views/layout.html Mon Dec 26 23:19:42 2011 +0800
> > +++ b/views/layout.html Mon Dec 26 23:26:26 2011 +0800
> > @@ -39,8 +39,10 @@
>
> >      {{#--  require CSS and JS files for this page (read info in
> > base.css) --}}
> >      {{response.files.append(URL('static','css/base.css'))}}
> > -    {{response.files.append(URL('static','css/superfish.css'))}}
> > -    {{response.files.append(URL('static','js/superfish.js'))}}
> > +    {{if response.menu:}}
> > +        {{response.files.append(URL('static','css/superfish.css'))}}
> > +        {{response.files.append(URL('static','js/superfish.js'))}}
> > +        {{pass}}
> >      {{#-- include web2py specific js code (jquery, calendar, form
> > stuff) --}}
> >      {{include 'web2py_ajax.html'}}


[web2py] Minor optimize: skip superfish when possible

2011-12-26 Thread Ray (a.k.a. Iceberg)
Hey folks,

I just use this little trick in my app, to reduce two unnecessary http
requests when menus are not needed.

I think the optimization is reasonable. And people can always manually
re-enable superfish by response.files.extend([...]). So, my proposal
is to put this into the default welcome (scaffold) app. Shall we?

diff -r 483ebd275b49 views/layout.html
--- a/views/layout.html Mon Dec 26 23:19:42 2011 +0800
+++ b/views/layout.html Mon Dec 26 23:26:26 2011 +0800
@@ -39,8 +39,10 @@

 {{#--  require CSS and JS files for this page (read info in
base.css) --}}
 {{response.files.append(URL('static','css/base.css'))}}
-{{response.files.append(URL('static','css/superfish.css'))}}
-{{response.files.append(URL('static','js/superfish.js'))}}
+{{if response.menu:}}
+{{response.files.append(URL('static','css/superfish.css'))}}
+{{response.files.append(URL('static','js/superfish.js'))}}
+{{pass}}
 {{#-- include web2py specific js code (jquery, calendar, form
stuff) --}}
 {{include 'web2py_ajax.html'}}


[web2py] Re: One suggestion to formstyle=lambda

2011-12-25 Thread Ray (a.k.a. Iceberg)
It works!

On Dec 26, 4:03 am, Massimo Di Pierro 
wrote:
> In trunk. Please check it.
>
> On Dec 25, 1:16 pm, "Ray (a.k.a. Iceberg)"  wrote:
>
>
>
>
>
>
>
> > Here you are. And merry Chrismas!
>
> > diff -r 80b2c74561c0 gluon/sqlhtml.py--- a/gluon/sqlhtml.py     Mon Sep 26
> > 00:53:12 2011 -0500+++ b/gluon/sqlhtml.py       Mon Dec 26 03:14:58 2011
> > +0800
> > @@ -978,8 +978,8 @@
> >          elif type(self.formstyle) == type(lambda:None):
> >              table = TABLE()
> >              for id,a,b,c in xfields:
> > -                td_b = self.field_parent[id] = TD(b,_class='w2p_fw')
> > -                newrows = self.formstyle(id,a,td_b,c)
> > +                raw_b = self.field_parent[id] = b
> > +                newrows = self.formstyle(id,a,raw_b,c)
> >                  if type(newrows).__name__ != "tuple":
> >                      newrows = [newrows]
> >                  for newrow in newrows:
>
> > On Dec 26, 2:39 am, Massimo Di Pierro 
> > wrote:
>
> > > I changed my mind about this and you are right. Can you send me a
> > > patch? I would like to see what you want to change it into.
>
> > > Massimo
>
> > > On Dec 24, 3:39 am, "Ray (a.k.a. Iceberg)"  wrote:
>
> > > > Hi Massimo,
>
> > > > I just discovered the lovely formstyle=lambda ... feature. (http://
> > > > web2py.com/books/default/chapter/29/7?search=formstyle)
>
> > > > It saves me from the headache of css. However, it is strange that the
> > > > value of "field_widget" parameter is a TD instance. Should it better
> > > > be a raw widget instance?
>
> > > > Example. Right now I have to use the ugly ".comonents[0]" notation:
>
> > > >     crud.settings.formstyle = lambda record_id, field_label,
> > > > field_widget, field_comment: TR(
> > > >         field_label, DIV(field_widget.components[0], field_comment))
>
> > > > I prefer:
>
> > > >     crud.settings.formstyle = lambda record_id, field_label,
> > > > field_widget, field_comment: TR(
> > > >         field_label, DIV(field_widget, field_comment))
>
> > > > If you like this idea, tell me to open an issue to track its progress.
>
> > > > Regards,
> > > > Ray


[web2py] Re: One suggestion to formstyle=lambda

2011-12-25 Thread Ray (a.k.a. Iceberg)
Here you are. And merry Chrismas!

diff -r 80b2c74561c0 gluon/sqlhtml.py--- a/gluon/sqlhtml.py Mon Sep 26
00:53:12 2011 -0500+++ b/gluon/sqlhtml.py   Mon Dec 26 03:14:58 2011
+0800
@@ -978,8 +978,8 @@
 elif type(self.formstyle) == type(lambda:None):
 table = TABLE()
 for id,a,b,c in xfields:
-td_b = self.field_parent[id] = TD(b,_class='w2p_fw')
-newrows = self.formstyle(id,a,td_b,c)
+raw_b = self.field_parent[id] = b
+newrows = self.formstyle(id,a,raw_b,c)
 if type(newrows).__name__ != "tuple":
 newrows = [newrows]
 for newrow in newrows:

On Dec 26, 2:39 am, Massimo Di Pierro 
wrote:
> I changed my mind about this and you are right. Can you send me a
> patch? I would like to see what you want to change it into.
>
> Massimo
>
> On Dec 24, 3:39 am, "Ray (a.k.a. Iceberg)"  wrote:
>
>
> > Hi Massimo,
>
> > I just discovered the lovely formstyle=lambda ... feature. (http://
> > web2py.com/books/default/chapter/29/7?search=formstyle)
>
> > It saves me from the headache of css. However, it is strange that the
> > value of "field_widget" parameter is a TD instance. Should it better
> > be a raw widget instance?
>
> > Example. Right now I have to use the ugly ".comonents[0]" notation:
>
> >     crud.settings.formstyle = lambda record_id, field_label,
> > field_widget, field_comment: TR(
> >         field_label, DIV(field_widget.components[0], field_comment))
>
> > I prefer:
>
> >     crud.settings.formstyle = lambda record_id, field_label,
> > field_widget, field_comment: TR(
> >         field_label, DIV(field_widget, field_comment))
>
> > If you like this idea, tell me to open an issue to track its progress.
>
> > Regards,
> > Ray


[web2py] One suggestion to formstyle=lambda

2011-12-24 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

I just discovered the lovely formstyle=lambda ... feature. (http://
web2py.com/books/default/chapter/29/7?search=formstyle)

It saves me from the headache of css. However, it is strange that the
value of "field_widget" parameter is a TD instance. Should it better
be a raw widget instance?

Example. Right now I have to use the ugly ".comonents[0]" notation:

crud.settings.formstyle = lambda record_id, field_label,
field_widget, field_comment: TR(
field_label, DIV(field_widget.components[0], field_comment))

I prefer:

crud.settings.formstyle = lambda record_id, field_label,
field_widget, field_comment: TR(
field_label, DIV(field_widget, field_comment))

If you like this idea, tell me to open an issue to track its progress.

Regards,
Ray


[web2py] Re: Is there any "mainstream" wysiwyg html editor in web2py world?

2011-12-21 Thread Ray (a.k.a. Iceberg)
Just want to give some correction about my previous comment.

In WYMeditor, by default the heading 1/2/3/.../6 looks in normal black-
on-white color. They look in red, only when pasting formatted text
from MS WORD into any empty container in the editor panel. Pasting
into nonempty container won't trigger the "red problem". And all those
only happen in my Chrome 15.

If I use IE8 to test again, pasting formatted text from WORD into
editor panel results in losing all structures and formatting. That is
a show stopper for me.

In short, WYMeditor is somewhat intangible, inconsistent. What a pity,
I did love its WYSIWYM philosophy and really wanted to give it a shot.
Perhaps I can save it for being my personal blog posting tool.

Regards,
Ray

On Dec 22, 2:53 am, "Ray (a.k.a. Iceberg)"  wrote:
> Hi LightDot,
>
> Thanks for the remind. Actually WYMeditor was on my radar. I love its
> clean output code philosophy. However its default look-and-feel could
> surprise my end users, I am afraid. For example, those heading
> 1/2/3/.../6 containers look scary red when editing, although they look
> "normal" again when previewing. 
> Seehttp://files.wymeditor.org/wymeditor/trunk/src/examples/01-basic.html
>
> Maybe WYMeditor does this on purpose, but I expect an editing
> experience would be less surprising to end users. (The least-
> surprising rule when designing a UI.)
>
> That said, I think that is "just" a css issue. So if someday I found a
> handy css for it, then I would fall in love with WYMeditor.
>
> Regards,
> Ray
>
> On Dec 22, 1:45 am, LightDot  wrote:
>
>
>
>
>
>
>
> > I agree, most of the better known editors are bloated. I try to keep away
> > if I can, especially from tiny and ckeditor. I haven't used elrte before,
> > it seems a bit better. I have used jHtmlArea on a couple of projects with
> > success, but lately I prefer WYMeditor. The .js is about 120kb minified,
> > though, so still way bigger that jHtmlArea.
>
> > It's a strict XHTML WYSIWYM editor (not WYSIWYG, looks even better as far
> > as I'm concerned). It needs a bit of UI polishing, but it produces great
> > code. If anyone tries it out, I strongly suggest using the latest beta
> > releases or the code from the repo. Old stable releases are pretty stale.
>
> >https://github.com/wymeditor/wymeditor


[web2py] Re: Is there any "mainstream" wysiwyg html editor in web2py world?

2011-12-21 Thread Ray (a.k.a. Iceberg)
Hi LightDot,

Thanks for the remind. Actually WYMeditor was on my radar. I love its
clean output code philosophy. However its default look-and-feel could
surprise my end users, I am afraid. For example, those heading
1/2/3/.../6 containers look scary red when editing, although they look
"normal" again when previewing. See 
http://files.wymeditor.org/wymeditor/trunk/src/examples/01-basic.html

Maybe WYMeditor does this on purpose, but I expect an editing
experience would be less surprising to end users. (The least-
surprising rule when designing a UI.)

That said, I think that is "just" a css issue. So if someday I found a
handy css for it, then I would fall in love with WYMeditor.

Regards,
Ray

On Dec 22, 1:45 am, LightDot  wrote:
> I agree, most of the better known editors are bloated. I try to keep away
> if I can, especially from tiny and ckeditor. I haven't used elrte before,
> it seems a bit better. I have used jHtmlArea on a couple of projects with
> success, but lately I prefer WYMeditor. The .js is about 120kb minified,
> though, so still way bigger that jHtmlArea.
>
> It's a strict XHTML WYSIWYM editor (not WYSIWYG, looks even better as far
> as I'm concerned). It needs a bit of UI polishing, but it produces great
> code. If anyone tries it out, I strongly suggest using the latest beta
> releases or the code from the repo. Old stable releases are pretty stale.
>
> https://github.com/wymeditor/wymeditor


[web2py] Re: Is there any "mainstream" wysiwyg html editor in web2py world?

2011-12-21 Thread Ray (a.k.a. Iceberg)
The idea of uploading image to external and free server is clever! I
love this idea!

However your demo link does not work for uploading image.

By the way, your upload feature is based on swf? So your site won't
support ipad/iphone user?

And what do you mean "works fine ... except ie"? Do you mean the
entire ie family is not supported? That is not a good news :-/

Hope to see your finished doc and demo soon.

Regards,
Ray

On Dec 22, 1:53 am, Vasile Ermicioi  wrote:
> I am developing one, I already use it on production, for a cms and for a
> forum.
> Works fine on all browsers except ie :(
> Planning for next weeks to make a page with docs and to fix ie bugs.
>
> A few features that I am proud of:
> - inserting html (e.g for inserting code of a embedded video from youtube)
> - automatic resize to a given width and height (via flash)  and upload to
> imgur
>
> You will see that it is quite advanced and its js+html+css is less than 50
> kb and that without minifying.
> ~ 120kb with icons and swf that uploads to imgur, but requires jquery. I
> use jquery stored on google cdn
>
> About imgur uploader:
> - it resizes and converts  to png or jpg
> - images become smaller  - e.g if you have a 1Mb image and you have set to
> be resized to 800x800 it will be ~ 100kb after uploading.
> - your image is stored to an external server for free - imgur.com
>
> take a look and if someone is interested I can help you to include it in
> your pageshttp://fermer.md/fermer/static/bolteditor/index.html
>
> ideas and comments are wellcom


[web2py] Re: Is there any "mainstream" wysiwyg html editor in web2py world?

2011-12-21 Thread Ray (a.k.a. Iceberg)
Anthony, thank you for your input. And thank you too, Ross.

I did some evaluation in these days. Now I gonna share my thoughts.

elrte and ckeditor and tinymce etc. are definitely feature-riched, at
the same time somwhat bloated. Each sizes 135KB, 355KB, 203KB,
respectively. (How could this be called "tiny-something"? So ironic.)

After I notice the fact that, end user can (and very likely to) copy
formatted text from the popular MS WORD document, then paste into any
wysiwyg editor, I decide to choose some lightweight editor which only
provided some basic features. Oh, I don't need upload-image feature so
far.

Right now I am happy with the 9KB js jhtmlarea (http://pietschsoft.com/
demo/jHtmlArea/). Another similar option is 8KB tinyeditor (http://
www.scriptiny.com/2010/02/javascript-wysiwyg-editor/), but it is less
polished.

One caveat. When using such kind of html editors, end user could input
javascript code, which I consider potentially harmful. So we will need
something similar to this in our model:

Field('content', 'text', requires=CLEANUP(''))

But that is still not good enough. To Massimo, if you are reading this
thread, CLEANP(...) should be improved to support this syntax:

CLEANUP(re.compile('', re.S|re.I))

Regards,
Ray

On Dec 20, 3:20 am, Anthony  wrote:
> It shouldn't be too difficult to use any JS editor with web2py, but here
> are some web2py specific plugins:
>
> https://bitbucket.org/PhreeStyle/web2py_ckeditor/srchttp://dev.s-cubism.com/plugin_elrte_widgethttp://dev.s-cubism.com/plugin_managed_html/page1/_managed_html_preview
>
> Anthony
>
>
>
>
>
>
>
> On Monday, December 19, 2011 1:23:16 PM UTC-5, Ray (a.k.a. Iceberg) wrote:
>
> > Hi folks,
>
> > I used web2py for years but never have a need to use wysiwyg html
> > editor in my projects. Until recently. Then I surprisingly find no
> > "mainstream" editor mentioned in web2py world. Of course I can go with
> > any editor I will run into, but before that I just want to hear some
> > suggestion from those been-there-done-that people. Any thoughts,
> > gentlemen?
>
> > Regards,
> > Ray
>
> > PS: candidates I found.
>
> > 1. the plugin_wiki of web2py uses elrte (http://elrte.ru/en), which
> > has most powerful feature I even seen
>
> > 2. I saw this one in an unfamous web2py app, jhtmlarea. It is
> > lightweight. (http://pietschsoft.com/demo/jHtmlArea/)
>
> > 3. jwysiwyg mentioned in a web2pyslice
> >http://www.web2pyslices.com/slices/take_slice/54
>
> > 4. This sounds cool. "WYSIWYG editor with integrated image upload
> > Options"http://www.web2pyslices.com/main/slices/take_slice/18


[web2py] Is there any "mainstream" wysiwyg html editor in web2py world?

2011-12-19 Thread Ray (a.k.a. Iceberg)
Hi folks,

I used web2py for years but never have a need to use wysiwyg html
editor in my projects. Until recently. Then I surprisingly find no
"mainstream" editor mentioned in web2py world. Of course I can go with
any editor I will run into, but before that I just want to hear some
suggestion from those been-there-done-that people. Any thoughts,
gentlemen?

Regards,
Ray

PS: candidates I found.

1. the plugin_wiki of web2py uses elrte (http://elrte.ru/en), which
has most powerful feature I even seen

2. I saw this one in an unfamous web2py app, jhtmlarea. It is
lightweight. (http://pietschsoft.com/demo/jHtmlArea/)

3. jwysiwyg mentioned in a web2pyslice 
http://www.web2pyslices.com/slices/take_slice/54

4. This sounds cool. "WYSIWYG editor with integrated image upload
Options" http://www.web2pyslices.com/main/slices/take_slice/18


[web2py] Re: [ login | register | lost password? ]

2011-11-15 Thread Ray (a.k.a. Iceberg)
Hi Anthony,

So you are quite familiar with the web2py internal, this time the
navbar. Are you the programmer of that function? Would you comment on
this issue?

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

Regards,
Ray

On Nov 16, 3:47 am, Anthony  wrote:
> In trunk, auth.navbar now takes a new 'separators' argument -- the default
> is
>
> auth.navbar(..., separators=(' [ ', ' | ', ' ] '))
>
> The new 'welcome' app will actually get rid of the brackets, with 
> separators=('',
> ' | ', '').
>
> Also, auth.navbar() simply returns a web2py SPAN helper object, so you can
> manually edit it:
>
> navbar = auth.navbar()
> del navbar[0], navbar[-1]  # no more brackets
>
> Finally, it's easy to create your own navbar. Assuming your auth action is
> the standard /default/user function:
>
> SPAN(A('Login', _href=URL('default', 'user', args='login')), ' | ',
> A('Register', _href=URL('default', 'register', args='register')),
> _class='auth_navbar')
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, November 15, 2011 12:21:44 PM UTC-5, Michael Gheith wrote:
>
> > Does anyone know how to get rid of the brackets and pipes in:
> > [ login | register | lost password? ]
>
> > Also, would it be easy to append my own menu with the above?  If so,
> > then what file does this reside in?
>
> > Thanks in advance,
> > Michael Gheith


[web2py] Improvement for Crud.update()

2011-11-13 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

Following code snippet comes from gluon/tools.py 's line 3029~3030.

elif not request.extension in ('html','load'):
raise HTTP(401)

I suggest to change it into:

elif not request.extension in ('html','load'):
raise HTTP(401, str(form.errors()))

This way, client side has a chance to know what goes wrong when error
happens. That is important when client is visiting the page.json or
page.xml etc..

At least the suggested modification is harmless. So why not?

Please let me know if you will accept this proposal. Thanks!

Regards,
Ray


[web2py] Re: How about auth.define_tables(..., format='...')? [SOLVED]

2011-11-02 Thread Ray (a.k.a. Iceberg)
On Nov 1, 7:54 pm, Anthony  wrote:
> On Tuesday, November 1, 2011 6:20:57 AM UTC-4, Massimo Di Pierro wrote:
>
> > I am not sure I understand the proposal. You can override the format:
>
> > db.mytable._format = '%(name)s'
> > db.mytable._format = lambda record: SPAN(record.first_name)
>
> FYI, the above now works in trunk, but not in stable (previously, existing
> keys of Table objects could not be changed -- now they can if they start
> with an underscore).
>
> In stable, the above would have to be preceded by db.mytable.pop('_format').
>
> Anthony


That pop() does the trick right now. Thanks gentlemen!

Ray


[web2py] A typo in online book for update_or_insert()

2011-11-01 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

A typo in online book for update_or_insert() is spotted.

http://web2py.com/book/default/chapter/06#update_or_insert

The example quoted from current book:

db.person.update_or_insert(dict(name='John'),
name='John',birthplace='Chicago')

should be:

db.person.update_or_insert(db.person.name=='John',
name='John',birthplace='Chicago')

Regards,
Ray Luo


[web2py] Re: How about auth.define_tables(..., format='...')?

2011-10-31 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

So what do you think about the following idea? If it is ok for you, I
can commit a low-priority issue in google code, just to avoid it being
forgotten.

Regards,
Ray

On Oct 30, 10:52 pm, Anthony  wrote:
> Probably just settings.table_user_format (i.e., the format for the user
> table), and maybe settings.table_group_format as well.
>
> Anthony
>
>
>
>
> On Sunday, October 30, 2011 10:48:25 AM UTC-4, Ray (a.k.a. Iceberg) wrote:
>
> > Nice comment Anthony. So I would like to mend my previous suggestion
> > as:
>
> > 1. the auth.define_tables(...) interface remains state quo
> > 2. the auth.define_tables(...) implementation follows some new
> > settings, e.g.
>
> >     db.define_table(
> >         ...,
> >         format = self.settings.table_user_name_format)
>
> > Regards,
> > Ray
>
> > On Oct 30, 10:12 pm, Anthony  wrote:
> > > I think you'd need different format arguments for auth_user and
> > auth_group,
> > > as they both have formats specified.
>
> > > Anthony
>
> > > On Sunday, October 30, 2011 9:48:04 AM UTC-4, Ray (a.k.a. Iceberg)
> > wrote:
>
> > > > Hi Massimo,
>
> > > > How about add a new parameter to auth.define_tables()? As below.
>
> > > >   def define_tables(..., format=''%(first_name)s %(last_name)s (%
> > > > (id)s)"):
> > > >      ...
> > > >     db.define_table(..., format=format)
> > > >     ...
>
> > > > The idea is to let user has a chance to customize it. Currently we can
> > > > not override this value at all.
>
> > > > Regards,
> > > > Ray


[web2py] Re: WebFactions Applications

2011-10-30 Thread Ray (a.k.a. Iceberg)

On Oct 31, 3:27 am, Vasile Ermicioi  wrote:
> a few steps that I use, I assume that you already installed web2py :)
> 0) set your domain at your registrar to point to webfaction dns servers
> 1) add your domain to webfaction domains
> 2) set your domain to be handled by your app (see webfaction's websites)
> 3 )create a routes.py (or rename routes_example.py) file with the content
>
> routes_in = (
> ('(.*):https?://(www\.)?yoursitename1\.com:(.*)/', '/yourapp1/'),
>         ('(.*):https?://(www\.)?yoursitename2\.com:(.*)/', '/yourapp2/'),
>  )
>
> def __routes_doctest():
>     pass
>
> if __name__ == '__main__':
>     import doctest
>     from gluon.rewrite import *
>     load(routes=__file__)
>     doctest.testmod()
>
> 4) restart your server (apache, nginx or whatever server you use)
>
> this kind of installation doesn't need multiple web2py's installations


Thanks for the hint. I managed to come up with a seemingly simpler
routes.py for same purpose.

routers = dict(
   BASE = dict(
domains = {
"my_domain.com" : "app1",
"another_domain.com" : "app2",
},
),
)

However, the only downside is only one said app is exposed to the said
domain. What if my domain need two apps to serve?

Regards,
Ray


[web2py] Re: Persistent variables in web2py

2011-10-30 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

In the first post of this thread, Arturo said,

"Is there a way in web2py to have varibles be persistent. For example
when I instantiate a class I don't want to re-instantiate it every
time a page is loaded."

I guess what he concerns is performance. In other word, "web2py re-
instantiate all class, variables, app logics, etc. ... every time a
page is loaded. Isn't that sounds slow?" Do we have a doc for this
faq? By the way, does binary compiling a web2py app help much in this
aspect?

Regards,
Ray


On Oct 30, 10:40 pm, Massimo Di Pierro 
wrote:
> this is not a web2py issue. This is an issue for all web applications.
>
> What if your application is replicated on two server behing a load
> balancer? The two servers cannot share objects. What if you use a web
> servers that forks (apache can) than different requests are executed
> by different processes, not different threads? Processes cannot share
> objects. What if you have to restart the web server for maintenance
> purposes? Do you want to store all persistent data?
> The same user may request two pages and these two pages may be server
> by different servers or different processes.
>
> Web applications must be written without persistent objects. State is
> share using the database, using sessions and using cache.
>
> The bahvior you seek can be mimicked by serializing/deserializing the
> objects at every request in session or cache.
>
> Massimo
>
> On Oct 30, 4:39 am, evilaliv3  wrote:
>
>
>
>
>
>
>
> > On 30 Ott, 00:39, Massimo Di Pierro 
> > wrote:
>
> > > You must use cache.ram but this is not guaranteed to work.
>
> > Excuse me Massimo,
> > but, if i understand well this answer, there is no way to have also a
> > persistent connection to the database or a global application variable
> > in web2py?
> > for every request the whole application is reinitialized?
>
> > > In a multi-threaded environment the web server decides which threads
> > > to start/stop/kill.
>
> > does this happen in a deterministic fashion? is there some
> > documentation about?
>
> > Giovanni Pellerano


[web2py] Re: WebFactions Applications

2011-10-30 Thread Ray (a.k.a. Iceberg)
On Oct 30, 10:31 pm, Web2Py Freak  wrote:
> My app name is 'Web2py'  and in it i have two 'web2py app':
>
> 1- welcome
> 2-maestro
>
> now i have a domain and in the site app i selected web2py and there is
> nothing in the path so it takes the welcome app
>
> and now i have some other domain and i want it to start mastro web2py
> app  .. i will select web2py and then what to add in the URL path ???


If ALL your other domains only need ONE SAME "web2py app" named
mastro, you are lucky. You only need to rename "mastro" as "welcome"
or "init". Problem solved.

If, in my cases, different domain needs different web2py app to serve,
I use a naive trick. Here is my "web2py app" welcome/default.py 's
index():
Well, my simple

def index():  # serves as a springboard
if request.env.http_host.endswith('site_alpha.com'):
redirect(URL(a='alpha',c='default',f='index'))
if request.env.http_host.endswith('site_beta.com'):
redirect(URL(a='beta',c='default',f='index'))
...

You get the idea.

It is not perfect. End users see a long url, e.g.
http://www.site_alpha.com/alpha/default/index
Besides, if site alpha 's end user types in 
http://www.site_ALPHA.com/BETA/default/index,
oops, he sees contents in site beta. I can live with that. How about
you?

It is possible to use web2py's builtin url rewriting feature, or
nginx's url rewrite feature, which should be faster by the way. But I
did not go that far yet. People who've been there please give some
light.

Regards,
Ray


[web2py] Re: How about auth.define_tables(..., format='...')?

2011-10-30 Thread Ray (a.k.a. Iceberg)
Nice comment Anthony. So I would like to mend my previous suggestion
as:

1. the auth.define_tables(...) interface remains state quo
2. the auth.define_tables(...) implementation follows some new
settings, e.g.

db.define_table(
...,
format = self.settings.table_user_name_format)

Regards,
Ray


On Oct 30, 10:12 pm, Anthony  wrote:
> I think you'd need different format arguments for auth_user and auth_group,
> as they both have formats specified.
>
> Anthony
>
>
>
>
>
> On Sunday, October 30, 2011 9:48:04 AM UTC-4, Ray (a.k.a. Iceberg) wrote:
>
> > Hi Massimo,
>
> > How about add a new parameter to auth.define_tables()? As below.
>
> >   def define_tables(..., format=''%(first_name)s %(last_name)s (%
> > (id)s)"):
> >      ...
> >     db.define_table(..., format=format)
> >     ...
>
> > The idea is to let user has a change to customize it. Currently we can
> > override this value at all.
>
> > Regards,
> > Ray


[web2py] Re: WebFactions Applications

2011-10-30 Thread Ray (a.k.a. Iceberg)
On Oct 30, 7:23 pm, Web2Py Freak  wrote:
> Dear All ,
>
>  I am using WebFaction for hosting , i install the web2py app in a
> custom script , now do i have to install an app for every website or
> use just one app , and if using one app how can i point the domain to
> it ??
>
> Best Regards ,
> Hassan Alnator


Hi Hassan,

You use so many webfaction slang in your post. Fortunately I use
webfaction too so I can understand.

Yes I think you can install the entire web2py package as a "webfaction
app" for your each "webfaction website". But that way each "webfaction
app" contains at least one dedicate process. Your webfaction account
may exceed memory quota quickly.

I install only one web2py package as a one-for-all "webfaction app".
Then bind my several domains to this unique "webfaction app" via
webfaction control panel, so requests to all my domain go to that same
web2py process. Later, setup some url rewrite rules so requests for
different domain go to different "web2py app". This solution is good
for many light traffic sites.

Hope I describe it clearly.

Regards,
Ray




[web2py] How about auth.define_tables(..., format='...')?

2011-10-30 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

How about add a new parameter to auth.define_tables()? As below.

  def define_tables(..., format=''%(first_name)s %(last_name)s (%
(id)s)"):
 ...
db.define_table(..., format=format)
...

The idea is to let user has a change to customize it. Currently we can
override this value at all.

Regards,
Ray


[web2py] Re: Does auth.requires() always requires login?

2011-10-18 Thread Ray (a.k.a. Iceberg)
Thanks Massimo and everyone took part in this thread.

By the way, Massimo did not give the reason why changed
auth.requires() behavior in 1.99.x, but here is my guess: otherwise it
would become an easy mistake for web2py users (all of us), to just
write auth.requires(condition) and forgetting it could become a
vulnerability for unregistered end users.

Regards,
Ray

On Oct 18, 6:29 am, Massimo Di Pierro 
wrote:
> ok. requires_login instead of login. Uploading to trunk.
>
> On Oct 17, 10:55 am, Jonathan Lundell  wrote:
>
> > On Oct 17, 2011, at 6:21 AM, Massimo Di Pierro wrote:
>
> > > @auth.requires(condition)
>
> > > First checks that user is logged in then it check whether the
> > > condition is true or False.
> > > This behavior has changed but it was undocumented.
>
> > > I guess next question is how do you do what you need to do. I thought
> > > about it and I pushed this to trunk:
>
> > > @auth.requires(request.client=='127.0.0.1' or auth.user,login=False)
>
> > > The login=False skips the pre-check on user login.
>
> > Could that be changed perhaps to require_login=False? It's a little less 
> > ambiguous, since login=False could be read to require that the user *not* 
> > be logged in.
>
> > > Massimo
>
> > > On Oct 17, 1:19 am, "Ray (a.k.a. Iceberg)"  wrote:
> > >> Thanks for the workaround, I might take that. But I will still argue
> > >> that:
>
> > >> 1. Does authentication have to mean logged-in, or can it be something
> > >> else, such as "accessing from localhost", "accessing via ajax", etc.?
>
> > >> 2. if @auth already means authentication, why there is still an
> > >> auth.requires_login() which implemented as
> > >> auth.requires(auth.is_logged_in())? Shouldn't this implementation
> > >> imply that auth.requires() does not check is_logged_in()? All in all,
> > >> what is auth.requires()'s semantics?
>
> > >> Regards,
> > >> Ray
>
> > >> On Oct 17, 1:41 pm, Bruno Rocha  wrote:
>
> > >>> I think it should be, because @auth means authentication, so needs
> > >>> authenticated user.
>
> > >>> In your case I should do differently.
>
> > >>> def secret():
> > >>>    if not request.client == '127.0.0.1' or not auth.user:
> > >>>        redirect(URL('default', 'user', args='login'))
> > >>>    return {"": "some cool stuff"}


[web2py] Re: Does auth.requires() always requires login?

2011-10-16 Thread Ray (a.k.a. Iceberg)
Thanks for the workaround, I might take that. But I will still argue
that:

1. Does authentication have to mean logged-in, or can it be something
else, such as "accessing from localhost", "accessing via ajax", etc.?

2. if @auth already means authentication, why there is still an
auth.requires_login() which implemented as
auth.requires(auth.is_logged_in())? Shouldn't this implementation
imply that auth.requires() does not check is_logged_in()? All in all,
what is auth.requires()'s semantics?

Regards,
Ray

On Oct 17, 1:41 pm, Bruno Rocha  wrote:
> I think it should be, because @auth means authentication, so needs
> authenticated user.
>
> In your case I should do differently.
>
> def secret():
>    if not request.client == '127.0.0.1' or not auth.user:
>        redirect(URL('default', 'user', args='login'))
>    return {"": "some cool stuff"}


[web2py] Re: Does auth.requires() always requires login?

2011-10-16 Thread Ray (a.k.a. Iceberg)
Thanks for prompt response Bruno. But unfortunately your suggestion
doesn't help in my case, system admin still can not access from
localhost without login.

Regards,
Ray

On Oct 17, 12:41 pm, Bruno Rocha  wrote:
> Change teh behaviour with this:
>
> auth.settings.on_failed_authorization = lambda or function
> auth.settings.on_failed_authentication = lambda or function
>
> On Mon, Oct 17, 2011 at 2:23 AM, Ray (a.k.a. Iceberg) wrote:
>
>
>
>
>
>
>
>
>
> > Hi there,
>
> > Following code works in web2py 1.98.2. That is, to allow registered
> > users, as well as the system administrator (who always access the
> > system from localhost), to access data.
>
> > @auth.requires(request.client=='127.0.0.1' or auth.is_logged_in())
> > def secret():
> >    return {"": "some cool stuff"}
>
> > The snippet does not work in web2py 1.99.3. Looks like web2py 1.99.x
> > enforces user login in auth.requires(...). Should it be?
>
> > Any feedback is welcome.
>
> > Regards,
> > Ray (a.k.a. Iceberg)
>
> --
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
> [ Aprenda a programar:http://CursoDePython.com.br]
> [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> [ Consultoria em desenvolvimento web:http://www.blouweb.com]


[web2py] Does auth.requires() always requires login?

2011-10-16 Thread Ray (a.k.a. Iceberg)
Hi there,

Following code works in web2py 1.98.2. That is, to allow registered
users, as well as the system administrator (who always access the
system from localhost), to access data.

@auth.requires(request.client=='127.0.0.1' or auth.is_logged_in())
def secret():
return {"": "some cool stuff"}

The snippet does not work in web2py 1.99.3. Looks like web2py 1.99.x
enforces user login in auth.requires(...). Should it be?

Any feedback is welcome.

Regards,
Ray (a.k.a. Iceberg)


[web2py] Re: what about web2py 2.0?

2011-09-21 Thread Ray (a.k.a. Iceberg)
Hi there,

My 3 cents.

1. Ignore those people advocating a "backward-incompatible" web2py
2.0. They did not even provide a reasonable must-have backward-
incompatible feature wishlist. Shall we release a backward-
incompatible version of web2py just for, being backward-incompatible?
Nonsense.

2. According to Bruno Rocha's recommendation of Semantic Versioning
[1] (and thank you Bruno), I really like the idea and will vote for a
1.100 instead of 2.0. Under our "always-backward-compatible"
philosophy, there should never be a web2py 2.0, but we will have a
web3py 1.0 in future. (Perhaps web4py 1.0 in even longer future.)

3. The "alphabetic comparison in which case 100 is less than 99" is
considered a bug which will be fixed by web2py 1.99 according to
Massimo. That is already good enough. For those people who would skip
web2py 1.99, it is not a big disaster anyway. They can have a manual
upgrade later, which is a very little acceptable cost.

Regards,
Ray (a.k.a. Iceberg)

[1] http://semver.org/

On Sep 22, 1:25 am, Massimo Di Pierro 
wrote:
> True. In fact 1.99 will resolve this problem but some people may jump
> from 1.98 to 1.100 (pardon, 2.00) without passing through 1.99.
>
> On Sep 21, 11:20 am, pbreit  wrote:
> > Yeah, I suspect it's doing an alphabetic comparison in which case 100 is
> > less than 99.


[web2py] Re: file locations once web2py is deployed on fluxflex

2011-09-15 Thread Ray (a.k.a. Iceberg)
Hi Ian,

You mentioned "After using the online web2py ide to do some
development, I
cloned my fluxflex git repository only to find that it's empty".

If you developed your web2py app via your fluxflex's web2py's admin
interface, I am afraid all your app source code only exists as "on
site data" but not as "code inside repo". In this case there is still
easy way to get your code. Go to your fluxflex web2py 's admin, and
"pack" (then download) your app. That is the native web2py way to
handle your app. (I havn't tried that on fluxflex but it should work.)

Regards,
Ray

On Sep 16, 4:20 am, monotasker  wrote:
> Hi,
>
> I realize this is really a support issue for fluxflex, but their customer
> service has been really slow (days) to respond. Since a few people on here
> seem to have tried out fluxflex I'm hoping someone can help.
>
> I've deployed web2py using the one-click install on fluxflex, and it's
> working well. After using the online web2py ide to do some development, I
> cloned my fluxflex git repository only to find that it's empty. No web2py
> files. Does anyone know where the web2py files would be and how to get them
> out using git?
>
> Thanks,
>
> Ian


[web2py] Re: Using a lambda to set a default

2011-09-07 Thread Ray (a.k.a. Iceberg)
On Sep 7, 3:00 am, Lennon  wrote:
> I'm try to use a lambda to set a default value based on a value in
> another table.  Here is my model:
>
> db.define_table('trip_instance', timestamp, sos_table,
>     Field('trip_type_id',  db.trip_type, label='Trip Type',
> widget=trip_select_widget, requires = IS_IN_DB(db, 'trip_type.id', '%
> (name)s'), represent=lambda id:db.trip_type(id)['name']),
>     Field('total_slots', 'integer', default=lambda r:
> db.trip_type(r.trip_type_id)['total_slots']),
>
> Locally this causes an error that says:
>
> TypeError: () takes exactly 1 argument (0 given)
>
> And on my server (Linode) there is no error but when I try and create
> a new trip instance with sqlform the total slots field is pre-
> populated with this:
>
>  at 0x7f27684b7140>
>
> My lambda looks almost identical to the one that works fine for
> represent in the trip_type_id field except I'm using the table instead
> of the field.  Is that what I'm doing wrong?


Looks like the default parameter does not want a lambda. Try to give
it a computed value instead.

Regards,
Ray


[web2py] Re: what is web2py doing internally with unicode?

2011-09-04 Thread Ray (a.k.a. Iceberg)
Generally speaking, you can't assume a file's encoding, unless you are
the creator of that file therefore knows its encoding.

Regards,
Ray

On Sep 5, 7:52 am, weheh  wrote:
> I have a text string which is read from a file. The file was created
> by the db...store mechanism. The original data came from either an
> uploaded file or a text field. I have neither decoded nor encoded
> anything. Shouldn't I assume the text in the file is utf8? (Please oh
> please say yes.)
>
> On Sep 4, 7:30 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > web2py internally expects everything to be bytes representing utf8-
> > encoded strings.
>
> > On Sep 4, 1:02 pm, weheh  wrote:
>
> > > When I create a form with form=SQLFORM(...), if I have a myfield of
> > > type "text"is the form.vars.myfield value of type unicode? If I then
> > > save the field in a file by doing a db.mytable.myfield.store(...) does
> > > it automatically get encoded to utf-8?


[web2py] Re: fluxflex - how to?

2011-08-27 Thread Ray (a.k.a. Iceberg)
On Aug 27, 10:03 am, MidGe  wrote:
> I am trying to use fluxflex but I must be missing something
> fundamental as I do not understand what is happening when I follow the
> instructions.
>
> First of all, it all seems to be working fine. I can see the site and
> I can log in admin etc...
>
> When I use git to clone the fluxflex install on my machine, it gives
> me a nearly empty repository!  I would expect to get an install
> similar to the one I get when I unpack web2py on my machine.  I cannot
> see any applications, let alone other files that I may need modify or
> create, like routes.py.
>
> Can someone point out to me where am I supposed to make the changes I
> may require?  Where is the install of web2py located?  Should it not
> be there when I git clone the flexflux instance to my drive?
>
> Any help or pointer to a help would be greatly appreciated.


I am not the author of web2py-for-fluxflex, but here is my
understanding anyway.

The web2py-for-fluxflex repo is designed to be "nearly empty". It just
contains scripts to download latest official web2py stable release.
That is it. Nothing more. And this way every user can use this repo,
instead of everyong forking his own web2py repo which will soon become
out-of-sync.

So later we need to use "web2py way" to do all other jobs, includes
but not limited to:

1. upgrade the web2py by clicking "upgrade" button in web2py's admin
app (I guess no one did that yet, at the time of my writing this post)

2. upload/upgrade/deploy individual app, by packing your web2py app
into a .w2p file and then upload it. I havn't tried that yet. It might
encounter some "post-size-limit" of fluxflex. We will see. I don't
know how to git-pull or hg-pull an individual app, like I did on
webfaction. Perhaps that is not possible on fluxflex, unless they
provide an ssh shell in the future.

Just my 2 cents.

Regards,
Ray


[web2py] Re: Understanding Rocket Threads

2011-08-26 Thread Ray (a.k.a. Iceberg)
Thank you Anthony, I knew session.forget() but did not know it would
be so helpful for performance. I'll try that in my projects from now
on.

Regards,
Ray

On Aug 26, 2:42 am, Anthony  wrote:
> If you don't explicitly "forget" the session, the session file will lock on
> each request, so subsequent requests will be blocked. Maybe you could forget
> the session on requests that don't need it and just keep it for requests
> that do need it (i.e., form submissions).
>
> Note, to immediately unlock the session file, you need to do
> session.forget(response), not just session.forget().
>
> Anthony
>
>
>
>
>
>
>
> On Thursday, August 25, 2011 2:14:54 PM UTC-4, G wrote:
>
> > I tried session.forget() but found that forms submitted by ajax in
> > components don't seem to work without a session, so that won't work in
> > my case.
>
> > I also tried removing the SQLite db, it may have helped some but I'm
> > still testing.
>
> > Thanks again for the suggestions
>
> > On Aug 24, 4:18 pm, Michele Comitini 
> > wrote:
> > > Try session.forget() and see what happens
>
> > > mic
>
> > > 2011/8/25 G :
>
> > > > Thank you for the suggestion. I made a test application that used no
> > > > database accesses (no auth and randomly generated data). It showed the
> > > > same behavior, so I do not think it is the culprit. In addition, since
> > > > the application is monitor only, the real application only reads from
> > > > the database, which I hope would not impose a transaction lock.
>
> > > > G
>
> > > > On Aug 24, 3:20 pm, ron_m  wrote:
> > > >> You also need to consider the database type used by the application
> > for the
> > > >> model. The SQLite database has a transaction lock which will cause the
>
> > > >> application to look like it is single threaded if the database is held
> > in a
> > > >> transaction pending state while the background work is performed.


[web2py] Re: fluxflex

2011-08-25 Thread Ray (a.k.a. Iceberg)
Hi Yota,

Thanks for your time. Hopefully these can help.
[1] 
http://stackoverflow.com/questions/872565/how-do-i-remove-sensitive-files-from-gits-history
[2] http://help.github.com/remove-sensitive-data/

Regards,
Ray


On Aug 26, 12:05 am, Yota Ichino  wrote:
> You're right, Iceberg.
>
> Uh..., there is a issue. I don't know how to delete history in git.
> Could you tell me it?
>
> 2011/8/25 Ray (a.k.a. Iceberg) :
>
> > That's a good merge.
>
> > By the way, is it possible to completely remove the old master branch
> > stuff? (This is actually a question for git.) Current repo still
> > contains many web2py files in its history. This makes it a little bit
> > unnecessary slow when cloning the repo.
>
> > Regards,
> > Ray
>
> > On Aug 25, 2:36 am, Yota Ichino  wrote:
> >> I merged get_new_stable branch into master branch.
>


[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread Ray (a.k.a. Iceberg)
Hi G,

I saw similar behaviors in some of my lightweight app, which also uses
sqlite and rocket. I need not solve that problem at that time (it was
really a little app for a small group). But I can provide some
information to you this time.

When you try to isolate the sqlite, "using no auth and randomly
generating data" are not enough. You would better completely take out
this line:

db = DAL('sqlite://storage.sqlite')

that means completely avoid db definition and db opening. That is
because, in web2py, even a sqlite db open attempt will open the db in
exclusive mode, hence blocking other requests to the same app. (That
was true, I don't know whether that was changed since then. Massimo
can confirm that.)

Regards,
Ray

On Aug 25, 6:37 am, G  wrote:
> Thank you for the suggestion. I made a test application that used no
> database accesses (no auth and randomly generated data). It showed the
> same behavior, so I do not think it is the culprit. In addition, since
> the application is monitor only, the real application only reads from
> the database, which I hope would not impose a transaction lock.
>
> G
>
> On Aug 24, 3:20 pm, ron_m  wrote:
>
> > You also need to consider the database type used by the application for the
> > model. The SQLite database has a transaction lock which will cause the
> > application to look like it is single threaded if the database is held in a
> > transaction pending state while the background work is performed.


[web2py] Re: Upload & Install packed application on FluxFlex - Error500

2011-08-25 Thread Ray (a.k.a. Iceberg)
Hi Tito, there is an ongoing discussion here.
http://groups.google.com/group/web2py/msg/aa293a99cda711e9

Regards,
Ray

On Aug 25, 10:21 pm, Tito Garrido  wrote:
> Is there a way to update web2py on fluxflex?
>
>
> On Thu, Aug 25, 2011 at 10:52 AM, Yota Ichino  wrote:
> > The Error is caused POST size restriction, maybe. I tried to upload a
> > file which is about
> > 128KB but could not upload.
>
> > 2011/8/25 Massimo Di Pierro :
> > > I emailed the author of the installation script. It just got updated.
> > > Perhaps there is a bug?
>
> > > massimo
>
> > > On Aug 24, 4:26 pm, Valter Foresto  wrote:
> > >> I tryed to Upload & Install some simple packed applications on FluxFlex
> > but
> > >> I get always "Error 500" from the Server.
> > >> I attached here the file with the "Error 500" message send by the
> > FluxFlex
> > >> Server.
> > >> Are there anybody experienced the same problem ?
>
> > >> - Valter
>
> > >>  Error500.JPG
> > >> 58KViewDownload
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___


[web2py] Re: Re : Re: fluxflex

2011-08-25 Thread Ray (a.k.a. Iceberg)
On Aug 24, 10:25 pm, "Ray (a.k.a. Iceberg)"  wrote:
> > Another big issue. How to upgrade to the latest web2py (when
> > available)? Every time I do a git import in fluxflex panel, with or
> > WITHOUT checking "Run initialize scripts for setting up the project",
> > ends up with my whole web2py project being completely reset. My
> > manually uploaded web2py apps and their data will be lost.
> >
> > I've read the doc [1] by the help of Google Translate, but still can
> > not figure out how to trigger the "deploy-only" mode.
> > By the way, problems raised on Fluxflex's support forum [2] never got
> > answered. Not a good service standard I expected. (Shrug.)
> > [1] http://jp.doc.fluxflex.com/settoappumodotodepuroimodo
> > [2] http://getsatisfaction.com/fluxflex

On Aug 24, 10:53 pm, JmiXIII  wrote:
> Hello,
>
> Does'nt it work with the upgrade button of the admin page ?


Hi JimXIII,

Thanks for reminding me about the web2py's builtin ugrade button. It
should work, unless there will be so weird "post limit" prevent us to
do so. (http://groups.google.com/group/web2py/browse_frm/thread/
8ccb23cb0fad2e04)

Things might become more complicated if our project on fluxflex
autoscale-able (https://www.fluxflex.com/about#auto-scaling). Does the
upgrade on one cluster automatically broadcast to other clusters?

We will see. Meanwhile, I still consider fluxflex support for web2py
is limited.

Regards,
Ray


[web2py] Re: fluxflex

2011-08-25 Thread Ray (a.k.a. Iceberg)
That's a good merge.

By the way, is it possible to completely remove the old master branch
stuff? (This is actually a question for git.) Current repo still
contains many web2py files in its history. This makes it a little bit
unnecessary slow when cloning the repo.

Regards,
Ray

On Aug 25, 2:36 am, Yota Ichino  wrote:
> I merged get_new_stable branch into master branch.
>

> 2011/8/24 Yota Ichino :
>
> > Iceberg, Massimo Di Pierro,
>
> > Your idea is great. These influence me and I rewrite .flx file.
> > It is created on same github project with branch "get_new_stable".
> >https://github.com/nus/web2py-for-fluxflex/tree/get_new_stable
> > We can import this branch by using "Github import" menu.
>
> > The branch doing:
> > 1. get new stable file from web2py.com.
> > 2. unzip
> > 3. deploying
>
> > This idea's strong point:
> > - User can get new stable file everytime.
>
> > Iceberg,
> > How to write .flx file is inhttp://jp.doc.fluxflex.com/and other library 
> > code.
>
> > 2011/8/23 Massimo Di Pierro :
> >> I think there should be a recommended way to created branded versions
> >> of web2py.
>
> >> I would recommend:
> >> - getting the latest official stable
> >> - unzip
> >> - add your own "init" app, with landing branded page etc, linking
> >> admin.
> >> - have a standard mechanism to add a brand logo to admin as well
> >> - rezip and distribute
>
> >> we could create a hook (div) for the admin logo, a sample branded
> >> init, and a script to create this.
>
> >> Massimo
>
> >> On Aug 22, 2:24 am, Iceberg  wrote:
> >>> Omi Chiba,
>
> >>> Thanks VERY MUCH for your effort on building the web2py installation
> >>> package (a.k.a. library on fluxflex). Deploying web2py on a hosting
> >>> server has never been so easy! (I start crying for the hours I spent
> >>> in setting up my first web2py instance on my previous hosting
> >>> provider.)
>
> >>> One thing though. Your web2py library is a forked (and tailored)
> >>> version of official web2py 1.98.2. This way it will soon be outdated
> >>> when web2py trunk grows into 1.99, 1.100, etc.. So I see the only
> >>> practical way is:
>
> >>> 1. modify your .flx file (in order to get rid of the "public_html"
> >>> directory, shall we?)
> >>> 2. and commit it into the trunk.
> >>> 3. and then someone of us (if not Massimo) maintain an identical clone
> >>> (rather than a fork) of web2py on github, until fluxflex will support
> >>> google code as app backend someday. (Will they?)
>
> >>> Later we will figure out a way to upload (perhaps download too?) each
> >>> web2py app, one by one.
>
> >>> By the way, how did you find out how to write the .flx file? I did not
> >>> see any documentation section on fluxflex site. Hope to know more so
> >>> that we can tweak more.
>
> >>> Regards,
> >>> Ray
>
> >>> On Aug 21, 8:37 pm, Omi Chiba  wrote:
>
> >>> > Ichino who is a member of web2py Japan created a library on fluxflex
> >>> > and it works great !
>
> >>> >http://www.fluxflex.com/library/47
>
> >>> > 1. Sign up fluxflex
> >>> > 2. Create new project (e.g. ochiba)
> >>> > 3. Install the library (It will be done in one second!)
> >>> > 4. Access to your project with HTTPS not HTTP 
> >>> > (e.g.https://ochiba.fluxflex.com)
> >>> > 5. Access Administrative Interface with /admin 
> >>> > (e.g.https://ochiba.fluxflex.com/admin
> >>> > )
> >>> > 5. Admin password is the same as your MySQL database on fluxflex
> >>> > project.
>
> >>> > Enjoy :)


[web2py] Re: fluxflex

2011-08-24 Thread Ray (a.k.a. Iceberg)
Yota Ichino,

Thanks for your prompt response! It looks working well.

Another big issue. How to upgrade to the latest web2py (when
available)? Every time I do a git import in fluxflex panel, with or
WITHOUT checking "Run initialize scripts for setting up the project",
ends up with my whole web2py project being completely reset. My
manually uploaded web2py apps and their data will be lost.

I've read the doc [1] by the help of Google Translate, but still can
not figure out how to trigger the "deploy-only" mode.

By the way, problems raised on Fluxflex's support forum [2] never got
answered. Not a good service standard I expected. (Shrug.)

[1] http://jp.doc.fluxflex.com/settoappumodotodepuroimodo
[2] http://getsatisfaction.com/fluxflex

Regards,
Ray



On Aug 24, 3:10 am, Yota Ichino  wrote:
> Iceberg, Massimo Di Pierro,
>
> Your idea is great. These influence me and I rewrite .flx file.
> It is created on same github project with branch 
> "get_new_stable".https://github.com/nus/web2py-for-fluxflex/tree/get_new_stable
> We can import this branch by using "Github import" menu.
>
> The branch doing:
> 1. get new stable file from web2py.com.
> 2. unzip
> 3. deploying
>
> This idea's strong point:
> - User can get new stable file everytime.
>
> Iceberg,
> How to write .flx file is inhttp://jp.doc.fluxflex.com/and other library code.
>
> 2011/8/23 Massimo Di Pierro :
>
>
>
>
>
>
>
> > I think there should be a recommended way to created branded versions
> > of web2py.
>
> > I would recommend:
> > - getting the latest official stable
> > - unzip
> > - add your own "init" app, with landing branded page etc, linking
> > admin.
> > - have a standard mechanism to add a brand logo to admin as well
> > - rezip and distribute
>
> > we could create a hook (div) for the admin logo, a sample branded
> > init, and a script to create this.
>
> > Massimo
>
> > On Aug 22, 2:24 am, Iceberg  wrote:
> >> Omi Chiba,
>
> >> Thanks VERY MUCH for your effort on building the web2py installation
> >> package (a.k.a. library on fluxflex). Deploying web2py on a hosting
> >> server has never been so easy! (I start crying for the hours I spent
> >> in setting up my first web2py instance on my previous hosting
> >> provider.)
>
> >> One thing though. Your web2py library is a forked (and tailored)
> >> version of official web2py 1.98.2. This way it will soon be outdated
> >> when web2py trunk grows into 1.99, 1.100, etc.. So I see the only
> >> practical way is:
>
> >> 1. modify your .flx file (in order to get rid of the "public_html"
> >> directory, shall we?)
> >> 2. and commit it into the trunk.
> >> 3. and then someone of us (if not Massimo) maintain an identical clone
> >> (rather than a fork) of web2py on github, until fluxflex will support
> >> google code as app backend someday. (Will they?)
>
> >> Later we will figure out a way to upload (perhaps download too?) each
> >> web2py app, one by one.
>
> >> By the way, how did you find out how to write the .flx file? I did not
> >> see any documentation section on fluxflex site. Hope to know more so
> >> that we can tweak more.
>
> >> Regards,
> >> Ray
>
> >> On Aug 21, 8:37 pm, Omi Chiba  wrote:
>
> >> > Ichino who is a member of web2py Japan created a library on fluxflex
> >> > and it works great !
>
> >> >http://www.fluxflex.com/library/47
>
> >> > 1. Sign up fluxflex
> >> > 2. Create new project (e.g. ochiba)
> >> > 3. Install the library (It will be done in one second!)
> >> > 4. Access to your project with HTTPS not HTTP 
> >> > (e.g.https://ochiba.fluxflex.com)
> >> > 5. Access Administrative Interface with /admin 
> >> > (e.g.https://ochiba.fluxflex.com/admin
> >> > )
> >> > 5. Admin password is the same as your MySQL database on fluxflex
> >> > project.
>
> >> > Enjoy :)


[web2py] Re: Calender / datetime picker - localization

2011-08-23 Thread Ray (a.k.a. Iceberg)
Then I think you need a dynamic include in your controller. Something
like this:

def index():
return {'foo': DIV(
SCRIPT(_src=URL(..., 'calendar-%s-utf8.js'%language)),
DIV(...all_cool_stuff...),
)}

Regards,
Ray

On Aug 24, 4:54 am, Martin Weissenboeck  wrote:
> Hi Ray,
> yes, I have read it.
> My problem is to change the language "on the fly", depending on the language
> the visitor excepts.
>
> Regards, Martin
>
> 2011/8/22 Iceberg 
>
>
>
>
>
>
>
> > Hi Martin,
>
> > About the translation, have you checked out its official package?
> >http://www.dynarch.com/projects/calendar/old/
>
> > It contains lots of different language files. Just include one of
> > them, and you are good to go. It works for me, for years!
>
> > Regards,
> > Ray (a.k.a. Iceberg)
>
> > On Aug 17, 10:24 pm, Martin Weissenboeck  wrote:
> > > Thx. But how can I translate the names of the months and the days and how
> > > can I make the calendar start at Monday (and not at Sunday)?
>
> > > By the way: I wanted to get a timepicker and I have tried to use "...
> > > _class='time'...". The datepicker works (_class='date') and also
> > > _class='datetime', but not 'time'.
>
> > > Regards, Martin
>
> > > 2011/8/17 Anthony 
>
> > > > If you want to localize the date format in particular, in
> > > > /views/web2py_ajax.html, you'll notice variables w2p_ajax_date_format
> > and
> > > > w2p_ajax_datetime_format. Both of those are translated via the web2py
> > > > translation system, so you can simply add translations for those two
> > formats
> > > > to your language files.
>
> > > > Anthony
>
> > > > On Wednesday, August 17, 2011 5:53:07 AM UTC-4, mweissen wrote:
>
> > > >> Who knows where to find details about the localization (and other
> > > >> customization) of the built-in calender?
> > > >> In calendar.js I have found the link
> > > >>http://www.dynarch.com/projects/calendar, but I could only find there
> > > >> something about a (new) version JSCal2
>
> > > >> Regards, Martin


[web2py] Re: fluxflex

2011-08-22 Thread Iceberg
Omi Chiba,

Thanks VERY MUCH for your effort on building the web2py installation
package (a.k.a. library on fluxflex). Deploying web2py on a hosting
server has never been so easy! (I start crying for the hours I spent
in setting up my first web2py instance on my previous hosting
provider.)

One thing though. Your web2py library is a forked (and tailored)
version of official web2py 1.98.2. This way it will soon be outdated
when web2py trunk grows into 1.99, 1.100, etc.. So I see the only
practical way is:

1. modify your .flx file (in order to get rid of the "public_html"
directory, shall we?)
2. and commit it into the trunk.
3. and then someone of us (if not Massimo) maintain an identical clone
(rather than a fork) of web2py on github, until fluxflex will support
google code as app backend someday. (Will they?)

Later we will figure out a way to upload (perhaps download too?) each
web2py app, one by one.

By the way, how did you find out how to write the .flx file? I did not
see any documentation section on fluxflex site. Hope to know more so
that we can tweak more.

Regards,
Ray

On Aug 21, 8:37 pm, Omi Chiba  wrote:
> Ichino who is a member of web2py Japan created a library on fluxflex
> and it works great !
>
> http://www.fluxflex.com/library/47
>
> 1. Sign up fluxflex
> 2. Create new project (e.g. ochiba)
> 3. Install the library (It will be done in one second!)
> 4. Access to your project with HTTPS not HTTP 
> (e.g.https://ochiba.fluxflex.com)
> 5. Access Administrative Interface with /admin 
> (e.g.https://ochiba.fluxflex.com/admin
> )
> 5. Admin password is the same as your MySQL database on fluxflex
> project.
>
> Enjoy :)


[web2py] Re: Calender / datetime picker - localization

2011-08-21 Thread Iceberg
Hi Martin,

About the translation, have you checked out its official package?
http://www.dynarch.com/projects/calendar/old/

It contains lots of different language files. Just include one of
them, and you are good to go. It works for me, for years!

Regards,
Ray (a.k.a. Iceberg)


On Aug 17, 10:24 pm, Martin Weissenboeck  wrote:
> Thx. But how can I translate the names of the months and the days and how
> can I make the calendar start at Monday (and not at Sunday)?
>
> By the way: I wanted to get a timepicker and I have tried to use "...
> _class='time'...". The datepicker works (_class='date') and also
> _class='datetime', but not 'time'.
>
> Regards, Martin
>
> 2011/8/17 Anthony 
>
>
>
>
>
>
>
> > If you want to localize the date format in particular, in
> > /views/web2py_ajax.html, you'll notice variables w2p_ajax_date_format and
> > w2p_ajax_datetime_format. Both of those are translated via the web2py
> > translation system, so you can simply add translations for those two formats
> > to your language files.
>
> > Anthony
>
> > On Wednesday, August 17, 2011 5:53:07 AM UTC-4, mweissen wrote:
>
> >> Who knows where to find details about the localization (and other
> >> customization) of the built-in calender?
> >> In calendar.js I have found the link
> >>http://www.dynarch.com/projects/calendar, but I could only find there
> >> something about a (new) version JSCal2
>
> >> Regards, Martin


[web2py] Re: jqgrid-module import problem

2011-08-21 Thread Iceberg
Hi Johann,

It is not about local_import() vs the new "from jqgrid import JqGrid"
syntax.
It is because you install your jqgrid app with a name other than
"jqgrid".
And this bug is fixed in latest trunk of jqgrid app already.

Regards,
Ray

On Aug 17, 7:28 pm, Bruno Rocha  wrote:
> No more need to use lical_import it is deprecated. Newest web2py has a
> custom importer which works much better.
>
> Em 17/08/2011 08:20, "Johann Spies"  escreveu:
>
> > On 17 August 2011 12:55, Bruno Rocha  wrote:
>
> >> try changing this:
>
> >> JqGrid = local_import('jqgrid', app='jqgrid', reload=True).JqGrid
>
> >> to this:
>
> >> from jqgrid import JqGrid
>
> > Thanks. That solved the problem but not the mystery (because my lack of
> > understanding).
>
> > When is it better to use the first version?
>
> > Regards
> > Johann
> > --


[web2py] Re: Building web2py binary for windows with extra libs

2011-08-05 Thread Iceberg
Nice tips, Praneeth. And looks like Massimo has not objection to these
kind of attempts (he even participated in some of the discussions). So
I guess all these kind of approaches are not considered as violation
of the web2py license. Yes? No?

http://web2py.com/book/default/chapter/12#How-to-Distribute-your-Applications-as-Binaries

said: make sure it states that it (your app) is being "distributed
with an unmodified copy of web2py from web2py.com"

Regards,
Ray (a.k.a. Iceberg)

On Aug 5, 3:34 pm, Praneeth Bodduluri  wrote:
> Hello Syed,
>
> It is possible for you to rebuild the web2py exe adding in your
> required libraries.
>
> The following links might be of help:
>
> 1)http://eden.sahanafoundation.org/browser/static/scripts/tools/standal...
> 2)https://groups.google.com/d/topic/web2py/Lirvj_J8q1U/discussion
>
> Regards,
> Praneeth
> IRC: lifeeth
>
>
>
>
>
>
>
> On Fri, Aug 5, 2011 at 5:13 AM, Syed Mushtaq  wrote:
> > Hi ,
>
> > I have an app that I want to ship as a windows binary . I was looking at
> >http://web2py.com/book/default/chapter/12#How-to-Distribute-your-Appl...
> > . I use PIL in my
> > app for doing some image manipulation . It is possible to generate the
> > windows binary of web2py which includes PIL or any other library ?
>
> > Thanks
> > -Syed


[web2py] Re: Login form's "remember for 30 days" not working

2011-08-02 Thread Iceberg
Hi Massimo, I've sent you the file yesterday. Did you get it? If that
mail somehow lost, I can open an issue and submit a patch there.

Regards,
Ray

On Aug 1, 6:32 pm, Massimo Di Pierro 
wrote:
> No objection but can you please email me the new file as an
> attachment?
>
> On Aug 1, 5:26 am, Iceberg  wrote:
>
>
>
>
>
>
>
> > Hi Massimo,
>
> > This problem exists for quite some time, today I trace it to these old
> > source.
>
> > [1] The 
> > diagnosis.http://groups.google.com/group/web2py/browse_thread/thread/bb9f92e255...
>
> > [2] The 
> > fix.http://groups.google.com/group/web2py/browse_thread/thread/b9ad5c501d...
>
> > Would you please take the above fix? Thanks.
>
> > Regards,
> > Ray (a.k.a. Iceberg)


[web2py] Login form's "remember for 30 days" not working

2011-08-01 Thread Iceberg
Hi Massimo,

This problem exists for quite some time, today I trace it to these old
source.

[1] The diagnosis. 
http://groups.google.com/group/web2py/browse_thread/thread/bb9f92e255323a94

[2] The fix. 
http://groups.google.com/group/web2py/browse_thread/thread/b9ad5c501df50be6

Would you please take the above fix? Thanks.

Regards,
Ray (a.k.a. Iceberg)


[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-27 Thread Iceberg
Hi Massimo, will this issue be addressed in coming web2py 1.98.1?
Thanks in advance.

Ray

On Jul 24, 10:29 pm, Iceberg  wrote:
> I prefer to use crud, but it is not qualified for your workaround I
> think.
>
> On the other hand, you said that there is a "custom" widget which
> interfere with validators. Is it possible that I switch "back" to an
> old style widget, which respects validators? Because I need server
> side validation more than an appealing UI.
>
> I've tried this, still no luck. When submit, ticket occurs. Do you see
> a chance here?
>
>     ...
>     Field('participants', 'list:reference employee',
>         requires = [IS_NOT_EMPTY(),
>
> IS_LIST_OF(IS_IN_DB(db,'employee.id',db.employee._format,multiple=True))],
>         widget = SQLFORM.widgets.list.widget, # default is "multiple"
> widget
>         )
>
> Regards,
> Ray
>
> On Jul 24, 9:54 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > try one more thing:
>
> > form = SQLFORM()
> > form.element('input#appointment_participants')
> > ['requires']=IS_NOT_EMPTY()
> > if form.accepts(...)
>
> > The problem is that the custom widget interfere with validators and
> > validators may have to be attached to the widget.
>
> > On Jul 24, 8:22 am, Iceberg  wrote:
>
> > > Hi Massimo,
>
> > > Thanks for trying to help. Perhaps I did not clearly explain the
> > > point.
>
> > > I hope to add an IS_NOT_EMPTY() constraint to any "list:reference
> > > table_name" field. My previous snippet is copied from web2py book, but
> > > in my real need, that "list:reference" field is not necessary a tag.
> > > So I'm not going to plugin_tagging or plugin_wiki direction. Instead
> > > you can think about a booking system inside a company.
>
> > > db.define_table('employee', Field('name'))
> > > db.define_table('appointment',
> > >     Field('subject', 'string'),
> > >     Field('participants', 'list:reference employee'),
> > >     )
>
> > > So I don't need any comma-separated-employee-name UI. In fact the
> > > default widget for list:reference is already great. What I need is
> > > just make sure any appointment will have at least one participant.
>
> > > Can we somehow hook a IS_NOT_EMPTY() into list:reference 's default
> > > widget? Thanks!
>
> > > Regards,
> > > Ray (a.k.a. Iceberg)


[web2py] Re: please check out the nightly built

2011-07-26 Thread Iceberg
I gave it a shot. The "generic_patterns=[...] and LOAD(...,
ajax=False)" issue is finally fixed. Good job!

By the way, will a fix for "IS_NOT_EMPTY and list:reference" issue be
included in 1.98.1?

Regards,
Ray (a.k.a. Iceberg)

On Jul 26, 6:42 am, Massimo Di Pierro 
wrote:
> I am planning to release a 1.98.1 on Sunday.
> Many tickets have been closed.
> Please check out the nightly built 
> onhttp://web2py.com/examples/default/download
> and report any issue.
>
> Massimo


[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-24 Thread Iceberg
I prefer to use crud, but it is not qualified for your workaround I
think.

On the other hand, you said that there is a "custom" widget which
interfere with validators. Is it possible that I switch "back" to an
old style widget, which respects validators? Because I need server
side validation more than an appealing UI.

I've tried this, still no luck. When submit, ticket occurs. Do you see
a chance here?

...
Field('participants', 'list:reference employee',
requires = [IS_NOT_EMPTY(),
 
IS_LIST_OF(IS_IN_DB(db,'employee.id',db.employee._format,multiple=True))],
widget = SQLFORM.widgets.list.widget, # default is "multiple"
widget
)

Regards,
Ray

On Jul 24, 9:54 pm, Massimo Di Pierro 
wrote:
> try one more thing:
>
> form = SQLFORM()
> form.element('input#appointment_participants')
> ['requires']=IS_NOT_EMPTY()
> if form.accepts(...)
>
> The problem is that the custom widget interfere with validators and
> validators may have to be attached to the widget.
>
> On Jul 24, 8:22 am, Iceberg  wrote:
>
>
>
>
>
>
>
> > Hi Massimo,
>
> > Thanks for trying to help. Perhaps I did not clearly explain the
> > point.
>
> > I hope to add an IS_NOT_EMPTY() constraint to any "list:reference
> > table_name" field. My previous snippet is copied from web2py book, but
> > in my real need, that "list:reference" field is not necessary a tag.
> > So I'm not going to plugin_tagging or plugin_wiki direction. Instead
> > you can think about a booking system inside a company.
>
> > db.define_table('employee', Field('name'))
> > db.define_table('appointment',
> >     Field('subject', 'string'),
> >     Field('participants', 'list:reference employee'),
> >     )
>
> > So I don't need any comma-separated-employee-name UI. In fact the
> > default widget for list:reference is already great. What I need is
> > just make sure any appointment will have at least one participant.
>
> > Can we somehow hook a IS_NOT_EMPTY() into list:reference 's default
> > widget? Thanks!
>
> > Regards,
> > Ray (a.k.a. Iceberg)
>
> > On Jul 24, 3:16 pm, Massimo Di Pierro 
> > wrote:
>
> > > I understand and what you need to do is a bit more complex than needs
> > > to be. For this reason we have plugin_tagging and tagging in
> > > plugin_wiki. Another approach is the following...
>
> > > class TAGGING:
> > >     def __call__(self,field,value):
> > >           return INPUT(_name='%s_%s' % (field._tablename,field.name),
> > >                        _value=', '.join(r.name for r in
> > > db(db.tag.id.belongs(value or [])).select()),
> > >                        requires = self.validate)
> > >     def validate(self,tags):
> > >           names = [x.strip() for x in tags.split(',')]
> > >           ids = [r.id for r in
> > > db(db.tag.name.belongs(names)).select()]
> > >           if len(ids) < len(names):
> > >               return (ids, "one of the tags is invalid or repeated")
> > >           return (ids,None)
>
> > > db.define_table('tag',
> > >                 Field('name', requires=IS_NOT_EMPTY()), format='%
> > > (name)s')
> > > db.define_table('product',
> > >                 Field('name', requires=IS_NOT_EMPTY()),
> > >                 Field('tags', 'list:reference tag',widget=TAGGING()),)
>
> > > def testme():
> > >     return {
> > >         'a': crud.update(db.product, request.args(0)),
> > >         'b': crud.select(db.product),
> > >         }
>
> > > The custom TAGGING widget renders the list of IDS as a a list of comma-
> > > separated names. You can also cache the mapping between ids and tag
> > > names for speed.


[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-24 Thread Iceberg
Hi Massimo,

Thanks for trying to help. Perhaps I did not clearly explain the
point.

I hope to add an IS_NOT_EMPTY() constraint to any "list:reference
table_name" field. My previous snippet is copied from web2py book, but
in my real need, that "list:reference" field is not necessary a tag.
So I'm not going to plugin_tagging or plugin_wiki direction. Instead
you can think about a booking system inside a company.

db.define_table('employee', Field('name'))
db.define_table('appointment',
Field('subject', 'string'),
Field('participants', 'list:reference employee'),
)

So I don't need any comma-separated-employee-name UI. In fact the
default widget for list:reference is already great. What I need is
just make sure any appointment will have at least one participant.

Can we somehow hook a IS_NOT_EMPTY() into list:reference 's default
widget? Thanks!

Regards,
Ray (a.k.a. Iceberg)


On Jul 24, 3:16 pm, Massimo Di Pierro 
wrote:
> I understand and what you need to do is a bit more complex than needs
> to be. For this reason we have plugin_tagging and tagging in
> plugin_wiki. Another approach is the following...
>
> class TAGGING:
>     def __call__(self,field,value):
>           return INPUT(_name='%s_%s' % (field._tablename,field.name),
>                        _value=', '.join(r.name for r in
> db(db.tag.id.belongs(value or [])).select()),
>                        requires = self.validate)
>     def validate(self,tags):
>           names = [x.strip() for x in tags.split(',')]
>           ids = [r.id for r in
> db(db.tag.name.belongs(names)).select()]
>           if len(ids) < len(names):
>               return (ids, "one of the tags is invalid or repeated")
>           return (ids,None)
>
> db.define_table('tag',
>                 Field('name', requires=IS_NOT_EMPTY()), format='%
> (name)s')
> db.define_table('product',
>                 Field('name', requires=IS_NOT_EMPTY()),
>                 Field('tags', 'list:reference tag',widget=TAGGING()),)
>
> def testme():
>     return {
>         'a': crud.update(db.product, request.args(0)),
>         'b': crud.select(db.product),
>         }
>
> The custom TAGGING widget renders the list of IDS as a a list of comma-
> separated names. You can also cache the mapping between ids and tag
> names for speed.


[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Iceberg
>From the user-interface aspect, of course we expect end user to input
real names, rather than IDs. Actually web2py already provides a nice-
looking multi-selection widget by default, in scenario 1 of my first
post.

The only and real problem right now, is that end user can add/edit a
record with its list:reference field being empty. I hope to add an
IS_NOT_EMPTY() constraint on it.

Hope I explain it clear. If not, feel free to ask me again. Thanks!

Regards,
Ray


On Jul 24, 1:07 am, Massimo Di Pierro 
wrote:
> I see what the problem is. The default widget overrides the validator.
> Before we look for a solution let me undertand what you need.
>
> The way you phrased looks like you want users to input the IDs of the
> tags. I suspect you want instead the user to insert tag names, perhaps
> comma separated, and you want the system to parse them and store the
> corresponding ids in the product.tags field. Is this correct?
>
> massimo
>
> On Jul 23, 2:52 am, Iceberg  wrote:
>
>
>
>
>
>
>
> > Hi Massimo,
>
> > How to add a IS_NOT_EMPTY constrait to list:reference field? This
> > seems a simple task but I ends up opening a can of worms. :-/  Here is
> > what I did.
>
> > 1. Firstly, setup the sandbox.
>
> >     db.define_table('tag',
> >         Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
> >     db.define_table('product',
> >         Field('name', requires=IS_NOT_EMPTY()),
> >         Field('tags', 'list:reference tag'),)
>
> >     def product():
> >         return {
> >             1: crud.update(db.product, request.args(0)),
> >             2: crud.select(db.product),
> >             }
>
> > Now we can add new product with or without tags. Fine.
>
> > 2. What if we need new product to have at least one tag?
>
> > I tried changing the tags field definition into (I thought it was
> > intuitive):
>
> >     Field('tags', 'list:reference tag', required=True)
>
> > But nothing different. I can't force a tag.
>
> > 3. Then I tried to change tags into:
>
> >     Field('tags','list:reference tag',
> >         requires =
> > IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),
>
> > This is the so-called default constraint, according to the book,
> > chapter 6.
> > But situation gets worse. Now I get error ticket whenever submitting
> > new product.
>
> > 4. I even tried:
>
> >     requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]
>
> > still tickets.
>
> > Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.
>
> > Did I miss something really obvious? Thanks in advance.
>
> > Regards,
> > Ray (a.k.a. Iceberg)


[web2py] Re: How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Iceberg
Thanks but, it doesn't work either. Still tickets. Do you have another
suggestion?

On Jul 23, 3:54 pm, Massimo Di Pierro 
wrote:
> Try IS_LIST_OF(IS_IN_DB(.))
>
> On Jul 23, 2:52 am, Iceberg  wrote:
>
>
>
>
>
>
>
> > Hi Massimo,
>
> > How to add a IS_NOT_EMPTY constrait to list:reference field? This
> > seems a simple task but I ends up opening a can of worms. :-/  Here is
> > what I did.
>
> > 1. Firstly, setup the sandbox.
>
> >     db.define_table('tag',
> >         Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
> >     db.define_table('product',
> >         Field('name', requires=IS_NOT_EMPTY()),
> >         Field('tags', 'list:reference tag'),)
>
> >     def product():
> >         return {
> >             1: crud.update(db.product, request.args(0)),
> >             2: crud.select(db.product),
> >             }
>
> > Now we can add new product with or without tags. Fine.
>
> > 2. What if we need new product to have at least one tag?
>
> > I tried changing the tags field definition into (I thought it was
> > intuitive):
>
> >     Field('tags', 'list:reference tag', required=True)
>
> > But nothing different. I can't force a tag.
>
> > 3. Then I tried to change tags into:
>
> >     Field('tags','list:reference tag',
> >         requires =
> > IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),
>
> > This is the so-called default constraint, according to the book,
> > chapter 6.
> > But situation gets worse. Now I get error ticket whenever submitting
> > new product.
>
> > 4. I even tried:
>
> >     requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]
>
> > still tickets.
>
> > Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.
>
> > Did I miss something really obvious? Thanks in advance.
>
> > Regards,
> > Ray (a.k.a. Iceberg)


[web2py] How to add a IS_NOT_EMPTY constrait to list:reference field?

2011-07-23 Thread Iceberg
Hi Massimo,

How to add a IS_NOT_EMPTY constrait to list:reference field? This
seems a simple task but I ends up opening a can of worms. :-/  Here is
what I did.

1. Firstly, setup the sandbox.

db.define_table('tag',
Field('name', requires=IS_NOT_EMPTY()), format='%(name)s')
db.define_table('product',
Field('name', requires=IS_NOT_EMPTY()),
Field('tags', 'list:reference tag'),)

def product():
return {
1: crud.update(db.product, request.args(0)),
2: crud.select(db.product),
}

Now we can add new product with or without tags. Fine.


2. What if we need new product to have at least one tag?

I tried changing the tags field definition into (I thought it was
intuitive):

Field('tags', 'list:reference tag', required=True)

But nothing different. I can't force a tag.


3. Then I tried to change tags into:

Field('tags','list:reference tag',
requires =
IS_IN_DB(db,'tag.id',db.tag._format,multiple=True),),

This is the so-called default constraint, according to the book,
chapter 6.
But situation gets worse. Now I get error ticket whenever submitting
new product.


4. I even tried:

requires = [IS_NOT_EMPTY(), IS_IN_DB(...)]

still tickets.


Problem persists in both web2py 1.95.1 and 1.97.1, on Windows.

Did I miss something really obvious? Thanks in advance.


Regards,
Ray (a.k.a. Iceberg)


[web2py] Re: Two problems with LOAD; one may be a bug(?)

2011-07-20 Thread Iceberg


On Jul 13, 8:49 am, Anthony  wrote:
>
> > Second problem:
> > In trying to find out if setting ajax to True was causing my first
> > problem, I stumbled over a second.  Setting 'ajax=False' or not
> > setting ajax at all causes an exception.  Could this be a bug?  If so,
> > please let me know where and how to report the thing.  It's totally
> > reproducible on my system.
>
> There is currently a bug with ajax=False where response.generic_patterns is
> not getting passed to the component, so generic views are not working with
> non-ajax components at the moment. If you're getting an invalid view error,
> that could be the problem.
>
> Anthony


Hi Anthony,

I encounter same problem. STFW and I read your two posts. One is
above, the other is here:

http://groups.google.com/group/web2py/msg/25bd655665bf47bf

I am curious to see a bug exists for 2 weeks. That is not normal,
considering web2py has a tradition of fixing bug within 24 hours. Is
there anything special about this one? Thanks in advance.

Regards,
Ray (a.k.a. Iceberg)


[web2py] Re: Demystifying some web2py magic

2011-07-09 Thread Iceberg
Good to know that.

One thing though. If track_changes() is that good, how about we always
put it in every app's db.py? Any pros and cons?

Thanks in advance.

Regards,
Iceberg

On Jul 9, 3:20 am, Anthony  wrote:
> local_import should work, but you should now use regular import statements
> instead. If you want your modules reloaded automatically, do the following:
>
> from gluon.custom_import import track_changes
> track_changes()
>
> That will reload your modules, but only when they change (which is an
> improvement over local_import, which will reload whether or not there are
> changes). Note, I believe the above will affect all applications. To turn
> off reloading, do:
>
> track_changes(track=False)
>
> And to test whether changes are currently being tracked:
>
> from gluon.custom_import import track_changes, is_tracking_changes
> if not is_tracking_changes():
>     track_changes()
>
> Anthony
>
>
>
>
>
>
>
> On Friday, July 8, 2011 3:06:07 PM UTC-4, Jim S wrote:
> > Hi
>
> > I have a utility module that I use regularly where I put some of my
> > application-specific helper functions.  What is the proper way to import
> > this to make it available in my controllers and views?
>
> > I've tried the local_import in db.py but have seen references on this list
> > that recommend against using that.  This method had the reload=True option
> > that allowed me to make changes to my utility module and not have to restart
> > the web2py server to make the changes visible.  
>
> > If I recall correctly (and I certainly could be wrong), the preferred
> > method is to now use import.  But, using this method I have to restart
> > web2py every time I make a change so I can see the results.
>
> > Can someone please tell me how I can import a module and have it reload
> > automatically like local_import('module', reload=True) does?  Or, should I
> > still be using local_import when I want reloading to occur?
>
> > Thanks
>
> >     -Jim


[web2py] Re: Want to stop getting responses from web2py

2011-06-22 Thread Iceberg
What do you mean stop getting response? How about response with some
"empty" stuff? Such as:

def index():
if delay_time_for_responding=='infinite':
return 'nothing'
... # normal code starts here

Or if you really mean a response is suspended infinitely, you might
need something called "comet".

Regards,
Iceberg

On Jun 22, 10:36 pm, sheM  wrote:
> Hi,
>
>  We have an application developed using web2py.
>
>   There is a requirement where we should be stopping the application
> respond to the requests.
> Eg: when delay_time_for_responding == 'infinite' there should be no
> response.
> sys.exit() or break is something that we don't want to do as web2py
> errors out.
>
> Any way out in web2py?
>
> Sheetal. M


  1   2   3   4   5   6   7   >