Comments (13)
I'm aware of the session removal issue. I've been using the false assignment workaround in my sites, but I think it's time to make it a little bit more proper and detect nil assignments.
As for __index being a function, I've never seen that happen before, but I see no issue with adding a check there.
from lapis.
Thank you. Regarding __index
being a function I will try to make a simple test case that exhibits the problem this weekend.
from lapis.
Actually the 2nd workaround does not work, it did only because I had commented out code (using false instead of nil does). And I couldn't reproduce __index
being a function so disregard that for now.
from lapis.
@leafo I am currently experiencing the __index
being a function issue. Completely have no idea why this would happen. I have dig around but found no solutions.
So I use cookies instead now.
from lapis.
I have had a look and here's where I think the issue with __index
being a function comes from. Well, that's if I have understood all this meta-magic correctly :)
OK, so the session is an auto_table. An auto_table is a table with a __index metamethod by default (so "__index
is a function").
The reason this bug does not happen all the time is that actually the __index
metamethod is a closure, and when it is called it replaces itself with the result of the enclosed fn
(a table). So if you access a field in the session before trying to iterate __index
it works, but not if you don't.
from lapis.
Ah good catch, thanks for looking into it.
from lapis.
Question: Has the session issue been fixed? I am using the latest github checked out version and I am still having the aforementioned session issues.
Thank you!
from lapis.
Still haven't changed the delete issue. The __index being a function has been fixed.
from lapis.
Right, that's what I noticed. It renders sessions almost unusable ... and I was hoping to use Lapis for an important site that requires sessions.
from lapis.
I wouldn't say they're unusable. Set to false if you want to delete. I'll try to get patch out asap.
from lapis.
So I've taken care of the assigning nil issue, but I'm not satisfied with the overall result. You will still run into trouble if you have a table serialized into the session and you modify it, the code won't be able to detect the change in the child object. I'm wondering if I should just change the interface completely, have some method that marks the session as dirty and forces it to be written, or write something that wraps the objects that come from the session so I can tell if any nested object is changed.
from lapis.
That last solution looks right. What can be stored in sessions exactly? Userdata, functions? If neither can then just adding metatables to tables stored in sessions so that they propagate the "modified" state upwards sounds good.
from lapis.
Anything that can be serialized by lua cjson. I should mention that somewhere.
from lapis.
Related Issues (20)
- Postgresql how to add default value current_date HOT 1
- luarocks install lapis did not see installed openssl HOT 5
- route name cannot be one of the paths HOT 2
- Specifying backend=pgmoon now required? HOT 1
- Value not available in sub-sub-template if render(..., {value = ...}) used in the template
- Default Route - Open Redirect HOT 1
- Module Migrations not found HOT 1
- Error when trying to start server HOT 3
- display "listening on ..." on startup HOT 2
- Loading static files like css with cqueues server HOT 2
- Database type could not be determined from configuration (postgres, mysql, sqlite)
- How to get client ip? HOT 1
- Remove luarocks dependency
- request:read_body_as_string() fails if body was buffered to a temporary file with nginx
- SQL fields all nil using sqlite
- app:before_filter(json_params) not work? HOT 1
- Feature Request: Foreign Key constraint option in schema types
- Add database field types in docs
- Lua 5.1 Support HOT 2
- Parameter parser doesn't parse `+` correctly. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lapis.