Comments (7)
from overholt.
Thanks for the explanation. I think my second question is not answered. Actually I can't use some sqlalchemy's query method by calling Service methods. For instance, I want to query obj whose attr1=val1 and attr2=val2 or more complicated.
If I'm using obj.model.query, it seems to break the abstract of Service.
from overholt.
Nothing is stopping you from using the models directly, or creating a service method that abstracts the query you're trying to make. A hypothetical example:
class UserService(Service):
def custom_method(self, email):
return self.__model__.query.filter(self.__model__.email==email).all()
from overholt.
Well, I assume that Service abstracts external stuffs like sqlalchemy, and UserService should only call methods provided by Service. Thus in the future, suppose we want to migrate from sqlalchemy to something else, we only need to change the implementation of Service.
However, if we are calling sqlalchemy methods directly in UserService, it breaks the assumption above. Otherwise, what's the benefit to define a Service rather than using external stuffs directly.
from overholt.
Thats an assumption you have made for yourself. I've never suggested that custom service methods must use the methods provided by Service
. It is by no means a complete abstraction on top of SQLAlchemy either. As described in the blog post, the service layer is to expose a logical API that encapsulates your platforms core logic. That service can then be used in multiple contexts such as a web app, or even a CLI if you wanted to build one on top of it.
from overholt.
I see. That make sense. Thank you very much Matt! Also thank you for sharing your insight on Flask.
from overholt.
No sweat! Appreciate the discussion.
from overholt.
Related Issues (20)
- requirements.txt == versus >= HOT 1
- Authentication for Api HOT 1
- Cookies seem to contain successive registration emails. HOT 3
- Thoughts on imports HOT 3
- Where to discuss? Also next steps... HOT 2
- Where would I put signals? HOT 2
- How to use one service from another? HOT 1
- Overholt how to send the flask-security emails via Celery? HOT 4
- Deployment HOT 4
- Test suite hangs and never finishes successfully
- Service Objects vs Service Mixins HOT 4
- Trouble overriding default Flask-Security Forms
- How is the circular import of celery tasks handled? HOT 1
- decorative view function two times HOT 2
- celery context
- How to use Flask-Restful with this structure HOT 1
- Flask Principal within Overholt
- how to init database HOT 2
- potential decorator issue
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 overholt.