bobthemighty / blog-code-samples Goto Github PK
View Code? Open in Web Editor NEWDemos and playgrounds for articles on io.made.com
Home Page: https://io.made.com
Demos and playgrounds for articles on io.made.com
Home Page: https://io.made.com
Hi, thanks for the interesting blog!
I've run into an issue with this code that I can't work out - it doesn't help that I haven't used the NamedTuple
datatype before.
When I try and define a Command
object I get a TypeError
.
Traceback (most recent call last):
File "test.py", line 5, in <module>
class ReportIssueCommand(NamedTuple):
TypeError: function() argument 1 must be code, not str
This happens with simply the following:
from typing import NamedTuple
class ReportIssueCommand(NamedTuple):
pass
Do you have any advise on how to proceed? Many thanks
Hello, i have just cloned the repo, followed instructions to deploy the code and got this error after trying to run tests:
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/issues/quick_tests/test_assignment.py", line 3, in <module>
from .adapters import FakeUnitOfWork, FakeEmailSender, FakeViewBuilder
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/issues/quick_tests/adapters.py", line 4, in <module>
from issues.domain.emails import EmailSender
ModuleNotFoundError: No module named 'issues.domain.emails'
And this is correct, because there are no emails module in the repo (step 04).
The ports and adapters example is really, really great. This series is the most readable assembly of this set of concepts that I have seen so far, and I think this style of architecture is one that people could benefit from using a lot more.
Something I took note of as I was reading through was that you never really touched on error handling. If CQS dictates that no values are returned when you're writing data, what do you do if some invariant is violated and thus you can't write the data?
Do you raise an exception? (which is a kind of return value, albeit one intended for unexpected cases)
Do you instead have validation at another layer, doing a Query to inspect what the command is trying to do before running the Command?
Here's an example: what if the assignee for an issue had to be one of a known list? Where would you check that?
I have thoughts on approaches to this, but I'm curious to know how you handle the situation in the architecture you've built up.
Thanks for putting the effort into this!
Hi again, this deps are missing from requirements file:
jinja2 flask sqlalchemy sqlalchemy_utils requests punq
Hi
I stumbled upon this repository and blog posts from this reddit comment thread.
Thanks a lot for the blog posts and the code. It has been very helpful.
I had a question though. In one of the reddit comments you mentioned that it is possible to inject the repository objects instead of defining them as properties like so.
Could you please provide and example or point me to some article or git repo that shows how to do it?
Thanks again.
Hello again, flask run is not working due to missing config
module:
(env) ➜ 04 git:(master) ✗ flask run
Traceback (most recent call last):
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/bin/flask", line 11, in <module>
sys.exit(main())
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/flask/cli.py", line 513, in main
cli.main(args=args, prog_name=name)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/flask/cli.py", line 380, in main
return AppGroup.main(self, *args, **kwargs)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/flask/cli.py", line 423, in run_command
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/flask/cli.py", line 152, in __init__
self._load_unlocked()
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/flask/cli.py", line 176, in _load_unlocked
self._app = rv = self.loader()
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/flask/cli.py", line 237, in load_app
rv = locate_app(self.app_import_path)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/env/lib/python3.6/site-packages/flask/cli.py", line 90, in locate_app
__import__(module)
File "/Users/asyncee/blog-code-samples/ports-and-adapters/04/issues/adapters/flask.py", line 3, in <module>
from . import config
ImportError: cannot import name 'config'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.